/*
 * ─────────────────────────────────────────────────────────────
 *  NoTell — Global Design System
 * ─────────────────────────────────────────────────────────────
 *  Single source of truth for design tokens + shared primitives.
 *  Every page links this so the site shares one cohesive identity:
 *  dark cinematic base with subtle ember-red accents.
 *
 *  Load order per page:
 *    hero-bg.css  →  design-system.css  →  site-font.css
 * ─────────────────────────────────────────────────────────────
 */

:root {
  /* ── Surface + text ── */
  --bg: #0d0d0d;
  --bg-raise: #141414;
  --fg: #f0ede8;
  --fg-dim: rgba(240, 237, 232, 0.62);
  --fg-mute: rgba(240, 237, 232, 0.48);
  --muted: #6a6560;
  --line: #2a2a2a;
  --line-soft: rgba(255, 255, 255, 0.07);
  --line-strong: #3a3a3a;
  --panel: #0d0d0d;

  /* ── Ember accent (hex + space-RGB form for rgb(var(--accent-rgb) / a)) ── */
  --accent: #d23720;
  --accent-strong: #e2481f;
  --accent-deep: #8c1a0a;
  --accent-rgb: 210 55 32;
  --accent-line: rgba(210, 55, 32, 0.85);
  --accent-glow: rgba(140, 26, 10, 0.22);

  /* ── Spacing scale (rhythm) ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* Fluid page padding used by section shells */
  --pad-inline: clamp(0.85rem, 2.8vw, 2.4rem);
  --pad-block: clamp(0.9rem, 2.3vw, 2rem);
  --stack-gap: clamp(0.7rem, 1.2vw, 0.95rem);

  /* ── Radii ── */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: clamp(14px, 1.5vw, 20px);
  --radius-pill: 999px;

  /* ── Type scale (fluid) ── */
  --text-xs: clamp(0.52rem, 0.22vw + 0.48rem, 0.6rem);
  --text-sm: clamp(0.62rem, 0.2vw + 0.56rem, 0.72rem);
  --text-base: clamp(0.72rem, 0.18vw + 0.66rem, 0.82rem);
  --text-md: clamp(0.8rem, 0.3vw + 0.72rem, 0.95rem);
  --text-lg: clamp(0.92rem, 0.35vw + 0.82rem, 1.08rem);
  --text-xl: clamp(1rem, 0.5vw + 0.9rem, 1.25rem);
  --text-2xl: clamp(1.2rem, 1vw + 1rem, 1.6rem);

  --tracking-tight: 0.04em;
  --tracking-wide: 0.08em;
  --tracking-wider: 0.14em;
  --tracking-widest: 0.22em;

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.62;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ── Depth / shadow ── */
  --shadow-sm: 0 2px 16px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 90px rgba(0, 0, 0, 0.55);
  --shadow-hairline: 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-card: var(--shadow-hairline), var(--shadow-lg);

  /* ── Motion ── */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 180ms;
  --dur-slow: 260ms;
  --transition-ui: border-color var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease),
    color var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);

  /* ── Focus ── */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent-line);

  /* ── Legacy back-pill tokens (kept for existing usage) ── */
  --back-btn-bg-rgb: 13 13 13;
  --back-btn-bg-opacity: 0.75;
  --back-btn-bg-opacity-hover: 0.82;
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL PRIMITIVES
   ───────────────────────────────────────────────────────────── */

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

/* Screen-reader / keyboard-only helpers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 200;
  padding: 0.55rem 0.85rem;
  background: var(--bg-raise);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-decoration: none;
}

.skip-link:focus {
  top: calc(0.75rem + env(safe-area-inset-top));
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Consistent, accessible keyboard focus across the whole site */
:where(a, button, [tabindex], input, select, textarea, summary):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Ember-tinted text selection */
::selection {
  background: rgb(var(--accent-rgb) / 0.32);
  color: var(--fg);
}

/* Subtle themed scrollbar */
@supports (scrollbar-color: auto) {
  html {
    scrollbar-color: var(--line-strong) transparent;
    scrollbar-width: thin;
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--line-strong) 70%, var(--accent) 30%);
  background-clip: padding-box;
}

/* Media never overflows its box */
img,
svg,
video {
  max-width: 100%;
}

/* ─────────────────────────────────────────────────────────────
   TYPOGRAPHY HIERARCHY (shared, non-hub headings)
   Hub keeps its bespoke wordmark; these tune the content pages.
   ───────────────────────────────────────────────────────────── */

.ds-eyebrow {
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────────
   SHARED COMPONENTS
   ───────────────────────────────────────────────────────────── */

/* Section title above a .rule (content pages) */
.card h1,
.card h2 {
  margin: 0 0 var(--space-2);
  padding-left: 14px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg);
  line-height: var(--leading-tight);
}

