/* ============================================================
   RIBL — design tokens, type, base
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

/* ------------------------------------------------------------
   SK Quadratica — the brand mark face (the colophon "R.")
   Commercial font; drop the file at assets/fonts/ to activate.
   Until then the mark falls back to Instrument Serif gracefully.
   ------------------------------------------------------------ */
@font-face {
  font-family: "SK Quadratica";
  src: url("assets/fonts/SKQuadratica.woff2") format("woff2"),
       url("assets/fonts/SKQuadratica.woff") format("woff"),
       url("assets/fonts/SKQuadratica.otf") format("opentype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
:root { --mark-font: "SK Quadratica", "Instrument Serif", "Times New Roman", serif; }

:root {
  /* Dark surfaces (default) */
  --ink: #0d0c0a;
  --ink-2: #131210;
  --ink-3: #1a1815;
  --paper: #f4efe6;
  --paper-2: #ebe5d6;
  --paper-3: #e2dcc9;

  --fg: #e8e2d2;
  --fg-soft: #b8b1a0;
  --fg-mute: #6b6557;
  --fg-faint: #3d3a33;

  --rule: rgba(232, 226, 210, 0.10);
  --rule-strong: rgba(232, 226, 210, 0.18);

  --gold: #c69a5b;
  --gold-soft: #a78147;
  --gold-deep: #7a5d31;

  --crimson: #a8392c;   /* used once or twice for stamps only */

  /* Spatial */
  --col: minmax(0, 1fr);
  --bleed: clamp(24px, 5vw, 80px);
  --max: 1440px;

  /* Type */
  --display: "Instrument Serif", "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* Motion */
  --ease: cubic-bezier(.2, .6, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

[data-theme="light"] {
  --ink: #f4efe6;
  --ink-2: #ebe5d6;
  --ink-3: #e2dcc9;
  --paper: #0d0c0a;
  --paper-2: #131210;
  --paper-3: #1a1815;

  --fg: #1a1612;
  --fg-soft: #4a443a;
  --fg-mute: #7a7263;
  --fg-faint: #b9b09d;

  --rule: rgba(26, 22, 18, 0.10);
  --rule-strong: rgba(26, 22, 18, 0.18);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--ink);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv01", "cv11";
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

button {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer;
}

/* Paper grain — extremely subtle */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.95  0 0 0 0 0.93  0 0 0 0 0.87  0 0 0 0.06 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  opacity: .35;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 2;
}
[data-theme="light"] body::before {
  opacity: 0.25;
  mix-blend-mode: multiply;
}

/* ============================================================
   Type system
   ============================================================ */
.display {
  font-family: var(--display);
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: -0.02em;
}
.display em { font-style: italic; letter-spacing: -0.015em; }

.h-xxl { font-family: var(--display); font-weight: 400; font-size: clamp(64px, 9vw, 144px); line-height: 0.92; letter-spacing: -0.03em; }
.h-xl  { font-family: var(--display); font-weight: 400; font-size: clamp(48px, 6vw, 96px); line-height: 0.95; letter-spacing: -0.025em; }
.h-lg  { font-family: var(--display); font-weight: 400; font-size: clamp(36px, 4vw, 64px); line-height: 1.02; letter-spacing: -0.02em; }
.h-md  { font-family: var(--display); font-weight: 400; font-size: clamp(28px, 3vw, 40px); line-height: 1.1; letter-spacing: -0.015em; }
.h-sm  { font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1.15; }

.body { font-family: var(--sans); font-size: 16px; line-height: 1.55; color: var(--fg-soft); }
.body-lg { font-family: var(--sans); font-size: 18px; line-height: 1.55; color: var(--fg-soft); font-weight: 300; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.eyebrow.gold { color: var(--gold); }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--fg-mute);
}

.italic { font-style: italic; }

/* ============================================================
   Layout primitives
   ============================================================ */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--bleed);
  padding-right: var(--bleed);
}

.rule { height: 1px; background: var(--rule); width: 100%; }
.rule-strong { height: 1px; background: var(--rule-strong); width: 100%; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 22px;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 999px;
  transition: all .25s var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--fg); color: var(--ink);
}
.btn-primary:hover { background: var(--gold); }
.btn-ghost {
  border: 1px solid var(--rule-strong); color: var(--fg);
}
.btn-ghost:hover { border-color: var(--fg); }
.btn-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--fg); padding-bottom: 2px;
  border-bottom: 1px solid var(--rule-strong);
  transition: border-color .25s var(--ease);
}
.btn-link:hover { border-color: var(--gold); color: var(--gold); }

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 50;
  padding: 22px var(--bleed);
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: blur(12px);
  background: color-mix(in oklab, var(--ink) 70%, transparent);
  border-bottom: 1px solid var(--rule);
}
.site-header .nav {
  display: flex; align-items: center; gap: 36px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--fg-mute);
}
.site-header .nav a:hover { color: var(--fg); }
.site-header .end {
  display: flex; align-items: center; gap: 16px;
}

