/* ============================================================
   THE DAILY THREAD - one piece of the story a day.
   Lifted from the owner-approved mocks:
     docs/design/mocks/daily-thread/desktop-mock.html
     docs/design/mocks/daily-thread/mobile-mock.html
   Scoped under .dt-page (the codex-room convention) so the shared
   topbar and footer keep their own styling. Illuminated Codex
   palette per docs/design/DESIGN-PRINCIPLES.md; gold means
   persistence and nothing else.
   ============================================================ */

.dt-page {
  --dt-vellum: #F3E9D2;
  --dt-vellum2: #EFE3C6;
  --dt-vellum3: #E6D5AF;
  --dt-lapis: #24356E;
  --dt-vermilion-deep: #A93226;
  --dt-gold: #C9A227;
  --dt-gold-hi: #F0DD9A;
  --dt-gold-deep: #8C6E1D;
  --dt-ink: #2A2419;

  background:
    radial-gradient(1200px 500px at 70% -5%, rgba(240, 221, 154, .28), transparent 60%),
    linear-gradient(175deg, var(--dt-vellum) 0%, var(--dt-vellum2) 55%, var(--dt-vellum3) 100%);
  color: var(--dt-ink);
  font-family: var(--body);
  min-height: 100vh;
  overflow-x: clip;
}

.dt-inner { max-width: 880px; margin: 0 auto; padding: 48px 28px 90px; }

/* The script hides sections with the `hidden` attribute. Author rules like
   `.dt-filament { display: block }` beat the browser's own `[hidden]` rule, so
   this restores it - without it, "hidden" sections stay on screen. */
.dt-page [hidden] { display: none !important; }

/* ── the masthead: the era filament, first thing on the page, with its
   identity/progress caption folded onto the same row as its own edge
   labels (#dt-thread-labels below), not stacked beneath them - one caption
   row, not three. The filament is the hero (drawn by drawFilament() into
   #dt-filament, same geometry as ever); the caption is quiet utility text,
   never competing with it. Hidden entirely on the threshold via
   #dt-filament-wrap's `hidden` attribute - there is no walk yet for it to
   summarise; #dt-walkline-threshold (below) stands in for it there. ── */
.dt-masthead { margin-bottom: 44px; }

/* ── the identity/progress caption. Shared type between the two places it
   appears: folded into the filament's own label row as a flex child
   (.dt-thread-labels .dt-walkline, laid out below), and standing alone,
   full-width, before a walk exists (#dt-walkline-threshold). Both are held
   to one line - white-space:nowrap plus the ellipsis is a last-resort
   safety net, not the mechanism: daily-thread.js's fitCaption() measures
   the rendered row and swaps in the shorter "Day N / total" form (dropping
   the "The Daily Thread ·" prefix) before overflow would ever bite. ── */
.dt-walkline {
  font-family: var(--utility); font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--dt-gold-deep);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dt-walkline-threshold { display: block; max-width: 560px; margin: 0 auto; text-align: center; }

/* ── screen one: the daily moment (masthead → door). On desktop this is just
   the masthead and folio in normal flow, unchanged. On mobile portrait it
   becomes a fixed-height flex column capped to the viewport - see the
   breakpoint below - so the whole moment reads without scrolling. ── */

/* ── the threshold: first visit ── */
.dt-threshold { text-align: center; padding: 40px 0 20px; }
.dt-threshold h1 {
  font-family: var(--display); font-weight: 700; font-size: clamp(28px, 4.6vw, 40px);
  line-height: 1.15; max-width: 18ch; margin: 0 auto 18px; color: var(--dt-ink);
}
.dt-threshold p {
  font-size: clamp(18px, 2.4vw, 21px); line-height: 1.65;
  max-width: 46ch; margin: 0 auto; color: rgba(42, 36, 25, .88);
}

