/* =========================================================
   Tema Habitat: fondo gris claro, celeste / naranja / verde lima
   ========================================================= */
:root {
  --blue: #0099cc;
  --orange: #E55D25;
  --lime: #C4D600;
  --bg: #f0f0f0;
  --ink: #1d1d1b;
  --muted: #5d6368;
  --card: #ffffff;
  --line: #d8dbde;
  --cta: #c9d3dd;
  --star-glow: #ffcc33;           /* brillo de la estrella: amarillo (por defecto) */
  --font: "Helvetica Neue", "Segoe UI", Arial, system-ui, sans-serif;
  --font-display: "Neue Haas Grotesk Text", "Helvetica Neue", "Segoe UI", Arial, system-ui, sans-serif;
}
body[data-star="celeste"] { --star-glow: #29b6e8; }

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  line-height: 1.35;
}

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.topbar, .layout, .donate-layout, .sim-wrap { position: relative; z-index: 1; }

h1, h2 { line-height: 1.05; margin: 0 0 .5rem; font-family: var(--font-display); }
.stat .num, .btn, .bar-label, .brand { font-family: var(--font-display); }
h1 { font-size: clamp(2rem, 3.5vw, 3.1rem); font-weight: 800; letter-spacing: -.02em; color: var(--blue); }
h2 { font-size: 1.25rem; font-weight: 800; }
p { margin: 0 0 .8rem; }
a { color: var(--blue); }

/* ---------- Destellos decorativos ---------- */
.decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.spark-cluster { position: absolute; width: 64px; height: 72px; }
.spark-cluster .tw { animation: tw 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.tw.b { fill: var(--blue); } .tw.o { fill: var(--orange); } .tw.l { fill: var(--lime); }
.c1 { left: 4%;  top: 10%; }
.c2 { right: 2%; top: 3%; }
.c3 { left: 12%; top: 40%; }
.c4 { left: 41%; top: 36%; }
.c5 { left: 4%;  bottom: 6%; }
.c6 { right: 2%; top: 63%; }
@keyframes tw { 0%, 100% { opacity: .35; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.1); } }

