/* ============================================================
   THOTH.AU — Dev Gremlin / Egyptian Terminal Maximalism
   Dark mode only. Navy + gold. Cabinet Grotesk / General Sans / Fira Code.
   ============================================================ */

:root {
  /* core palette (spec §3.2) */
  --bg:        #1A1A2E;   /* page background — dark navy */
  --surface:   #0F1520;   /* cards, panels */
  --surface-2: #141b29;   /* raised */
  --gold:      #C9A84C;   /* primary accent */
  --gold-dim:  #8e7733;
  --plum:      #AA5388;   /* secondary accent / hover */
  --amber:     #E8832A;   /* torch glow ONLY */
  --text:      #F2F2F2;   /* body text */
  --muted:     #7A8499;   /* secondary / meta */
  --green:     #4ADE80;   /* status dot ONLY, sparingly */
  --line:      #262d3d;   /* hairlines */
  --line-soft: #1d2433;

  /* type */
  --display: "Cabinet Grotesk", "Arial Black", sans-serif;
  --body:    "General Sans", system-ui, -apple-system, sans-serif;
  --mono:    "Fira Code", ui-monospace, "SF Mono", Menlo, monospace;

  /* layout */
  --gutter: clamp(20px, 4vw, 64px);
  --max-w:  1280px;

  /* legacy aliases (so legal pages inherit dark theme) */
  --ink: var(--text);
  --ink-soft: #c3c9d6;
  --ink-mute: var(--muted);
  --rule: var(--line);
  --rule-soft: var(--line-soft);
  --bg-card: var(--surface);
  --bg-soft: var(--surface);
  --accent: var(--gold);
  --accent-deep: var(--gold-dim);
  --sage: var(--plum);
  --serif: var(--display);
  --sans: var(--body);
  --radius: 4px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html.reduce-motion { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* ---- atmospheric overlays: scanlines + grain ---- */
.fx-scanlines,
.fx-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
}
.fx-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.10) 3px,
    rgba(0,0,0,0) 4px
  );
  opacity: 0.5;
  mix-blend-mode: multiply;
}
.fx-grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: overlay;
}
html.reduce-motion .fx-grain { opacity: 0.02; }

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

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

p { margin: 0 0 1em; text-wrap: pretty; }

h1,h2,h3,h4 {
  font-family: var(--display);
  font-weight: 800;
  margin: 0;
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

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

/* ---- layout ---- */
.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.section { padding: clamp(44px, 6vw, 88px) 0; position: relative; }
.section__head { margin-bottom: clamp(22px, 3vw, 40px); }
.section__head h2 {
  font-size: clamp(34px, 5.2vw, 76px);
  line-height: 0.98;
}
.section__head .eyebrow { display: block; margin-bottom: 18px; }
.section__head p {
  color: var(--muted);
  max-width: 56ch;
  margin-top: 18px;
  font-size: 18px;
}

/* gold-bracketed section number */
.sec-index {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sec-index::before { content: "//"; color: var(--plum); }

/* ---- buttons ---- */
.btn {
  --bw: 1px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 14px 26px;
  border: var(--bw) solid var(--gold);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  border-radius: 2px;
  transition: color .18s, background .18s, box-shadow .18s, transform .12s;
  text-transform: uppercase;
}
.btn:hover {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 0 1px var(--gold), 0 0 24px -4px var(--gold);
}
.btn:active { transform: translateY(1px); }
.btn--solid { background: var(--gold); color: var(--bg); }
.btn--solid:hover { background: var(--plum); border-color: var(--plum); box-shadow: 0 0 24px -4px var(--plum); }
.btn--ghost { border-color: var(--line); color: var(--text); }
.btn--ghost:hover { border-color: var(--plum); background: transparent; color: var(--plum); box-shadow: 0 0 18px -6px var(--plum); }
.btn--block { width: 100%; }
.btn__arrow { transition: transform .18s; }
.btn:hover .btn__arrow { transform: translateX(4px); }

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
}
.nav__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.nav__brand .mark { color: var(--gold); display: inline-flex; }
.nav__brand .tld { color: var(--plum); }

.nav__mid { display: flex; align-items: center; gap: 28px; }
.nav__links { display: flex; gap: 26px; font-family: var(--mono); font-size: 14px; letter-spacing: 0.02em; }
.nav__links a { color: var(--muted); transition: color .15s; position: relative; padding: 4px 0; }
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: -2px; height: 1px; width: 0;
  background: var(--gold); transition: width .2s;
}
.nav__links a:hover, .nav__links a[aria-current="page"] { color: var(--gold); }
.nav__links a:hover::after, .nav__links a[aria-current="page"]::after { width: 100%; }

