/**
 * Layout and components.
 *
 * Header, hero, catalogue sections, pre footer band, footer, drawer, search
 * results, the more link and the not found page. Colours and sizes come from
 * base.css, movement from motion.css.
 */

/* ----------------------------------------------------------------------------
   1. HEADER
   ------------------------------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--canvas);
    border-bottom: 1px solid var(--line-soft);
}

.header__inner {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: var(--gap-head);
}

/* Divider between the burger and the brand. Fades out at both ends. */
.header__rule {
    width: 1px;
    align-self: stretch;
    margin: 12px 6px 12px 2px;
    flex: 0 0 auto;
    background: linear-gradient(to bottom, transparent, var(--line) 30%, var(--line) 70%, transparent);
}

.header__spacer {
    flex: 1;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    color: var(--ink);
}

.brand:hover {
    text-decoration: none;
}

.brand__mark {
    /* mark: the umlaut sign */
    width: 36px;
    height: 36px;
    display: block;
    border-radius: var(--r-surface);
}

.brand__name {
    font-weight: 600;
    white-space: nowrap;
    font-size: var(--fs-lead);
    letter-spacing: -0.015em;
}

.icon-button {
    /* burger, close, search button */
    width: var(--tap);
    height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--r-control);
    color: var(--ink-2);
    cursor: pointer;
    padding: 0;
}

.icon-button:hover {
    background: var(--raise);
    color: var(--ink);
}

.icon-button--search {
    display: var(--show-search-button);
}

.search {
    display: var(--show-search-field);
    align-items: center;
    position: relative;
    flex: 0 1 300px;
    min-width: 150px;
}

.search__input {
    flex: 1;
    min-width: 0;
    height: var(--tap);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-control);
    background: var(--raise);
    padding: 0 42px 0 11px;
    outline: none;
    font-size: var(--fs-functional);
    color: var(--ink);
    caret-color: var(--accent);
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.search__input:hover {
    border-color: var(--line);
}

.search__input:focus {
    border-color: var(--accent);
    background: var(--canvas);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__clear {
    /* HOOK: show while the field is not empty */
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--r-control);
    color: var(--muted);
    cursor: pointer;
    font-size: var(--fs-functional);
}

.search__clear:hover {
    color: var(--accent);
}

.kbd {
    /* hint key, inset into the field */
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: calc(var(--tap) - 8px);
    padding: 0 6px;
    background: var(--line-soft);
    border-radius: var(--r-control);
    box-shadow: var(--shadow-inset);
    color: var(--ink-2);
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-quiet);
    line-height: 1;
}

.kbd--inline {
    /* same key in footer text, raised */
    position: static;
    transform: none;
    min-width: 22px;
    height: 22px;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    box-shadow: none;
    color: var(--accent);
    top: 1px;
    position: relative;
}

/* Theme and language menus. HOOK: data-open on .dropdown */
.dropdown {
    position: relative;
    flex: 0 0 auto;
}

.dropdown--theme {
    display: var(--show-theme-header);
}

.dropdown--lang {
    margin-left: calc(-1 * var(--gap-head) + 2px);
}

.dropdown__trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: var(--tap);
    padding: 0 8px;
    background: transparent;
    border: 0;
    border-radius: var(--r-control);
    color: var(--ink-2);
    cursor: pointer;
}

.dropdown__trigger:hover {
    background: var(--raise);
    color: var(--ink);
}

.dropdown[data-open] .dropdown__trigger {
    background: var(--raise);
    color: var(--ink);
}

.dropdown__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    display: none;
    gap: 2px;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: var(--r-surface);
    box-shadow: var(--shadow);
    padding: 4px;
    z-index: 40;
}

.dropdown[data-open] .dropdown__menu {
    display: flex;
}

.dropdown__option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap);
    width: var(--tap);
    height: var(--tap);
    background: transparent;
    border: 0;
    border-radius: var(--r-control);
    color: var(--ink-2);
    cursor: pointer;
}

.dropdown__option:hover {
    background: var(--raise);
    color: var(--ink);
}

.dropdown__option[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}

.dropdown__option--lang {
    width: auto;
    padding: 0 10px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-decoration: none;
}

/* ----------------------------------------------------------------------------
   2. TONE BAND: HERO
   ------------------------------------------------------------------------- */
.band {
    background: var(--tone);
    color: var(--tone-ink);
}

.band--hero {
    border-bottom: 1px solid var(--tone-line);
}

.band__inner {
    padding-block: var(--sec);
}

.hero__head {
    width: fit-content;
    max-width: 100%;
}

