/* ============================================================
   Waystone — _shared.css
   Design tokens, global chrome (nav, footer), type system,
   motion utilities. Paper mode via [data-mode="paper"].
   ============================================================ */

/* View Transitions ------------------------------------------- */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 480ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
::view-transition-old(root) { animation-name: ws-fade-out; }
::view-transition-new(root) { animation-name: ws-fade-in;  }
@keyframes ws-fade-out { to   { opacity: 0; } }
@keyframes ws-fade-in  { from { opacity: 0; transform: translateY(6px); } }

/* Tokens ----------------------------------------------------- */
:root {
  /* Dark (default) */
  --bg:           #0B0D12;
  --surface:      #11141C;
  --raised:       #181C28;
  --raised-2:     #1f2433;
  --border:       rgba(255,255,255,0.06);
  --rule:         rgba(201,168,76,0.10);
  --rule-strong:  rgba(201,168,76,0.24);

  --t1:           #EDE9E2;   /* primary text (moonlight) */
  --t2:           #7A8090;   /* secondary    (mist)      */
  --t3:           #363B48;   /* tertiary                 */
  --t1-soft:      rgba(237,233,226,0.86);

  --gold:         #C9A84C;
  --gold-dim:     #7A6228;
  --gold-bright:  #F0D080;
  --gold-deep:    #3A2A08;
  --gold-soft:    rgba(201,168,76,0.18);

  --user-blue:    #4A90D9;
  --ancient-blue: #4A9ECC;

  /* Type */
  --font-display: 'Cormorant Garamond', 'EB Garamond', Garamond, serif;
  --font-body:    'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:    'DM Mono', 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --tr-label:     0.22em;
  --tr-display:   0.005em;

  /* Spacing */
  --sp-xs: 8px;
  --sp-sm: 14px;
  --sp-md: 24px;
  --sp-lg: 40px;
  --sp-xl: 72px;
  --sp-xxl: 120px;

  /* Radii */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-pill: 28px;

  /* Shadows */
  --shadow-card: 0 2px 8px rgba(0,0,0,0.30);
  --shadow-sheet: 0 -8px 24px rgba(0,0,0,0.45);
  --glow-gold: 0 0 0 1px rgba(201,168,76,0.30), 0 0 24px rgba(201,168,76,0.18);

  /* Motion */
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 180ms;
  --dur-base: 320ms;
  --dur-slow: 560ms;
}

/* Paper mode ------------------------------------------------- */
[data-mode="paper"] {
  --bg:          #F0E8D4;
  --surface:     #EAE1C9;
  --raised:      #F5EEDC;
  --raised-2:    #EFE6CB;
  --border:      rgba(28,23,16,0.12);
  --rule:        rgba(139,104,32,0.22);
  --rule-strong: rgba(139,104,32,0.42);

  --t1:          #1C1710;
  --t2:          #5C4E36;
  --t3:          #8A7A5A;
  --t1-soft:     rgba(28,23,16,0.85);

  --gold:        #8B6820;   /* gilt */
  --gold-dim:    #6A4F18;
  --gold-bright: #B68A2A;
  --gold-deep:   #4A350C;
  --gold-soft:   rgba(139,104,32,0.18);

  --shadow-card: 0 2px 6px rgba(92,70,24,0.18);
}

/* Reset ------------------------------------------------------ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;        /* Lenis owns the scroll */
}
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

body {
  font-family: var(--font-body);
  color: var(--t1);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
::selection { background: rgba(201,168,76,0.30); color: var(--t1); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* Skip link -------------------------------------------------- */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--bg); color: var(--gold);
  padding: 12px 18px; border: 1px solid var(--gold);
  font: 500 12px/1 var(--font-body); letter-spacing: var(--tr-label); text-transform: uppercase;
  z-index: 100;
}
.skip:focus { left: 16px; top: 16px; }

