/* ————————————————————————————————————————————————
   Agora Cosmica — The Living Library
   base.css: tokens, reset, chrome, gate, cursor, film
   ———————————————————————————————————————————————— */

:root {
  --ink: var(--text-primary, #D2D2D2);
  --ink2: var(--text-secondary, #CACACA);
  --ink3: var(--text-tertiary, #9E9E9E);
  --gold: var(--gold-primary, #E6BC5C);
  --goldui: var(--gold-ui, #D4A539);
  --goldhov: var(--gold-hover, #F6D55C);
  --golddeep: var(--gold-deep, #B38B30);
  --navy0: #080B20;
  --navy1: #0C1133;
  --navy2: #151C47;
  --navy3: #1C245C;
  --navy4: #2A3374;
  --cool: #9FB4E8;
  --serif: 'Libre Caslon Text', Georgia, serif;
  --sans: 'Space Grotesk', system-ui, sans-serif;
  --expo: cubic-bezier(0.16, 1, 0.3, 1);
  --soft: cubic-bezier(0.65, 0, 0.35, 1);
  --measure: 65ch;
}

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

html {
  height: 100%;
  scrollbar-color: rgba(212, 165, 57, 0.4) #080B20;
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(120% 90% at 50% 0%, #101642 0%, #0C1133 42%, #080B20 100%),
    #080B20;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-loading, body.is-gated { overflow: hidden; }

::selection { background: rgba(230, 188, 92, 0.28); color: #F0EAD8; }

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--gold); text-decoration: none; }

h1, h2, h3, h4, p, ul, figure { margin: 0; padding: 0; }
ul { list-style: none; }

:focus-visible {
  outline: 1px solid var(--goldhov);
  outline-offset: 4px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* On fine pointers with motion allowed, the gold cursor takes over */
@media (pointer: fine) {
  body.has-cursor, body.has-cursor a, body.has-cursor button,
  body.has-cursor input[type='range'] { cursor: none; }
}

.skip {
  position: fixed;
  top: 1rem; left: 50%;
  translate: -50% 0;
  z-index: 200;
  padding: 0.7rem 1.4rem;
  background: #101642;
  border: 1px solid rgba(230, 188, 92, 0.5);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
}
.skip:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ——— shared type voices ——— */

.ovl {
  font: 300 0.72rem/1.4 var(--sans);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--goldui);
}

.voice {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--ink);
}

/* ——— buttons ——— */

.btn {
  display: inline-block;
  font: 500 var(--step-0)/1 var(--sans);
  letter-spacing: 0.04em;
  padding: 1.05rem 1.9rem;
  border-radius: 999px;
  transition: background-color 0.35s var(--soft), border-color 0.35s var(--soft),
              color 0.35s var(--soft), box-shadow 0.5s var(--soft), transform 0.6s var(--expo);
}
.btn--solid {
  background: linear-gradient(180deg, #EDC76B 0%, var(--goldui) 100%);
  color: #10143A;
  box-shadow: 0 0 0 rgba(230, 188, 92, 0);
}
.btn--solid:hover {
  background: linear-gradient(180deg, var(--goldhov) 0%, var(--gold) 100%);
  box-shadow: 0 8px 40px rgba(230, 188, 92, 0.25);
  transform: translateY(-2px);
}
.btn--ghost {
  border: 1px solid rgba(230, 188, 92, 0.36);
  color: var(--ink);
}
.btn--ghost:hover {
  border-color: var(--goldhov);
  color: var(--goldhov);
  transform: translateY(-2px);
}
.btn--big { padding: 1.2rem 2.6rem; font-size: var(--step-1); }

/* ——— designed loading moment ——— */

.boot {
  position: fixed; inset: 0;
  z-index: 120;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.4rem;
  background:
    radial-gradient(60% 45% at 50% 52%, rgba(28, 36, 92, 0.55) 0%, rgba(8, 11, 32, 0) 70%),
    #080B20;
  transition: opacity 0.9s var(--soft), visibility 0.9s;
}
.boot__ember {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px 4px rgba(230, 188, 92, 0.55);
  animation: emberpulse 1.6s var(--soft) infinite alternate;
}
.boot__word {
  font: 300 0.72rem/1 var(--sans);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ink3);
  padding-left: 0.5em;
}
@keyframes emberpulse {
  from { transform: scale(0.7); opacity: 0.5; }
  to   { transform: scale(1.15); opacity: 1; }
}
body:not(.is-loading) .boot { opacity: 0; visibility: hidden; }

/* ——— entry gate ——— */

.gate {
  position: fixed; inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  background:
    radial-gradient(90% 62% at 50% 46%, rgba(21, 28, 71, 0.9) 0%, rgba(12, 17, 51, 0.55) 46%, rgba(8, 11, 32, 0.97) 100%),
    #0A0E2C;
  transition: opacity 1.1s var(--soft), visibility 1.1s;
}
body.is-entered .gate { opacity: 0; visibility: hidden; pointer-events: none; }

.gate__inner {
  display: grid;
  justify-items: center;
  max-width: 46rem;
}

.gate__logo { width: clamp(84px, 12vh, 120px); height: auto; margin-bottom: 2.2rem; overflow: visible; }
.gate__logo .lg-halo { fill: none; stroke: var(--gold); stroke-width: 7; opacity: 0.15; filter: blur(3px); }
.gate__logo .lg-ring { fill: none; stroke: var(--gold); stroke-width: 3.5; stroke-linecap: round; }
.gate__logo .lg-glow { fill: var(--gold); opacity: 0.12; filter: blur(6px); }

.gate__title {
  font: 400 clamp(2.2rem, 6.5vw, 3.6rem)/1.1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #E4E1D4;
  margin-bottom: 1.1rem;
}
.gate__tagline {
  font: 300 var(--step-0)/1.5 var(--sans);
  letter-spacing: 0.24em;
  color: var(--gold);
  margin-bottom: 2.6rem;
}
.gate__line {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--step-2);
  color: var(--ink2);
  margin-bottom: 2.8rem;
}
.gate__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 1.2rem;
  margin-bottom: 1.6rem;
}
.gate__hint {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--ink3);
  margin-bottom: 3.2rem;
}
.gate__trust {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: rgba(158, 158, 158, 0.9);
}
.gate__noscript {
  margin-top: 1.4rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--goldhov);
}

/* staged gate reveal */
.gate [data-reveal] { opacity: 0; transform: translateY(14px); }
body.gate-ready .gate [data-reveal] {
  opacity: 1;
  transform: none;
  transition: opacity 1s var(--soft), transform 1.2s var(--expo);
  transition-delay: var(--rd, 0s);
}
.gate__logo .lg-ring { stroke-dasharray: 100; stroke-dashoffset: 100; }
.gate__logo .lg-core, .gate__logo .lg-glow { transform-origin: 100px 100px; transform: scale(0); }
body.gate-ready .gate__logo .lg-ring {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.6s var(--expo) 0.15s;
}
body.gate-ready .gate__logo .lg-core,
body.gate-ready .gate__logo .lg-glow {
  transform: scale(1);
  transition: transform 1.1s var(--expo) 0.7s;
}

/* ——— chrome ——— */

.chrome { position: fixed; z-index: 70; }
.chrome--top {
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.3rem clamp(1.2rem, 3vw, 2.4rem);
  pointer-events: none;
}
.chrome--top > * { pointer-events: auto; }
.chrome--bottom { right: clamp(1rem, 2.6vw, 2rem); bottom: clamp(1rem, 2.6vw, 1.6rem); left: clamp(1rem, 2.6vw, 2rem); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.chrome--bottom > * { pointer-events: auto; }

.chrome--top, .chrome--bottom { opacity: 0; visibility: hidden; transition: opacity 1s var(--soft) 0.4s, visibility 1s; }
body.is-entered .chrome--top, body.is-entered .chrome--bottom { opacity: 1; visibility: visible; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink2);
  font: 400 0.8rem/1 var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.85;
  transition: opacity 0.3s;
}
.wordmark:hover { opacity: 1; }
.wordmark svg { width: 15px; height: 15px; opacity: 0.9; }

.chrome__cta {
  font: 400 0.84rem/1 var(--sans);
  letter-spacing: 0.14em;
  color: var(--goldui);
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(212, 165, 57, 0.35);
  transition: color 0.3s, border-color 0.3s;
}
.chrome__cta:hover { color: var(--goldhov); border-color: var(--goldhov); }

.scrollhint {
  font: 300 0.74rem/1 var(--sans);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink3);
  opacity: 0;
  transition: opacity 1s var(--soft);
  animation: hintdrift 2.6s var(--soft) infinite alternate;
}
body.show-hint .scrollhint { opacity: 0.9; }
@keyframes hintdrift {
  from { transform: translateY(0); }
  to   { transform: translateY(6px); }
}

.mutebtn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
  height: 42px;
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid rgba(230, 188, 92, 0.3);
  background: rgba(8, 11, 32, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.3s;
}
.mutebtn:hover { border-color: var(--goldhov); }
.mutebtn__bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 14px; }
.mutebtn__bars i {
  width: 2px; height: 4px;
  background: var(--goldui);
  border-radius: 1px;
  transition: height 0.4s var(--soft), background-color 0.4s;
}
.mutebtn[aria-pressed='true'] .mutebtn__bars i { background: var(--gold); }
.mutebtn[aria-pressed='true'] .mutebtn__bars i:nth-child(1) { animation: eq 1.1s ease-in-out infinite alternate; }
.mutebtn[aria-pressed='true'] .mutebtn__bars i:nth-child(2) { animation: eq 0.9s ease-in-out 0.18s infinite alternate; }
.mutebtn[aria-pressed='true'] .mutebtn__bars i:nth-child(3) { animation: eq 1.3s ease-in-out 0.32s infinite alternate; }
@keyframes eq { from { height: 4px; } to { height: 14px; } }
.mutebtn__label {
  font: 400 0.72rem/1 var(--sans);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink3);
}