.card h1 {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.card h2 {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

/* Accent underline rule beneath headings */
.rule {
  height: 1px;
  max-width: min(12rem, 40vw);
  margin-bottom: clamp(0.78rem, 1.2vw, 0.96rem);
  margin-left: 14px;
  background: linear-gradient(90deg, var(--accent-line), transparent);
}

/* Back link — minimal ghost style (matches top nav, not the old pill) */
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  align-self: flex-start;
  color: var(--fg);
  text-decoration: none;
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  opacity: 0.55;
  transition: var(--transition-ui);
}

.back__arrow {
  color: var(--accent);
  font-size: 1.05em;
  line-height: 1;
  transition: transform var(--dur-fast) var(--ease);
}

.back:hover,
.back:focus-visible {
  opacity: 1;
  outline: none;
}

.back:hover .back__arrow,
.back:focus-visible .back__arrow {
  transform: translateX(-3px);
}

/* Card — primary content surface */
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(0.64rem, 1.05vw, 0.8rem) clamp(0.82rem, 1.35vw, 1.01rem);
  background: linear-gradient(145deg, rgba(22, 22, 22, 0.97) 0%, rgba(10, 10, 10, 0.98) 100%);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Ember stripe down the card's leading edge */
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(
    180deg,
    rgb(var(--accent-rgb) / 0.85) 0%,
    rgb(var(--accent-rgb) / 0.35) 55%,
    transparent 100%
  );
  pointer-events: none;
}

.card-inner {
  position: relative;
  z-index: 1;
}

/* Generic pill button (opt-in via .ds-btn) */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  background: rgba(18, 18, 18, 0.55);
  transition: var(--transition-ui);
}

.ds-btn:hover,
.ds-btn:focus-visible {
  border-color: rgb(var(--accent-rgb) / 0.55);
  box-shadow: 0 0 22px var(--accent-glow);
  background: rgba(24, 10, 8, 0.75);
}

/* Fixed wordmark — top-left brand watermark (hub + content pages) */
.nav-logo {
  position: fixed;
  top: calc(26px + env(safe-area-inset-top));
  left: calc(34px + env(safe-area-inset-left));
  z-index: 110;
  display: block;
  line-height: 0;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

.nav-logo img {
  display: block;
  width: clamp(88px, 8.5vw, 128px);
  height: auto;
  opacity: 0.92;
  transition: opacity var(--dur-base) var(--ease);
  -webkit-user-drag: none;
}

.nav-logo:hover img,
.nav-logo:focus-visible img {
  opacity: 1;
}

/* Top-right section navigation (hub + content pages) */
.nav-links {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  right: calc(24px + env(safe-area-inset-right));
  z-index: 110;
  list-style: none;
  display: flex;
  align-items: center;
  gap: clamp(1.65rem, 3.3vw, 3.08rem);
  margin: 0;
  padding: 0;
}

.nav-link {
  font-weight: var(--weight-semibold);
  font-size: clamp(0.68rem, 0.88vw, 0.83rem);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity var(--dur-base) var(--ease);
  -webkit-user-select: none;
  user-select: none;
}

.nav-link:hover,
.nav-link:focus-visible {
  opacity: 1;
  outline: none;
}

.nav-link--active {
  opacity: 1;
  border-bottom: 1px solid var(--accent-line);
  padding-bottom: 2px;
}

.nav-link--tba {
  cursor: default;
  pointer-events: none;
  opacity: 0.22;
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — larger touch targets + type on small screens
   ───────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  :root {
    --mobile-header-offset: 4.5rem;
  }

  html,
  body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .nav-logo {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(16px + env(safe-area-inset-left));
  }

  .nav-logo img {
    width: 96px;
  }

  .nav-links {
    top: calc(16px + env(safe-area-inset-top));
    right: calc(14px + env(safe-area-inset-right));
    gap: 1rem;
    max-width: calc(100vw - 9.25rem);
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .nav-link {
    font-size: 0.78rem;
    letter-spacing: 0.11em;
  }

  .back {
    font-size: 0.68rem;
  }

  .card {
    padding: 1.2rem 1rem 1.35rem;
    border-radius: 14px;
  }

  .card h1 {
    font-size: 1.45rem;
  }

  .card h2 {
    font-size: 1rem;
  }
}

/* Small phones — centered wordmark with nav row beneath (avoids logo/nav collision) */
@media (max-width: 520px) {
  :root {
    --mobile-header-offset: 8rem;
  }

  .nav-logo {
    top: calc(8px + env(safe-area-inset-top));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .nav-logo img {
    width: 114px;
  }

  .nav-links {
    top: calc(64px + env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    max-width: none;
    justify-content: center;
    gap: 0.65rem 1.35rem;
    flex-wrap: wrap;
  }

  .nav-link {
    font-size: 0.76rem;
    letter-spacing: 0.1em;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