/* Nav -------------------------------------------------------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  padding: 18px clamp(20px, 4vw, 48px);
  display: flex; align-items: center; justify-content: space-between;
  transition: background var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              backdrop-filter var(--dur-base) var(--ease-out);
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-bottom-color: var(--border);
}
.nav-brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 300;
  font-size: 22px; letter-spacing: 0.005em;
  color: var(--t1);
  view-transition-name: ws-wordmark;
}
.nav-brand .stone { color: var(--gold); }
.nav-glyph { height: 26px; width: auto; flex: none; display: flex; align-items: center; }
.nav-glyph img, .nav-glyph svg { height: 100%; width: auto; display: block; }

.nav-links {
  list-style: none;
  display: flex; align-items: center;
  gap: clamp(14px, 2vw, 30px);
}
.nav-links a {
  display: inline-block;
  font: 500 11px/1 var(--font-body);
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--t2);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.nav-links a:hover, .nav-links a:focus-visible { color: var(--t1); }
.nav-links a.active { color: var(--gold); border-bottom-color: var(--gold); }

/* Mobile menu */
.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  color: var(--t1);
  border-radius: var(--r-sm);
}
.nav-toggle:hover { background: rgba(255,255,255,0.04); }
.nav-toggle .bars { width: 22px; height: 12px; position: relative; }
.nav-toggle .bars::before, .nav-toggle .bars::after {
  content: ""; position: absolute; left: 0; right: 0; height: 1px;
  background: currentColor;
  transition: transform var(--dur-base) var(--ease-out), top var(--dur-base) var(--ease-out);
}
.nav-toggle .bars::before { top: 2px; }
.nav-toggle .bars::after  { top: 9px; }
.nav-toggle[aria-expanded="true"] .bars::before { top: 5.5px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bars::after  { top: 5.5px; transform: rotate(-45deg); }

.nav-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: 100px clamp(28px, 8vw, 80px) 60px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.nav-overlay.is-open { opacity: 1; pointer-events: auto; }
.nav-overlay ol { list-style: none; display: flex; flex-direction: column; gap: 18px; }
.nav-overlay li {
  opacity: 0; transform: translateY(14px);
  transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out);
  transition-delay: calc(60ms * var(--i, 0));
}
.nav-overlay.is-open li { opacity: 1; transform: none; }
.nav-overlay a {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(36px, 8vw, 56px);
  line-height: 1; color: var(--t1);
  display: inline-block;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
}
.nav-overlay a.active { color: var(--gold); border-bottom-color: var(--gold); }
.nav-overlay .num {
  display: inline-block;
  width: 2.4em;
  font: 500 11px/1 var(--font-mono);
  color: var(--t3); letter-spacing: 0.04em;
  vertical-align: middle;
}

@media (max-width: 760px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
}

/* Layout helpers -------------------------------------------- */
.wrap        { width: 100%; margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px); max-width: 1180px; }
.wrap--text  { max-width: 720px; }
.wrap--wide  { max-width: 1320px; }

.eyebrow {
  display: inline-block;
  font: 600 10.5px/1 var(--font-body);
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--gold-dim);
}
.eyebrow .num { font-family: var(--font-mono); margin-right: 10px; color: var(--gold); }

.gold-rule {
  display: block; width: 40px; height: 1px; border: 0;
  background: linear-gradient(90deg, var(--gold-deep) 0%, var(--gold) 50%, var(--gold-deep) 100%);
  opacity: 0.85;
}

.display {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(40px, 6.2vw, 88px);
  line-height: 1.04; letter-spacing: var(--tr-display);
  color: var(--t1); text-wrap: balance;
}
.display--xl { font-size: clamp(56px, 9vw, 132px); line-height: 0.98; font-weight: 300; }
.display--sm { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.12; }
.tagline {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(18px, 2vw, 26px); color: var(--t2);
  line-height: 1.4;
}
.lede {
  font-family: var(--font-body); font-weight: 400;
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.7; color: var(--t1-soft);
  text-wrap: pretty;
}
.lede + .lede { margin-top: 1.15em; }
.body {
  font: 400 15.5px/1.7 var(--font-body);
  color: var(--t2);
}
.body + .body { margin-top: 1em; }
.mono {
  font: 500 11px/1.4 var(--font-mono);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--t3);
}