/* ——— progress rail ——— */

.rail {
  position: fixed;
  right: clamp(0.9rem, 2vw, 1.6rem);
  top: 50%;
  translate: 0 -50%;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 14px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s var(--soft) 0.6s, visibility 1s;
}
body.is-entered .rail { opacity: 1; visibility: visible; }
@media (max-width: 900px) { .rail { display: none; } }

.rail__tick {
  position: relative;
  width: 22px; height: 10px;
  display: grid;
  place-items: center;
}
.rail__tick::before {
  content: '';
  width: 5px; height: 5px;
  rotate: 45deg;
  background: rgba(202, 202, 202, 0.28);
  transition: background-color 0.4s, box-shadow 0.4s, scale 0.4s var(--expo);
}
.rail__tick:hover::before { background: var(--ink2); }
.rail__tick[aria-current='true']::before {
  background: var(--gold);
  box-shadow: 0 0 10px rgba(230, 188, 92, 0.8);
  scale: 1.35;
}
.rail__tip {
  position: absolute;
  right: 30px; top: 50%;
  translate: 6px -50%;
  white-space: nowrap;
  font: 400 0.68rem/1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink2);
  background: rgba(8, 11, 32, 0.85);
  border: 1px solid rgba(230, 188, 92, 0.22);
  padding: 0.45rem 0.7rem;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, translate 0.4s var(--expo);
}
.rail__tick:hover .rail__tip, .rail__tick:focus-visible .rail__tip { opacity: 1; translate: 0 -50%; }