/* ── today's folio ── */
.dt-yearblock { text-align: center; margin-bottom: 8px; }
.dt-year {
  font-family: var(--display); font-weight: 900; font-size: clamp(72px, 14vw, 128px);
  line-height: .9; color: var(--dt-vermilion-deep); letter-spacing: -.01em;
}
.dt-year .dt-suffix { font-size: .38em; font-weight: 500; letter-spacing: .06em; }
.dt-era {
  font-family: var(--utility); font-size: 12px; letter-spacing: .3em;
  text-transform: uppercase; color: rgba(42, 36, 25, .5); margin-top: 10px;
}
.dt-register {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 26px;
  font-family: var(--utility); font-size: 11px; letter-spacing: .26em;
  text-transform: uppercase; color: var(--dt-gold-deep);
}
.dt-register::before, .dt-register::after {
  content: ""; width: 44px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--dt-gold));
}
.dt-register::after { background: linear-gradient(90deg, var(--dt-gold), transparent); }

.dt-plate { margin: 34px auto 0; max-width: 640px; position: relative; }
.dt-plate img {
  width: 100%; display: block; border-radius: 2px;
  filter: sepia(.14) saturate(1.05) contrast(1.02);
  box-shadow: 0 2px 6px rgba(42, 36, 25, .25), 0 18px 50px rgba(42, 36, 25, .22),
              inset 0 0 0 1px rgba(140, 110, 29, .4);
}
.dt-plate::after {
  content: ""; position: absolute; inset: 0; border-radius: 2px; pointer-events: none;
  box-shadow: inset 0 0 60px rgba(42, 36, 25, .35); mix-blend-mode: multiply;
}
.dt-plate figcaption {
  font-family: var(--utility); font-size: 11px; color: rgba(42, 36, 25, .5);
  margin-top: 10px; text-align: center; letter-spacing: .05em;
}

.dt-title {
  font-family: var(--display); font-weight: 700; font-size: clamp(28px, 4.6vw, 40px);
  text-align: center; margin: 42px auto 18px; max-width: 620px; line-height: 1.15;
  color: var(--dt-ink);
}
.dt-blurb {
  font-size: clamp(18px, 2.4vw, 21px); line-height: 1.65; max-width: 600px;
  margin: 0 auto; text-align: center; color: rgba(42, 36, 25, .88);
}

/* the connective line: one authored sentence carrying the point of the whole
   feature - a caption register (quieter than the blurb, never grey-on-grey),
   set off from it by a short gold hairline rather than a rule across the
   full column. */
.dt-line {
  font-family: var(--body); font-style: italic; font-size: clamp(15px, 1.7vw, 17px);
  line-height: 1.55; max-width: 540px; margin: 20px auto 0; padding-top: 18px;
  text-align: center; color: rgba(42, 36, 25, .74); position: relative;
}
.dt-line::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 40px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--dt-gold), transparent);
}

.dt-door {
  display: block; width: fit-content; margin: 36px auto 0; font-family: var(--utility);
  font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--dt-lapis);
  text-decoration: none; border: 1px solid rgba(36, 53, 110, .35); padding: 14px 34px;
  border-radius: 2px; background: rgba(243, 233, 210, .5); cursor: pointer;
  transition: border-color .25s, color .25s, box-shadow .25s;
}
.dt-door:hover, .dt-door:focus-visible {
  border-color: var(--dt-gold); color: var(--dt-gold-deep);
  box-shadow: 0 0 24px rgba(201, 162, 39, .35);
}
.dt-revisit-note {
  margin-top: 22px; text-align: center; font-family: var(--utility);
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(42, 36, 25, .55);
}

/* ── below the folio: progress caption + the revisit list. The filament
   itself now lives in the masthead at the top of the page (#dt-masthead);
   this section is what is left once it moved - a plain-text echo of the
   same progress plus the accessible list of walked pieces. ── */
.dt-thread { margin: 72px 0 0; }
.dt-thread-caption {
  font-family: var(--utility); font-size: 11px; letter-spacing: .24em; text-transform: uppercase;
  color: rgba(42, 36, 25, .5); text-align: center; margin-bottom: 18px;
}
/* the filament itself - shared by the masthead (top) wherever it is placed */
.dt-filament-wrap { max-width: 560px; margin: 0 auto; }
.dt-filament { display: block; width: 100%; height: 22px; overflow: visible; }
.dt-thread-labels {
  display: flex; align-items: baseline; gap: 12px;
  font-family: var(--utility); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: rgba(42, 36, 25, .48); margin-top: 8px;
}
/* the two endpoints keep their natural width and never shrink or wrap -
   the caption between them (below) is the one flexible, one-line element,
   filling exactly the band between them so its centred text reads as
   centred against the endpoints either side of it, not the row itself. */
