/* ============================================================
   COMTRAZ · v4 · 4 worlds · scroll-snap · dramatic reveals
   ============================================================ */

:root {
  --bg:        #050403;
  --bg-2:      #0A0907;
  --ink:       #EDE8DA;
  --ink-2:     #C8C2B4;
  --ink-3:     #827B6E;
  --ink-4:     #4A453E;
  --line:      rgba(237, 232, 218, 0.08);
  --line-2:    rgba(237, 232, 218, 0.04);
  --line-3:    rgba(237, 232, 218, 0.14);
  --accent:    #E0552A;
  --accent-2:  #FF6A2E;

  --serif: 'Instrument Serif', Georgia, serif;
  --sans:  'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --edge: clamp(1.5rem, 4vw, 3rem);
  --ease-out:   cubic-bezier(0.23, 1, 0.32, 1);
  --ease-expo:  cubic-bezier(0.19, 1, 0.22, 1);
  --ease-drama: cubic-bezier(0.32, 0.72, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  /* Scroll snap — proximity so the footer is reachable after world IV */
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img, svg, canvas { display: block; max-width: 100%; }
em, i { font-family: var(--serif); font-style: italic; font-weight: 400; }
::selection { background: var(--accent); color: #fff; }

/* ============================================================
   WebGL stage — fixed behind all worlds
   ============================================================ */
#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 1.5s var(--ease-out);
}
body.is-ready #stage { opacity: 1; }

/* ============================================================
   Boot sequence
   ============================================================ */
.boot {
  position: fixed; inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity 0.7s var(--ease-out), visibility 0s linear 0.7s;
}
.boot__code {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 1.2rem;
}
.boot__bar { width: 180px; height: 1px; background: var(--line); overflow: hidden; }
.boot__bar span {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width 0.2s linear;
}
body.is-ready .boot { opacity: 0; pointer-events: none; visibility: hidden; }

/* ============================================================
   Nav — floating
   ============================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 1.5rem var(--edge);
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.8s var(--ease-out) 0.8s, transform 0.8s var(--ease-out) 0.8s;
}
body.is-ready .nav { opacity: 1; transform: translateY(0); }
.nav__brand { pointer-events: auto; display: inline-flex; align-items: center; height: 22px; }
.nav__brand img { height: 100%; filter: invert(1) brightness(1.08); opacity: 0.92; }
.nav__links {
  pointer-events: auto;
  display: flex; gap: 1.75rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.nav__links a { transition: color 0.25s var(--ease-out); position: relative; }
.nav__links a:hover { color: var(--ink); }
.nav__links a:hover::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px;
  background: var(--accent);
}
@media (max-width: 720px) { .nav__links { gap: 1rem; font-size: 0.6rem; } }

/* ============================================================
   Side dot nav (world indicator)
   ============================================================ */
.dots {
  position: fixed;
  top: 50%;
  right: var(--edge);
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  opacity: 0;
  transition: opacity 0.8s var(--ease-out) 1.4s;
}
body.is-ready .dots { opacity: 1; }
.dots a {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  pointer-events: auto;
}
.dots a span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-4);
  transition: all 0.4s var(--ease-out);
}
.dots a.is-current span {
  background: var(--accent);
  width: 10px; height: 10px;
  box-shadow: 0 0 0 4px rgba(224, 85, 42, 0.15);
}
.dots a:hover span { background: var(--ink-2); }
@media (max-width: 720px) { .dots { display: none; } }

/* ============================================================
   WORLDS — each a fullscreen chapter
   ============================================================ */
.world {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--edge);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  align-items: center;
  pointer-events: none;
  overflow: hidden;
}
.world > * { pointer-events: auto; }

/* WORLD I · HERO — grid rows for bottom-aligned content */
.world--hero {
  grid-template-rows: 1fr auto auto auto;
  align-items: end;
  gap: 2rem;
}

/* WORLD II+III+IV — centered content */
.world--work,
.world--place,
.world--write {
  grid-template-rows: auto auto auto;
  justify-items: start;
  align-content: center;
  gap: clamp(1.5rem, 3vh, 3rem);
  padding-left: clamp(2rem, 8vw, 6rem);
  padding-right: clamp(2rem, 8vw, 6rem);
}

/* ============================================================
   Hero-specific elements
   ============================================================ */
.world__kicker {
  display: inline-flex; align-items: center;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line-3);
  border-radius: 999px;
  background: rgba(10, 9, 7, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  width: max-content;
}
.pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: #26D07C;
  box-shadow: 0 0 0 3px rgba(38, 208, 124, 0.2);
  animation: pulse 2s ease-in-out infinite;
  margin-right: 0.5rem;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(38, 208, 124, 0.2); }
  50%     { box-shadow: 0 0 0 7px rgba(38, 208, 124, 0); }
}

