/* ===============================
   THRESHOLD v1 — Architectural
   Warm charcoal · Amber seam
   Cormorant Garamond · SC
   =============================== */

:root {
  /* Palette */
  --bg:        #0d0b09;
  --bg1:       #131009;
  --bg2:       #1a1610;
  --char:      #ede6d6;
  --char-dim:  rgba(237,230,214,0.55);
  --char-ghost:rgba(237,230,214,0.18);
  --amber:     rgba(201,158,79,0.85);
  --amber-dim: rgba(201,158,79,0.32);
  --amber-ghost:rgba(201,158,79,0.09);
  --border:    rgba(237,230,214,0.10);

  /* Question size levels — default shifted up */
  --qSize: clamp(2.2rem, 5.8vw, 3.2rem);
  --qLine: 1.55;
}

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

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: 'Cormorant Garamond', 'Georgia', serif;
  color: var(--char);
  background: var(--bg);
  height: 100svh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}

/* Subtle grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%; height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.78' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.042'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 100;
  animation: grainDrift 8s steps(2) infinite;
}
@keyframes grainDrift {
  0%,100% { transform: translate(0,0); }
  25%  { transform: translate(-1%,-1%); }
  50%  { transform: translate(1%,1%); }
  75%  { transform: translate(-1%,1%); }
}

/* Ambient background glow */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(201,158,79,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(237,230,214,0.025) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: ambientPulse 12s ease-in-out infinite;
}
@keyframes ambientPulse {
  0%,100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ══ LANDING ══ */
#landing {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  padding-top: calc(32px + env(safe-area-inset-top));
  z-index: 50;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(201,158,79,0.04) 0%, transparent 70%),
    var(--bg);
}

/* THRESHOLD / UMBRAL wordmark */
.landing-wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  user-select: none;
}

.landing-title-en {
  font-family: 'Cormorant SC', serif;
  font-size: clamp(2rem, 8vw, 3.8rem);
  font-weight: 300;
  letter-spacing: 0.30em;
  color: var(--char);
  opacity: 0.92;
  text-shadow: 0 0 60px rgba(237,230,214,0.06);
  line-height: 1;
}

.landing-seam-node {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow:
    0 0 10px rgba(201,158,79,0.7),
    0 0 24px rgba(201,158,79,0.3);
  animation: nodeGlow 4s ease-in-out infinite;
}

.landing-title-es {
  font-family: 'Cormorant SC', serif;
  font-size: clamp(1.2rem, 4.5vw, 2.1rem);
  font-weight: 300;
  letter-spacing: 0.42em;
  color: var(--char-dim);
  opacity: 0.55;
  line-height: 1;
}

/* Choice buttons */
.landing-choices {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(440px, 92vw);
  gap: 0;
}

.landing-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--char);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  transition:
    background 280ms ease,
    border-color 280ms ease,
    transform 200ms ease;
  -webkit-tap-highlight-color: transparent;
}

.landing-btn:hover,
.landing-btn:focus-visible {
  background: rgba(201,158,79,0.05);
  border-color: var(--amber-dim);
  outline: none;
}

.landing-btn.detected {
  border-color: rgba(201,158,79,0.38);
  background: rgba(201,158,79,0.05);
  box-shadow: 0 0 28px rgba(201,158,79,0.06);
}

.landing-btn-lang {
  font-family: 'Cormorant SC', serif;
  font-size: clamp(1.1rem, 3.5vw, 1.4rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--char);
  line-height: 1;
}

.landing-btn.detected .landing-btn-lang {
  color: var(--amber);
}

.landing-btn-line {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(0.88rem, 2.4vw, 1.05rem);
  font-style: italic;
  font-weight: 300;
  line-height: 1.6;
  color: var(--char-dim);
  opacity: 0.7;
}

/* Horizontal divider between buttons */
.landing-divider {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 24px;
  gap: 0;
  pointer-events: none;
}

.landing-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--amber-dim), transparent);
  opacity: 0.5;
}

.landing-divider-node {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--amber-dim);
  margin: 0 8px;
  animation: nodeGlow 4s ease-in-out infinite;
}

@keyframes nodeGlow {
  0%,100% { opacity: 0.5; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.2); }
}