/* the rule matches the heading width */
.hero__title {
    font-size: var(--fs-display);
    line-height: var(--lh-display);
    letter-spacing: -0.035em;
    color: var(--tone-ink);
    text-wrap: balance;
    margin-bottom: 14px;
}

.hero__title em {
    font-style: normal;
    font-weight: 400;
    color: var(--tone-accent);
}

.hero__lede {
    font-size: var(--fs-lead);
    line-height: var(--lh-lead);
    font-weight: 500;
    color: var(--tone-ink);
    padding-bottom: 22px;
}

.hero__rule {
    height: 1px;
    background: var(--tone-line);
    margin-bottom: 30px;
}

.hero__grid {
    display: grid;
    grid-template-columns: var(--cols-hero);
    gap: 28px calc(var(--pad) * 1.6);
    align-items: start;
}

.hero__prose p {
    line-height: var(--lh-prose);
    max-width: 58ch;
    color: var(--tone-muted);
    text-wrap: pretty;
}

.hero__prose p + p {
    margin-top: 14px;
}

.hero__prose strong {
    font-weight: 600;
    color: var(--tone-ink);
}

/* Routes card. Lifted by --hero-card-lift on desktop */
.card {
    background: var(--canvas);
    color: var(--ink);
    border-radius: var(--r-surface);
    overflow: hidden;
    box-shadow: 0 1px 0 var(--line);
    margin-top: calc(-1 * var(--hero-card-lift));
    position: relative;
    z-index: 1;
}

.card__head {
    padding: 16px 18px;
    background: var(--accent);
    color: var(--canvas);
}

.card__title {
    font-size: var(--fs-lead);
    line-height: var(--lh-lead);
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 2px;
}

.card__hint {
    opacity: .88;
}

.card__row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--line-soft);
    color: var(--ink);
}

.card__row:hover {
    background: var(--accent-soft);
    text-decoration: none;
}

/* The title and the description stack, the icon stays beside them. */
.card__row > span:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.card__row-title {
    color: var(--title);
}

/* key word of the route */
.card__row-title b {
    font-weight: 600;
}

.card__row-desc {
    color: var(--muted);
    margin-top: 2px;
    text-wrap: pretty;
}

/* ----------------------------------------------------------------------------
   3. CATALOGUE SECTIONS
   Alternating: canvas, raised band, canvas.
   ------------------------------------------------------------------------- */
.section {
    border-block: 1px solid transparent;
}

.section--lift {
    background: var(--raise);
    border-block-color: var(--line-soft);
}

.section__inner {
    padding-block: calc(var(--sec) * 0.55);
    display: flex;
    flex-direction: column;
}

.section__head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ink);
}

.section__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-top: -2px;
}

.section__icon svg {
    width: var(--icon-section);
    height: var(--icon-section);
    display: block;
}

.section__title {
    font-size: var(--fs-heading);
    line-height: var(--lh-heading);
    letter-spacing: -0.015em;
    color: var(--title);
}

.section__hint {
    color: var(--muted);
    margin-top: 3px;
}

.row {
    display: grid;
    grid-template-columns: var(--cols-row);
    gap: 4px 24px;
    align-items: start;
    padding: 14px 10px 14px 4px;
    margin: 0 -10px 0 -4px;
    border-bottom: 1px solid var(--line-soft);
    border-radius: var(--r-control);
    color: var(--ink);
    min-height: var(--tap);
}

.row:hover {
    background: var(--accent-soft);
    text-decoration: none;
}

.row__title {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 500;
    color: var(--title);
}

.row__icon {
    flex: 0 0 var(--icon);
    height: var(--icon);
    margin-top: 2px;
    color: var(--accent);
}

.row__icon svg {
    width: var(--icon);
    height: var(--icon);
    display: block;
}

.row__desc {
    color: var(--muted);
    text-wrap: pretty;
    text-align: var(--row-desc-align);
    justify-self: var(--row-desc-align);
    /* start on phone, end on desktop */
    padding-left: var(--row-desc-indent);
}

/* ----------------------------------------------------------------------------
   4. PRE FOOTER BAND
   ------------------------------------------------------------------------- */
.poster {
    padding-top: calc(var(--sec) * 0.8);
}

.poster__code {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-poster);
    line-height: 1.14;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.poster__code em {
    font-style: normal;
    color: var(--tone-accent);
}

.poster__line {
    line-height: var(--lh-prose);
    color: var(--tone-muted);
    margin-top: 18px;
    max-width: 46ch;
    text-wrap: pretty;
}

.poster__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 2px;
    color: var(--tone-accent);
}

