/* === Relics — shared styles === */

@font-face {
  font-family: 'Comfortaa';
  src: url('Comfortaa.ttf') format('truetype-variations');
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat';
  src: url('Montserrat.ttf') format('truetype-variations');
  font-weight: 300 800;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrainsMono';
  src: url('JetBrainsMono.ttf') format('truetype-variations');
  font-weight: 100 800;
  font-display: swap;
}

:root {
  /* Type */
  --font-display: 'Comfortaa', system-ui, sans-serif;
  --font-body: 'Montserrat', system-ui, sans-serif;

  /* Spacing scale */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 36px;

  /* Horizontal padding tokens (unified across reader pages) */
  --pad-x: 18px;          /* mobile (≤640px) */
  --pad-x-md: 24px;       /* tablet (641–960px) */
  --pad-x-lg: 28px;       /* desktop (>960px) */
  --pad-y-section: clamp(48px, 8vw, 96px);
  --gap-stack: clamp(14px, 3vw, 22px);
  --touch-min: 44px;
}

/* === Dark theme (default) === */
:root[data-theme="dark"] {
  /* Palette — warm dark with deep red accent */
  --bg: #0e0b0d;
  --bg-2: #151113;
  --bg-3: #1c1719;
  --surface: #221c1f;
  --surface-2: #2a2326;
  --line: #3a3034;
  --line-soft: #2a2326;

  --ink: #f1e7df;
  --ink-soft: #c8b8af;
  --ink-dim: #8a7a72;
  --ink-faint: #8b7f7a;

  --accent: #c1352b;
  --accent-2: #e25b4d;
  --accent-glow: rgba(193, 53, 43, 0.35);

  --gold: #c9a461;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .5), 0 24px 60px rgba(0, 0, 0, .55);
  --shadow-glow: 0 0 0 1px rgba(193, 53, 43, .25), 0 20px 60px rgba(193, 53, 43, .18);
}

/* === Light theme === */
:root[data-theme="light"] {
  /* Backgrounds — crema papyrus */
  --bg: #FDF6E3;
  --bg-2: #F5EED5;
  --bg-3: #EEE8D5;
  --surface: #FFFFFF;
  --surface-2: #F8F1DC;
  --line: #D9CFB3;
  --line-soft: #EEE8D5;

  /* Ink — warm browns */
  --ink: #433422;
  --ink-soft: #6B5942;
  --ink-dim: #9A8866;
  --ink-faint: #BFAE8C;

  /* Accents — siena tostada */
  --accent: #8B4513;
  --accent-2: #A85A22;
  --accent-glow: rgba(139, 69, 19, 0.20);

  --gold: #2E8B57;  /* verde esmeralda — reliquia */

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .10);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .10), 0 24px 60px rgba(0, 0, 0, .14);
  --shadow-glow: 0 0 0 1px rgba(139, 69, 19, .18), 0 20px 60px rgba(139, 69, 19, .10);
}

/* === Smooth theme transitions === */
:root {
  transition: background-color .25s ease, color .25s ease;
}

body,
.site-header,
.feature,
.step,
.choice,
.tag,
.relic-found,
.final-cta {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  min-height: 100vh;
  background-attachment: fixed;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

/* === Accessibility: Skip Link === */
.skip-link {
  position: absolute;
  top: -100px;
  left: 32px;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 0 0 12px 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  z-index: 2000;
  transition: top 0.2s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: var(--shadow-2);
}

.skip-link:focus {
  top: 0;
  outline: none;
}

/* Body radial glow — dark mode */
:root[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(193, 53, 43, .08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(201, 164, 97, .04), transparent 60%);
}

/* Body radial glow — light mode */
:root[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(168, 38, 30, .05), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(156, 122, 50, .03), transparent 60%);
}

/* Subtle film grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

:root[data-theme="dark"] body::before {
  opacity: .035;
}

:root[data-theme="light"] body::before {
  opacity: .025;
  mix-blend-mode: multiply;
}

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

:root[data-theme="dark"] .site-header {
  background: rgba(14, 11, 13, 0.72);
}

:root[data-theme="light"] .site-header {
  background: rgba(246, 241, 232, 0.78);
}

.site-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px var(--pad-x-lg);
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .08em;
  font-size: 22px;
  text-transform: uppercase;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border-radius: 10px;
  position: relative;
}

/* GL8: soft radial glow behind the brand-mark, breathing slowly */
.brand-mark::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  animation: brandGlow 5s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