.landing-hint {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  text-align: center;
  font-family: 'Cormorant SC', serif;
  font-size: clamp(0.65rem, 1.6vw, 0.78rem);
  font-weight: 300;
  letter-spacing: 0.22em;
  color: var(--char-ghost);
  pointer-events: none;
  transition: opacity 600ms ease;
}

/* Entry animation */
#landing.entering .landing-btn {
  transition: opacity 700ms ease, transform 700ms ease;
}
#landing.entering.pick-en #landing-es,
#landing.entering.pick-es #landing-en {
  opacity: 0.1;
}
#landing.entering .landing-hint { opacity: 0; }

#landing.fade-out {
  animation: landingFade 800ms forwards;
}
@keyframes landingFade {
  to { opacity: 0; visibility: hidden; }
}

/* ══ INTRO ══ */
#intro {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  z-index: 40;
}

.intro-seam {
  position: fixed;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom,
    transparent 0%,
    var(--amber-dim) 20%,
    var(--amber-dim) 80%,
    transparent 100%);
  opacity: 0;
  transition: opacity 800ms ease;
  z-index: -1;
}

#intro-title {
  font-family: 'Cormorant SC', serif;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 300;
  letter-spacing: 0.32em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 900ms ease, transform 900ms ease;
}
#intro-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1rem, 2.8vw, 1.3rem);
  font-style: italic;
  font-weight: 300;
  color: var(--char-dim);
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 900ms ease, transform 900ms ease;
}

#intro.stage-title #intro-title { opacity: 0.92; transform: translateY(0); }
#intro.stage-title .intro-seam { opacity: 1; }
#intro.stage-sub #intro-subtitle { opacity: 0.72; transform: translateY(0); }
#intro.fade-out { animation: introFade 1000ms forwards; }
@keyframes introFade { to { opacity: 0; visibility: hidden; } }

/* ══ UI ══ */
#ui {
  position: relative;
  width: 100%;
  max-width: 1000px;
  height: 100%;
  padding:
    calc(20px + env(safe-area-inset-top))
    20px
    calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  z-index: 10;
}

/* Persistent ghost seam */
.ui-seam {
  position: fixed;
  left: 50%;
  top: 0; bottom: 0;
  transform: translateX(-50%);
  width: 1px;
  pointer-events: none;
  z-index: 1;
}
.ui-seam-line {
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(201,158,79,0.08) 20%,
    rgba(201,158,79,0.14) 50%,
    rgba(201,158,79,0.08) 80%,
    transparent 100%);
  animation: seamBreath 6s ease-in-out infinite;
}
.ui-seam-glow {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 80px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 100% 60% at 50% 50%,
    rgba(201,158,79,0.04) 0%, transparent 100%);
}

/* Controls */
#top-right {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
}

.ctrl {
  font-family: 'Cormorant SC', serif;
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  color: var(--char-dim);
  border: 1px solid var(--border);
  background: rgba(13,11,9,0.6);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 200ms ease, border-color 200ms ease, color 200ms ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  min-height: 36px;
}
.ctrl:hover {
  opacity: 1;
  border-color: var(--amber-dim);
  color: var(--char);
}

.lang-ctrl {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

#lang-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#size-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: rgba(13,11,9,0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
#size-pop.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.size-btn {
  font-family: 'Cormorant SC', serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--char-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  transition: color 150ms ease;
}
.size-btn:hover { color: var(--char); }

/* Categories */
#cats {
  margin-top: calc(52px + env(safe-area-inset-top));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 0 8px;
  z-index: 5;
}

.cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--char);
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity 250ms ease,
    border-color 250ms ease,
    background 250ms ease,
    transform 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.cat:hover {
  opacity: 0.8;
  border-color: var(--amber-dim);
}
.cat.active {
  opacity: 1;
  border-color: var(--amber-dim);
  background: rgba(201,158,79,0.06);
}
.cat:hover, .cat.active {
  transform: translateY(-1px);
}

.cat-ico {
  font-size: 1rem;
  line-height: 1;
  color: var(--amber);
  opacity: 0.8;
}
.cat.active .cat-ico { opacity: 1; }

.cat-name {
  font-family: 'Cormorant SC', serif;
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.18em;
  color: var(--char-dim);
  white-space: nowrap;
  text-transform: uppercase;
}
.cat.active .cat-name { color: var(--char); }

/* Question */
#question-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 0 clamp(20px, 8vw, 80px);
  position: relative;
  z-index: 5;
}

