/* The shipped components. Load tokens.css first: every value here comes from
   it, and nothing here sets a shadow, a gradient or a corner radius. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: var(--t-body) / 1.5 var(--serif);
}

a {
    color: var(--spot);
    text-underline-offset: 3px;
}

/* Components set display, which outranks the UA rule for [hidden]. */
[hidden] {
    display: none !important;
}

code,
kbd,
.mono {
    font-family: var(--mono);
}

/* Mono runs wider than the serif at one size; inline it drops a step. */
code,
kbd {
    font-size: 0.9em;
}

/* One focus treatment for every focusable thing, drawn outside its box so a
   row's own hairline stays readable under it. */
:focus-visible {
    outline: 2px solid var(--spot);
    outline-offset: 3px;
}

/* Read aloud, never drawn: clipping keeps the element in the accessibility
   tree, which display:none does not. */
.vh {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip {
    position: fixed;
    top: 8px;
    left: -9999px;
    z-index: 5;
}

.skip:focus {
    left: 8px;
    padding: 10px 14px;
    background: var(--paper);
    border: var(--edge);
}

/* Page frame */

.page {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--pad-top) var(--pad-x) var(--pad-bottom);
}

.prose {
    max-width: var(--measure);
}

/* Navigation band */

.nav {
    border-bottom: var(--band-rule);
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 22px var(--pad-x) 14px;
}

.nav-logo a {
    color: var(--ink);
    font-size: var(--t-small);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    text-decoration: none;
}

/* One step down from the logo in size and weight, on the same baseline: the
   site's own name stays the loudest thing in the band. */
