/* ============================================================================
   The Daily Next — v2 · BASE
   Reset, type roles, page frame, the rule-draw, reduced-motion.
   Owned by the foundation. Surface agents must not edit this file.
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* The masthead is sticky; anchor jumps must clear it. */
  scroll-padding-top: calc(var(--masthead-h) + var(--s-5));
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--t-body-size);
  line-height: 1.62;
  font-optical-sizing: auto;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overflow-x: hidden;
  /* Theme swap should read as a considered change, not a flash. */
  transition: background-color var(--d-base) var(--e-in-out),
              color var(--d-base) var(--e-in-out);
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { background: none; border: 0; padding: 0; cursor: pointer; }

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

ul, ol { list-style: none; padding: 0; }

hr { border: 0; height: 1px; background: var(--rule); }

::selection { background: var(--accent-wash); color: var(--ink); }

/* Focus is visible, always. Never `outline: none` without a replacement. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* A heading focused programmatically on route change is a screen-reader
   affordance, not an interactive control — it must not draw a ring. */
h1[tabindex='-1']:focus-visible,
[data-focus-quiet]:focus-visible { outline: none; }

/* Restrained, theme-aware scrollbars. */
* { scrollbar-color: var(--rule-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ── Type roles ──────────────────────────────────────────────────────── */
.dn-display,
.dn-h1,
.dn-h2,
.dn-h3 {
  font-family: var(--font-display);
  font-weight: 400;
  text-wrap: balance;
  color: var(--ink);
}

.dn-display {
  font-size: var(--t-display-size);
  letter-spacing: var(--t-display-track);
  line-height: var(--t-display-lead);
}
.dn-h1 {
  font-size: var(--t-h1-size);
  letter-spacing: var(--t-h1-track);
  line-height: var(--t-h1-lead);
}
.dn-h2 {
  font-size: var(--t-h2-size);
  letter-spacing: var(--t-h2-track);
  line-height: var(--t-h2-lead);
}
.dn-h3 {
  font-size: var(--t-h3-size);
  letter-spacing: var(--t-h3-track);
  line-height: var(--t-h3-lead);
  font-weight: 500;
}

.dn-lede {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--t-lede-size);
  line-height: 1.55;
  letter-spacing: -0.005em;
  color: var(--ink-2);
  max-width: var(--measure);
  text-wrap: pretty;
}

.dn-eyebrow {
  font-family: var(--font-text);
  font-size: var(--t-eyebrow-size);
  font-weight: 560;
  letter-spacing: var(--t-eyebrow-track);
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--ink-3);
  /* An 11px uppercase label reads better with its own optical alignment. */
  font-variant-numeric: tabular-nums;
}
.dn-eyebrow--accent { color: var(--accent); }

.dn-meta {
  font-size: var(--t-meta-size);
  line-height: 1.4;
  color: var(--ink-3);
}
.dn-micro {
  font-size: var(--t-micro-size);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}
.dn-ref {
  font-family: var(--font-mono);
  font-size: var(--t-ref-size);
  letter-spacing: 0.02em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Every price, spec value, count and date aligns. */
.dn-num,
.dn-price,
time { font-variant-numeric: tabular-nums; }

.dn-prose {
  max-width: var(--measure);
  font-size: var(--t-body-lg-size);
  line-height: 1.72;
  color: var(--ink-2);
  text-wrap: pretty;
}
.dn-prose p + p { margin-top: 1.05em; }
.dn-prose strong { color: var(--ink); font-weight: 600; }
.dn-prose em { font-style: italic; }

/* Editorial prose set in the display serif — used for brand stories. */
.dn-prose--serif {
  max-width: var(--measure-serif);
  font-family: var(--font-display);
  font-size: var(--t-lede-size);
  line-height: 1.68;
  letter-spacing: -0.003em;
}

.dn-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: var(--accent-line);
  transition: text-decoration-color var(--d-fast) var(--e-out);
}
.dn-link:hover { text-decoration-color: var(--accent); }

/* ── Page frame ──────────────────────────────────────────────────────── */
.dn-page {
  width: 100%;
  max-width: calc(var(--maxw) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.dn-page--narrow { max-width: calc(var(--maxw-narrow) + var(--gutter) * 2); }

/* Full-bleed escape from the centred column. */
.dn-bleed {
  width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
}

/* Recessed full-bleed band. */
.dn-band {
  background: var(--paper-2);
  border-block: 1px solid var(--rule);
}

.dn-stack > * + * { margin-top: var(--rhythm-block); }
.dn-section + .dn-section { margin-top: var(--rhythm-movement); }

/* ── The rule-draw — v2's one signature move ─────────────────────────── */
/* Everything below starts hidden and is revealed by an IntersectionObserver.
   That is a content-hiding animation, so it is gated on `html.dn-js`, which
   main.js sets the moment it boots. If the script never runs, never parses, or
   the observer never fires, the copy is simply visible — text must never be
   permanently invisible because an animation didn't happen. */
.dn-rule {
  height: 1px;
  background: var(--rule);
  transform: scaleX(1);
  transform-origin: left center;
}
.dn-js .dn-rule--draw {
  transform: scaleX(0);
  transition: transform var(--d-base) var(--e-out);
}
.dn-rule--draw.is-drawn { transform: scaleX(1); }

/* Section header: eyebrow + rule, the recurring page furniture. */
.dn-sechead {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.dn-sechead__rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
  transform-origin: left center;
  transition: transform var(--d-base) var(--e-out);
}
.dn-js .dn-sechead__rule { transform: scaleX(0); }
.dn-sechead.is-drawn .dn-sechead__rule { transform: scaleX(1); }
.dn-js .dn-sechead__label {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--d-base) var(--e-out) 60ms,
              transform var(--d-base) var(--e-out) 60ms;
}
.dn-sechead.is-drawn .dn-sechead__label { opacity: 1; transform: none; }
.dn-sechead__aside { flex: 0 0 auto; }

/* Generic reveal used sparingly for first-screen entrances. */
.dn-js .dn-reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--d-base) var(--e-out), transform var(--d-base) var(--e-out);
}
.dn-js .dn-reveal.is-in { opacity: 1; transform: none; }

/* ── Utilities ───────────────────────────────────────────────────────── */
.dn-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.dn-skip {
  position: absolute;
  left: var(--s-4);
  top: var(--s-2);
  z-index: 200;
  transform: translateY(-200%);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-4);
  box-shadow: var(--lift-2);
  transition: transform var(--d-fast) var(--e-out);
}
.dn-skip:focus-visible { transform: none; }

.dn-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dn-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dn-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Below-fold sections skip layout+paint until near the viewport. The
   contain-intrinsic-size placeholder keeps the scrollbar honest → no CLS. */
.dn-defer {
  content-visibility: auto;
  contain-intrinsic-size: auto 640px;
}

/* Scroll lock while a sheet is open, without the iOS jump. */
html.dn-locked, body.dn-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── Reduced motion — implemented once, globally ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  /* Keep opacity crossfades legible; kill every transform. */
  .dn-reveal,
  .dn-sechead__label { opacity: 1 !important; transform: none !important; }
  .dn-rule--draw,
  .dn-sechead__rule { transform: scaleX(1) !important; }
  .dn-reveal,
  .dn-sechead__label,
  .dn-img > img { transition-duration: 90ms !important; }
}

/* ── Print — it is a printed annual, after all ───────────────────────── */
@media print {
  :root { --paper: #fff; --ink: #000; }
  .dn-masthead, .dn-themetoggle, .dn-skip, .dn-tabbar { display: none !important; }
  body { background: #fff; }
  .dn-watch-card { break-inside: avoid; }
}