.brand-mark svg {
  display: block;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

:root[data-theme="dark"] .brand-logo--light { display: none; }
:root[data-theme="light"] .brand-logo--dark { display: none; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 4px;
}

.brand-text small {
  font-size: 10px;
  letter-spacing: .3em;
  color: var(--ink-dim);
  font-weight: 500;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav a {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--ink-soft);
  transition: color .2s, background .2s;
}

.nav a:hover {
  color: var(--ink);
  background: var(--surface);
}

.nav a {
  position: relative;
}

.nav a.active {
  color: var(--ink);
}

/* SH7: shimmer sweep on the active nav underline every ~8s */
.nav a.active::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: navSweep 8s ease-in-out infinite;
  border-radius: 1px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  transition: background .2s, color .2s;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--ink);
}

/* === Main wrap === */
main {
  position: relative;
  z-index: 2;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--pad-x-lg);
}

.wrap-narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--pad-x-lg);
}

/* === Buttons === */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform .15s, background .2s, box-shadow .2s, color .2s;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 30px var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: var(--accent-2);
  /* GL1: breathing halo on hover */
  animation: pulseGlow 2s ease-in-out infinite;
}

/* SH1: diagonal shimmer sweep on hover */
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.22) 50%, transparent 70%);
  transform: translateX(-150%) skewX(-20deg);
  pointer-events: none;
}
.btn-primary:hover::before {
  animation: shimmerSweep45 .65s ease forwards;
}

.btn-ghost {
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
  background: var(--surface);
}

/* Press feedback — tactile "click" scale for all interactive elements */
.btn:active,
.choice:active,
.icon-btn:active,
.profile-menu-item:active,
.tag.has-link:active {
  transform: scale(0.97) !important;
  transition-duration: .08s !important;
}

/* === Tags & badges === */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

.tag.has-link {
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s, color .2s;
}

.tag.has-link:hover {
  transform: translateY(-1px);
}

:root[data-theme="dark"] .tag-accent {
  color: var(--accent-2);
  border-color: rgba(225, 91, 77, .3);
  background: rgba(225, 91, 77, .08);
}

:root[data-theme="dark"] .tag-accent.has-link:hover {
  background: rgba(225, 91, 77, .15);
  border-color: rgba(225, 91, 77, .5);
  color: #fff;
}

:root[data-theme="light"] .tag-accent {
  color: var(--accent);
  border-color: rgba(168, 38, 30, .28);
  background: rgba(168, 38, 30, .10);
}

:root[data-theme="light"] .tag-accent.has-link:hover {
  background: rgba(168, 38, 30, .18);
  border-color: rgba(168, 38, 30, .50);
  color: var(--accent);
}

.tag-gold {
  color: var(--gold);
}

:root[data-theme="dark"] .tag-gold {
  border-color: rgba(201, 164, 97, .3);
  background: rgba(201, 164, 97, .06);
}

:root[data-theme="light"] .tag-gold {
  border-color: rgba(156, 122, 50, .30);
  background: rgba(156, 122, 50, .08);
}

:root[data-theme="dark"] .tag-moss {
  color: #8db481;
  border-color: rgba(141, 180, 129, .32);
  background: rgba(141, 180, 129, .08);
}

:root[data-theme="light"] .tag-moss {
  color: #5e8a4f;
  border-color: rgba(94, 138, 79, .30);
  background: rgba(94, 138, 79, .10);
}

:root[data-theme="dark"] .tag-amber {
  color: #d39a52;
  border-color: rgba(211, 154, 82, .32);
  background: rgba(211, 154, 82, .08);
}

:root[data-theme="light"] .tag-amber {
  color: #a86b1f;
  border-color: rgba(168, 107, 31, .30);
  background: rgba(168, 107, 31, .08);
}

/* === Footer (Wild Ideas) === */
.wi-footer {
  border-top: 1px solid var(--line-soft);
  position: relative;
  z-index: 2;
}

:root[data-theme="dark"] .wi-footer {
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .3));
}

:root[data-theme="light"] .wi-footer {
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .04));
}

.wi-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 60px var(--pad-x-lg) 50px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 40px;
}

