/* ============================================================================
   The Daily Next — v2 · COMPONENTS
   Shared, cross-surface components. Owned by the foundation.
   Surface agents consume these; they do not redefine them.
   ========================================================================== */

/* ── Masthead ────────────────────────────────────────────────────────── */
.dn-masthead {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--masthead-h);
  background: var(--masthead-bg);
  /* The ONE permitted backdrop-filter — a single, non-repeated element. */
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d-fast) var(--e-out),
              background-color var(--d-base) var(--e-in-out);
}
.dn-masthead.is-stuck { border-bottom-color: var(--rule); }

.dn-masthead__in {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-5);
}

.dn-wordmark {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--ink);
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 0.34em;
}
.dn-wordmark__mark { color: var(--accent); }
@media (max-width: 520px) { .dn-wordmark { font-size: 1rem; } }

.dn-nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-left: var(--s-2);
  min-width: 0;
  overflow: hidden;
}
.dn-nav__link {
  position: relative;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--t-ui-size);
  font-weight: 450;
  letter-spacing: -0.004em;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--d-fast) var(--e-out), background-color var(--d-fast) var(--e-out);
}
.dn-nav__link:hover { color: var(--ink); background: var(--accent-wash); }
.dn-nav__link[aria-current='page'] { color: var(--ink); }
.dn-nav__link[aria-current='page']::after {
  content: '';
  position: absolute;
  left: var(--s-3);
  right: var(--s-3);
  bottom: 2px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--accent);
}

.dn-masthead__spacer { flex: 1 1 auto; }
.dn-masthead__tools { display: flex; align-items: center; gap: var(--s-1); flex: 0 0 auto; }

/* Mobile: nav collapses to a bottom tab bar. */
.dn-tabbar { display: none; }
@media (max-width: 760px) {
  .dn-nav { display: none; }
  .dn-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 95;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: var(--masthead-bg);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--rule);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dn-tabbar__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: var(--s-2) var(--s-1) calc(var(--s-2) - 2px);
    color: var(--ink-3);
    font-size: 10px;
    font-weight: 550;
    letter-spacing: 0.02em;
    transition: color var(--d-fast) var(--e-out);
  }
  .dn-tabbar__link[aria-current='page'] { color: var(--accent); }
  .dn-tabbar__link svg { width: 20px; height: 20px; }
  /* Keep the last content row clear of the bar. */
  main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}

/* ── Controls ────────────────────────────────────────────────────────── */
.dn-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding-inline: var(--s-5);
  border-radius: var(--r-sm);
  font-size: var(--t-ui-size);
  font-weight: 550;
  letter-spacing: -0.004em;
  white-space: nowrap;
  color: var(--ink);
  border: 1px solid transparent;
  transition: background-color var(--d-fast) var(--e-out),
              border-color var(--d-fast) var(--e-out),
              color var(--d-fast) var(--e-out),
              transform var(--d-instant) var(--e-snap);
}
/* Inflate every control to a 44px touch target without changing its look. */
.dn-btn::after,
.dn-iconbtn::after,
.dn-chip::after {
  content: '';
  position: absolute;
  inset: 50% 0 auto 0;
  height: 44px;
  transform: translateY(-50%);
}
.dn-btn:active { transform: scale(0.985); }

.dn-btn--primary { background: var(--accent); color: var(--accent-ink); }
.dn-btn--primary:hover { filter: brightness(1.08); }
.dn-btn--quiet { border-color: var(--rule-strong); background: transparent; }
.dn-btn--quiet:hover { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent); }
.dn-btn--ghost { color: var(--ink-2); padding-inline: var(--s-3); }
.dn-btn--ghost:hover { color: var(--ink); background: var(--accent-wash); }
.dn-btn--sm { height: 32px; padding-inline: var(--s-4); font-size: var(--t-meta-size); }
.dn-btn[disabled] { opacity: 0.45; pointer-events: none; }

.dn-iconbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  transition: color var(--d-fast) var(--e-out), background-color var(--d-fast) var(--e-out);
}
.dn-iconbtn:hover { color: var(--ink); background: var(--accent-wash); }
.dn-iconbtn svg { width: 20px; height: 20px; }
.dn-iconbtn::after { inset: 50% 50% auto auto; width: 44px; height: 44px; transform: translate(50%, -50%); }

