/* Canary yellow is the app's accent: the ring around the selected button, the sliders, the
   Save button. The dark chrome below is what gives it its contrast - the same yellow over
   light chrome was barely distinguishable from the surface it sat on and needed propping
   up to read at all. --accent-edge is the same hue taken down, used wherever canary meets
   something it cannot hold an edge against - the Save button's fill, and the outside of the
   selected button's ring, which sits on the fractal and so can find itself on white. */
:root {
    --accent: #ffef00;
    --accent-edge: #c7ae00;
    /* One declaration colours every range slider - inherited, so the sliders in every panel
       pick it up, as would any checkbox or progress bar added later. */
    accent-color: var(--accent);

    /* Dark, translucent chrome. Every surface in the UI is one of these, so the whole thing
       shifts together: --chrome for the rail buttons, --chrome-panel for the side panel,
       --chrome-inset for the surfaces inside it, --chrome-field for anything you type into.
       `color-scheme: dark` covers what is left to the browser - the panel's scrollbar, the
       unfilled half of a slider track - so those come up dark too without being styled. */
    --chrome: rgba(18, 18, 20, 0.55);
    --chrome-active: rgba(38, 38, 42, 0.72);
    --chrome-panel: rgba(16, 16, 18, 0.72);
    --chrome-inset: rgba(255, 255, 255, 0.08);
    --chrome-field: rgba(0, 0, 0, 0.3);
    --chrome-line: rgba(255, 255, 255, 0.2);
    --ink: rgba(255, 255, 255, 0.93);
    --ink-dim: rgba(255, 255, 255, 0.72);
    color-scheme: dark;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: #101012;
    color: var(--ink);
}

/* Fractalysis app shell */

/* The shell fills the window and the canvas fills the shell; the icon rail and side
   panel float over the fractal rather than sitting beside it. */
.fractal-shell {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

#fractalCanvas {
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    width: 100%;
    height: 100%;
    background: #000;
    touch-action: none;
    cursor: grab;
}

/* A hairline along the bottom edge. Deliberately slight: it reports on a render that is
   already showing its own progress in the picture, so it only has to say "still working"
   and roughly how far along. Never takes pointer events - the canvas beneath it is a drag
   surface all the way to the edge. It fades rather than popping, because it appears and
   disappears often enough that a hard cut would read as a flicker. */
.render-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    z-index: 3;
    background: var(--chrome-panel);
    opacity: 0;
    transition: opacity 180ms ease;
    pointer-events: none;
}

.render-progress.is-visible {
    opacity: 1;
}

.render-progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    /* Just enough easing to smooth the step between one animation frame's figure and the
       next; short enough that the bar still tracks the render rather than trailing it. */
    transition: width 120ms linear;
}

.icon-rail {
    position: absolute;
    top: 0;
    left: 0;
    width: 56px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Matches the side panel's top offset, so the first button and the panel start on the
       same line. */
    padding: 12px 0;
    z-index: 2;
}

.icon-btn {
    width: 48px;
    height: 48px;
    margin: 0 4px;
    /* Border-box so the 3px active border thickens the ring in place instead of growing
       the button past the 56px rail and nudging its icon off centre. */
    box-sizing: border-box;
    display: grid;
    place-items: center;
    border-radius: 24px;
    border: 1px solid var(--chrome-line);
    background: var(--chrome);
    backdrop-filter: blur(8px);
    cursor: pointer;
    color: var(--ink);
}

.icon-btn.active {
    background: var(--chrome-active);
    border: 3px solid var(--accent);
    /* Outer hairline only. On the inside the ring has the dark button to define it, but its
       outside edge sits on the fractal - and wherever that is white, canary on white has
       almost no edge at all. The inset hairline the light chrome needed is gone. */
    box-shadow: 0 0 0 1px var(--accent-edge);
}

/* One stroke weight and one colour for every icon; the individual shapes only say which
   parts are filled instead. Non-scaling-stroke keeps the weight honest if the viewBox is
   ever drawn at another size. */
.icon-btn svg {
    width: 25px;
    height: 25px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

/* Solid accents - the paint blobs, the crosshair centre, the dot of the i. */
.icon-btn .icon-dot {
    fill: currentColor;
    stroke: none;
}

/* The cast shadow behind the Shadows icon's front circle. */
.icon-btn .icon-shade {
    fill: currentColor;
    stroke: none;
    opacity: 0.36;
}

.side-panel {
    position: absolute;
    /* Floated clear of the top edge, with the same gap left at the bottom so a tall panel
       stops short of it rather than running into the corner. */
    top: 12px;
    left: 56px;
    width: 264px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    z-index: 1;
    /* Let the fractal show through, but keep the blur heavy: it is what holds the text
       legible over whatever happens to be underneath. */
    background: var(--chrome-panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--chrome-line);
    border-radius: 10px;
    /* Rounded on all four sides now that the panel floats rather than butting against the
       window edge, so the shadow drops straight down instead of only to one side. */
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
    padding: 4px 8px 8px 8px;
    box-sizing: border-box;
}

.panel-card {
    padding: 4px 4px 8px 4px;
}

.panel-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--ink);
}

.panel-content {
    background: var(--chrome-inset);
    border-radius: 10px;
    padding: 8px;
}

.slider-row {
    display: grid;
    grid-template-columns: 60px 1fr 60px;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

.slider-label {
    font-size: 0.85em;
    color: var(--ink-dim);
}

.slider-range {
    width: 100%;
}

.slider-number {
    width: 56px;
    font-size: 0.85em;
}

.fixed-point-entry {
    width: 100%;
    box-sizing: border-box;
    font-size: 0.85em;
    font-family: monospace;
}

/* Fields read as recessed rather than raised - darker than the surface they sit in, which
   is the way round that looks right on dark chrome. */
.slider-number,
.fixed-point-entry {
    background: var(--chrome-field);
    border: 1px solid var(--chrome-line);
    border-radius: 4px;
    color: var(--ink);
    padding: 2px 4px;
}

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.color-swatch {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--chrome-line);
    cursor: pointer;
    position: relative;
    padding: 0;
}

    /* Punches the swatch's conic gradient into a ring. It has to be opaque to hide the
       gradient underneath, so it cannot simply be the panel's own translucent surface -
       this is that surface's composite, matched by eye. */
    .color-swatch::after {
        content: "";
        position: absolute;
        inset: 32%;
        border-radius: 50%;
        background: #1c1c1f;
    }

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.preset-btn {
    height: 32px;
    font-weight: bold;
    border-radius: 6px;
    border: 1px solid var(--chrome-line);
    background: var(--chrome-inset);
    color: var(--ink);
    cursor: pointer;
}

.preset-btn:hover {
    background: var(--accent);
    border-color: var(--accent-edge);
    color: #2b2600;
}

.position-fields {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: center;
    gap: 4px;
}

/* The panel's primary action, so it carries the accent as a fill rather than an edge.
   Canary is light enough that dark text on it stays comfortably readable. */
.save-btn {
    width: 100%;
    height: 40px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    background: var(--accent);
    border: 1px solid var(--accent-edge);
    color: #2b2600;
}

.save-btn:hover {
    background: #fff44d;
}

/* Carries the accent rather than a link colour - a default blue would be the one thing on
   the panel that did not belong to the palette, and it reads well on the dark surface. */
.info-feedback {
    float: right;
    text-decoration: none;
    font-size: 1.4em;
    color: var(--accent);
}
