/* ==========================================================
   SHUTTER

   One stylesheet for the two hand-written worlds: the landing
   (_layouts/landing.html) and the gallery (_layouts/cinematic.html).
   The tokens, the font, the wordmark, the nav, the panels and the move
   between pages are all here, so the two cannot run different greys or
   different golds again. What only one of them needs stays with it: the
   gallery's grid is in cinematic.html's own <style> block.

   The idea the whole thing is built on is a shutter. The field behind
   every page is drawn as embers, and each ember is drawn as the line it
   travels while the shutter is open. See assets/shutter/streak.js.
   ========================================================== */

@font-face {
    font-family: 'Inter Variable';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
}

/* ==========================================================
   TOKENS
   ========================================================== */
:root {
    /* Which canvas the browser paints before it has read any of this. The
       boot script sets it inline as well. This is the no-JS path. */
    color-scheme: dark;

    --brand-font: 'Inter Variable', 'Helvetica Neue', Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* The ground, and the same colour as a channel list so a rule can put
       its own alpha on it. streak.js reads --stage-body to clear its canvas. */
    --stage-body: #050505;
    --ground-rgb: 5, 5, 5;

    /* Off-white, never #ffffff. */
    --ink: #EDEDEA;
    --ink-rgb: 237, 237, 234;
    --muted: #7C7C78;

    /* Two tokens for one accent. --brand-gold is the gold as it is drawn:
       ticks, outlines, hairlines. --brand-gold-ink is the gold as text. On
       this ground they are the same value. On a light one the first is too
       pale to read as a word, so the second darkens. */
    --brand-gold: #a39339;
    --brand-gold-ink: #a39339;

    --line: rgba(var(--ink-rgb), 0.2);
    --rec: #c0564d;
    --error: #c9736a;

    /* What shows behind a photograph before it loads. */
    --tile: #111111;

    /* The panel is a pane and not a fill, thin enough that the field shows
       moving through it. */
    --pane: rgba(5, 5, 5, 0.4);

    /* A warm light rising off the bottom edge. It only reads as a light
       when there is dark for it to rise out of, so light mode turns it off. */
    --stage-glow: radial-gradient(120% 60% at 50% 110%, rgba(163, 147, 57, 0.13), transparent 70%);

    /* How streak.js draws the embers. "light" is light that adds, for a
       ground dark enough to add to. "ink" is ink laid over a pale one. A
       custom property and not a test of data-theme, because the second
       ground the switch goes to is not always a pale one. */
    --ember: light;

    --wm-size: clamp(30px, 5.2vw, 68px);
}

/* ---------- The second ground ----------
   data-theme is the switch. data-light is which ground it goes to, from
   appearance.light in _config.yml. Both are written by theme-boot.html
   before the first paint.

   There are two kinds. The DIM grounds are still dark, only less so:
   light type on a lifted ground, for a bright room where #050505 turns
   the screen into a mirror. They change the ground and a few greys and
   nothing else. The PALE grounds invert the page, so they also need a
   darker gold, ink embers, no glow and a white pane, and that is the
   block below.

   Only NEUTRAL is in use. The rest are kept so that trying one is a
   single word in _config.yml. A DIM ground needs two more things before
   it goes live: theme-boot.html and theme-toggle.html both set an inline
   color-scheme of "light", which would flash pale on the first paint, and
   the switch would read LIGHT with a sun over a dark page. */
:root[data-theme="light"]:is([data-light="bone"], [data-light="paper"], [data-light="neutral"], [data-light="gallery"]) {
    color-scheme: light;
    --brand-gold: #8E7F2C;
    --brand-gold-ink: #6C6021;
    --stage-glow: none;
    --pane: rgba(255, 255, 255, 0.5);
    --ember: ink;
}

/* GRAPHITE. Charcoal, with the warm bias the off-white and the greys
   already have. About where an edit suite's own interface sits. */