.dn-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 30px;
  padding-inline: var(--s-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-meta-size);
  font-weight: 480;
  letter-spacing: -0.002em;
  white-space: nowrap;
  transition: background-color var(--d-fast) var(--e-out),
              border-color var(--d-fast) var(--e-out),
              color var(--d-fast) var(--e-out);
}
.dn-chip:hover { border-color: var(--rule-strong); color: var(--ink); }
.dn-chip[aria-pressed='true'],
.dn-chip.is-on {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent);
}
.dn-chip__n { color: var(--ink-4); font-variant-numeric: tabular-nums; }
.dn-chip[aria-pressed='true'] .dn-chip__n { color: var(--accent); opacity: 0.7; }
/* aria-disabled, not disabled: a chip that filters to zero should still be
   reachable so a screen reader can land on it and hear why it's empty. */
.dn-chip[aria-disabled='true'],
.dn-chip[disabled] {
  color: var(--ink-4);
  border-color: var(--rule);
  cursor: default;
}
.dn-chip[aria-disabled='true']:hover,
.dn-chip[disabled]:hover { border-color: var(--rule); color: var(--ink-4); }

/* A static, non-interactive tag. */
.dn-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding-inline: var(--s-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: var(--t-micro-size);
  font-weight: 500;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.dn-input {
  width: 100%;
  height: 44px;
  padding-inline: var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-ui-size);
  transition: border-color var(--d-fast) var(--e-out), box-shadow var(--d-fast) var(--e-out);
}
.dn-input::placeholder { color: var(--ink-4); }
.dn-input:hover { border-color: var(--ink-4); }
.dn-input:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}

/* ── Photo frame ─────────────────────────────────────────────────────── */
/* Every image in v2 lives in one of these. Fixed aspect ratio + warm tile =
   zero layout shift and a product shot that joins the page. */
.dn-img {
  position: relative;
  overflow: hidden;
  background: var(--photo-tile);
  /* The keyline is what makes the tile a MOUNT rather than a mismatched
     background — see the --photo-tile note in tokens.css. */
  box-shadow: inset 0 0 0 1px var(--photo-edge);
  border-radius: var(--r-sm);
  aspect-ratio: 4 / 5;
  /* The tile IS the skeleton — no shimmer under a photograph. */
}
.dn-img--square { aspect-ratio: 1 / 1; }
.dn-img--wide { aspect-ratio: 3 / 2; }
.dn-img--pano { aspect-ratio: 16 / 9; }

.dn-img > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: var(--s-4);
  opacity: 0;
  transition: opacity var(--d-base) var(--e-out), transform var(--d-base) var(--e-out);
}
.dn-img > img.is-loaded { opacity: 1; }
.dn-img--cover > img { object-fit: cover; padding: 0; }
.dn-img--flush > img { padding: 0; }
/* The container owns the ground — used where a surface draws its own plate
   around the photograph rather than letting each frame carry one. */
.dn-img--plain { background: transparent; border-radius: 0; box-shadow: none; }
.dn-img--plain > img { padding: 0; }

/* Dignified placeholder — the tile plus a 1px watch-case mark.
   The ink is fixed dark (not --ink-*) because the tile is always near-white in
   BOTH themes; a theme-following colour would vanish on night. At .12 the mark
   was invisible and an image-less card read as a blank white hole punched in
   the page — especially on the night ground. .2 plus a hairline frame makes an
   empty plate read as a deliberate plate. */
.dn-img__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--photo-ink);
  pointer-events: none;
}
.dn-img__ph svg { width: 30%; max-width: 84px; height: auto; }


/* ── The watch card (the atom) ───────────────────────────────────────── */
.dn-watch-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-align: left;
  width: 100%;
  /* Fill the grid track so a row of cards with different model lengths still
     lands its prices on one baseline — see __body/__foot below. */
  height: 100%;
  border-radius: var(--r);
  transition: transform var(--d-base) var(--e-out);
}
.dn-watch-card__frame {
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: box-shadow var(--d-base) var(--e-out);
}
.dn-watch-card__frame > img,
.dn-watch-card .dn-img > img { transition: opacity var(--d-base) var(--e-out), transform var(--d-base) var(--e-out); }

