/* ===== the chrome =====
   The corner (the way back and the menu button), the skip link and the menu
   panel — everything lucid.js injects into a page, and nothing else.

   This lives apart from lucid.css because the Soup Lab store is its own
   design system, with its own :root, its own .panel and its own links: it
   wants the menu and would be restyled from the ground up by the rest of
   lucid.css. A page links this file to get the chrome alone; lucid.css
   imports it so every other page is unchanged.

   One source of truth either way — a copy would have drifted. */

:root {
    /* The chrome's own tokens. lucid.css defines these too — and because it
       imports this file at the top, its values are the ones that land on a
       site page. These are for the page that loads the chrome alone: the Soup
       Lab store, which has its own design system and none of lucid.css.
       Without them the menu button lost its font, its corners and its colour,
       and the panel fell back to Times. */
    --lucid-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --lucid-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --lucid-radius: 3px;
    --lucid-track: .18em;
    --lucid-accent: #9b7bff;
    --lucid-accent-2: #8ae04b;

    /* How far down the page has to start to clear the fixed chrome in the
       corner. Every page that draws a title across the full width needs this
       number, and every page had been guessing at it separately — which is how
       the SynthSoup wordmark ended up underneath the index button. One number,
       stated where the chrome itself is defined, so it cannot drift. */
    --lucid-chrome-clear: 48px;   /* 12 top + 27 tall + 9 of air */
    /* And the same number sideways, for a page that writes across the top
       rather than down from it: how far in from the right edge the corner
       reaches. The gallery's altitude readout needs it — without it the menu
       button sits on the word "flights". */
    --lucid-chrome-slot: 104px;   /* 12 right + ~84 wide + 8 of air */
}

/* ===== the corner =====
   The way back and the menu button, in one row, pinned top right. Every page
   that does not already carry a way back gets the same one, to the bowl on
   the front page: before that, the entrance was the only page that linked
   anywhere, so each tool was a dead end. The menu arrived later and sits
   beside it; a page with a bar of its own can host both instead (see
   data-lucid-chrome-slot in lucid.js). */