/* ---------- Barra superior (solo página de donación) ---------- */
.topbar { max-width: 1200px; margin: 0 auto; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { color: var(--blue); text-decoration: none; font-weight: 800; font-size: 1.05rem; }

.btn {
  display: inline-block; border: 2px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 20px; border-radius: 999px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .12s, background .12s, box-shadow .12s;
}
.btn:hover { background: #e9edf0; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(0, 153, 204, .3); }
.btn-primary:hover { background: #0087b8; }
.btn-block { display: block; width: 100%; text-align: center; padding: 14px 20px; font-size: 1.15rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-width: 1px; }
.btn-danger { border-color: #e0a090; color: #b3391a; }

/* ---------- Página principal ---------- */
.layout { max-width: 1366px; margin: 0 auto; padding: 44px 40px 60px; display: grid; gap: 28px; align-items: start; }
.layout.home {
  grid-template-columns: minmax(0, 1fr) minmax(0, 600px);
  column-gap: 44px; row-gap: 0; align-content: center; min-height: 100vh;
}
.layout.home .stage { grid-column: 1; grid-row: 1 / span 2; }
.layout.home .hero  { grid-column: 2; grid-row: 1; }
.layout.home .side  { grid-column: 2; grid-row: 2; }

.hero-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.hero-title h1, .hero-title h2 { margin: 0; min-width: 0; }
.hero-title h1 span { display: block; }
.hero-icons { position: static; flex: 0 0 auto; width: clamp(90px, 8vw, 130px); height: auto; }

.stats { display: flex; gap: 12px; margin: 18px 0 16px; }
.stat {
  flex: 1; min-width: 0; text-align: center; padding: 16px 10px; border-radius: 22px; color: #fff;
  display: flex; flex-direction: column; justify-content: center;
}
.stat .num { display: block; font-size: clamp(1.1rem, 1.8vw, 1.6rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 1rem; font-weight: 600; line-height: 1.15; margin-top: 2px; }
.stats .stat:nth-child(1) { background: var(--orange); }
.stats .stat:nth-child(2) { background: var(--lime); color: var(--ink); }
.stats .stat:nth-child(3) { background: var(--blue); }

.bar { position: relative; margin-bottom: 14px; height: 26px; background: #d9dcdf; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--orange) 55%, var(--lime)); background-size: 600px 100%; transition: width .5s ease; }
.bar-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: .9rem; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .45); }

.gifts-line { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; font-size: 1.1rem; font-weight: 700; }

.stage { position: relative; min-width: 0; }
#tree { position: relative; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; margin-bottom: 16px; }
.cta { background: var(--cta); border: 0; }
.cta p { font-size: 1.05rem; font-weight: 500; }
.cta h2 { margin-bottom: .3rem; }
.cta .hint, .empty { color: var(--muted); font-size: .85rem; margin: .7rem 0 0; }

.feed { list-style: none; margin: 8px 0 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: start; padding: 9px 0; border-top: 1px solid var(--line); animation: slide .45s ease both; }
.feed li:first-child { border-top: 0; }
.feed .dot { width: 10px; height: 10px; border-radius: 3px; margin-top: 6px; background: var(--lime); }
.feed li:nth-child(3n+2) .dot { background: var(--blue); }
.feed li:nth-child(3n+3) .dot { background: var(--orange); }
.feed strong { display: block; font-size: .95rem; }
.feed small { color: var(--muted); }
.feed time { color: var(--muted); font-size: .75rem; white-space: nowrap; margin-top: 3px; }
@keyframes slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.complete { margin: 12px 0 0; padding: 12px 16px; border-radius: 16px; background: var(--lime); font-weight: 800; text-align: center; }
.offline { text-align: center; color: #b3391a; font-size: .85rem; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; z-index: 20;
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; transition: .3s; pointer-events: none; box-shadow: 0 8px 26px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Árbol (SVG) ---------- */
.brick-tree svg { display: block; width: 100%; height: auto; max-height: max(480px, calc(100vh - 100px)); margin: 0 auto; overflow: visible; touch-action: manipulation; }
.brick-tree.compact svg { max-height: max(420px, calc(100vh - 250px)); }

.slot { fill: rgba(0, 0, 0, .035); stroke: rgba(0, 0, 0, .25); stroke-width: 1; stroke-dasharray: 3 3; cursor: pointer; transition: fill .15s, stroke .15s; }
.slot:hover { fill: rgba(0, 153, 204, .18); stroke: var(--blue); }

.brick { cursor: pointer; }
.brick-inner { transform-box: fill-box; transform-origin: 50% 100%; }
.brick-inner.drop { animation: drop .95s cubic-bezier(.3, .7, .4, 1) both; }
@keyframes drop {
  0%   { transform: translateY(-440px) rotate(-12deg); opacity: 0; }
  12%  { opacity: 1; }
  55%  { transform: translateY(0) rotate(0); }
  70%  { transform: translateY(-14px); }
  85%  { transform: translateY(0) scaleY(.9); }
  100% { transform: translateY(0) scaleY(1); }
}
.shine { fill: #fff; opacity: 0; animation: shine 1s .5s ease-out both; pointer-events: none; }
@keyframes shine { 0% { opacity: .85; } 100% { opacity: 0; } }

.hole { fill: #0a1a14; stroke: rgba(0, 0, 0, .45); stroke-width: 1; }
.hole.lit { fill: var(--glow); stroke: none; filter: drop-shadow(0 0 3px var(--glow)); animation: twinkle 2.6s ease-in-out infinite; animation-delay: var(--d); }
@keyframes twinkle { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.ring { fill: none; stroke: var(--orange); stroke-width: 2.5; animation: ring 1s ease-in-out infinite; }
@keyframes ring { 0%, 100% { opacity: 1; stroke-width: 2.5; } 50% { opacity: .35; stroke-width: 5; } }

/* Estrella: brillo amarillo o celeste (ver --star-glow arriba) */
.star-halo { fill: transparent; pointer-events: none; }
.star-halo.lit { fill: url(#starGlow); animation: pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.star-shape { fill: rgba(0, 0, 0, .04); stroke: rgba(0, 0, 0, .35); stroke-width: 1.5; stroke-dasharray: 4 3; stroke-linejoin: round; cursor: pointer; transition: fill .6s, stroke .6s; }
.star-shape.lit { fill: #ffd23f; stroke: #f5a800; stroke-width: 2; stroke-dasharray: none; filter: drop-shadow(0 0 8px var(--star-glow)); animation: pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .9; transform: scale(1.07); } }

.tip {
  position: absolute; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 12px; max-width: 240px; font-size: .85rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.tip.show { opacity: 1; }
.tip strong, .tip em, .tip small { display: block; }
.tip em { color: #dfe8ee; }
.tip small { color: #aebbc4; margin-top: 2px; }

/* ---------- Regalos debajo del árbol ---------- */
.gift { cursor: pointer; }
.gift-inner { transform-box: fill-box; transform-origin: 50% 100%; }
.gift-inner.drop { animation: drop .95s cubic-bezier(.3, .7, .4, 1) both; }

/* ---------- Meta cumplida: animaciones permanentes ---------- */
.rays, .spark { opacity: 0; }
.ray { fill: url(#rayGrad); }
.brick-tree.is-complete .rays { opacity: 1; transform-box: fill-box; transform-origin: center; animation: spin-slow 26s linear infinite; }
.brick-tree.is-complete .spark { opacity: 1; animation: spark 1.8s ease-in-out infinite; fill: var(--star-glow); transform-box: fill-box; transform-origin: center; }
@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes spark { 0%, 100% { opacity: .2; transform: scale(.4); } 50% { opacity: 1; transform: scale(1.15); } }

/* Todos los huecos se encienden (celeste / naranja / lima) y una ola de luz sube por el árbol */
.brick-tree.is-complete .hole {
  fill: var(--glow); stroke: none; filter: drop-shadow(0 0 3px var(--glow));
  animation: wave 2.4s ease-in-out infinite; animation-delay: calc(var(--rr) * .16s);
}
@keyframes wave { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* Adornos redondos: aparecen con un salto y luego se mecen suavemente */
.bauble { opacity: 0; transform-box: fill-box; transform-origin: center; }
.brick-tree.is-complete .bauble {
  animation: bauble-in .7s cubic-bezier(.3, 1.6, .5, 1) var(--bd) both, bauble-float 3.2s ease-in-out calc(.7s + var(--bd)) infinite;
}
@keyframes bauble-in { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes bauble-float { 0%, 100% { opacity: 1; transform: translateY(0) scale(1); } 50% { opacity: 1; transform: translateY(-2.5px) scale(1.06); } }

/* ---------- Página de donación ---------- */
.sim-wrap { padding: 0 20px; }
.sim-banner {
  max-width: 1200px; margin: 0 auto; padding: 8px 20px; text-align: center; font-size: .9rem; font-weight: 700;
  background: repeating-linear-gradient(45deg, rgba(229, 93, 37, .14) 0 14px, rgba(229, 93, 37, .06) 14px 28px);
  border: 1px dashed var(--orange); border-radius: 12px;
}

.donate-layout { max-width: 1200px; margin: 0 auto; padding: 16px 20px 60px; display: grid; grid-template-columns: minmax(320px, 460px) 1fr; gap: 28px; align-items: start; }
.donate-layout .card h1 { font-size: 2rem; }

form fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
form legend, form label.field > span { display: block; font-weight: 700; margin-bottom: 6px; font-size: .92rem; }
.field { display: block; margin-bottom: 16px; }

input[type=text], input[type=number], textarea {
  width: 100%; background: #fff; border: 2px solid var(--line); border-radius: 12px; color: var(--ink);
  padding: 10px 12px; font: inherit;
}
input:focus-visible, textarea:focus-visible, .chip input:focus-visible + span, button:focus-visible, a:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
input:disabled { opacity: .5; }
textarea { resize: vertical; min-height: 64px; }
.counter { text-align: right; color: var(--muted); font-size: .75rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: block; padding: 9px 16px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font-weight: 700; transition: .12s; }
.chip span small { display: block; font-weight: 500; font-size: .72rem; opacity: .8; line-height: 1.2; }
.chip input:checked + span { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip:hover span { border-color: var(--blue); }
#customAmount { margin-top: 10px; }
.preview { margin: 10px 0 0; color: var(--orange); font-weight: 700; font-size: .95rem; }

.check { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; color: var(--muted); }
.error { color: #8f2a10; background: #fde6de; border: 1px solid #f0b8a6; padding: 8px 12px; border-radius: 10px; margin: 0 0 14px; font-size: .9rem; }

.processing { text-align: center; padding: 30px 10px; }
.spinner { width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 50%; border: 4px solid #dfe3e6; border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.success { text-align: center; padding: 8px 0; }
.success .big { font-size: 3rem; }
.receipt { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; background: #f0f0f0; border: 1px dashed #aab; padding: 4px 12px; border-radius: 8px; color: var(--blue); font-weight: 700; margin-bottom: 10px; }

.mini-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.mini-stats .stat { padding: 10px 12px; border-radius: 18px; }
.mini-stats .stat .num { font-size: 1.2rem; }
.mini-stats .stat .lbl { font-size: .8rem; }
.mini-stats .stat:nth-child(1) { background: var(--orange); }
.mini-stats .stat:nth-child(2) { background: var(--lime); color: var(--ink); }
.mini-stats .stat:nth-child(3) { background: var(--blue); }

details.tools { margin-top: 8px; }
details.tools summary { cursor: pointer; font-weight: 800; margin-bottom: 8px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .layout, .donate-layout { grid-template-columns: 1fr; padding-left: 20px; padding-right: 20px; }
  .layout.home { grid-template-columns: 1fr; min-height: 0; }
  .layout.home .stage, .layout.home .hero, .layout.home .side { grid-column: 1; grid-row: auto; }
  .layout.home .stage { margin: 8px 0 16px; }
  .brick-tree svg, .brick-tree.compact svg { max-height: none; }
  .decor .c3, .decor .c4 { display: none; }
}
@media (max-width: 520px) {
  .stats { gap: 8px; }
  .stat { padding: 12px 6px; border-radius: 16px; }
  .stat .lbl { font-size: .8rem; }
  h1 { font-size: 1.85rem; }
  .hero-icons { width: 62px; top: -14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =========================================================
   Pantalla grande (escritorio): el árbol ocupa toda la mitad
   izquierda y el contenido va más a la derecha y más chico
   ========================================================= */
@media (min-width: 1001px) {
  html.home-page { font-size: clamp(13px, .72vw, 16px); }   /* reduce todo el panel derecho */

  .layout.home {
    max-width: none; padding: 0; column-gap: 0; row-gap: 0;
    grid-template-columns: 50% minmax(0, 1fr);
    align-content: start; align-items: start; min-height: 100vh;
  }

  /* El árbol queda fijo a la vista, centrado en la mitad izquierda */
  .layout.home .stage {
    grid-column: 1; grid-row: 1 / span 2;
    position: sticky; top: 0; height: 100vh; margin: 0;
    display: flex; align-items: center; justify-content: center;
  }
  .layout.home #tree { width: 100%; }
  .layout.home .brick-tree svg { width: 100%; height: calc(100vh - 16px); max-height: none; }

  /* Contenido de la derecha: más corrido a la derecha y más compacto */
  .layout.home .hero, .layout.home .side {
    grid-column: 2; margin-left: 8vw; width: min(36em, calc(100% - 11vw));
  }
  .layout.home .hero { grid-row: 1; padding-top: 6vh; }
  .layout.home .side { grid-row: 2; padding-bottom: 5vh; }

  .layout.home .hero-icons { width: 8.6em; top: -.4em; }
  .layout.home .stats { gap: .7em; margin: 1.2em 0 1em; }
  .layout.home .stat { padding: 1.1em .6em; border-radius: 1.4em; }
  .layout.home .stat .num { font-size: 1.35rem; }
  .layout.home .stats .stat:nth-child(2) .num { white-space: nowrap; }
  .layout.home .bar { height: 1.7em; }
  .layout.home .card { padding: 1.1em 1.3em; border-radius: 1.4em; margin-bottom: 1em; }
  .layout.home .btn-block { padding: .8em 1em; }
  .layout.home .feed li { padding: .55em 0; }
}