.dt-thread-edge { flex: 0 0 auto; white-space: nowrap; }
.dt-thread-labels .dt-walkline { flex: 1 1 auto; min-width: 0; text-align: center; }

.dt-walked-list { margin: 22px auto 0; max-width: 560px; }
.dt-walked-list > summary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--utility); font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--dt-gold-deep); cursor: pointer; list-style: none;
  padding: 6px 10px; border-radius: 3px; transition: color .15s ease, background-color .15s ease;
}
.dt-walked-list > summary::-webkit-details-marker { display: none; }
.dt-walked-list > summary:hover {
  color: var(--dt-gold); background-color: rgba(201, 162, 39, .08);
}
.dt-walked-list > summary:focus-visible {
  outline: 2px solid var(--dt-gold); outline-offset: 2px;
}
.dt-walked-list[open] > summary { color: var(--dt-gold); }
/* drawn disclosure affordance: a small gold chevron, not the browser default
   triangle - points right when closed, rotates to point down when open. */
.dt-walked-marker {
  flex: 0 0 auto; display: inline-block; width: 7px; height: 7px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s ease;
}
.dt-walked-list[open] > summary .dt-walked-marker { transform: rotate(45deg); }
.dt-walked-items { list-style: none; margin: 18px 0 0; padding: 0; }
.dt-walked-items li + li { border-top: 1px solid rgba(140, 110, 29, .2); }
.dt-walked-items button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 10px 4px; font-family: var(--body); font-size: 16px;
  color: var(--dt-ink); cursor: pointer;
}
.dt-walked-items button:hover, .dt-walked-items button:focus-visible { color: var(--dt-gold-deep); }
.dt-walked-items .dt-walked-day {
  font-family: var(--utility); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(42, 36, 25, .5); margin-right: 10px;
}

/* ── tomorrow, sealed ── */
.dt-sealed {
  margin: 130px auto 0; max-width: 560px; text-align: center; position: relative;
  padding: 150px 30px 44px; border-radius: 3px;
  background: linear-gradient(168deg, rgba(230, 213, 175, .9) 0%,
              rgba(230, 213, 175, .45) 40%, rgba(230, 213, 175, .25) 100%);
  box-shadow: inset 0 0 0 1px rgba(140, 110, 29, .25), inset 0 0 70px rgba(42, 36, 25, .12),
              0 10px 30px rgba(42, 36, 25, .1);
}
.dt-sealed::before {   /* the folded flap */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 64px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(214, 192, 146, .95),
              rgba(222, 202, 158, .55) 90%, rgba(160, 130, 70, 0));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  box-shadow: inset 0 -2px 4px rgba(42, 36, 25, .2);
  filter: drop-shadow(0 3px 3px rgba(42, 36, 25, .18));
}
.dt-wax {
  position: absolute; left: 50%; top: 26px; transform: translateX(-50%) rotate(-4deg);
  width: 110px; height: 110px; z-index: 2;
  filter: drop-shadow(0 6px 10px rgba(42, 36, 25, .4));
}
.dt-sealed .dt-tlabel {
  font-family: var(--utility); font-size: 11px; letter-spacing: .26em; text-transform: uppercase;
  color: rgba(42, 36, 25, .45); margin-bottom: 16px; position: relative;
}
.dt-sealed .dt-year { font-size: 56px; color: rgba(42, 36, 25, .4); filter: blur(.6px); }
.dt-sealed .dt-year .dt-suffix { font-size: .5em; }
.dt-returns {
  font-family: var(--body); font-style: italic; font-size: 17px;
  color: rgba(42, 36, 25, .6); margin-top: 26px;
}

/* the skip control: a deliberate secondary action, quiet next to the seal -
   no border, no box, smaller and fainter than .dt-door, brightening only on
   hover/focus. Existing palette/type variables only. */