.lucid-chrome {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    z-index: 2147483000;          /* above whatever the page has */
    display: flex;
    align-items: center;
    gap: 8px;
}
.lucid-return {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(139, 108, 245, .40);
    border-radius: var(--lucid-radius);
    background: rgba(5, 5, 10, .82);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: var(--lucid-accent);
    font-family: var(--lucid-mono);
    font-size: 10px;
    letter-spacing: var(--lucid-track);
    text-transform: uppercase;
    text-decoration: none;
    line-height: 1;
    opacity: .78;
    transition: opacity .2s ease, border-color .2s ease, background .2s ease;
}
.lucid-return:hover,
.lucid-return:focus-visible {
    opacity: 1;
    color: var(--lucid-accent-2);
    border-color: rgba(138, 224, 75, .8);
    background: rgba(138, 224, 75, .14);
    outline: none;
}
.lucid-return::before {
    content: '';
    width: 11px; height: 6px;
    /* A bowl, seen from the side: the mark the front page is named by. */
    border: 1px solid currentColor;
    border-top: 0;
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
@media (max-width: 640px) {
    :root {
        --lucid-chrome-clear: 41px;          /* 8 top + 25 tall + 8 of air */
        --lucid-chrome-slot: 52px;           /* the word is hidden: icon only */
    }
    .lucid-return { font-size: 9px; padding: 7px 10px; }
}

/* Installed to a home screen there is no browser chrome, so the page starts
   at the very top of the glass — under the clock and the notch. Everything
   pinned to a corner has to come in by the safe area or it lands beneath
   them. Zero on every desktop, so this costs nothing anywhere else. */
@media (max-width: 640px) {
    .lucid-chrome {
        top: calc(8px + env(safe-area-inset-top, 0px));
        right: calc(8px + env(safe-area-inset-right, 0px));
        gap: 6px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .lucid-return { transition: none; }
}


/* ----- the way past the chrome ----------------------------------------
   Injected by lucid.js into every page, so a keyboard does not have to walk
   the whole stack bar to reach the content. Off-screen until focused. */
.lucid-skip {
    position: fixed;
    top: 0; left: 50%;
    transform: translate(-50%, -140%);
    z-index: 2147483001;                /* over the chrome, which is ...000 */
    padding: 10px 18px;
    background: #05040f;
    color: var(--lucid-focal, #6fe3e8);
    border: 1px solid var(--lucid-focal, #6fe3e8);
    border-radius: 0 0 var(--lucid-radius, 3px) var(--lucid-radius, 3px);
    font-family: var(--lucid-mono, ui-monospace, Menlo, Consolas, monospace);
    font-size: 12px;
    letter-spacing: var(--lucid-track, .18em);
    text-transform: uppercase;
    text-decoration: none;
    transition: transform .14s ease;
}
.lucid-skip:focus { transform: translate(-50%, 0); }

/* ===== the menu =====
   The site's two indexes before this were the bowl and the Stack, and both
   are places: you have to be on the front page to use one and you have to
   turn the other. This is the plain list, on every page, in the same corner,
   saying where you already are.

   Nothing here is clever on purpose. It is a <nav> of <ul>s under headings,
   each row is a link, the whole thing works from the keyboard with the arrow
   keys or with Tab, Escape closes it, and if the stylesheet never arrives it
   is still a list of links. */
.lucid-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    /* 25px tall to match the chip beside it, but the touch target is grown
       back to 44 with the pseudo-element below: a 25px control is fine to
       look at and not fine to hit. */
    padding: 8px 12px;
    border: 1px solid rgba(139, 108, 245, .40);
    border-radius: var(--lucid-radius);
    background: rgba(5, 5, 10, .82);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: var(--lucid-accent);
    font-family: var(--lucid-mono);
    font-size: 10px;
    letter-spacing: var(--lucid-track);
    text-transform: uppercase;
    line-height: 1;
    cursor: pointer;
    position: relative;
    opacity: .78;
    transition: opacity .2s ease, border-color .2s ease, background .2s ease;
}
.lucid-menu-btn::after {
    /* The target, not the paint. */
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: max(100%, 44px); height: max(100%, 44px);
    transform: translate(-50%, -50%);
}
.lucid-menu-btn:hover,
.lucid-menu-btn:focus-visible,
.lucid-menu-btn[aria-expanded="true"] {
    opacity: 1;
    color: var(--lucid-accent-2);
    border-color: rgba(138, 224, 75, .8);
    background: rgba(138, 224, 75, .14);
}
.lucid-menu-ico {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 12px;
}
.lucid-menu-ico i {
    display: block;
    height: 1.5px;
    background: currentColor;
    border-radius: 1px;
    transition: transform .2s ease, opacity .2s ease;
}
/* Three lines become a cross, so the button says what pressing it again
   will do. */
.lucid-menu-btn[aria-expanded="true"] .lucid-menu-ico i:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
.lucid-menu-btn[aria-expanded="true"] .lucid-menu-ico i:nth-child(2) { opacity: 0; }
.lucid-menu-btn[aria-expanded="true"] .lucid-menu-ico i:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

.lucid-menu {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    z-index: 2147483000;
    width: min(92vw, 340px);
    max-height: min(78vh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 4px 10px;
    border: 1px solid rgba(155, 123, 255, .42);
    border-radius: 6px;
    /* Opaque enough that a link over a live WebGL scene is still a link: the
       pages this lands on include two with a shader running behind them. */
    background: rgba(7, 5, 15, .96);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .66), 0 0 0 1px rgba(0, 0, 0, .5);
    animation: lucid-menu-in .16s ease-out;
}
@keyframes lucid-menu-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}
.lucid-menu[hidden] { display: none; }
/* This panel lands inside thirteen pages with thirteen sets of house rules,
   several of which style bare h2, ul and a. Everything it needs is stated
   here rather than inherited, so the menu looks the same on all of them. */
.lucid-menu, .lucid-menu * { text-align: left; box-sizing: border-box; }
.lucid-menu { font-family: var(--lucid-sans); }
.lucid-menu-group + .lucid-menu-group { margin-top: 2px; }
.lucid-menu h2 {
    margin: 8px 0 2px;
    border: 0;
    padding: 0 12px;
    font-family: var(--lucid-mono);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--lucid-ink-label, #b49cff);
}
.lucid-menu ul { list-style: none; margin: 0; padding: 0; }
.lucid-menu li { margin: 0; }
.lucid-menu a,
.lucid-menu button {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    /* 40px of row at the smallest, which is what a thumb needs. */
    min-height: 40px;
    justify-content: center;
    padding: 4px 12px;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 3px;
    background: none;
    color: var(--lucid-ink, rgba(255,255,255,.93));
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.lucid-menu a > span, .lucid-menu button > span { font-size: 13.5px; line-height: 1.25; }
.lucid-menu small {
    font-family: var(--lucid-mono);
    font-size: 10px;
    line-height: 1.3;
    letter-spacing: .04em;
    color: var(--lucid-ink-faint, rgba(255,255,255,.54));
}
.lucid-menu a:hover,
.lucid-menu button:hover,
.lucid-menu a:focus-visible,
.lucid-menu button:focus-visible {
    background: rgba(155, 123, 255, .16);
    border-left-color: var(--lucid-accent-2, #8ae04b);
    color: #fff;
}
.lucid-menu a:hover small,
.lucid-menu button:hover small { color: var(--lucid-ink-dim, rgba(255,255,255,.74)); }
/* Where you are. A bar and a word, not a colour: colour alone is not an
   answer for anyone who cannot see this one. */
.lucid-menu a[aria-current="page"] {
    border-left-color: var(--lucid-accent-3, #d44fb0);
    background: rgba(212, 79, 176, .12);
}
.lucid-menu a[aria-current="page"]::after {
    content: 'you are here';
    font-family: var(--lucid-mono);
    font-size: 9px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--lucid-accent-3, #d44fb0);
}
.lucid-menu-aside { border-top: 1px solid rgba(155, 123, 255, .18); margin-top: 8px; padding-top: 2px; }
@media (max-width: 640px) {
    .lucid-menu {
        top: calc(48px + env(safe-area-inset-top, 0px));
        right: calc(8px + env(safe-area-inset-right, 0px));
        left: calc(8px + env(safe-area-inset-left, 0px));
        width: auto;
    }
    .lucid-menu-word { display: none; }       /* the icon is the button */
    .lucid-menu-btn { padding: 7px 10px; }
}
@media (prefers-reduced-motion: reduce) {
    .lucid-menu { animation: none; }
    .lucid-menu-btn, .lucid-menu a, .lucid-menu button { transition: none; }
}