:root[data-theme="light"][data-light="graphite"] {
    --stage-body: #1D1D1B;
    --ground-rgb: 29, 29, 27;
    --muted: #8C8C87;
    --tile: #2A2A28;
    --pane: rgba(29, 29, 27, 0.45);
}

/* ASH. A mid-dark grey, the surround a photographer's editing software
   puts round a picture. Light enough to read in daylight and still dark
   enough that the type stays light and the embers still glow. The gold
   as text is lifted, because #a39339 is too close to this ground. */
:root[data-theme="light"][data-light="ash"] {
    --stage-body: #3A3A37;
    --ground-rgb: 58, 58, 55;
    --ink: #F1F1EE;
    --ink-rgb: 241, 241, 238;
    --muted: #A6A6A0;
    --tile: #474744;
    --brand-gold-ink: #C2B25A;
    --pane: rgba(58, 58, 55, 0.45);
}

/* DUSK. A blue-grey. The one ground with a colour in it, which the gold
   sits against the way tungsten sits against a sky after sunset. */
:root[data-theme="light"][data-light="dusk"] {
    --stage-body: #232830;
    --ground-rgb: 35, 40, 48;
    --muted: #8E949C;
    --tile: #2E343D;
    --brand-gold-ink: #B3A24A;
    --pane: rgba(35, 40, 48, 0.45);
}

/* BONE. A touch lighter than PAPER with less yellow in it. Drawn as the
   new default with Shutter and turned down the same day: it is a cream,
   so going to it changed the page's colour as well as its brightness. */
:root[data-theme="light"][data-light="bone"] {
    --stage-body: #F4F1EA;
    --ground-rgb: 244, 241, 234;
    --ink: #1A1917;
    --ink-rgb: 26, 25, 23;
    --muted: #6E6A61;
    --tile: #E6E1D5;
}

/* PAPER. The warm cream that was the default before BONE. */
:root[data-theme="light"][data-light="paper"] {
    --stage-body: #F0EBE1;
    --ground-rgb: 240, 235, 225;
    --ink: #1A1917;
    --ink-rgb: 26, 25, 23;
    --muted: #6E6A61;
    --tile: #E2DBCB;
}

/* NEUTRAL. The ground the switch goes to. A pale grey card, which adds
   nothing to a photograph, and the same warm-biased grey as the rest of
   the ramp at a higher brightness, so the switch reads as the lights
   coming up in the same room. */
:root[data-theme="light"][data-light="neutral"] {
    --stage-body: #DCDCDA;
    --ground-rgb: 220, 220, 218;
    --ink: #1C1C1A;
    --ink-rgb: 28, 28, 26;
    --muted: #63635F;
    --tile: #CBCBC8;
}

/* GALLERY. Museum white. The pane steps down from the page here, because
   a white pane on a white ground is no pane. cinematic.html also opens
   the grid's gutter for this scheme. */
:root[data-theme="light"][data-light="gallery"] {
    --stage-body: #FFFFFF;
    --ground-rgb: 255, 255, 255;
    --ink: #15171A;
    --ink-rgb: 21, 23, 26;
    --muted: #74797E;
    --tile: #EFEFEE;
    --pane: rgba(240, 240, 239, 0.6);
}

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

html { background: var(--stage-body); }

/* Transparent, so the fixed canvas behind the page shows through it. */
body {
    margin: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--brand-font);
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 1px solid var(--brand-gold); outline-offset: 4px; }

/* ==========================================================
   THE FIELD
   ========================================================== */
#field {
    position: fixed; inset: 0;
    z-index: -2;
    width: 100%; height: 100%;
    display: block;
}
.glow {
    position: fixed; inset: 0;
    z-index: -1;
    background: var(--stage-glow);
    pointer-events: none;
}

/* ==========================================================
   THE LOCKUP
   ========================================================== */

/* One string, and the weight step is the only join. text-indent balances
   the tracking that letter-spacing hangs off the last letter, or a centred
   wordmark sits left of centre. */