.nav-links {
    display: flex;
    gap: 22px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-links a {
    color: var(--ink);
    font-size: var(--t-label);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: var(--track-band);
    text-decoration: none;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* Page head */

.head h1,
.detail h1 {
    margin: 0 0 6px;
    font-size: var(--t-page);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.015em;
}

.lead {
    max-width: var(--measure);
    margin: 0;
    color: var(--muted);
    font-style: italic;
}

/* A page with no navigation band: the head draws the rule the band would
   have, and the page takes the band's height as top padding. */
.head--rule {
    padding-bottom: 18px;
    border-bottom: var(--band-rule);
}

.page:has(> .head--rule) {
    padding-top: 56px;
}

/* Aside: a caveat under a heading, held off the text column by a vertical
   rule. It is the only vertical rule in the system, and it is `rule`, so it
   never reads as a control's edge. */
.aside {
    max-width: var(--measure);
    margin: 12px 0 0;
    padding: 8px 12px;
    border-left: 3px solid var(--rule);
    color: var(--muted);
}

/* Band: a section under a heavy rule */

.band {
    margin-top: var(--gap-band);
    border-top: var(--band-rule);
    padding-top: 12px;
}

/* The navbar's rule already closes the top of the page, so a second one under
   it is two rules and a band of nothing between them. */
.band:first-of-type {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

.page:has(> .head--rule) .band:first-of-type {
    margin-top: var(--gap-band);
    border-top: var(--band-rule);
    padding-top: 12px;
}

/* Dotted marks a second channel where one exists, so the split survives
   greyscale and colour blindness. */
.band--alt {
    border-top-style: dotted;
}

.band > h2 {
    margin: 0;
    font-size: var(--t-body);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--track-band);
}

.band-note {
    margin-left: 14px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: var(--t-small);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

/* Block: a label column and its content */

.block {
    display: grid;
    grid-template-columns: var(--label-col) minmax(0, 1fr);
    gap: var(--gap-col);
    max-width: 100%;
    margin-top: 16px;
}

.block > h3 {
    margin: 0;
    align-self: start;
    font-size: var(--t-label);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--track-band);
}

.block--mono > h3 {
    font-family: var(--mono);
    text-transform: none;
    letter-spacing: 0;
}

/* Rows: a list read down the name column */

.rows {
    margin: 0;
    padding: 0;
    list-style: none;
}

.row {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr) 7rem;
    gap: 3px 28px;
    align-items: baseline;

    /* The negative margin lets the hover fill reach past the text column without
     moving the text, so the rules above and below stay aligned. */
    margin: 0 -12px;
    border-bottom: var(--hairline);
    padding: 12px;
}

.row:hover,
.row:has(:focus-visible) {
    background: var(--tint);
}

.row-head {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    align-items: baseline;
    gap: 10px;
}

.row-index {
    flex: none;
    min-width: 2.2rem;
    color: var(--muted);
    font-family: var(--mono);
    font-size: var(--t-meta);
    text-align: right;
}

.row-index.on {
    color: var(--ink);
}

.row-name {
    margin: 0;
    font-family: var(--mono);
    font-size: var(--t-row);
    font-weight: 700;
}

/* The name is the row's link or button; it takes the row's colour, so the
   hover rule below is what turns it spot. */
/* stylelint-disable-next-line no-descending-specificity */
.row-name a,
.row-name button {
    padding: 0;
    color: inherit;
    font: inherit;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
}

.row:hover .row-name,
.row:has(:focus-visible) .row-name {
    color: var(--spot);
}

.row-mark {
    color: var(--spot);
    font-size: var(--t-meta);
}

.row-note {
    grid-column: 2;
    margin: 0;
    font-size: var(--t-row);

    /* Five lines, so no row grows taller than the ones it is scanned against. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    overflow: hidden;
}

.row-meta {
    display: flex;
    flex-wrap: wrap;
    grid-column: 3;
    grid-row: 1;
    justify-content: flex-end;
    color: var(--muted);
    font-size: var(--t-meta);
    text-transform: uppercase;
    letter-spacing: var(--track-meta);
}

.tag + .tag::before {
    content: "·";
    margin: 0 0.6em;
    color: var(--rule);
}

.tag.on {
    color: var(--ink);
}

/* Tiles: a fixed-width image card */

.tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A column, so the meta line sits at the bottom of the tallest tile in the
   row rather than wherever the title above it ended. */
.tile {
    display: flex;
    flex: 0 0 var(--tile);
    flex-direction: column;
    width: var(--tile);
}

.tile-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.tile-image {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--tint);
    border: var(--hairline);
}

.tile:hover .tile-image,
.tile:has(:focus-visible) .tile-image {
    border-color: var(--ink);
}

/* Two lines held open for the title, which is what most tiles need: a short
   title then starts its sub-line where its neighbours do. */
.tile-title {
    display: block;
    min-height: 2.5em;
    margin-top: 9px;
    overflow-wrap: break-word;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.25;
}

.tile:hover .tile-title,
.tile:has(:focus-visible) .tile-title {
    color: var(--spot);
}

/* The sub-line takes its own line, so a two-word title keeps the full width
   to wrap in and the values line up down the column. */
.tile-sub {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: var(--t-fine);
}

.tile-meta {
    min-height: 2.6em;
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Columns: groups that wrap as units under a dateline. A group keeps the
   width its content needs, and the rule under its heading runs that width,
   which is what shows where one group ends and the next starts. */

.columns {
    display: flex;
    flex-wrap: wrap;
    gap: 32px 40px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

/* Packed: newspaper columns on a fixed track, filled from the top, for groups
   of unequal height that a flex row would leave holes beside. */
.columns--packed {
    display: block;
    columns: 200px;
    column-gap: 40px;
}

.column {
    flex: 0 0 auto;
    max-width: 100%;
}

/* Padding, not margin: WebKit carries a margin over a column break, so the
   next column would start that far down. */
.columns--packed > .column {
    break-inside: avoid;
    padding-bottom: 32px;
    overflow-wrap: break-word;
}

.column > h3 {
    margin: 0 0 10px;
    padding-bottom: 7px;
    border-bottom: var(--edge);
    font-family: var(--mono);
    font-size: var(--t-meta);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* The date under a weekday, on its own line so the weekday stays the word
   the eye lands on. */
.column-sub {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

/* Links: a list read as names, ink at rest so a column of them is not a
   column of red. */

.links {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--t-row);
    line-height: 1.6;
}

/* A gap marks a group boundary inside a column. */
.links + .links {
    margin-top: 10px;
}

/* stylelint-disable-next-line no-descending-specificity */
.links a {
    color: var(--ink);
    text-decoration: none;
}

.links a:hover,
.links a:focus-visible {
    color: var(--spot);
    text-decoration: underline;
}

/* Rail: a row of filters and its legend */

.rail {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    margin: 22px 0 10px;
}

.rail button {
    padding: 3px 2px;
    color: var(--muted);
    font: inherit;
    font-size: var(--t-label);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.rail button:hover {
    color: var(--ink);
}

.rail button[data-channel] {
    border-bottom-color: var(--rule);
}

.rail button[data-channel="alt"] {
    border-bottom-style: dotted;
}

.rail button[aria-pressed="true"] {
    color: var(--spot);
    border-bottom-color: var(--spot);
    border-bottom-style: solid;
}

.rail .arrow {
    color: var(--rule);
    font-size: var(--t-meta);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin-bottom: 20px;
    color: var(--muted);
    font-size: var(--t-label);
}

.legend span::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 0;
    margin-right: 8px;
    vertical-align: middle;
    border-top: var(--band-rule);
}

.legend .alt::before {
    border-top-style: dotted;
}

.legend .marked::before {
    content: none;
}

.legend .marked {
    color: var(--spot);
}

/* Controls */

.controls {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.field {
    flex: 1 1 auto;
    padding: 8px 2px;
    color: var(--ink);
    font: inherit;
    font-style: italic;
    background: none;
    border: 0;
    border-bottom: var(--edge);
}

/* The underline thickens in place, so focus does not move the baseline. */
.field:focus {
    outline: 0;
    padding-bottom: 7px;
    border-bottom: 2px solid var(--spot);
}

.link-button {
    flex: none;
    padding: 4px 0;
    color: var(--spot);
    font: inherit;
    font-size: var(--t-label);
    background: none;
    border: 0;
    border-bottom: 1px solid var(--spot);
    cursor: pointer;
}

/* An action at the rail's far end, set like the filters so the row reads as
   one line. */
.rail .link-button {
    margin-left: auto;
    padding: 3px 2px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.count {
    margin: 14px 0 30px;
    color: var(--muted);
    font-size: var(--t-meta);
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

/* Facts: a labelled value list */

.facts {
    display: grid;
    grid-template-columns: var(--term-col) minmax(0, 1fr);
    margin: 26px 0 0;
}

.facts dt,
.facts dd {
    padding: 8px 0;
    border-bottom: var(--hairline);
}

.facts dt {
    color: var(--muted);
    font-size: var(--t-meta);
    text-transform: uppercase;
    letter-spacing: var(--track-meta);
}

.facts dd {
    margin: 0;
    font-size: var(--t-row);
}

/* Definitions: a mono term against its one-line summary */

.defs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 40px;
}

.def {
    display: grid;
    grid-template-columns: var(--term-col) minmax(0, 1fr);
    gap: 14px;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: var(--hairline);
}

.def dt {
    font-family: var(--mono);
    font-size: 12.5px;
}

.def dd {
    margin: 0;
    color: var(--muted);
    font-size: var(--t-small);
}

.def dd strong {
    color: var(--ink);
}

/* Detail: one entry's page, a band capped at reading width */

.detail {
    max-width: 860px;
    margin-top: 28px;
    border-top: var(--band-rule);
    padding-top: 18px;
}

.detail-image {
    display: block;
    width: 100%;
    margin-bottom: 22px;
    background: var(--tint);
    border: var(--hairline);
}

/* An alternate title under the main one: the original, or the English. */
.detail-alt {
    margin: 0;
    color: var(--muted);
    font-style: italic;
}

.tagline {
    margin: 10px 0 0;
    font-size: var(--t-lead);
    font-style: italic;
}

.detail h2 {
    margin: 26px 0 0;
    font-size: var(--t-label);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--track-band);
}

/* pre-line: the source writes paragraphs and the blank lines come through. */
.detail-prose {
    max-width: var(--measure);
    margin: 26px 0 0;
    white-space: pre-line;
}

.detail-source {
    margin: 26px 0 0;
    font-size: var(--t-small);
    overflow-wrap: anywhere;
}

/* Showings: a day, a mono time and a place, over hairlines */

.showings {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.showing {
    display: grid;
    grid-template-columns: 1fr 4rem 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: var(--hairline);
}

.showing-time {
    font-family: var(--mono);
    font-size: var(--t-small);
}

.showing-where {
    color: var(--muted);
    font-size: var(--t-label);
}

/* Sheet: the dialog */

dialog.sheet {
    width: min(1180px, 92vw);
    max-height: 88vh;
    overflow: auto;
    padding: 0;
    color: var(--ink);
    background: var(--paper);
    border: var(--edge);
    border-radius: 0;
}

dialog.sheet::backdrop {
    background: rgb(22 21 15 / 40%);
}

.sheet-body {
    padding: 26px 34px 34px;
}

.sheet-body > h2 {
    margin: 0;
    font-size: var(--t-sheet);
    font-weight: 700;
}

/* The heading takes focus so the dialog reads from its own name; the ring
   would frame the whole line. */
.sheet-body > h2:focus {
    outline: 0;
}

.sheet-body h4 {
    margin: 24px 0 10px;
    padding-bottom: 4px;
    color: var(--muted);
    font-size: var(--t-fine);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--track-band);
    border-bottom: var(--hairline);
}

/* Sticky so it stays reachable while a tall sheet scrolls, opaque so the text
   passes under it. */
.close {
    position: sticky;
    top: 0;
    float: right;
    min-width: 44px;
    margin-right: 4px;
    padding: 12px;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    background: var(--paper);
    border: 0;
    cursor: pointer;
}

/* Footer */

.foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    max-width: var(--page-max);
    margin: 0 auto;
    border-top: var(--band-rule);
    padding: 14px var(--pad-x) 40px;
}

.foot p {
    margin: 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.5;
}

.empty {
    padding: 26px 0;
    color: var(--muted);
    font-style: italic;
}

.empty .link-button {
    margin-left: 8px;
    font-style: normal;
}

/* Messages: the flashed lines any page can carry above its content. The
   error line is spot's one use outside a state. */

.msg {
    margin: 0 0 12px;
}

.msg--error {
    color: var(--spot);
}

.msg--info {
    color: var(--muted);
    font-style: italic;
}

/* Below this the meta column takes width from the note, which is the column
   being read. */
@media (width <= 1080px) {
    .row {
        grid-template-columns: 15rem minmax(0, 1fr);
    }

    .row-meta {
        grid-column: 2;
        grid-row: auto;
        justify-content: flex-start;
        margin-top: 2px;
    }

    .defs {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (width <= 720px) {
    .nav-inner {
        padding: 18px var(--pad-x) 12px;
    }

    .rail {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .rail::-webkit-scrollbar {
        display: none;
    }

    .rail > * {
        flex: none;
    }

    .rail button {
        min-height: 44px;
    }

    .block {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    /* One identity line per row: name, mark, meta. The index goes, since the
     list is already printed in its order. */
    .row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .row-index {
        display: none;
    }

    .row-meta {
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-start;
    }

    .row-note {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    /* A 155px term column against a 300px row leaves the summary four words
     wide. */
    .def,
    .facts {
        grid-template-columns: minmax(0, 1fr);
    }

    .def {
        gap: 2px;
    }

    .facts dt {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .columns {
        gap: 26px 24px;
    }

    /* A phone is one 200px track plus a gap short of two, so ask for two
       columns outright and let long names wrap. */
    .columns--packed {
        columns: 2;
        column-gap: 24px;
    }

    .tiles {
        gap: 16px 10px;
    }

    .detail-image {
        margin-bottom: 16px;
    }

    .foot {
        padding: 12px var(--pad-x) 32px;
    }
}

/* Swatch: the visible key a colour needs on the page that uses it */

.swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 10px;
    vertical-align: -6px;
    border: var(--edge);
}