.dn-watch-card:hover,
.dn-watch-card:focus-within { transform: translateY(-2px); }
.dn-watch-card:hover .dn-watch-card__frame,
.dn-watch-card:focus-within .dn-watch-card__frame { box-shadow: var(--lift-1); }
.dn-watch-card:hover .dn-img > img.is-loaded,
.dn-watch-card:focus-within .dn-img > img.is-loaded { transform: scale(1.012); }
.dn-watch-card:hover .dn-watch-card__model,
.dn-watch-card:focus-within .dn-watch-card__model { color: var(--accent); }
.dn-watch-card:active { transform: scale(0.994); transition-duration: var(--d-instant); }

.dn-watch-card__body { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; flex: 1; }
.dn-watch-card__brand { color: var(--accent); }
.dn-watch-card__model {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--t-h3-size);
  line-height: 1.22;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: pretty;
  /* Catalog names are printed verbatim and some are a single unbreakable token
     ("SEATURTLE.OCEAN(BRONZE)"). Without this, line-clamp cannot clamp them and
     the name overflows its card. */
  overflow-wrap: anywhere;
  transition: color var(--d-fast) var(--e-out);
}
.dn-watch-card__specs {
  font-size: var(--t-meta-size);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.dn-watch-card__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  /* auto, not a fixed step: pushes the price to the bottom of the card so a
     grid row shares one price baseline regardless of model-name length. */
  margin-top: auto;
  padding-top: var(--s-1);
}
.dn-watch-card__price {
  font-size: var(--t-ui-size);
  font-weight: 550;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.004em;
}
.dn-watch-card__note { font-size: var(--t-micro-size); color: var(--ink-4); }

/* Compact horizontal variant — "more from brand", archive rows. */
.dn-watch-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  width: 100%;
  transition: background-color var(--d-fast) var(--e-out);
}
.dn-watch-row:hover { background: var(--accent-wash); }
.dn-watch-row .dn-img { aspect-ratio: 1/1; border-radius: var(--r-sm); }
.dn-watch-row .dn-img > img { padding: var(--s-1); }

/* ── Grids ───────────────────────────────────────────────────────────── */
.dn-grid {
  display: grid;
  gap: var(--gap) var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.dn-grid--tight { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.dn-grid--wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 600px) {
  .dn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-4); }
  .dn-grid--tight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Spec table ──────────────────────────────────────────────────────── */
/* The gutter is padding on the <dt>, NOT column-gap: the row rule is drawn by
   border-top on each cell, and a gap would punch a visible hole through the
   middle of every hairline. */
.dn-spec-table { display: grid; grid-template-columns: minmax(96px, auto) 1fr; column-gap: 0; }
.dn-spec-table > dt,
.dn-spec-table > dd {
  padding-block: var(--s-2);
  border-top: 1px solid var(--rule);
  font-size: var(--t-meta-size);
  min-width: 0;
}
.dn-spec-table > dt { color: var(--ink-3); padding-inline-end: var(--s-5); }
.dn-spec-table > dd {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.dn-spec-table > dt:first-of-type,
.dn-spec-table > dt:first-of-type + dd { border-top: 0; }
/* Two spec columns when there's room. */
/* Two spec columns when there's room. Four grid columns, so <dt>s alternate
   between column 1 and column 3; the even ones open the right-hand pair and
   carry its leading gutter as padding (not column-gap — see above). */
@media (min-width: 900px) {
  .dn-spec-table--2col {
    grid-template-columns: minmax(96px, auto) 1fr minmax(96px, auto) 1fr;
  }
  .dn-spec-table--2col > dt:nth-of-type(even) { padding-inline-start: var(--s-7); }
  /* The single-column rule above clears the top border on the FIRST dt/dd pair.
     In two columns the right-hand column starts at the second pair, so it kept
     a hairline the left column had lost and the band read lopsided. */
  .dn-spec-table--2col > dt:nth-of-type(2),
  .dn-spec-table--2col > dt:nth-of-type(2) + dd { border-top: 0; }
}

/* ── Sheet (right panel desktop / bottom sheet mobile) ───────────────── */
.dn-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--d-slow) var(--e-in-out);
}
.dn-scrim.is-open { opacity: 1; }

.dn-sheet {
  position: fixed;
  z-index: 101;
  background: var(--surface);
  box-shadow: var(--lift-3);
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(560px, 100vw);
  transform: translateX(100%);
  transition: transform var(--d-slow) var(--e-out);
}
.dn-sheet.is-open { transform: none; }
.dn-sheet.is-closing { transition-duration: var(--d-base); transition-timing-function: var(--e-in-out); }
.dn-sheet--wide { width: min(760px, 100vw); }