.wordmark {
    margin: 0;
    font-size: var(--wm-size);
    font-weight: 200;
    line-height: 1.1;
    letter-spacing: 0.15em;
    text-indent: 0.15em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
    /* The same name as the gallery's header mark, so it is this wordmark
       that travels up there when a page changes. */
    view-transition-name: wordmark;
}

/* inline-block so the smear filter has a box of its own to work on. An
   inline-block starts a line of its own inside, so without the reset it
   takes the wordmark's text-indent a second time and opens a gap at the
   join. */
.wordmark .wm-bold { display: inline-block; font-weight: 700; text-indent: 0; will-change: filter; }

/* 0.394 is the margin that puts the tagline baseline 0.90 of the wordmark
   size below the wordmark's, worked from Inter's metrics at these two
   line-heights. Change either font-size or either line-height and it has
   to be measured again in a real page load. */
.tagline {
    margin: calc(var(--wm-size) * 0.394) 0 0;
    font-size: calc(var(--wm-size) * 0.275);
    font-weight: 300;
    line-height: 1.6;
    letter-spacing: 0.5em;
    text-indent: 0.5em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--muted);
}

.lockup { text-align: center; }

/* ==========================================================
   NAV
   ========================================================== */
.nav { display: flex; gap: 8px; justify-content: center; align-items: center; }
.nav a {
    /* 17px above and below a 10.4px line is a 44px target. */
    padding: 17px 14px;
    font-size: 10.4px;
    font-weight: 300;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    text-transform: uppercase;
    color: rgba(var(--ink-rgb), 0.75);
    transition: color 0.2s ease;
}
.nav a:hover { color: var(--brand-gold-ink); }

/* ---------- Corner ticks ----------
   Four empty elements, because each draws two borders of a box. */
.ticks { position: absolute; inset: var(--tick-inset, 10px); pointer-events: none; }
.ticks i { position: absolute; width: 14px; height: 14px; border: 0 solid var(--brand-gold); }
.ticks i:nth-child(1) { top: 0; left: 0;     border-top-width: 1px; border-left-width: 1px; }
.ticks i:nth-child(2) { top: 0; right: 0;    border-top-width: 1px; border-right-width: 1px; }
.ticks i:nth-child(3) { bottom: 0; left: 0;  border-bottom-width: 1px; border-left-width: 1px; }
.ticks i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

/* Anything the page measures. Mono, small and muted, and nothing else on
   the site is set in mono. */
.readout {
    font-family: var(--mono);
    font-size: 9.3px;
    font-weight: 400;
    letter-spacing: 2.2px;
    text-transform: uppercase;
    color: rgba(var(--ink-rgb), 0.45);
}