/* Buttons / links ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 26px;
  font: 500 12px/1 var(--font-body);
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: var(--r-pill);
  background: transparent;
  transition: background var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:hover, .btn:focus-visible {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: var(--gold-soft);
}
.btn:active { transform: scale(0.97); }
.btn .arr { transition: transform var(--dur-base) var(--ease-out); }
.btn:hover .arr { transform: translateX(4px); }

.btn--primary {
  background: var(--gold);
  color: #0B0D12;
  border-color: var(--gold);
}
.btn--primary:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  color: #0B0D12;
}

.linkish {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 11.5px/1 var(--font-body);
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--gold);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule-strong);
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), gap var(--dur-base) var(--ease-out);
}
.linkish:hover { color: var(--gold-bright); border-color: var(--gold); gap: 14px; }

/* Beta marker ----------------------------------------------- */
.beta-tag {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 10px;
  font: 600 10px/1 var(--font-body);
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--gold-bright);
  background: rgba(201,168,76,0.06);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-pill);
}
.beta-tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: ws-pulse 2.6s var(--ease-in-out) infinite;
}
@keyframes ws-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.25); }
}

/* Footer ---------------------------------------------------- */
.foot {
  margin-top: var(--sp-xxl);
  padding: var(--sp-xl) 0 var(--sp-lg);
  border-top: 1px solid var(--border);
  color: var(--t2);
}
.foot-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: var(--sp-lg);
}
.foot-col h4 {
  font: 600 10px/1 var(--font-body);
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 16px;
}
.foot-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.foot-col a {
  font: 500 12px/1.3 var(--font-body);
  color: var(--t2);
  transition: color var(--dur-fast) var(--ease-out);
}
.foot-col a:hover { color: var(--gold); }
.foot-brand {
  font-family: var(--font-display); font-weight: 300; font-size: 28px; line-height: 1;
  margin-bottom: 14px;
}
.foot-brand .stone { color: var(--gold); }
.foot-desc {
  font: 400 13.5px/1.55 var(--font-body);
  color: var(--t2); max-width: 28ch;
}
.foot-meta {
  margin-top: var(--sp-xl);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-between;
  font: 500 10.5px/1.5 var(--font-mono);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--t3);
}
.foot-meta a:hover { color: var(--gold); }
@media (max-width: 880px) {
  .foot-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .foot-inner { grid-template-columns: 1fr; }
}

/* Motion utilities ------------------------------------------ */
[data-reveal]      { opacity: 0; transform: translateY(16px); transition: none; }
[data-reveal-line] { overflow: hidden; display: block; }
[data-reveal-line] > * { display: block; transform: translateY(110%); transition: none; }

[data-parallax] { will-change: transform; }

/* When JS is missing, restore everything */
.no-js [data-reveal]            { opacity: 1; transform: none; }
.no-js [data-reveal-line] > *   { transform: none; }

/* Section primitive ----------------------------------------- */
.sec { padding-block: var(--sp-xxl); position: relative; }
.sec--tight { padding-block: var(--sp-xl); }
.sec--hero  { padding: 0; min-height: 100vh; display: flex; align-items: center; position: relative; }

.section-head { display: flex; flex-direction: column; gap: 22px; margin-bottom: var(--sp-lg); }
.section-head .gold-rule { margin: 4px 0; }

/* Paper-texture utility (real CSS, no images) --------------- */
.paper-tex {
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(0deg,
      rgba(28,23,16,0.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg,
      rgba(28,23,16,0.06) 0 1px, transparent 1px 23px),
    linear-gradient(135deg,
      rgba(255,250,225,0.18), rgba(0,0,0,0) 60%);
}

/* Reduced motion ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  [data-reveal-line] > * { transform: none; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}