.instrument {
    /* instrument row: versions and sources */
    padding-bottom: calc(var(--sec) * 0.65);
}

.instrument__inner {
    margin-top: 30px;
    padding-top: 18px;
    border-top: 1px solid var(--tone-line);
    display: flex;
    flex-wrap: wrap;
    gap: 18px 48px;
    align-items: flex-start;
    justify-content: space-between;
}

.stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 26px;
}

.stack__item {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.stack__name {
    font-size: var(--fs-quiet);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tone-muted);
}

.stack__num {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-lead);
    font-weight: 500;
    color: var(--tone-accent);
}

/* The label sits on its own line, the links follow underneath. */
.sources {
    display: grid;
    gap: 8px 22px;
    align-items: baseline;
}

.sources .label {
    grid-column: 1 / -1;
}

.sources .label {
    color: var(--tone-muted);
}

@media (min-width: 768px) {
    .sources {
        display: flex;
        flex-wrap: wrap;
    }

    .sources .label {
        grid-column: auto;
    }
}

.sources a {
    font-family: 'JetBrains Mono', monospace;
    color: var(--tone-ink);
}

.sources a:hover {
    color: var(--tone-accent);
    text-decoration: none;
}

/* ----------------------------------------------------------------------------
   5. FOOTER
   ------------------------------------------------------------------------- */
.footer {
    border-top: 1px solid var(--line-soft);
    background: var(--raise);
}

.footer__grid {
    /* Block only: the side padding belongs to .wrap and must survive. */
    padding-block: 32px 40px;
    display: grid;
    grid-template-columns: var(--cols-footer);
    gap: 22px 28px;
    align-items: start;
}

.footer__brand {
    font-weight: 600;
    margin-bottom: 3px;
}

.footer__text {
    font-size: var(--fs-functional);
    color: var(--muted);
}

.footer__links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: var(--fs-functional);
}

.footer__links a {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
}

.footer__note {
    font-size: var(--fs-functional);
    color: var(--muted);
    max-width: 30ch;
    text-wrap: pretty;
}

.footer__hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-functional);
    color: var(--muted);
}

/* ----------------------------------------------------------------------------
   6. DRAWER
   HOOK: data-state on .drawer, either open or closing.
   The panel leaves the document only after the closing animation, 200ms.
   The page is pinned while the drawer is open and restored on close.
   ------------------------------------------------------------------------- */
.veil {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: oklch(0.2 0.02 200 / 0.44);
    animation: veilIn .24s ease-out both;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(86vw, 340px);
    background: var(--canvas);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    will-change: transform;
    animation: drawerIn .24s cubic-bezier(.22, .61, .36, 1) both;
}

.drawer[data-state="closing"] {
    animation: drawerOut .2s ease-in both;
}

.veil[data-state="closing"] {
    animation: veilOut .2s ease-in both;
}

.drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 12px 0 20px;
    min-height: 60px;
    border-bottom: 1px solid var(--line-soft);
}

.drawer__search {
    display: var(--show-search-drawer);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
    position: relative;
}

.drawer__search .search__input {
    width: 100%;
    height: 44px;
    padding-right: 40px;
}

.drawer__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.drawer__body::-webkit-scrollbar {
    width: 6px;
}

.drawer__body::-webkit-scrollbar-track {
    background: transparent;
}

.drawer__body::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: var(--r-control);
}

.drawer__group-name {
    /* sticky group label */
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 8px 20px;
    background: var(--raise);
    border-block: 1px solid var(--line-soft);
    font-size: var(--fs-quiet);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.drawer__list {
    padding-block: 6px;
}

.drawer__row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 9px 20px;
    min-height: var(--tap);
    color: var(--ink);
}

.drawer__row:hover {
    background: var(--accent-soft);
    text-decoration: none;
}

.drawer__row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.drawer__row-title {
    font-weight: 500;
    color: var(--title);
}

.drawer__row-short {
    font-size: var(--fs-functional);
    color: var(--muted);
}

.drawer__foot {
    border-top: 1px solid var(--line);
    padding: 12px 12px 12px 20px;
    display: var(--show-theme-drawer);
    align-items: center;
    gap: 12px;
    background: var(--raise);
}

.drawer__foot .dropdown__option {
    border-radius: var(--r-control);
}

/* ----------------------------------------------------------------------------
   7. SEARCH RESULTS
   The panel drops out of the field it belongs to, header or drawer alike.
   ------------------------------------------------------------------------- */