.copyright {
    margin: 0;
    font-size: 9.6px;
    font-weight: 300;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ==========================================================
   THE LANDING
   html.landing is set by _layouts/landing.html.
   ========================================================== */
html.landing, html.landing body { height: 100%; overflow: hidden; }
/* Without this a finger dragged across the page is taken as a scroll and
   the pan never hears about it. */
html.landing body { touch-action: none; }

/* The gate. The window is the frame. */
.gate { position: fixed; --tick-inset: 22px; }

.stage {
    position: fixed; inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(28px, 5vh, 56px);
    pointer-events: none;
}
.stage .nav { pointer-events: auto; }

.live-readout {
    position: fixed;
    top: 38px; left: 44px;
    display: flex; gap: 18px;
    margin: 0;
}

.hint {
    position: fixed;
    left: 0; right: 0; bottom: 72px;
    margin: 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    pointer-events: none;
}
.hint.done { opacity: 0; }
.hint .touch { display: none; }
@media (hover: none) {
    .hint .mouse { display: none; }
    .hint .touch { display: inline; }
}

html.landing .copyright {
    position: fixed;
    left: 0; right: 0; bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- The ground switch ----------
   An 18px glyph and one word, reporting the ground you are on. The button
   is 44px tall and all of the difference is padding, so change the glyph
   size and the padding has to change with it. The negative margins take
   that padding back out of the copyright line, so the line keeps its own
   height and the target keeps its 44px. */
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: -13px 0 -13px 4px;
    padding: 13px 10px;
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s ease;
}
/* The hairline between the name and the control. */
.theme-switch::before { content: ""; width: 1px; height: 12px; margin-right: 8px; background: var(--line); }
.theme-switch:hover { color: var(--brand-gold-ink); }

.theme-switch-glyph { position: relative; width: 18px; height: 18px; }
.theme-switch-glyph svg {
    position: absolute; inset: 0;
    width: 18px; height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* The two glyphs cross-fade. Only the record tally snaps. */
    transition: opacity 0.3s ease;
}
.glyph-sun { opacity: 0; }
:root[data-theme="light"] .glyph-sun { opacity: 1; }
:root[data-theme="light"] .glyph-moon { opacity: 0; }

.theme-switch-readout {
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

@media (max-width: 560px) {
    .gate { --tick-inset: 14px; }
    .live-readout { top: 28px; left: 30px; }
    .stage .nav { gap: 0; }
    .stage .nav a { padding: 17px 9px; }
}

/* ==========================================================
   ABOUT AND CONTACT
   Native <dialog> elements, written out in _includes/panels.html and
   opened by assets/shutter/panels.js. Focus trapping, Escape and the
   inert page behind all come from the browser.
   ========================================================== */
dialog.panel {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    background: var(--pane);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    color: var(--ink);

    /* It comes in off a pan, from the side the camera is turning to. */
    opacity: 0;
    transform: translateX(80px);
    filter: blur(8px);
    transition: opacity 0.35s ease,
                transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1),
                filter 0.45s ease,
                overlay 0.45s allow-discrete, display 0.45s allow-discrete;
}
dialog.panel[open] { opacity: 1; transform: none; filter: none; }
@starting-style {
    dialog.panel[open] { opacity: 0; transform: translateX(80px); filter: blur(8px); }
}

/* Barely a veil, and it blurs nothing. The field carries on behind an
   open panel and the camera pans across to it, which is the page's own
   answer to a panel opening. */
dialog.panel::backdrop {
    background: rgba(var(--ground-rgb), 0);
    transition: background 0.45s ease,
                overlay 0.45s allow-discrete, display 0.45s allow-discrete;
}
dialog.panel[open]::backdrop { background: rgba(var(--ground-rgb), 0.15); }
@starting-style {
    dialog.panel[open]::backdrop { background: rgba(var(--ground-rgb), 0); }
}

/* What steps back is the page's own type and work, which would otherwise
   sit sharp behind the panel and argue with it. panels.js puts the class
   on <html>. */
.stage, .hint { transition: opacity 0.4s ease; }
html.panel-open .stage, html.panel-open .hint { opacity: 0; }

.panel-inner { position: relative; padding: 64px 44px 44px; }
.panel-inner .ticks i { border-color: rgba(var(--ink-rgb), 0.55); }

.panel h2 {
    margin: 0 0 28px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    font-weight: 300;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}
.panel p {
    margin: 0 0 1.1em;
    font-size: 15px;
    line-height: 1.75;
    color: rgba(var(--ink-rgb), 0.82);
}
.panel-actions { margin-top: 30px !important; margin-bottom: 0 !important; }

.panel-close {
    position: absolute;
    top: 14px; right: 14px;
    width: 44px; height: 44px;
    background: none;
    border: 0;
    color: rgba(var(--ink-rgb), 0.6);
    font: 300 16px var(--brand-font);
    cursor: pointer;
}
/* Focus is answered with the same gold a hover gets and no outline. The
   page-wide focus outline drew a gold box round a 44px button to mark a
   16px ✕. */
.panel-close:hover, .panel-close:focus-visible { color: var(--brand-gold-ink); outline: 0; }

/* The About heading takes the opening focus, so the ✕ does not. See
   _includes/panels.html. A focused heading is not a control and shows
   nothing. */
.panel h2:focus { outline: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 28px;
    background: transparent;
    border: 0;
    border-radius: 0;
    /* The gold takes the outline and the label. It never fills. */
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--ink);
    font: 300 10.4px var(--brand-font);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    cursor: pointer;
    transition: box-shadow 0.2s ease, color 0.2s ease;
}
.btn:hover, .btn:focus-visible {
    box-shadow: inset 0 0 0 1px var(--brand-gold);
    color: var(--brand-gold-ink);
    outline: 0;
}
.btn:disabled { opacity: 0.5; cursor: default; }