.wi-brand {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.wi-logo {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: .04em;
}

.wi-logo-mark {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: transparent;
  display: grid;
  place-items: center;
  position: relative;
}

.wi-logo-mark svg {
  position: relative;
  z-index: 1;
  display: block;
}

.wi-tagline {
  color: var(--ink-dim);
  font-size: 13px;
  max-width: 280px;
  line-height: 1.6;
}

.wi-footer {
  position: relative;
}

.wi-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 60px var(--pad-x-lg) 50px;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 40px;
}

.wi-col-end {
  margin: 18px 0;
  justify-self: end;
  min-width: 180px;
}

.wi-social {
  display: flex;
  gap: 8px;
}

@media (max-width: 640px) {
  .wi-copy-wrap {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

.wi-social a {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  transition: background .2s, color .2s, border-color .2s;
}

.wi-social a:hover {
  background: var(--surface-2);
  color: var(--accent-2);
  border-color: var(--line);
}

.wi-col h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 16px;
}

.wi-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wi-col a {
  color: var(--ink-soft);
  font-size: 14px;
  transition: color .2s;
}

.wi-col a:hover {
  color: var(--accent-2);
}

.wi-bottom {
  border-top: 1px solid var(--line-soft);
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px var(--pad-x-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: .08em;
}

.wi-bottom .tiny-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: .14em;
}

/* === Trapezoid frame === */
/* Using clip-path with smooth corners via a wrapper */
.trapezoid {
  position: relative;
  width: 100%;
  /* The path: top is wider, bottom is narrower; bottom corners rounded via path approximation */
  clip-path: polygon(0% 0%,
      100% 0%,
      100% calc(100% - 0px),
      92% 100%,
      8% 100%,
      0 calc(100% - 0px));
}

/* Better trapezoid using SVG mask — set via inline style on element */
.trapezoid-frame {
  --trap-inset: 12%;
  /* how much each bottom corner pulls in */
  --trap-radius: 28px;
  /* corner roundness */
  position: relative;
  overflow: hidden;
}

/* === Utility === */
.muted {
  color: var(--ink-dim);
}

.faint {
  color: var(--ink-faint);
}

.eyebrow {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.hr-soft {
  border: 0;
  height: 1px;
  background: var(--line-soft);
  margin: 32px 0;
}

/* Animations — disabled for users who prefer reduced motion */
@media (prefers-reduced-motion: no-preference) {
  @keyframes fadeUp {
    from {
      opacity: 0;
      transform: translateY(12px);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  /* SC1: fade-up now triggers on viewport entry (IntersectionObserver adds .in-view).
     opacity/transform are the initial hidden state; animation fires only when visible. */
  .fade-up {
    opacity: 0;
    transform: translateY(12px);
  }
  .fade-up.in-view {
    animation-name: fadeUp;
    animation-duration: .5s;
    animation-timing-function: ease;
    animation-fill-mode: both;
    /* animation-delay intentionally omitted so per-element stagger classes (e.g. .node-meta.fade-up, .what-grid .feature:nth-child) are respected */
  }

  @keyframes pulseGlow {

    0%,
    100% {
      box-shadow: 0 0 0 1px rgba(193, 53, 43, .25), 0 20px 60px rgba(193, 53, 43, .18);
    }

    50% {
      box-shadow: 0 0 0 1px rgba(193, 53, 43, .45), 0 26px 80px rgba(193, 53, 43, .32);
    }
  }

  /* === Motion utilities (shared across reader pages) === */

  /* Rotating spinner — mirrors Writer Studio "Generar" pattern */
  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  .spin {
    animation: spin 1s linear infinite;
    will-change: transform;
    display: inline-block;
  }

  /* Pop-in: scale + rotate entrance with slight overshoot (used on relic star, status badges) */
  @keyframes popIn {
    from {
      opacity: 0;
      transform: scale(.4) rotate(-30deg);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* Contact form success icon entrance */
  .contact-sent-icon--pop {
    animation: popIn .4s cubic-bezier(.34,1.56,.64,1) both;
  }

  /* Gentle idle bob — for empty state icons (mochila backpack) */
  @keyframes idleBob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%       { transform: translateY(-4px) rotate(2deg); }
  }

  .idle-bob {
    animation: idleBob 3.5s ease-in-out infinite;
    transform-origin: center;
  }

  /* Subtle locked-overlay breath (artists page: undiscovered images) */
  @keyframes lockedBreath {
    0%, 100% { opacity: 1; }
    50%       { opacity: .6; }
  }

  /* Dim-pulse for loading text states */
  @keyframes pulseDim {
    0%, 100% { opacity: 1; }
    50%       { opacity: .45; }
  }

  /* Relic-gated choice icon hint (subtle scale loop) */
  @keyframes relicHint {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.1); }
  }

  /* === Ambient backgrounds (BG2-BG9) === */

  /* BG2: vignette breathing */
  @keyframes vignetteBreath {
    0%, 100% { opacity: .55; }
    50%      { opacity: .80; }
  }

  /* BG3: aurora drift (mesh-gradient style) */
  @keyframes auroraDrift {
    0%   { background-position: 0% 0%, 100% 50%, 50% 100%; }
    50%  { background-position: 60% 40%, 30% 80%, 80% 20%; }
    100% { background-position: 0% 0%, 100% 50%, 50% 100%; }
  }

  /* BG4: dust motes floating upward */
  @keyframes dustFloat {
    0%   { transform: translate3d(0, 100vh, 0) translateX(0); opacity: 0; }
    10%  { opacity: var(--mote-opacity, .25); }
    90%  { opacity: var(--mote-opacity, .25); }
    100% { transform: translate3d(0, -10vh, 0) translateX(var(--mote-drift, 30px)); opacity: 0; }
  }

  /* BG5: constellation star twinkle */
  @keyframes twinkle {
    0%, 100% { opacity: .25; }
    50%      { opacity: 1; }
  }

  /* BG5: constellation line draw-on */
  @keyframes constellationDraw {
    from { stroke-dashoffset: var(--line-len, 200); }
    to   { stroke-dashoffset: 0; }
  }

  /* BG6: conic-gradient slow rotation */
  @keyframes conicSpin {
    to { transform: rotate(360deg); }
  }

  /* === GL — Glows & halos === */

  /* GL2: relic-found aura (one-shot gold pulse, fades out in 6s) */
  @keyframes relicAura {
    0%   { box-shadow: 0 0 0 2px rgba(201,164,97,.8), 0 0 40px rgba(201,164,97,.5); }
    60%  { box-shadow: 0 0 0 1px rgba(201,164,97,.3), 0 0 20px rgba(201,164,97,.15); }
    100% { box-shadow: none; }
  }

  /* GL3: trap-img perimeter glow on image load (one-shot 1.5s) */
  @keyframes trapLoad {
    0%   { box-shadow: 0 0 0 2px var(--accent-glow), 0 0 60px var(--accent-glow); }
    100% { box-shadow: none; }
  }

  /* GL6: mochila card breathing (staggered via nth-child delays) */
  @keyframes cardBreathe {
    0%, 100% { box-shadow: 0 2px 12px rgba(0,0,0,.25); }
    50%       { box-shadow: 0 2px 12px rgba(0,0,0,.25), 0 0 24px rgba(201,164,97,.12); }
  }

  /* GL7: drop-cap first-letter glow */
  @keyframes dropCapGlow {
    0%, 100% { text-shadow: 0 0 12px var(--accent-glow); }
    50%       { text-shadow: 0 0 24px var(--accent-glow), 0 0 40px rgba(193,53,43,.15); }
  }

  /* GL8: brand-mark halo breathing */
  @keyframes brandGlow {
    0%, 100% { opacity: .22; }
    50%       { opacity: .50; }
  }

  /* GL9: relic-use choice border glow */
  @keyframes relicUseGlow {
    0%, 100% { box-shadow: 0 0 0 1px rgba(201,164,97,.25), 0 0 10px rgba(201,164,97,.08); }
    50%       { box-shadow: 0 0 0 2px rgba(201,164,97,.55), 0 0 18px rgba(201,164,97,.22); }
  }

  /* GL5: current node pulse in Camino graph */
  @keyframes nodeCurrentPulse {
    0%, 100% { box-shadow: 0 0 0 0px rgba(193,53,43,.35), 0 4px 16px rgba(0,0,0,.4); }
    50%       { box-shadow: 0 0 0 5px rgba(193,53,43,.35), 0 4px 16px rgba(0,0,0,.4); }
  }

  /* === SH — Shimmers & sweeps === */

  /* SH1/SH2: diagonal shimmer sweep (btn-primary on hover, choice on hover) */
  @keyframes shimmerSweep45 {
    from { transform: translateX(-150%) skewX(-20deg); }
    to   { transform: translateX(250%)  skewX(-20deg); }
  }

  /* SH4: star flash (gold inner glow after popIn) */
  @keyframes starFlash {
    0%   { box-shadow: inset 0 0 0   0  rgba(255,255,255,.0); }
    40%  { box-shadow: inset 0 0 16px 6px rgba(255,255,255,.3); }
    100% { box-shadow: inset 0 0 0   0  rgba(255,255,255,.0); }
  }

  /* SH5: rotating border spotlight on .feature cards */
  @keyframes borderSpin { to { transform: rotate(360deg); } }

  /* SH6: periodic shimmer sweep on hero-card-main */
  @keyframes heroSweep {
    0%   { transform: translateX(-150%) skewX(-15deg); opacity: 0; }
    8%   { opacity: 1; }
    20%  { transform: translateX(250%)  skewX(-15deg); opacity: 0; }
    100% { transform: translateX(-150%) skewX(-15deg); opacity: 0; }
  }

  /* SH7: navlink active underline sweep (every ~8s) */
  @keyframes navSweep {
    0%        { background-position: -200% 0; opacity: .4; }
    30%       { background-position:  200% 0; opacity: 1; }
    31%, 100% { background-position:  200% 0; opacity: .3; }
  }

  /* Shared shimmer sweep (used in node pill, trap-img skeleton, artists locked) */
  @keyframes shimmer-sweep {
    0%   { transform: translateX(-100%); }
    60%  { transform: translateX(100%); }
    100% { transform: translateX(100%); }
  }

  /* SC7: .hr-soft draws left→right on viewport entry */
  .hr-soft {
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .7s ease;
  }
  .hr-soft.in-view { transform: scaleX(1); }

  /* SC8: decorative line draws before .eyebrow on viewport entry */
  .eyebrow::before {
    content: '';
    display: inline-block;
    vertical-align: middle;
    width: 20px;
    height: 1px;
    background: var(--accent-2);
    margin-right: 8px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .5s ease;
  }
  .eyebrow.in-view::before { transform: scaleX(1); }
}

/* TR1: view-transition fade */
::view-transition-old(root) { animation: none; opacity: 0; }
::view-transition-new(root) { animation: fadeUp .35s ease both; }

/* TR3: navigation spinner */
#nav-spinner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  color: var(--accent);
  filter: drop-shadow(0 2px 8px var(--accent-glow));
}

/* === Ambient layers container (BG1 grain ya existe en body::before) === */
#ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  contain: strict;
}

#ambient-bg .ambient-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* BG2: vignette breathing — global */
.ambient-vignette {
  background: radial-gradient(
    ellipse 110% 80% at 50% 50%,
    transparent 35%,
    rgba(0, 0, 0, .35) 75%,
    rgba(0, 0, 0, .65) 100%
  );
  opacity: .55;
  animation: vignetteBreath 9s ease-in-out infinite;
}

:root[data-theme="light"] .ambient-vignette {
  background: radial-gradient(
    ellipse 110% 80% at 50% 50%,
    transparent 40%,
    rgba(67, 52, 34, .10) 80%,
    rgba(67, 52, 34, .20) 100%
  );
  opacity: .50;
}

/* BG3: aurora — only on Landing and Camino */
.ambient-aurora {
  display: none;
  background:
    radial-gradient(ellipse 50% 40% at 20% 30%, var(--accent-glow), transparent 60%),
    radial-gradient(ellipse 40% 50% at 80% 60%, rgba(201, 164, 97, .14), transparent 60%),
    radial-gradient(ellipse 55% 45% at 50% 90%, var(--accent-glow), transparent 60%);
  background-size: 200% 200%, 200% 200%, 200% 200%;
  background-repeat: no-repeat;
  opacity: .55;
  filter: blur(40px);
  animation: auroraDrift 28s ease-in-out infinite;
  will-change: background-position;
}

:root[data-theme="light"] .ambient-aurora {
  opacity: .35;
}

body[data-screen-label="Landing"] .ambient-aurora,
body[data-screen-label="Camino"] .ambient-aurora {
  display: block;
}

/* BG4: dust particles — only on Landing / Sobre / Mochila / Login */
.ambient-dust {
  display: none;
}

body[data-screen-label="Landing"] .ambient-dust,
body[data-screen-label="Sobre"] .ambient-dust,
body[data-screen-label="Mochila"] .ambient-dust,
body[data-screen-label="Login"] .ambient-dust {
  display: block;
}

.ambient-dust .dust-mote {
  position: absolute;
  top: 0;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  animation: dustFloat linear infinite;
}

:root[data-theme="light"] .ambient-dust .dust-mote {
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent-glow);
}