.results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: var(--r-surface);
    box-shadow: var(--shadow);
    max-height: 60vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.results__hit {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    border-bottom: 1px solid var(--line-soft);
}

.results__hit:last-child {
    border-bottom: 0;
}

.results__hit:hover {
    background: var(--accent-soft);
}

.results__name {
    display: block;
    color: var(--ink);
    font-weight: 500;
}

.results__desc {
    display: block;
    color: var(--muted);
    font-size: var(--fs-functional);
    line-height: var(--lh-ui);
    margin-top: 2px;
}

.results__empty {
    padding: 16px 14px;
    margin: 0;
    color: var(--muted);
}

/* Inside the drawer the panel flows instead of floating. */
.drawer__search .results {
    position: static;
    box-shadow: none;
    margin-top: 8px;
    max-height: none;
}

/* ----------------------------------------------------------------------------
   8. MORE LINK
   Sits under a section when the list on the homepage is shortened.
   ------------------------------------------------------------------------- */
.more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-top: 4px;
    padding: 8px 2px;
    color: var(--accent);
    text-decoration: none;
    font-size: var(--fs-functional);
}

.more:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.section__inner > .more {
    align-self: flex-end;
}

/* The trigger shows the icon of the current theme, the rest stay hidden. */
.theme-icon {
    display: none;
    line-height: 0;
}

:root[data-theme="auto"] .theme-icon[data-theme-icon="auto"], :root[data-theme="light"] .theme-icon[data-theme-icon="light"], :root[data-theme="dark"] .theme-icon[data-theme-icon="dark"], :root[data-theme="warm"] .theme-icon[data-theme-icon="warm"] {
    display: inline-flex;
}

.dropdown__caret {
    color: var(--muted);
    flex: 0 0 auto;
}

/* Language options are real links, so they must not look like text. */

.dropdown__option--lang[aria-current="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ----------------------------------------------------------------------------
   9. NOT FOUND PAGE
   ------------------------------------------------------------------------- */

.notfound__code {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-display);
    line-height: var(--lh-display);
    letter-spacing: -0.035em;
    margin-bottom: 14px;
}

.notfound__lead {
    font-size: var(--fs-lead);
    line-height: var(--lh-lead);
    font-weight: 500;
    padding-bottom: 22px;
}

.notfound__rule {
    height: 1px;
    max-width: var(--col-text);
    background: var(--tone-line);
    margin-bottom: 30px;
}

.notfound__body {
    line-height: var(--lh-prose);
    max-width: 56ch;
    color: var(--tone-muted);
    text-wrap: pretty;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    margin-top: 26px;
}

.button {
    display: inline-flex;
    align-items: center;
    min-height: 52px;
    padding: 0 18px;
    border-radius: var(--r-control);
    white-space: nowrap;
}

.button--primary {
    background: var(--tone-accent);
    color: var(--tone);
    font-weight: 500;
    border: 0;
}

.button--primary:hover {
    text-decoration: none;
    opacity: .92;
}

.button--ghost {
    border: 1px solid var(--tone-line);
    color: var(--tone-ink);
}

.button--ghost:hover {
    text-decoration: none;
    border-color: var(--tone-accent);
    color: var(--tone-accent);
}

.band-search {
    display: flex;
    align-items: center;
    position: relative;
    margin-top: 26px;
    max-width: 440px;
}

.band-search__input {
    flex: 1;
    min-width: 0;
    height: 52px;
    border: 1px solid var(--tone-line);
    border-radius: var(--r-control);
    background: oklch(1 0 0 / 0.06);
    padding: 0 14px;
    outline: none;
    color: var(--tone-ink);
    caret-color: var(--tone-accent);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.band-search__input:hover {
    border-color: var(--tone-accent);
}

.band-search__input:focus {
    border-color: var(--tone-accent);
    box-shadow: 0 0 0 3px oklch(1 0 0 / 0.10);
}

.results__row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 11px 2px;
    border-bottom: 1px solid var(--tone-line);
    color: var(--tone-ink);
}

.results__row:hover {
    background: oklch(1 0 0 / 0.06);
    text-decoration: none;
}

.results__title {
    font-weight: 500;
}

.results__short {
    font-size: var(--fs-functional);
    color: var(--tone-muted);
}

.empty {
    margin-top: 14px;
    max-width: 560px;
    color: var(--tone-muted);
}

.empty__hints {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 0 14px;
    background: transparent;
    border: 1px solid var(--tone-line);
    border-radius: var(--r-control);
    color: var(--tone-ink);
    cursor: pointer;
}

.chip:hover {
    border-color: var(--tone-accent);
    color: var(--tone-accent);
}