/* status indicator */
.status {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  letter-spacing: 0.04em;
}
.status__dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green); position: relative;
}
.status__dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  background: var(--green); opacity: .35; animation: ping 1.8s ease-out infinite;
}
html.reduce-motion .status__dot::after { animation: none; opacity: .2; }
@keyframes ping { 0%{transform:scale(.5);opacity:.4} 100%{transform:scale(2);opacity:0} }

/* CTA with hover label swap */
.nav__cta {
  font-family: var(--mono); font-size: 13px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 18px; border: 1px solid var(--gold); border-radius: 2px; color: var(--gold);
  transition: background .18s, color .18s, box-shadow .18s;
  position: relative; overflow: hidden; white-space: nowrap;
}
.nav__cta:hover { background: var(--gold); color: var(--bg); box-shadow: 0 0 22px -6px var(--gold); }
.nav__cta .swap-a, .nav__cta .swap-b { display: inline-block; transition: transform .2s, opacity .2s; }
.nav__cta .swap-b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transform: translateY(120%); }
.nav__cta:hover .swap-a { opacity: 0; transform: translateY(-120%); }
.nav__cta:hover .swap-b { opacity: 1; transform: translateY(0); }

.nav__burger { display: none; background: none; border: 1px solid var(--line); border-radius: 3px; color: var(--gold); padding: 8px 10px; cursor: pointer; font-family: var(--mono); }