#question {
  max-width: 44rem;
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--qSize);
  font-weight: 500;
  font-style: italic;
  line-height: var(--qLine);
  letter-spacing: 0.01em;
  color: var(--char);
  text-align: center;
  text-wrap: pretty;
  text-shadow: 0 0 40px rgba(237,230,214,0.12);

  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1100ms ease, transform 1100ms ease;
  will-change: opacity, transform;
}

#question.show {
  opacity: 1;
  transform: translateY(0);
}
#question.hide {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 700ms ease, transform 700ms ease;
}

/* Non-italic mode for dyslexia accessibility */
body.no-italic #question {
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.015em;
}

/* ══ CROSS BUTTON — the seam you touch ══ */
.cross-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  margin-bottom: 4px;
  -webkit-tap-highlight-color: transparent;
  z-index: 5;
}

.cross-visual {
  position: relative;
  width: 1px;
  height: 72px;
  overflow: visible;
}

.cross-line {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom,
    transparent,
    var(--amber) 30%,
    var(--amber) 70%,
    transparent);
  animation: crossBreath 4s ease-in-out infinite;
  transition: filter 300ms ease;
}

.cross-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 60px; height: 100%;
  background: radial-gradient(ellipse 100% 60% at 50% 50%,
    rgba(201,158,79,0.14) 0%, transparent 100%);
  animation: crossBreath 4s ease-in-out infinite;
}

.cross-node {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow:
    0 0 10px rgba(201,158,79,0.7),
    0 0 22px rgba(201,158,79,0.3);
  animation: nodeGlow 4s ease-in-out infinite;
}

@keyframes crossBreath {
  0%,100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Ripples on tap */
.cross-ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  transform: translate(-50%,-50%) scale(1);
  border: 1px solid rgba(201,158,79,0.5);
  opacity: 0;
}

.cross-visual.rippling .r1 { animation: crossRipple 1000ms ease-out 0ms; }
.cross-visual.rippling .r2 { animation: crossRipple 1200ms ease-out 100ms; }
.cross-visual.rippling .r3 { animation: crossRipple 1400ms ease-out 200ms; }

@keyframes crossRipple {
  0% { opacity: 0.7; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(18); }
}

.cross-btn:hover .cross-line {
  filter: brightness(1.4);
}
.cross-btn:hover .cross-node {
  box-shadow:
    0 0 16px rgba(201,158,79,0.9),
    0 0 32px rgba(201,158,79,0.4);
}

.cross-hint {
  font-family: 'Cormorant SC', serif;
  font-size: clamp(0.72rem, 1.8vw, 0.85rem);
  font-weight: 300;
  letter-spacing: 0.24em;
  color: var(--char-dim);
  text-transform: lowercase;
  opacity: 0.75;
  transition: color 300ms ease, opacity 300ms ease;
}
.cross-btn:hover .cross-hint {
  color: var(--char);
  opacity: 1;
}

/* ══ INFO MODAL ══ */
.hidden { display: none !important; }

#info-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,4,3,0.72);
  padding: 20px;
  z-index: 80;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#info-card {
  width: min(640px, 94vw);
  border: 1px solid var(--border);
  border-radius: 2px;
  background: rgba(13,11,9,0.92);
  padding: 32px 28px 24px;
  position: relative;
}

#info-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: var(--char-dim);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 200ms ease;
}
#info-close:hover { opacity: 1; }

.info-title {
  font-family: 'Cormorant SC', serif;
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: 0.28em;
  color: var(--char-dim);
  margin-bottom: 20px;
}

.info-block { margin-top: 16px; }

.info-label {
  font-family: 'Cormorant SC', serif;
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  color: var(--amber);
  opacity: 0.8;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.info-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 300;
  line-height: 1.7;
  color: var(--char-dim);
}

/* ══ CATEGORY ATMOSPHERE ══ */
body.field-shadow {
  --bg: #080608;
  --bg1: #0e0b0e;
}
body.field-body {
  --bg: #0c0b08;
}
body.field-silence {
  --bg: #09090b;
}
body.field-time {
  --bg: #080a0d;
}

/* ══ MOTION SAFETY ══ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ══ MOBILE ══ */
@media (max-width: 480px) {
  #cats { gap: 6px; }
  .cat { padding: 8px 12px; }
  .cat-name { font-size: 0.72rem; }
  .cross-visual { height: 56px; }
}