/* Quiet at rest, and the gold arrives on the text and its rule. The same
   gesture as the production notes link under a film. */
.quiet-link {
    padding: 0 0 3px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font: 300 13px var(--brand-font);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.quiet-link:hover, .quiet-link:focus-visible { color: var(--brand-gold-ink); border-bottom-color: var(--brand-gold); outline: 0; }

/* ---------- The form ---------- */
.dm-form { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 28px; }
.dm-form .field { display: flex; flex-direction: column; gap: 8px; }
.dm-form .field.wide { grid-column: 1 / -1; }
.dm-form label, .char-count {
    font-family: var(--mono);
    font-size: 9.3px;
    letter-spacing: 2.2px;
    text-transform: uppercase;
    color: rgba(var(--ink-rgb), 0.45);
}
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.char-count { color: rgba(var(--ink-rgb), 0.3); }

.dm-form input, .dm-form textarea {
    width: 100%;
    padding: 8px 0;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    /* 16px, because iOS zooms the page into any field set smaller. */
    font: 300 16px/1.5 var(--brand-font);
    caret-color: var(--brand-gold);
}
.dm-form input:focus, .dm-form textarea:focus { outline: 0; border-bottom-color: var(--brand-gold); }
.dm-form textarea { min-height: 104px; max-height: 40vh; overflow-y: auto; resize: none; }

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

/* The honeypot. Off-screen and not display: none, because a field hidden
   by display is the first thing a form-filling script skips. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-message { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--error); }
.form-message:empty { display: none; }

/* Sent. The height is held, because a panel that collapses under the
   pointer turns the next click into a click on the backdrop, and that
   closes the confirmation before it has been read. */
.sent { display: none; }
.is-sent .dm-form { display: none; }
.is-sent .sent { display: block; }
.is-sent .panel-inner { min-height: 400px; }

@media (max-width: 560px) {
    .panel-inner { padding: 60px 26px 32px; }
    .dm-form { grid-template-columns: 1fr; }
}

/* ==========================================================
   BETWEEN PAGES
   The landing and the gallery are separate documents. This lets the
   browser animate from one to the next where it used to cut: the wordmark
   travels between the middle of the landing and the gallery's header, and
   the rest of the page leaves and arrives on a whip pan.

   Where the browser has no cross-document view transitions the pages cut,
   as they always did. The Chirpy pages do not opt in, so a move to or
   from a note cuts as well.
   ========================================================== */
@view-transition { navigation: auto; }

::view-transition-group(wordmark) { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.3, 0, 0.1, 1); }

::view-transition-old(root) { animation: 0.3s cubic-bezier(0.5, 0, 1, 0.6) both vt-whip-out; }
::view-transition-new(root) { animation: 0.45s cubic-bezier(0, 0.4, 0.3, 1) 0.12s both vt-whip-in; }
@keyframes vt-whip-out { to { transform: translateX(-16%); filter: blur(16px); opacity: 0; } }
@keyframes vt-whip-in { from { transform: translateX(16%); filter: blur(16px); opacity: 0; } }

/* ==========================================================
   REDUCED MOTION
   The field holds still in streak.js. Here the pages cut and the panels
   appear.
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    dialog.panel, dialog.panel::backdrop, .stage, .hint { transition: none; }
}
