:root {
    /* https://ethanschoonover.com/solarized/ */
    --bg:       #fdf6e3;
    --bg-alt:   #eee8d5;
    --bg-err:   #fee8c8;
    --fg:       #657b83;
    --fg-alt:   #586e75;
    --fg-light: #93a1a1;
    --fg-err:   #800026;

    /* other */
    --plot-bg:  #f6f6f6;
    --plot-g1:  #dadada;
    --plot-g2:  #e8e8e8;
}

* { box-sizing: border-box; }
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    background: var(--bg);
    color: var(--fg);
}
header, footer {
    background: var(--bg-alt);
    color: var(--fg-alt);
    flex: initial;
    padding: 0.5rem;
}
main {
    flex: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#test-plot {
    width: 90%;
    height: auto;
    aspect-ratio: 4 / 3;
    /* yes, this is really how you're supposed to center multiline text
       within a <div> both horizontally and vertically.  also, if this
       is display:block then it tries to be three pixels taller than
       the SVG inside that's trying to be exactly as tall as it is,
       putting the resize logic into an infinite loop.  display:flex
       fixes that. my interest in *why* it fixes that, or why
       display:block does that in the first place, is currently not
       enough to debug any farther.  */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.plot-with-controls {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    text-align: center;
}
.plot-with-controls {
    background: var(--plot-bg);
}
.plot-with-controls > legend {
    font-weight: bold;
    font-size: 18px;
}
.controls-box {
    flex: initial;
    display: flex;
    flex-direction: row;
    justify-content: end;
    align-items: center;
    padding-bottom: 0.75rem;
}

.tool-button {
    display: flex;
    padding: .3rem;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: transparent;
    border: 1px solid #aaa;
    border-radius: 0;
    position: relative;  /* make this an abspos container */
}
.tool-button + .tool-button {
    border-left: 0px;
}
.tool-button:hover {
    background: rgb(0,0,0,.2);
}
.tool-button:active {
    background: rgb(0,0,0,.4);
}

.tool-button:disabled,
.tool-button:disabled:hover,
.tool-button:disabled:active {
    background: transparent;
}

.tool-icon {
    width: 1.4rem;
    height: 1.4rem;
    fill: #444;
}

.tool-button.selected {
    background: #444;
}
.tool-button.selected > .tool-icon {
    fill: #ddd;
}
.tool-button:disabled > .tool-icon {
    fill: #aaa;
}

.tool-label {
    z-index: 100;
    position: absolute;
    width: max-content;
    bottom: 2.4rem;
    right: 0.6rem;
    border-radius: 2px;
    padding: 2px 4px;
    background: #cef;
    filter:
        drop-shadow(0px 0px 1px #444)
        drop-shadow(0px 0px 1px #444)
    ;
    opacity: 0;
    transition-property: opacity;
    transition-duration: 300ms;
}
.tool-label::before {
    content: "";
    position: absolute;
    top: calc(100% - 1.5px);
    right: 0;
    height: 1rem;
    width: 0.8rem;
    background: inherit;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.tool-label.interested {
    opacity: 1;
}


.plot-box {
    flex: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.plot-box.no-plot, .plot-box.load-error {
    font-size: 2rem;
}
.plot-box.no-plot {
    color: var(--fg-light);
    font-style: italic;
}
.plot-box.load-error {
    color: var(--fg-err);
    background: var(--bg-err);
}

.plot-box > svg {
    /* this peculiar little incantation forces the svg to adapt to the size
       of its container _without_ the JS-level "reposition" hook helping out,
       which reduces visual stuttering on resize, and also enables it
       to shrink vertically; the reposition hook won't do that by itself
       because "this box insists on being yea tall" wins over the parent's
       "i want to have this aspect ratio".  we still need the JS-level
       reposition hook to control *what gets stretched*; by itself this
       would stretch *everything*, including stroke widths and text.

       "width: 100%; height: 100%" doesn't work, but this does.
       again my interest in these matters is not enough to dig deeper.

       TODO: figure out if we can get away with merging the <svg> into
       the parent <div class="plot-box">.  */
    width: 0;
    height: 0;
    min-width: 100%;
    min-height: 100%;
}
.plot-box > svg.zoombox-active {
    cursor: zoom-in;
}
.plot-box > svg.pan-active {
    cursor: grab;
}
.plot-box > svg.pan-active.panning {
    cursor: grabbing;
}

#please-wait {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: rgb(from var(--fg-alt) r g b / .4);
    font-size: 2rem;
    font-style: italic;
    /* yes, this is really how you're supposed to center multiline
       text within a block element both horizontally and vertically. */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
#please-wait.done {
    display: none;
}

text { text-anchor: middle;
       dominant-baseline: central;
       transform-origin: center;
       transform-box: content-box;
       font-size: 18px;
       font-family: "Linux Biolinum O"; }

.axis-left > text.axis-label { transform: rotate(-90deg); }
.axis-right > text.axis-label { transform: rotate(90deg); }

text.tick-label { font-size: 16px; }

rect.axis-bg { fill: none }
rect.plot-area-bg { fill: var(--plot-bg) }

rect.drag-box {
    fill: #222;
    fill-opacity: 10%;
    stroke: #000;
    stroke-width: 1px;
    stroke-opacity: 100%;
    stroke-dasharray: 3 3;
}

line.axis-line, line.tick-major, line.tick-minor {
    fill: none;
    stroke: var(--fg-alt);
    stroke-width: 1.5px;
    stroke-linecap: square;
}

line.gridline-major {
    fill: none;
    stroke: var(--plot-g1);
    stroke-width: 1.5px;
}
line.gridline-minor {
    fill: none;
    stroke: var(--plot-g2);
    stroke-width: 1px;
}

circle.refl-dot {
    fill: var(--rl-group-color);
    r: 3.5px;
}
path.refl-bar, polyline.refl-connline {
    fill: none;
    stroke: var(--rl-group-color);
    stroke-width: 2px;
}

g.rl-azure   { --rl-group-color: #80b1d3 }
g.rl-cyan    { --rl-group-color: #8dd3c7 }
g.rl-green   { --rl-group-color: #4daf4a }
g.rl-magenta { --rl-group-color: #f781bf }
g.rl-orange  { --rl-group-color: #ff7f00 }
g.rl-purple  { --rl-group-color: #984ea3 }