/* Logo lockup (in header) */
.brand-lockup {
  display: inline-flex; align-items: center; gap: 12px;
}
.brand-lockup .mark { width: 28px; height: 28px; }
.brand-lockup .wm-serif {
  font-family: var(--display); font-style: italic;
  font-size: 22px; line-height: 1; letter-spacing: -0.01em;
  color: var(--fg);
}
.brand-lockup .wm-mono {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; color: var(--fg-mute);
  position: relative; top: -6px; margin-left: -2px;
}

/* ============================================================
   Section frame
   ============================================================ */
.section {
  padding-top: clamp(80px, 12vw, 160px);
  padding-bottom: clamp(80px, 12vw, 160px);
  position: relative;
}
.section + .section { border-top: 1px solid var(--rule); }

.sec-head {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 64px;
  margin-bottom: 80px;
}
.sec-head .label { color: var(--fg-mute); }
@media (max-width: 880px) {
  .sec-head { grid-template-columns: 1fr; gap: 24px; margin-bottom: 56px; }
}

/* Theme toggle button */
.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  color: var(--fg-mute);
  transition: all .2s var(--ease);
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold); }
.theme-toggle svg { width: 14px; height: 14px; }

/* Utility */
.gold { color: var(--gold); }
.muted { color: var(--fg-mute); }
.soft { color: var(--fg-soft); }

/* ============================================================
   Footer — shared across landing, pricing, brand
   ============================================================ */
.site-footer {
  padding: 80px var(--bleed) 40px;
  border-top: 1px solid var(--rule);
  background: var(--ink);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 56px;
  max-width: var(--max);
  margin: 0 auto 60px;
}
@media (max-width: 880px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 36px; }
}
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}
.footer-brand-block .body {
  margin-top: 18px;
  font-size: 13px;
  color: var(--fg-mute);
  max-width: 280px;
  line-height: 1.5;
}
.footer-col h4 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 18px;
  font-weight: 500;
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.footer-col li a {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--fg);
  letter-spacing: -0.01em;
  transition: color .2s var(--ease);
}
.footer-col li a:hover { color: var(--gold); }
.footer-bottom {
  max-width: var(--max);
  margin: 0 auto;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--fg-mute);
  text-transform: uppercase;
}

/* ============================================================
   MOBILE — iOS Safari overflow fix
   ============================================================ */
html {
  overflow-x: hidden;
  max-width: 100%;
  position: relative;
}
body {
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}
.wrap { min-width: 0; overflow-x: hidden; }

@media (max-width: 480px) { :root { --bleed: 18px; } }

/* ============================================================
   HAMBURGER BUTTON (injected by theme.js into every .site-header)
   ============================================================ */
.nav-burger {
  display: none;
  width: 36px; height: 36px;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .2s var(--ease);
}
.nav-burger:hover { border-color: var(--gold); }
.nav-burger span {
  display: block;
  width: 13px; height: 1.5px;
  background: var(--fg-mute);
  border-radius: 2px;
  transition: transform .22s var(--ease), opacity .22s var(--ease), background .2s var(--ease);
  transform-origin: center;
}
.nav-burger:hover span { background: var(--gold); }

/* Burger → X when nav is open */
.site-header.nav-open .nav-burger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.site-header.nav-open .nav-burger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.site-header.nav-open .nav-burger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ============================================================
   MOBILE NAV DROPDOWN
   ============================================================ */