/* BG8: vetas de papel viejo — solo light theme */
.ambient-papyrus {
  display: none;
}

:root[data-theme="light"] .ambient-papyrus {
  display: block;
  background:
    repeating-linear-gradient(
      92deg,
      transparent 0,
      transparent 18px,
      rgba(139, 69, 19, .025) 19px,
      transparent 22px
    ),
    repeating-linear-gradient(
      178deg,
      transparent 0,
      transparent 26px,
      rgba(67, 52, 34, .018) 27px,
      transparent 32px
    );
  mix-blend-mode: multiply;
}

/* BG9: CRT scanlines — solo dark theme */
.ambient-scanlines {
  display: none;
}

:root[data-theme="dark"] .ambient-scanlines {
  display: block;
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, .25) 3px,
    transparent 4px
  );
  opacity: .25;
  mix-blend-mode: multiply;
}

/* Reduce ambient cost on small screens */
@media (max-width: 640px) {
  .ambient-aurora { filter: blur(28px); opacity: .35; }
  .ambient-dust   { display: none; } /* mobile: drop the particles entirely */
}

/* Ensure animations are disabled when user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Custom focus-visible styles for dark theme */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* Link-specific focus visibility */
a:focus-visible {
  outline-offset: 0px;
}

/* Button-specific focus visibility */
button:focus-visible {
  outline-color: var(--accent-2);
}