.world--hero .world__meta {
  display: flex; align-items: center; gap: 0.8rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.world--hero .world__meta .sep { color: var(--ink-4); }
.world--hero .world__meta a { color: var(--ink-2); transition: color 0.25s var(--ease-out); }
.world--hero .world__meta a:hover { color: var(--accent); }

.world__cue {
  position: absolute;
  right: var(--edge); bottom: var(--edge);
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.world__cue svg { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* ============================================================
   World display typography (shared)
   ============================================================ */
.world__display {
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: -0.05em;
  font-size: clamp(4rem, 17vw, 18rem);
  line-height: 0.85;
  color: var(--ink);
  display: flex; flex-direction: column;
}
.world__display .word { display: block; }
.world__display .em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.03em;
  padding-left: 0.15em;
}

.world__marker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.3rem 0.75rem;
  border: 1px solid rgba(224, 85, 42, 0.3);
  border-radius: 999px;
  background: rgba(224, 85, 42, 0.06);
}

.world__caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 56ch;
}
.world__caption strong {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* World IV email */
.world__mail {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(2rem, 7vw, 6rem);
  line-height: 1;
  color: var(--ink);
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--line);
  transition: color 0.3s var(--ease-out), border-color 0.3s;
}
.world__mail:hover { color: var(--accent); border-bottom-color: var(--accent); }
.world__mail svg { transition: transform 0.3s var(--ease-out); }
.world__mail:hover svg { transform: translate(4px, -4px); }

/* ============================================================
   DRAMATIC REVEAL (scroll-triggered per world)
   Each world's elements are hidden until the world is "active",
   then they scale/blur/rise in dramatically.
   ============================================================ */

/* Hero has its own boot-triggered reveal (data-fade-delay in JS) */
/* Hero elements visible by default when body.is-ready (boot complete) */
.world--hero .world__kicker,
.world--hero .world__display,
.world--hero .world__meta,
.world--hero .world__cue {
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  filter: blur(14px);
  transition:
    opacity 1.4s var(--ease-drama),
    transform 1.4s var(--ease-drama),
    filter 1.4s var(--ease-drama);
}
body.is-ready .world--hero.is-active .world__kicker { transition-delay: 900ms;  opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
body.is-ready .world--hero.is-active .world__display { transition-delay: 1100ms; opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
body.is-ready .world--hero.is-active .world__meta    { transition-delay: 1350ms; opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
body.is-ready .world--hero.is-active .world__cue     { transition-delay: 1600ms; opacity: 0.7; transform: translateY(0) scale(1); filter: blur(0); }

/* Other worlds: hidden until they scroll into view */
.world:not(.world--hero) .world__marker,
.world:not(.world--hero) .world__display,
.world:not(.world--hero) .world__caption,
.world:not(.world--hero) .world__mail {
  opacity: 0;
  transform: translateY(60px) scale(0.86);
  filter: blur(22px);
  transition:
    opacity 1.6s var(--ease-drama),
    transform 1.6s var(--ease-drama),
    filter 1.6s var(--ease-drama);
}
.world.is-active .world__marker   { transition-delay: 150ms;  opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
.world.is-active .world__display  { transition-delay: 380ms;  opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
.world.is-active .world__caption  { transition-delay: 780ms;  opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
.world.is-active .world__mail     { transition-delay: 380ms;  opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }

/* ============================================================
   Footer (compact, after world IV)
   ============================================================ */
.footer {
  position: relative;
  z-index: 10;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 1.25rem var(--edge);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  /* Footer is not snap-aligned — it trails after W4 */
}
.footer a { color: var(--ink-2); transition: color 0.2s var(--ease-out); }
.footer a:hover { color: var(--accent); }
.footer__sep { color: var(--ink-4); margin: 0 0.4rem; }
@media (max-width: 640px) {
  .footer { justify-content: center; text-align: center; }
}

/* ============================================================
   MODALS (Legal / Privacy)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out);
}
.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 2, 0.82);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  cursor: pointer;
}
.modal__panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%) scale(0.96);
  width: min(720px, 92vw);
  max-height: 86vh;
  background: var(--bg-2);
  border: 1px solid var(--line-3);
  border-radius: 18px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.45s var(--ease-drama);
}
.modal.is-open .modal__panel {
  transform: translate(-50%, -50%) scale(1);
}
.modal__head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 1.25rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 9, 7, 0.9);
  backdrop-filter: blur(6px);
  border-radius: 18px 18px 0 0;
}
.modal__head h2 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.modal__close {
  background: transparent;
  border: 1px solid var(--line-3);
  border-radius: 999px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: background 0.25s var(--ease-out), color 0.25s, border-color 0.25s, transform 0.2s var(--ease-out);
}
.modal__close:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.modal__close:active { transform: scale(0.94); }

.modal__body {
  padding: 1.75rem 1.75rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}
.modal__body h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 2rem 0 0.6rem;
}
.modal__body h3:first-child { margin-top: 0; }
.modal__body p {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ink-2);
  margin-bottom: 0.85rem;
}
.modal__body p strong {
  color: var(--ink);
  font-weight: 500;
}
.modal__body ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}
.modal__body ul li {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-2);
}
.modal__body ul li::before {
  content: "";
  position: absolute; left: 0; top: 0.65rem;
  width: 6px; height: 1px;
  background: var(--accent);
}
.modal__body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}
.modal__body a:hover { color: var(--accent-2); }

.modal__footer {
  margin-top: 2.5rem !important;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono) !important;
  font-size: 0.72rem !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4) !important;
}

body.modal-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-snap-type: none; }
  .world .world__marker,
  .world .world__display,
  .world .world__caption,
  .world .world__mail,
  .world .world__kicker,
  .world .world__meta,
  .world .world__cue { opacity: 1; transform: none; filter: none; }
  #stage { opacity: 0.4; }
}