/* Backdrop */
.nav-backdrop {
  display: none;
  position: fixed; inset: 0;
  z-index: 48;
  background: rgba(13,12,10,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.nav-backdrop.active { display: block; }

/* When nav is open, show backdrop */
.site-header.nav-open ~ .nav-backdrop,
body:has(.site-header.nav-open) .nav-backdrop { display: block; }

/* Nav panel slides down from header */
@media (max-width: 760px) {
  .nav-burger { display: inline-flex; }

  /* Keep nav hidden until opened */
  .site-header .nav {
    display: none;
    position: fixed;
    top: 57px; left: 0; right: 0;
    z-index: 49;
    flex-direction: column;
    gap: 0;
    background: color-mix(in oklab, var(--ink) 96%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--rule-strong);
    padding: 8px 0 20px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
  }

  /* Open state */
  .site-header.nav-open .nav {
    display: flex;
    animation: nav-drop .22s var(--ease-out) both;
  }

  @keyframes nav-drop {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Nav links — editorial serif style on mobile */
  .site-header .nav a {
    display: block;
    padding: 14px var(--bleed);
    font-family: var(--display);
    font-style: italic;
    font-size: 22px;
    letter-spacing: -0.01em;
    color: var(--fg-soft);
    border-bottom: 1px solid var(--rule);
    transition: color .15s var(--ease), padding-left .15s var(--ease);
    text-transform: none;
    letter-spacing: -0.01em;
  }
  .site-header .nav a:last-child { border-bottom: none; }
  .site-header .nav a:hover {
    color: var(--gold);
    padding-left: calc(var(--bleed) + 8px);
  }

  /* Header layout on mobile */
  .site-header { padding: 14px 18px; }
  .site-header .end { gap: 10px; }
  .site-header .end .mono { display: none; }
}

/* ============================================================
   HERO — keep the animation alive on mobile, just compact it
   ============================================================ */
.hero { overflow: hidden; }
.hero * { max-width: 100%; box-sizing: border-box; }

@media (max-width: 760px) {
  .hero { padding-top: 86px; padding-bottom: 40px; }

  /* Stack left + right, gap between them */
  .hero-grid { grid-template-columns: 1fr !important; gap: 28px; }

  /* ── Left column ── */
  .hero-title { font-size: clamp(40px, 11vw, 64px) !important; line-height: 0.98 !important; }
  .hero-sub   { font-size: 15px; max-width: 100%; }

  /* Input: stack vertically */
  .hero-input-row { flex-direction: column; gap: 10px; max-width: 100%; }
  .hero-input     { flex: none; width: 100%; }
  .hero-input-row .btn { width: 100%; justify-content: center; }

  /* Chips: wrap */
  .hero-chips  { flex-wrap: wrap; gap: 8px; }
  .chip        { font-size: 14px; padding: 5px 12px; }
  .chips-label { display: none; }

  /* Spec strip: scale down, wrap, hide rules */
  .hero-specstrip  { gap: 14px !important; flex-wrap: wrap !important; padding-top: 20px !important; }
  .spec-rule       { display: none !important; }
  .spec-num        { font-size: 24px !important; }
  .spec-formats    { font-size: 17px !important; white-space: normal !important; }

  /* ── Right column: the viewport (the beautiful part) ── */
  /* Keep it visible — it IS the product demo — but at phone height */
  .hero-right {
    display: block !important;
    height: 380px !important;
  }

  /* Inside the viewport: hide the ToC panel, show just the writing page */
  .vp-toc { display: none !important; }
  .vp-body { grid-template-columns: 1fr !important; }
  .vp-page { padding: 24px 22px !important; }

  /* Tighten the status bar */
  .vp-top { padding: 10px 16px !important; }
  .vp-top-right .vp-stat:not(:first-child) { display: none; } /* keep word count, hide rest */

  /* Bottom bar */
  .vp-bottom { padding: 10px 16px !important; gap: 12px; }
  .vp-tempo  { display: none; }  /* hide speed controls on mobile */
}

@media (max-width: 420px) {
  .hero-title  { font-size: clamp(36px, 10vw, 52px) !important; }
  .hero-right  { height: 320px !important; }
  .hero-specstrip { display: none !important; }
  .site-header .end .btn-primary { padding: 0 13px; font-size: 12px; height: 38px; }
}

/* ============================================================
   MOBILE — other sections
   ============================================================ */

/* Close CTA */
@media (max-width: 520px) {
  .close-cta-row { flex-direction: column; align-items: center; gap: 14px; }
  .close-title   { font-size: clamp(40px, 12vw, 72px); }
}

/* Auth pages */
@media (max-width: 760px) {
  .auth-page { flex-direction: column !important; }
  .auth-jacket {
    min-height: unset !important;
    padding: 36px var(--bleed) 28px !important;
    flex: none !important;
  }
  .auth-jacket-pull, .auth-jacket-stats, .auth-jacket-corner { display: none; }
  .auth-jacket-sub   { font-size: 14px !important; }
  .auth-jacket-title { font-size: clamp(28px, 8vw, 44px) !important; }
  .auth-form-panel   { padding: 32px var(--bleed) !important; flex: none !important; }
}

/* Studio sidebar */
@media (max-width: 760px) {
  .studio-app  { grid-template-columns: 1fr !important; }
  .studio-side { display: none !important; }
  .studio-main { padding: 72px 16px 40px !important; }
}

/* App bar */
@media (max-width: 600px) {
  .app-bar { padding: 0 14px !important; }
  .app-bar-right .btn { display: none; }
}

/* Phase list */
@media (max-width: 600px) {
  .phase-list li { grid-template-columns: 16px 1fr; gap: 10px; }
  .phase-list li .meta { display: none; }
}

/* Pricing compare table */
@media (max-width: 760px) {
  .compare-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tiers-grid { grid-template-columns: 1fr !important; gap: 18px !important; }
}

/* Shelf */
@media (max-width: 420px) {
  .shelf { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; }
}

/* Section headings */
@media (max-width: 600px) {
  .engine-head, .work-header { gap: 16px; }
  .engine-head h2, .work-header h2 { font-size: clamp(32px, 9vw, 52px); }
}
