/* Tipografías locales (SIL Open Font License, subset latino). Ver assets/fonts/LICENCIAS.md */
@font-face { font-family: 'Instrument Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(assets/fonts/instrument-serif.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(assets/fonts/instrument-serif-italic.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(assets/fonts/dm-sans.woff2) format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 500; font-display: swap; src: url(assets/fonts/caveat-500.woff2) format('woff2'); }
@font-face { font-family: 'Bodoni Moda'; font-style: italic; font-weight: 500; font-display: swap; src: url(assets/fonts/bodoni-moda-italic-500.woff2) format('woff2'); }
@font-face { font-family: 'Bebas Neue'; font-style: normal; font-weight: 400; font-display: swap; src: url(assets/fonts/bebas-neue.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-style: italic; font-weight: 500; font-display: swap; src: url(assets/fonts/cormorant-garamond-italic-500.woff2) format('woff2'); }

:root {
  --ink: #eef3f4;
  --soft: rgba(238, 243, 244, .72);
  --accent: #f46a18;
  --bg: #02090c;
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body {
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
}
button { font: inherit; cursor: pointer; color: inherit; }
#app { position: fixed; inset: 0; height: 100dvh; }
#stage, #stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage { z-index: 0; background: radial-gradient(ellipse at 50% 20%, #0d2229, #02090c 70%); }
#stage canvas[hidden] { display: none; }
.hidden { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }

/* inicio: deja ver y tocar el agua detrás */
.intro {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  transition: opacity 1.2s ease, visibility 1.2s;
  background: radial-gradient(ellipse at 50% 50%, rgba(2,9,12,.35), rgba(2,9,12,.05) 70%);
}
.intro-logo { width: clamp(70px, 16vw, 110px); height: auto; opacity: .92; margin-bottom: 18px; }
.intro h1 {
  margin: 0; font: 400 clamp(56px, 15vw, 150px)/.9 'Instrument Serif', Georgia, serif;
  letter-spacing: -.035em; text-shadow: 0 6px 40px rgba(0,10,16,.8);
}
.intro p { margin: 18px 0 30px; font: italic clamp(18px, 4.6vw, 26px)/1.3 'Instrument Serif', Georgia, serif; color: var(--soft); text-shadow: 0 2px 20px rgba(0,0,0,.7); }
.intro small { margin-top: 18px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: rgba(238,243,244,.5); }
.intro .release {
  pointer-events: auto;
  margin: 22px 0 0;
  max-width: 24em;
  font: italic clamp(15px, 3.4vw, 18px)/1.45 'Instrument Serif', Georgia, serif;
  color: var(--soft);
  text-shadow: 0 2px 16px rgba(0,0,0,.7);
}
.intro .release a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.intro .release a:hover { color: var(--accent); }

.start {
  pointer-events: auto; border: 0; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  padding: 17px 28px; min-height: 48px; display: inline-flex; align-items: center; gap: 12px;
  box-shadow: 0 10px 40px rgba(244,106,24,.28); transition: transform .2s, background .2s;
}
.start:hover { background: #d8530c; }
.start:active { transform: scale(.97); }
.start:focus-visible, .ghost:focus-visible, .round:focus-visible, .volume input:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.brand {
  position: absolute; z-index: 5; left: max(18px, env(safe-area-inset-left)); top: max(16px, env(safe-area-inset-top));
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: rgba(238,243,244,.55);
  pointer-events: none; transition: opacity 1s;
}
.brand span { color: rgba(238,243,244,.85); }

.lyric {
  --lbase: clamp(40px, 4.8vw, 78px);
  position: absolute; z-index: 4; pointer-events: none;
  left: var(--lx, 8%); top: var(--ly, 12%); transform: translateX(var(--lshift, 0%));
  width: min(calc(100vw - 40px), 760px);
  font-family: var(--lfont, 'Instrument Serif'), Georgia, serif;
  font-style: var(--lstyle, normal); font-weight: var(--lweight, 400);
  font-size: calc(var(--lbase) * var(--lk, 1)); line-height: var(--llh, 1);
  letter-spacing: var(--ltrack, -.03em); text-transform: var(--lcase, none);
  text-align: var(--lalign, left); text-wrap: balance;
  color: #f4f6f2; text-shadow: 0 4px 34px rgba(0, 10, 16, .85), 0 0 2px rgba(0,10,16,.45);
  transition: opacity .4s ease, filter .4s ease;
}
.lyric.out { opacity: 0; filter: blur(6px); }
.lyric .w, .lyric .c { display: inline-block; animation-fill-mode: both; animation-timing-function: cubic-bezier(.2,.7,.2,1); }
.lyric .w { white-space: nowrap; }
.anim-blur .w { animation-name: l-blur; animation-duration: .9s; }
.anim-sube .w { animation-name: l-sube; animation-duration: 1s; }
.anim-escribir .c { animation-name: l-escribir; animation-duration: .5s; animation-timing-function: ease-out; }
.anim-letras .c { animation-name: l-letras; animation-duration: .55s; }
.anim-brillo .c { animation-name: l-brillo; animation-duration: 1.3s; }
.anim-fade { animation: l-fade .35s ease both; }
@keyframes l-blur { from { opacity: 0; filter: blur(12px); } to { opacity: 1; filter: blur(0); } }
@keyframes l-sube { from { opacity: 0; transform: translateY(.55em); filter: blur(5px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes l-escribir { from { opacity: 0; clip-path: inset(0 100% 0 0); transform: translateY(.06em); } to { opacity: 1; clip-path: inset(0 -10% 0 0); transform: none; } }
@keyframes l-letras { from { opacity: 0; transform: translateY(.5em) scaleY(1.35); } to { opacity: 1; transform: none; } }
@keyframes l-brillo { 0% { opacity: 0; color: #fff6e0; text-shadow: 0 0 26px rgba(255,214,150,.95), 0 0 6px rgba(255,240,210,.9); } 45% { opacity: 1; } 100% { opacity: 1; color: #f4f6f2; text-shadow: 0 4px 34px rgba(0,10,16,.85), 0 0 2px rgba(0,10,16,.45); } }
@keyframes l-fade { from { opacity: 0; } to { opacity: 1; } }
.start.loading { opacity: .6; cursor: progress; }
.credits { margin-top: 10px; font-size: 11px; color: rgba(238,243,244,.55); }
.credits summary { cursor: pointer; letter-spacing: .08em; text-transform: uppercase; }
.credits ul { list-style: none; padding: 0; margin: 8px 0 0; line-height: 1.6; }
.garden .credits a { color: rgba(238,243,244,.7); font-size: 11px; letter-spacing: 0; font-weight: 400; margin: 0; text-decoration: underline; }

.hint {
  position: absolute; z-index: 5; left: 50%; bottom: max(84px, calc(env(safe-area-inset-bottom) + 70px)); transform: translateX(-50%);
  font: italic 18px/1 'Instrument Serif', Georgia, serif; color: var(--soft); pointer-events: none;
  text-shadow: 0 2px 16px rgba(0,0,0,.8); transition: opacity .8s; white-space: nowrap;
  animation: breathe 3.2s ease-in-out infinite;
}

.controls {
  position: absolute; z-index: 6; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  display: flex; align-items: center; gap: 12px; transition: opacity .5s;
}
.count { font: italic 17px/1 'Instrument Serif', Georgia, serif; color: var(--soft); min-width: 2ch; text-align: right; }
.count::after { content: ' ✿'; font-style: normal; font-size: 12px; color: #9cb8f5; }
.round {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.45);
  background: rgba(2,12,16,.35); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-size: 12px;
}
.volume { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--soft); }
.volume input { width: 76px; accent-color: #fff; }
.progress { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,255,255,.08); pointer-events: none; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, rgba(156,184,245,.4), rgba(244,106,24,.8)); }

.garden {
  position: absolute; z-index: 7; left: 50%; bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px)); transform: translateX(-50%);
  width: min(560px, calc(100vw - 28px)); padding: 22px 22px 18px; text-align: center;
  border-radius: 22px; background: rgba(2, 12, 16, .42); border: 1px solid rgba(255,255,255,.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  transition: opacity 1.4s ease, visibility 1.4s;
}
.garden h2 { margin: 0; font: 400 clamp(36px, 9vw, 54px)/1 'Instrument Serif', Georgia, serif; letter-spacing: -.03em; }
.garden-cover {
  display: block;
  width: clamp(88px, 26vw, 140px);
  height: auto;
  margin: 0 auto 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.16);
  pointer-events: none;
}
.ficha-dialog {
  max-width: min(1400px, 94vw);
  max-height: 96dvh;
  padding: 16px;
  border: 0;
  background: transparent;
  color: inherit;
}
.ficha-dialog::backdrop { background: rgba(0, 0, 0, .82); }
.ficha-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 82dvh;
  margin: 0 auto;
  border-radius: 12px;
}
.ficha-dialog form { display: flex; justify-content: center; margin-top: 12px; }
.ficha-dialog .ghost { pointer-events: auto; color: #fff; margin-top: 0; font-weight: 400; letter-spacing: .1em; }

.garden p { margin: 8px 0 16px; font: italic 18px/1.3 'Instrument Serif', Georgia, serif; color: var(--soft); }
.garden-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.garden .start { padding: 14px 20px; font-size: 12px; }
.ghost {
  border: 1px solid rgba(255,255,255,.35); background: transparent; border-radius: 999px; padding: 12px 16px; min-height: 44px;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}
.link-btn { border: 0; background: none; color: rgba(238,243,244,.6); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; text-decoration: underline; text-underline-offset: 4px; padding: 10px 6px; min-height: 40px; }
.link-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.garden a { display: inline-block; margin-top: 14px; color: var(--accent); font-size: 11px; letter-spacing: .2em; font-weight: 700; text-decoration: none; }
.garden-actions a.start {
  margin-top: 0;
  color: #fff;
  letter-spacing: .14em;
  text-decoration: none;
  font-size: 12px;
}
.garden-actions a.ghost {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  color: inherit;
  letter-spacing: .1em;
  font-weight: 400;
  text-decoration: none;
}


.fps { position: absolute; z-index: 9; left: 8px; bottom: 8px; font: 11px/1.3 ui-monospace, monospace; color: #9f9; background: rgba(0,0,0,.5); padding: 4px 6px; white-space: pre; pointer-events: none; }
.noscript { position: absolute; inset: 0; display: grid; place-items: center; z-index: 10; }

@keyframes breathe { 50% { opacity: .45; } }

@media (max-width: 650px) {
  .lyric { width: calc(100vw - 40px); --lbase: clamp(30px, 8.6vw, 44px); }
  .volume { display: none; }
  .brand { font-size: 9px; }
  .garden { top: max(46px, calc(env(safe-area-inset-top) + 34px)); bottom: auto; padding: 14px 14px 12px; border-radius: 18px; }
  .garden h2 { font-size: 34px; }
  .garden-cover { width: 72px; margin-bottom: 8px; }

  .garden p { font-size: 15px; margin: 4px 0 12px; }
  .garden .start { padding: 11px 16px; min-height: 42px; font-size: 11px; }
  .ghost { padding: 9px 12px; min-height: 40px; font-size: 10.5px; }
  .garden a { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; }
  .lyric { transition-duration: .2s; }
  .lyric.out { filter: none; }
  .lyric .w, .lyric .c { animation: none !important; }
  .intro, .garden { transition-duration: .3s; }
}