.dt-skip {
  display: block; width: fit-content; margin: 16px auto 0; font-family: var(--utility);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(42, 36, 25, .45); background: none; border: 0; border-bottom: 1px dotted rgba(42, 36, 25, .35);
  padding: 4px 2px; cursor: pointer; transition: color .2s, border-color .2s;
}
.dt-skip:hover, .dt-skip:focus-visible {
  color: var(--dt-gold-deep); border-bottom-color: var(--dt-gold);
}
.dt-skip:focus-visible { outline: 2px solid var(--dt-gold); outline-offset: 3px; }

/* ── the colophon: the whole walk done ── */
.dt-colophon {
  margin: 120px auto 0; max-width: 620px; text-align: center;
  border-top: 1px solid rgba(140, 110, 29, .3); padding-top: 40px;
}
.dt-colophon h2 {
  font-family: var(--display); font-weight: 700; font-size: clamp(26px, 4vw, 36px);
  line-height: 1.15; margin-bottom: 18px; color: var(--dt-ink);
}
.dt-colophon p { font-size: 19px; line-height: 1.65; color: rgba(42, 36, 25, .8); }

/* ── mobile: the folio narrows, the thread folds ── */
@media (max-width: 759px) {
  .dt-inner { padding: 26px 20px 70px; }
  .dt-masthead { margin-bottom: 30px; }
  .dt-walkline { font-size: 9.5px; letter-spacing: .18em; }
  .dt-walkline-threshold { margin-top: 10px; }
  .dt-year { font-size: 56px; }
  .dt-year .dt-suffix { font-size: .4em; }
  .dt-era { font-size: 10px; letter-spacing: .26em; margin-top: 8px; }
  .dt-register { font-size: 9.5px; letter-spacing: .24em; margin-top: 18px; }
  .dt-register::before, .dt-register::after { width: 32px; }
  .dt-plate { margin: 22px 0 0; }
  .dt-plate img { filter: sepia(.14) saturate(1.05);
    box-shadow: 0 2px 6px rgba(42, 36, 25, .25), 0 12px 34px rgba(42, 36, 25, .22),
                inset 0 0 0 1px rgba(140, 110, 29, .4); }
  .dt-plate figcaption { font-size: 10px; margin-top: 8px; }
  .dt-title { font-size: 26px; margin: 26px 0 12px; line-height: 1.2; }
  .dt-blurb { font-size: 17px; line-height: 1.6; }
  .dt-line { font-size: 15px; line-height: 1.5; margin-top: 16px; padding-top: 14px; }
  .dt-door { font-size: 12px; letter-spacing: .18em; padding: 13px 30px; margin-top: 26px; }
  .dt-thread { margin: 48px 0 0; }
  .dt-thread-caption { font-size: 9.5px; letter-spacing: .22em; margin-bottom: 14px; }
  .dt-thread-labels { font-size: 9px; letter-spacing: .1em; }
  .dt-sealed { margin-top: 70px; padding: 118px 22px 34px;
    background: linear-gradient(168deg, rgba(230, 213, 175, .9) 0%, rgba(230, 213, 175, .3) 100%);
    box-shadow: inset 0 0 0 1px rgba(140, 110, 29, .25), inset 0 0 50px rgba(42, 36, 25, .12); }
  .dt-sealed::before { height: 52px; }
  .dt-wax { width: 88px; height: 88px; top: 20px; }
  .dt-sealed .dt-tlabel { font-size: 9.5px; letter-spacing: .24em; margin-bottom: 10px; }
  .dt-sealed .dt-year { font-size: 40px; filter: blur(.5px); }
  .dt-returns { font-size: 15px; margin-top: 16px; }
  .dt-skip { font-size: 10px; letter-spacing: .14em; margin-top: 14px; }
}

