:root {
  --bg-deep: #050a0e;
  --bg: #0a1418;
  --bg-lift: #122028;
  --ink: #e8f0ec;
  --muted: #9bb0a6;
  --soft: #6d857a;
  --accent: #3d8f72;
  --accent-soft: rgba(61, 143, 114, 0.22);
  --border: rgba(232, 240, 236, 0.14);
  --sans: "Bricolage Grotesque", Georgia, serif;
  --serif: "Literata", "Times New Roman", serif;
  --water: #4aa3c8;
  --energy: #d4a14a;
  --forest: #4f9a6a;
  --food: #c49a55;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background: #02050a;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Gate */
body.site-locked > :not(.site-gate):not(script) {
  visibility: hidden;
  pointer-events: none;
}

.site-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 65% 50% at 50% 15%, var(--bg-lift) 0%, transparent 58%),
    linear-gradient(165deg, var(--bg-deep) 0%, var(--bg) 55%, #04080c 100%);
}

body.site-locked .site-gate {
  display: grid;
}

body.site-unlocking .site-gate {
  animation: gate-out 0.55s ease forwards;
  pointer-events: none;
}

.site-gate-card {
  width: min(22rem, 100%);
  text-align: center;
}

.site-gate-eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--soft);
}

.site-gate-title {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(1.75rem, 5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.site-gate-copy {
  margin: 0.75rem 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 1rem;
}

.site-gate-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.site-gate-form input,
.site-gate-form button {
  width: 100%;
  min-height: 2.85rem;
  padding: 0.7rem 1.1rem;
  border-radius: 0.35rem;
  font: inherit;
}

.site-gate-form input {
  border: 1px solid var(--border);
  background: rgba(5, 10, 14, 0.55);
  color: var(--ink);
  outline: none;
}

.site-gate-form input:focus {
  border-color: rgba(61, 143, 114, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.site-gate-form button {
  border: 0;
  background: var(--accent);
  color: #07140f;
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.site-gate-form button:hover {
  background: #4aa584;
}

.site-gate-error {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: #d97a6c;
}

/* 3D canvas */
.earth-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(ellipse 55% 45% at 50% 48%, #0d1a24 0%, transparent 60%),
    #02050a;
}

.earth-canvas:active {
  cursor: grabbing;
}

/* Stage overlay */
.stage {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  pointer-events: none;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.brand-lockup {
  text-align: center;
  justify-self: center;
  opacity: 0;
  transform: translateY(0.75rem);
  pointer-events: none;
}

body.is-ready .brand-lockup {
  animation: rise-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards;
}

.brand-kicker {
  margin: 0 0 0.35rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--soft);
}

.brand {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(2.4rem, 8vw, 4.25rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.95;
  background: linear-gradient(105deg, #f2f7f4 15%, #9fd4bc 50%, #e8f0ec 85%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

body.is-ready .brand {
  animation: sheen 8s ease-in-out 1.2s infinite;
}

.marker-layer {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.earth-marker {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  border: 1px solid color-mix(in srgb, var(--marker) 45%, transparent);
  border-radius: 999px;
  background: rgba(4, 10, 14, 0.72);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 0.25s ease, transform 0.2s ease, background 0.2s ease;
  will-change: left, top, opacity;
}

.earth-marker.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.earth-marker:hover,
.earth-marker.is-active {
  background: rgba(8, 18, 24, 0.9);
  transform: translate(-50%, -50%) scale(1.06);
}

.earth-marker-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--marker);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--marker) 28%, transparent);
}

.earth-marker-label {
  white-space: nowrap;
}

.stage-hint {
  margin: 0;
  justify-self: center;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--soft);
  opacity: 0;
  min-height: 1.25rem;
  pointer-events: none;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}

body.is-near .stage-hint {
  animation: fade-in 0.6s ease 0.2s forwards;
}

body.has-category .stage-hint {
  opacity: 0 !important;
}

/* Category panel */
.category-panel {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, transparent 0%, rgba(5, 10, 14, 0.55) 18%, rgba(8, 16, 20, 0.94) 100%);
  transform: translateY(110%);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}

.category-panel.is-open {
  transform: translateY(0);
}

.category-close {
  display: inline-flex;
  align-items: center;
  margin: 0 0 1rem;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.category-close:hover {
  color: var(--ink);
}

.category-eyebrow {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}

.category-title {
  margin: 0.35rem 0 0;
  font-family: var(--sans);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.category-panel[data-category="water"] .category-title { color: var(--water); }
.category-panel[data-category="energy"] .category-title { color: var(--energy); }
.category-panel[data-category="forest"] .category-title { color: var(--forest); }
.category-panel[data-category="food"] .category-title { color: var(--food); }

.category-copy {
  margin: 0.85rem 0 0;
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 1.05rem;
}

.category-note {
  margin: 1.25rem 0 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--soft);
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

@keyframes gate-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes sheen {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@media (max-width: 640px) {
  .brand {
    font-size: clamp(2rem, 11vw, 2.75rem);
  }

  .earth-marker-label {
    font-size: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.is-ready .brand,
  body.is-ready .brand-lockup,
  body.is-near .stage-hint {
    animation: none;
  }

  body.is-ready .brand-lockup,
  body.is-near .stage-hint {
    opacity: 1;
    transform: none;
  }

  .category-panel {
    transition: none;
  }
}