/* ——— film: grain, vignette, fog ——— */

.grain, .vignette, .fogveil, .endveil, .stage__sky { position: absolute; inset: 0; pointer-events: none; }

.grain {
  z-index: 9;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='280'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette {
  z-index: 8;
  background:
    radial-gradient(115% 90% at 50% 46%, rgba(8, 11, 32, 0) 50%, rgba(8, 11, 32, 0.85) 100%),
    linear-gradient(180deg, rgba(8, 11, 32, 0.55) 0%, rgba(8, 11, 32, 0) 14%, rgba(8, 11, 32, 0) 82%, rgba(8, 11, 32, 0.65) 100%);
}
.fogveil {
  z-index: 6;
  background:
    radial-gradient(20% 17% at 50% 51%, rgba(230, 188, 92, 0.075) 0%, rgba(230, 188, 92, 0) 100%),
    radial-gradient(46% 38% at 50% 47%, rgba(16, 22, 66, 0.55) 0%, rgba(12, 17, 51, 0.2) 55%, rgba(12, 17, 51, 0) 100%);
}
.motes { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.endveil {
  z-index: 10;
  background: radial-gradient(80% 70% at 50% 50%, #0A0E2C 0%, #080B20 100%);
  opacity: 0;
}

/* ——— custom cursor ——— */

.cursor { position: fixed; inset: 0; z-index: 300; pointer-events: none; display: none; }
body.has-cursor .cursor { display: block; }
.cursor__dot, .cursor__ring {
  position: absolute;
  top: 0; left: 0;
  border-radius: 50%;
  translate: -50% -50%;
  will-change: transform;
}
.cursor__dot {
  width: 5px; height: 5px;
  background: var(--goldhov);
  box-shadow: 0 0 8px rgba(246, 213, 92, 0.6);
}
.cursor__ring {
  width: 34px; height: 34px;
  border: 1px solid rgba(230, 188, 92, 0.55);
  transition: width 0.35s var(--expo), height 0.35s var(--expo), border-color 0.3s, opacity 0.3s;
}
.cursor.is-active .cursor__ring { width: 52px; height: 52px; border-color: rgba(246, 213, 92, 0.85); }
.cursor.is-hidden { opacity: 0; }

/* ——— reduced motion: calm everything ——— */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.24s !important;
  }
  .scrollhint { animation: none; }
}