/* === Tablet === */
@media (max-width: 960px) {
  .wrap,
  .wrap-narrow,
  .site-header-inner,
  .wi-footer-inner,
  .wi-bottom {
    padding-left: var(--pad-x-md);
    padding-right: var(--pad-x-md);
  }

  .wi-footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  .wi-brand {
    grid-column: 1 / -1;
  }
}

/* === Mobile === */
@media (max-width: 640px) {
  .site-header-inner {
    padding-top: 14px;
    padding-bottom: 14px;
    padding-left: var(--pad-x);
    padding-right: var(--pad-x);
    gap: 14px;
  }

  .nav {
    gap: 0;
  }

  .nav a {
    padding: 8px 10px;
    font-size: 12px;
  }

  .wrap,
  .wrap-narrow,
  .wi-footer-inner,
  .wi-bottom {
    padding-left: var(--pad-x);
    padding-right: var(--pad-x);
  }
}

/* === Very small (≤480px) === */
@media (max-width: 480px) {
  .wi-footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .site-header-inner {
    gap: 8px;
  }

  .nav {
    gap: 0;
  }

  .nav a {
    padding: 6px 8px;
    font-size: 11px;
    letter-spacing: .03em;
  }

  .brand {
    font-size: 18px;
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-text {
    display: none;
  }
}

/* === Profile slot (header avatar/login) ================================== */
.profile-slot {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  min-height: 44px;
  isolation: isolate;
}

/* GL4: rotating conic ring behind the profile trigger on hover */
.profile-trigger::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  z-index: -1;
  background: conic-gradient(
    from 0deg,
    var(--accent-glow) 0%,
    transparent 35%,
    rgba(201,164,97,.3) 55%,
    transparent 75%,
    var(--accent-glow) 100%
  );
  opacity: 0;
  transition: opacity .3s;
}