/* ── the daily moment, capped to one mobile screen ──
   Portrait only (landscape is allowed to scroll per the brief - squeezing a
   short landscape viewport this hard would make everything illegibly small
   instead).

   PROVEN BUG (2026-08-06): this used to read 100dvh. dvh tracks the
   *current* browser-chrome state, so on a real phone the address bar
   collapsing as you scroll makes dvh grow mid-scroll. That resizes
   .dt-screen-one, which flex-grows .dt-plate taller, which changes how
   much of the object-fit:cover plate image is visible - read on screen as
   the image "zooming"/"expanding" while you scroll, though nothing the
   visitor did was meant to touch it. Fixed by using 100svh - the *small*
   viewport height, i.e. sized as if the chrome is always showing - which
   does not fluctuate as the chrome collapses. Trade-off: svh is the more
   conservative (smaller) of the two, so on a browser that does collapse
   its chrome we do not reclaim that reappearing sliver of height; that is
   the deliberate cost of a plate that never moves under the visitor. A
   100vh rule stays first as the fallback for browsers that know neither
   dvh nor svh.

   The topbar sits above in normal flow (position: sticky, not fixed), and
   .dt-inner adds its own top padding above that again, so the true distance
   from the real viewport top to #dt-screen-one is topbar height + that
   padding - two numbers that already live in two other places in this
   stylesheet. Rather than a third copy to keep in sync, daily-thread.js
   measures the real offset once per render and writes it to
   --dt-screen-one-top; the constant here is only the pre-JS fallback for the
   very first paint.

   The image is the only element allowed to shrink: flex:1 1 auto with
   min-height:0 lets it give up space to the year/title/blurb/door, which
   keep their natural size and are never clipped. */
@media (max-width: 759px) and (orientation: portrait) {
  .dt-screen-one {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--dt-screen-one-top, 95px));
    height: calc(100svh - var(--dt-screen-one-top, 95px));
    min-height: 0;
  }
  .dt-screen-one > .dt-masthead { flex: 0 0 auto; }

  .dt-folio {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
  .dt-folio > .dt-yearblock,
  .dt-folio > .dt-title,
  .dt-folio > .dt-blurb,
  .dt-folio > .dt-line,
  .dt-folio > .dt-door,
  .dt-folio > .dt-revisit-note { flex: 0 0 auto; }

  .dt-plate {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 6px;
  }
  .dt-plate img {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .dt-plate figcaption { flex: 0 0 auto; }

  /* the threshold (first visit only) has no flex-grown child, so it simply
     sits at its natural height inside the capped column - no overflow, no
     forced stretch. Its masthead is just the plain utility line (the
     filament wrap is `hidden` - no walk exists yet to draw). */

  /* A tighter vertical rhythm than the general <=759px rules above: those are
     shared with landscape mobile and tablets, where there is no one-screen
     budget to protect. Here every margin is real space taken from the image
     - on a 360x640 phone the fixed chrome (masthead filament, year, title,
     blurb, door) already fills the viewport before the image gets anything,
     so this trims the gaps and drops the type a further notch to give the
     image a real, visible share rather than the sliver (or nothing) it
     would otherwise be left with. The year in particular is taken down a
     further notch here (40px, against 56px at the general <=759px
     breakpoint above) to pay for the filament's own height now that it
     sits above the fold too. */
  .dt-masthead { margin-bottom: 10px; }
  .dt-filament { height: 16px; }
  .dt-thread-labels { margin-top: 4px; }
  .dt-walkline-threshold { margin-top: 6px; }
  .dt-year { font-size: 40px; }
  .dt-era { margin-top: 3px; }
  .dt-register { margin-top: 8px; }
  .dt-plate { margin-top: 4px; }
  .dt-title { font-size: 20px; margin: 8px 0 4px; }
  .dt-blurb { font-size: 14px; line-height: 1.42; }
  .dt-line { font-size: 12.5px; line-height: 1.36; margin-top: 6px; padding-top: 6px; max-width: 92%; }
  .dt-line::before { width: 28px; }
  .dt-door { padding: 10px 24px; margin-top: 8px; }
}

/* ── stillness on request: no breathing bead, no glow transitions ── */
@media (prefers-reduced-motion: reduce) {
  .dt-door { transition: none; }
  .dt-page * { animation: none !important; }
  .dt-walked-marker, .dt-walked-list > summary { transition: none; }
}
