/* Oracools — con la identidad de Oráculos (oraculos.app):
   noche profunda, oro, terracota y arena; Chakra Petch para títulos y etiquetas, Gotham para el cuerpo.
   El verde menta queda sólo para los píxeles: es el filamento de los Oracools. */

@font-face { font-family: 'Chakra Petch'; font-weight: 400; font-display: swap; src: url('fuentes/ChakraPetch-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Chakra Petch'; font-weight: 500; font-display: swap; src: url('fuentes/ChakraPetch-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Chakra Petch'; font-weight: 600; font-display: swap; src: url('fuentes/ChakraPetch-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Gotham'; font-weight: 400; font-display: swap; src: url('fuentes/gotham/Gotham-Book.otf') format('opentype'); }
@font-face { font-family: 'Gotham'; font-weight: 500; font-display: swap; src: url('fuentes/gotham/Gotham-Medium.otf') format('opentype'); }

:root {
  --bg-0: #080a12;
  --bg-1: #0d0f1a;
  --panel: rgba(20, 23, 38, .66);
  --panel-hi: rgba(31, 35, 54, .9);
  --line: rgba(227, 176, 99, .16);
  --line-soft: rgba(214, 195, 165, .10);
  --gold: #e3b063;
  --gold-bright: #f6dca0;
  --gold-dim: #b0854a;
  --terra: #c98a5e;
  --sand: #d8c3a5;
  --text: #ece7dd;
  --text-dim: #9d97a9;
  --text-faint: #948fa4;
  --glow: rgba(227, 176, 99, .35);
  --oled: #05060b;
  --pixel: #b5ec9a;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, .7);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --titulo: 'Chakra Petch', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg-0); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.5 'Gotham', 'Segoe UI', system-ui, sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background:
    radial-gradient(1200px 900px at 78% -8%, rgba(201, 138, 94, .16), transparent 60%),
    radial-gradient(1000px 800px at 10% 110%, rgba(80, 96, 150, .18), transparent 55%),
    radial-gradient(900px 700px at 100% 100%, rgba(227, 176, 99, .08), transparent 60%),
    linear-gradient(160deg, #0a0c16 0%, #0b0d18 40%, #0d0e19 70%, #0a0b13 100%) fixed;
}

::selection { background: rgba(227, 176, 99, .3); color: #fff; }

header, main, footer { max-width: 520px; margin: 0 auto; position: relative; z-index: 1; }

/* ---------- encabezado ---------- */
header { padding: 30px 0 10px; text-align: center; }
h1 { margin: 0; line-height: 0; }
h1 img {
  width: min(250px, 70vw);
  height: auto;
  filter: invert(1) sepia(.32) saturate(1.1) drop-shadow(0 0 14px rgba(227, 176, 99, .4));
}
.lema {
  margin: 12px 0 0;
  font-family: var(--titulo);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold);
}
.lema span { color: var(--text-faint); letter-spacing: .2em; }

/* ---------- secciones ---------- */
section, .panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 14px 0;
  backdrop-filter: blur(6px);
  overflow: hidden;
}
section::before, .panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(160px 100px at 100% 0%, rgba(227, 176, 99, .08), transparent 70%);
  pointer-events: none;
}

h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  font-family: var(--titulo);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
h2::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

/* ---------- la pantalla ---------- */
.altar { text-align: center; padding-top: 20px; }

.marco {
  position: relative;
  background: var(--oled);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--gold-dim);
  box-shadow: 0 0 0 4px rgba(227, 176, 99, .06), 0 0 34px -6px var(--glow), inset 0 0 24px rgba(0, 0, 0, .9);
}

#pantalla {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 72 / 40;
  touch-action: none;
}
#pantalla.dibujando { cursor: crosshair; outline: 1px dashed var(--gold); outline-offset: 6px; }

.estado {
  margin: 14px 0;
  min-height: 1.5em;
  font-family: var(--titulo);
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--text-dim);
}

/* ---------- botones ---------- */
button {
  font-family: var(--titulo);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: .04em;
  color: var(--text-dim);
  background: rgba(8, 10, 18, .6);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
  transition: color .16s, background .16s, border-color .16s, box-shadow .16s;
}
button:hover { color: var(--gold-bright); border-color: var(--gold-dim); background: rgba(227, 176, 99, .07); }
button:focus-visible { outline: none; border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(227, 176, 99, .18); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button[aria-pressed="true"], button.activo {
  color: var(--gold-bright);
  border-color: var(--gold-dim);
  background: linear-gradient(90deg, rgba(227, 176, 99, .2), rgba(227, 176, 99, .06));
}

button.principal {
  width: 100%;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #1a1206;
  border: 0;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  box-shadow: 0 8px 26px -10px var(--glow);
}
button.principal:hover { color: #1a1206; background: linear-gradient(180deg, #fbe7b8, var(--gold-bright)); }

.rejilla {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

/* ---------- formularios ---------- */
.palabras { display: flex; gap: 8px; align-items: stretch; }
.palabras textarea {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: rgba(8, 10, 18, .7);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: vertical;
}
.palabras textarea::placeholder { color: var(--text-faint); }
.palabras textarea:focus { outline: none; border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(227, 176, 99, .12); }

.fila { display: flex; gap: 8px; flex-wrap: wrap; }
.fila button { flex: 1; }

.nota { color: var(--text-faint); font-size: 13px; margin: 10px 0 0; }
.contenido > .nota:first-of-type { margin: 0 0 12px; }

.ajuste { display: flex; align-items: center; gap: 12px; margin: 8px 0; color: var(--text-dim); font-size: 14px; }
.ajuste input[type="range"] { flex: 1; accent-color: var(--gold); }
.interruptor input { width: 20px; height: 20px; accent-color: var(--gold); }

.aviso {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 138, 94, .35);
  background: rgba(201, 138, 94, .1);
  color: var(--sand);
  font-size: 13.5px;
}

/* ---------- bitácora ---------- */
.bitacora {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 190px;
  overflow-y: auto;
  font-size: 13.5px;
  color: var(--text-dim);
}
.bitacora li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.bitacora li:first-child { color: var(--text); }
.bitacora li:last-child { border-bottom: 0; }
.bitacora time {
  font-family: var(--titulo);
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--gold-dim);
  margin-right: 10px;
  font-variant-numeric: tabular-nums;
}

footer {
  text-align: center;
  padding: 10px 0 30px;
  font-family: var(--titulo);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-faint);
}