.profile-trigger:hover::before {
  opacity: 1;
}

.profile-trigger {
  /* C3: scale on hover for tactile feel */
  transition: background .2s, border-color .2s, transform .15s;
}

.profile-trigger:hover {
  background: var(--surface-2);
  border-color: var(--line);
  transform: scale(1.03);
}

.profile-trigger svg {
  color: var(--ink-dim);
  flex-shrink: 0;
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  overflow: hidden;
}

.profile-avatar--img {
  background: var(--surface-2);
  object-fit: cover;
}

.profile-name {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.profile-login {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  padding: 8px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  /* Entrance animation — closed by default */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px) scaleY(.97);
  transform-origin: top right;
  transition: opacity 160ms ease-out, transform 160ms ease-out, visibility 0s linear 160ms;
  pointer-events: none;
}

.profile-menu.open {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition-delay: 0s;
  pointer-events: auto;
}

.profile-menu-header {
  padding: 10px 12px 12px;
}

.profile-menu-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-email {
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 4px 0;
}

.profile-menu-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  min-height: 44px;
}

.profile-menu-item:hover,
.profile-menu-item:focus-visible {
  background: var(--surface-2);
}

.profile-menu-item--danger {
  color: var(--accent-2);
}

.profile-menu-item--danger:hover {
  background: rgba(193, 53, 43, .12);
}