.dn-sheet__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d-fast) var(--e-out);
}
.dn-sheet__head.is-stuck { border-bottom-color: var(--rule); }
.dn-sheet__title { flex: 1; min-width: 0; }
.dn-sheet__body { flex: 1; overflow-y: auto; padding: 0 var(--s-5) var(--s-8); }

@media (max-width: 760px) {
  .dn-sheet {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: min(92dvh, 100dvh);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .dn-sheet__body { padding-bottom: calc(var(--s-8) + env(safe-area-inset-bottom)); }
  /* Grab handle — the affordance that says "drag me down". */
  .dn-sheet__head::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--rule-strong);
  }
  .dn-sheet__head { padding-top: var(--s-5); }
}

/* ── Skeletons — exact geometry, a slow breath, never a sweep ────────── */
.dn-skeleton {
  background: var(--skeleton);
  border-radius: var(--r-sm);
  animation: dn-breath 1.6s var(--e-in-out) infinite alternate;
}
@keyframes dn-breath { from { opacity: 0.55; } to { opacity: 0.9; } }
.dn-skeleton--text { height: 0.72em; margin-block: 0.2em; border-radius: 3px; }
.dn-skeleton--w40 { width: 40%; }
.dn-skeleton--w60 { width: 60%; }
.dn-skeleton--w80 { width: 80%; }

/* A skeleton watch card matching .dn-watch-card geometry to the pixel. */
.dn-skel-card { display: flex; flex-direction: column; gap: var(--s-3); }
.dn-skel-card__frame { aspect-ratio: 4/5; border-radius: var(--r-sm); }

/* ── Empty / error states ────────────────────────────────────────────── */
.dn-empty {
  max-width: 46ch;
  margin-inline: auto;
  padding-block: var(--s-9);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}
.dn-empty__mark { color: var(--ink-4); opacity: 0.7; margin-bottom: var(--s-1); }
.dn-empty__mark svg { width: 40px; height: 40px; }
.dn-empty__title { font-family: var(--font-display); font-size: var(--t-h3-size); font-weight: 500; color: var(--ink); }
.dn-empty__body { font-size: var(--t-body-size); color: var(--ink-3); text-wrap: pretty; }
.dn-empty__actions { display: flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; justify-content: center; }

/* ── Toast / live region ─────────────────────────────────────────────── */
.dn-toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-7);
  z-index: 120;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--lift-2);
  border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-5);
  font-size: var(--t-meta-size);
  transition: opacity var(--d-base) var(--e-out), transform var(--d-base) var(--e-out);
}
.dn-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Page transition ─────────────────────────────────────────────────── */
/* Opacity ONLY, and no fill-mode.
   The original animated translateY with `both`, which left a filled
   `transform: matrix(1,0,0,1,0,0)` on the view root forever. A transformed
   element becomes the containing block for its fixed descendants, so
   `position: fixed` silently scrolled with the page on EVERY v2 surface — a FAB,
   a scroll-to-top, a custom sheet would all have been broken. The 8px rise is
   not worth that; per-surface reveals carry the motion. */
.dn-view {
  animation: dn-view-in var(--d-base) var(--e-out);
}
@keyframes dn-view-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .dn-view { animation: none; }
}

/* ── Horizontal rail (more-from-brand, related) ──────────────────────── */
.dn-rail {
  display: grid;
  grid-auto-flow: column;
  /* A FIXED track, not minmax(…, 1fr). With 1fr, a rail holding a single card
     stretched it to the full page width — a 1312x1312 blank tile, and a
     blinding white slab in night mode. A rail is a rail at any length; it
     starts at the left and runs out when it runs out. */
  grid-auto-columns: 160px;
  justify-content: start;
  gap: var(--s-4);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding-bottom: var(--s-2);
  /* Let the rail bleed to the gutter edge on mobile without clipping. */
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  /* Without this, snap parks the first card flush under the viewport edge,
     inside the padding it was given. */
  scroll-padding-inline-start: var(--gutter);
}
.dn-rail::-webkit-scrollbar { display: none; }
.dn-rail > * { scroll-snap-align: start; }
@media (min-width: 761px) {
  .dn-rail {
    margin-inline: 0;
    padding-inline: 0;
    scroll-padding-inline-start: 0;
    grid-auto-columns: 180px;
  }
}