@media (max-width: 880px) {
  .nav__mid { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: flex-start; gap: 18px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 24px var(--gutter); }
  .nav__mid.open { display: flex; }
  .nav__links { flex-direction: column; gap: 16px; font-size: 16px; }
  .nav__burger { display: inline-flex; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer { border-top: 1px solid var(--line); background: var(--surface); padding: 48px 0 30px; }
.footer__top { display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; margin-bottom: 36px; }
.footer__brand { font-family: var(--display); font-weight: 800; font-size: 30px; margin-bottom: 12px; }
.footer__brand .tld { color: var(--plum); }
.footer__gremlin { font-family: var(--mono); font-size: 13px; color: var(--gold); margin-bottom: 6px; }
.footer__meta { font-family: var(--mono); font-size: 12.5px; color: var(--muted); line-height: 1.9; }
.footer__links { display: flex; gap: 40px; flex-wrap: wrap; }
.footer__col h4 { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); font-weight: 500; margin-bottom: 14px; }
.footer__col ul { list-style: none; padding: 0; margin: 0; }
.footer__col li { margin-bottom: 9px; font-size: 14px; }
.footer__col a { color: var(--muted); transition: color .15s; }
.footer__col a:hover { color: var(--gold); }
.footer__uptime { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.footer__uptime b { color: var(--green); font-weight: 500; }
.footer__base { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 26px; border-top: 1px solid var(--line-soft); font-family: var(--mono); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.footer__base .glyphs { color: var(--gold-dim); letter-spacing: 0.3em; }

/* ============================================================
   SCROLL PROGRESS + CUSTOM CURSOR + REDUCE-MOTION TOGGLE
   ============================================================ */
.scroll-rail {
  position: fixed; right: 14px; top: 50%; transform: translateY(-50%);
  height: 200px; width: 2px; background: var(--line); z-index: 150; border-radius: 2px;
}
.scroll-rail__fill { position: absolute; top: 0; left: 0; width: 100%; height: 0; background: linear-gradient(var(--gold), var(--plum)); border-radius: 2px; }
.scroll-rail__pct { position: absolute; left: 10px; top: 0; font-family: var(--mono); font-size: 10px; color: var(--gold); transform: translateY(-50%); white-space: nowrap; }
@media (max-width: 880px) { .scroll-rail { display: none; } }

#cursor, #cursor-dot { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9500; mix-blend-mode: difference; will-change: transform; }
#cursor { width: 22px; height: 22px; margin: -11px 0 0 -11px; }
#cursor::before, #cursor::after { content:""; position:absolute; background: var(--gold); }
#cursor::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
#cursor::after { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
#cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--gold); animation: curblink 1s steps(2) infinite; }
@keyframes curblink { 50% { opacity: 0; } }
html.reduce-motion #cursor-dot { animation: none; }
body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
@media (hover: none), (pointer: coarse) { #cursor, #cursor-dot { display: none !important; } body.has-cursor { cursor: auto; } }

.motion-toggle {
  position: fixed; bottom: 18px; left: 18px; z-index: 220;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: color .15s, border-color .15s;
}
.motion-toggle:hover { color: var(--gold); border-color: var(--gold); }
.motion-toggle__led { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
html.reduce-motion .motion-toggle__led { background: var(--muted); box-shadow: none; }

/* ---- scroll reveal ---- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .6s cubic-bezier(.2,.7,.2,1), transform .6s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
html.reduce-motion .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }

/* ============================================================
   PROSE (legal pages)
   ============================================================ */
.page-head { padding: clamp(48px,7vw,90px) 0 clamp(32px,5vw,56px); border-bottom: 1px solid var(--line); }
.page-head__eyebrow { margin-bottom: 16px; }
.page-head__title { font-size: clamp(40px,5.5vw,76px); max-width: 18ch; margin-bottom: 18px; }
.page-head__lede { font-family: var(--body); font-size: clamp(17px,1.5vw,20px); color: var(--muted); max-width: 56ch; }
.prose { max-width: 68ch; font-size: 16.5px; line-height: 1.7; color: var(--ink-soft); }
.prose h2 { margin-top: 52px; margin-bottom: 14px; color: var(--text); font-size: 26px; font-family: var(--display); }
.prose h3 { margin-top: 32px; margin-bottom: 10px; color: var(--gold); font-family: var(--mono); font-weight: 500; font-size: 15px; letter-spacing: 0.04em; }
.prose p { margin-bottom: 1.1em; }
.prose ul { padding-left: 1.2em; margin-bottom: 1.1em; }
.prose li { margin-bottom: 0.5em; }
.prose li::marker { color: var(--gold); }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--gold); border-bottom: 1px solid var(--gold-dim); }
.prose a:hover { color: var(--plum); border-color: var(--plum); }

.muted { color: var(--muted); }

/* ============================================================
   PAPYRUS MURAL BACKDROP (content sections — never the hero)
   Faint, gold-tinted hieroglyph wall so cards/content pop.
   ============================================================ */
.section--papyrus { position: relative; }
.papyrus-layer, .glyph-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-repeat: no-repeat; background-position: center; background-size: cover;
}
.papyrus-layer {
  background-image: url("assets/papyrus-gold.png");
  background-size: contain; background-position: right center; background-repeat: no-repeat;
  opacity: 0.17;
  -webkit-mask-image:
    linear-gradient(to right, transparent 0%, #000 28%, #000 88%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, #000 14%, #000 86%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent 0%, #000 28%, #000 88%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, #000 14%, #000 86%, transparent 100%);
  mask-composite: intersect;
}
.glyph-bg { opacity: 0.16; background-size: auto; background-repeat: repeat; }            /* image set by glyph-field.js; tiled at native size */
.papyrus-layer.pap-l, .glyph-bg.pap-l { background-position: left center; }
.papyrus-layer.pap-r, .glyph-bg.pap-r { background-position: right center; }
/* warm vignette + depth wash above the texture, below content */
.papyrus-layer::after, .glyph-bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(110% 80% at 50% -10%, rgba(201,168,76,.06), transparent 60%),
    linear-gradient(to bottom, rgba(26,26,46,.45), transparent 16%, transparent 84%, rgba(26,26,46,.55));
}
.section--papyrus > .wrap { position: relative; z-index: 1; }
html.reduce-motion .papyrus-layer { opacity: 0.11; }