@media (max-width: 640px) {
  .profile-name {
    display: none;
  }

  .profile-trigger {
    padding: 6px;
  }

  .profile-menu {
    right: -8px;
    min-width: 220px;
  }
}

/* === Login page ========================================================== */
body.login-body {
  background: var(--bg);
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px var(--pad-x);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 40px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  animation: fadeUp .45s ease both;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: center;
  text-decoration: none;
  margin-bottom: 22px;
  color: var(--ink);
}

.login-brand-mark {
  display: inline-flex;
}

.login-brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .02em;
}

.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.15;
  margin: 0 0 10px;
  color: var(--ink);
}

.login-lead {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.login-error {
  background: rgba(193, 53, 43, .12);
  border: 1px solid rgba(193, 53, 43, .35);
  color: var(--accent-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  text-align: left;
}

/* G3: login-error slides in when revealed (hidden attr removal triggers this) */
.login-error:not([hidden]) {
  animation: fadeUp .25s ease both;
}

.login-google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border: 0;
  min-height: 48px;
  transition: transform .15s, background .2s;
}

.login-google-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.login-google-icon {
  background: #fff;
  border-radius: 4px;
  padding: 2px;
}

.login-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
  min-height: 44px;
}

.login-secondary:hover {
  background: var(--surface-2);
}

.login-tertiary-row {
  margin-top: 22px;
  display: flex;
  justify-content: center;
}

.login-tertiary {
  background: transparent;
  border: 0;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
}

.login-tertiary:hover {
  color: var(--ink);
}

@media (max-width: 480px) {
  .login-card {
    padding: 32px 22px;
    border-radius: 20px;
  }

  .login-title {
    font-size: 24px;
  }
}

/* === Flash toast (vanilla, used outside the React admin) ================= */
.relics-toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.relics-toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-family: var(--font-body);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  animation: relicsToastIn .25s ease-out;
}

.relics-toast--error {
  border-color: rgba(193, 53, 43, .55);
  background: linear-gradient(180deg, var(--surface), rgba(193, 53, 43, .12));
}

@keyframes relicsToastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* C5: toast slide-out on dismiss */
.relics-toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease-in, transform 200ms ease-in;
}

/* Contact modal */
.contact-form { display: flex; flex-direction: column; gap: 16px; }
.contact-form-eyebrow {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}
.contact-form-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 4px;
}
.contact-field { display: flex; flex-direction: column; gap: 6px; }
.contact-field label {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-soft);
}
.contact-field input,
.contact-field textarea {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}
.contact-field input:focus,
.contact-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.contact-field textarea { resize: vertical; min-height: 110px; }
.contact-sent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  text-align: center;
}
.contact-sent-icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.contact-sent-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink);
  margin: 0;
}
.contact-sent-sub {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0;
}

@media (max-width: 480px) {
  .relics-toast-host {
    left: 16px;
    right: 16px;
    transform: none;
    max-width: none;
  }

  .relics-toast {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

/* ── Config panel & Modals (Global) ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade-in 160ms ease-out;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  width: 100%;
  max-width: 460px;
  animation: modal-scale-in 200ms ease-out;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 8px;
  position: relative;
}

.modal-header svg {
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.modal-body {
  padding: 4px 20px 20px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modal-scale-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.config-panel {
  width: min(420px, 92vw);
}

.config-panel-close {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  transition: color .2s, background .2s;
}

.config-panel-close:hover {
  color: var(--ink);
  background: var(--bg-3);
}

.config-panel-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 4px;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.config-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.config-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .25s ease;
}

.config-select:hover {
  border-color: var(--line);
}

.config-select:focus {
  outline: none;
  border-color: var(--accent);
}

.config-select option {
  background: var(--surface);
  color: var(--ink);
}