/* pistas que sólo se ven mientras el Oracool duerme */
.pista { margin: 0 0 12px; }
body.enlazado .pista { display: none; }
input:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- paneles que se colapsan ---------- */
.panel { padding: 0; }
.panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  user-select: none;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary h2 { margin: 0; }
.panel > summary h2::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .25s var(--ease);
  margin-right: 2px;
}
.panel[open] > summary h2::before { transform: rotate(45deg); }
.panel > summary:hover h2 { color: var(--gold); }
.panel > summary:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--gold-dim); }
.panel .contenido { padding: 0 16px 18px; }
.panel[open] .contenido { animation: desplegar .35s var(--ease); }
@keyframes desplegar { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- la pantalla se abre cuando despierta ---------- */
.ventana {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .9s var(--ease), opacity .6s .3s;
}
.ventana > div { overflow: hidden; min-height: 0; }
.marco.cerrado .ventana { grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .6s var(--ease), opacity .3s; }

.espera {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 72 / 14;
  image-rendering: pixelated;
  max-height: 0;
  opacity: 0;
  transition: max-height .5s var(--ease), opacity .4s;
}
.marco.cerrado .espera { max-height: 120px; opacity: 1; }
.marco.cerrado { padding: 18px 14px; }
.marco.buscando { box-shadow: 0 0 0 4px rgba(181, 236, 154, .08), 0 0 40px -4px rgba(181, 236, 154, .35), inset 0 0 24px rgba(0, 0, 0, .9); border-color: #7fae6c; }

/* ---------- el gran botón del azar ---------- */
.rejilla .aleatorio {
  grid-column: 1 / -1;
  min-height: 54px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold);
  border-color: var(--gold-dim);
  background:
    linear-gradient(90deg, transparent, rgba(227, 176, 99, .12), transparent) 0 0 / 200% 100%,
    rgba(8, 10, 18, .6);
  animation: brillo-azar 4s linear infinite;
}
.rejilla .aleatorio:disabled { animation: none; }
@keyframes brillo-azar { to { background-position: -200% 0, 0 0; } }

/* ---------- polvo de estrellas pixelado ---------- */
#polvo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

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

/* ---------- ánima ---------- */
.anima { margin-bottom: 16px; }
.animo { margin: 0; }
#animo-nombre {
  font-family: var(--titulo);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 0 18px var(--glow);
}
#animo-frase { margin: 4px 0 14px; }

.necesidad { display: grid; grid-template-columns: 64px 1fr 32px; align-items: center; gap: 10px; margin: 8px 0; }
.necesidad .etiqueta { font-family: var(--titulo); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-dim); }
.necesidad .valor { font-family: var(--titulo); font-size: 13px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.barra { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; height: 12px; }
.barra i { background: rgba(255, 255, 255, .05); border-radius: 1px; transition: background .4s, box-shadow .4s; }
.tierra .barra i.lleno { background: var(--terra); box-shadow: 0 0 6px rgba(201, 138, 94, .5); }
.chispa .barra i.lleno { background: var(--pixel); box-shadow: 0 0 6px rgba(181, 236, 154, .45); }
.barra.bajo i.lleno { animation: pedir 1.2s ease-in-out infinite; }
@keyframes pedir { 50% { opacity: .35; } }

.edad { margin: 10px 0 0; font-family: var(--titulo); font-size: 11.5px; letter-spacing: .1em; color: var(--text-faint); }

.ofrendas { display: grid; gap: 12px; }
.ofrendas h3 {
  margin: 0 0 8px;
  font-family: var(--titulo);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-faint);
}
[data-ofrenda="barro"], [data-ofrenda="agua"], [data-ofrenda="luna"] { border-color: rgba(201, 138, 94, .3); }
[data-ofrenda="chispa"], [data-ofrenda="codigo"], [data-ofrenda="eco"] { border-color: rgba(181, 236, 154, .22); }
button.ofrecida { animation: ofrecer .7s var(--ease); }
@keyframes ofrecer { 30% { transform: scale(1.06); box-shadow: 0 0 22px -2px var(--glow); color: var(--gold-bright); } }

body.petrificado #animo-nombre { color: var(--text-faint); text-shadow: none; }
