/* =============================================================================
 * QUIZ JAPONAL — Estilos. Mobile-first como prioridad absoluta.
 * App-shell: cabecera fija (progreso) · preguntas con scroll · controles fijos.
 * Identidad y paleta según el briefing (apartado 8).
 * ========================================================================== */

/* --- Fuentes -----------------------------------------------------------------
 * Briefing: Filson Pro (titulares) + Muli (cuerpo).
 *  - Muli = "Mulish" en Google Fonts → usada tal cual.
 *  - Filson Pro es de pago: stand-in "Poppins". Para fidelidad de marca,
 *    autoaloja Filson Pro y cambia --font-display abajo.
 * -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Mulish:wght@400;500;600;700;800&family=Poppins:wght@600;700;800&display=swap');

:root {
  --red: #e83700;
  --red-dark: #c72f00;
  --bg: #eee7df;
  --bg-card: #fbf8f3;
  --text: #2c2620;
  --text-soft: #6b645c;
  --olive: #a7ac3a;
  --line: #ddd4c7;

  --c-primavera: #e897ac;
  --c-verano: #427cdb;
  --c-otono: #eab83a;
  --c-invierno: #afdbde;

  --season: var(--red);

  --font-display: 'Poppins', 'Filson Pro', system-ui, sans-serif;
  --font-body: 'Mulish', 'Muli', system-ui, sans-serif;

  --radius: 16px;
  --radius-lg: 26px;
  --tile-radius: 18px;
  --shadow: 0 6px 22px rgba(44, 38, 32, 0.10);
  --shadow-lg: 0 18px 50px rgba(44, 38, 32, 0.18);
  --shadow-sel: 0 10px 28px rgba(232, 55, 0, 0.26);
  --maxw: 560px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

h1, h2 { font-family: var(--font-display); font-weight: 700; line-height: 1.18; margin: 0; }

/* --- App shell --------------------------------------------------------------- */
.page {
  height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brandbar {
  flex: 0 0 auto;
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 8px;
}
.brandbar__logo { font-family: var(--font-display); font-weight: 700; letter-spacing: .3px; font-size: 17px; }
.brandbar__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

.screen {
  width: 100%;
  max-width: var(--maxw);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 18px;
  transition: opacity .18s ease, transform .18s ease;
}
.screen.is-leaving { opacity: 0; transform: translateY(6px); }
.screen.is-entering { opacity: 0; transform: translateY(-6px); }

/* Pantallas que pueden ser más altas que el viewport: scroll + centrado seguro */
.screen--intro, .screen--result, .screen--calc { overflow-y: auto; }
.intro, .result, .calc { margin-block: auto; }

/* =============================================================================
 * INTRO
 * ========================================================================== */
.intro {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.intro__hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  height: 188px;
  background: var(--line);
}
.intro__tile { position: relative; display: block; }
.intro__tile img { width: 100%; height: 100%; object-fit: cover; }
.intro__heroglow {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom,
    transparent 58%,
    color-mix(in srgb, var(--bg-card) 55%, transparent) 80%,
    var(--bg-card) 100%);
}
.intro__content { position: relative; margin-top: -16px; padding: 6px 24px 28px; }
.intro__badge {
  display: inline-block; font-weight: 800; font-size: 12px; letter-spacing: .5px;
  color: var(--red); background: rgba(232, 55, 0, .10);
  padding: 6px 12px; border-radius: 999px; text-transform: uppercase;
}
.intro__title { font-size: 29px; font-weight: 800; margin: 14px 0 10px; letter-spacing: -.3px; }
.intro__lead { color: var(--text-soft); margin: 0 0 20px; font-size: 16px; }
.intro__points { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; }
.intro__points li { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.intro__ico { flex: 0 0 auto; font-size: 18px; width: 22px; text-align: center; }
.intro__actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

/* =============================================================================
 * PROGRESO  (cabecera fija de la pregunta)
 * ========================================================================== */
.screen--question .progress { flex: 0 0 auto; padding-top: 2px; }
.progress { width: 100%; margin-bottom: 14px; }
.progress__meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; gap: 12px; }
.progress__section {
  font-weight: 800; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; white-space: nowrap;
  color: var(--red); background: rgba(232,55,0,.09); padding: 4px 10px; border-radius: 999px;
}
.progress__count { font-size: 12px; color: var(--text-soft); white-space: nowrap; font-weight: 600; }
.progress__track { height: 8px; background: #e3dacb; border-radius: 999px; overflow: hidden; }
.progress__bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--red), #ff6a3d);
  box-shadow: 0 0 12px rgba(232,55,0,.45);
  transition: width .4s cubic-bezier(.4,0,.2,1);
}

/* =============================================================================
 * PREGUNTA
 * ========================================================================== */
.qcard { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 2px 18px; }
.qcard__title { font-size: 22px; font-family: var(--font-display); font-weight: 700; letter-spacing: -.2px; }
.qcard__title--quote::before { content: '“'; color: var(--red); }
.qcard__title--quote::after { content: '”'; color: var(--red); }
.qcard__hint { color: var(--text-soft); font-size: 14px; margin: 8px 0 0; }

.options { display: grid; gap: 12px; margin-top: 18px; }
.options--stack { grid-template-columns: 1fr; }
.options--grid { grid-template-columns: 1fr 1fr; }
.options--duo { grid-template-columns: 1fr 1fr; }

/* Entrada escalonada */
@keyframes optin { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.options .option { animation: optin .34s ease both; animation-delay: calc(var(--i, 0) * 45ms); }

.option {
  position: relative; cursor: pointer; font: inherit; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.option:focus-visible { outline: 3px solid rgba(232,55,0,.45); outline-offset: 2px; }

/* --- Opción de TEXTO --------------------------------------------------------- */
.option--text {
  background: var(--bg-card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; display: flex; align-items: center; gap: 14px; min-height: 60px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease, background .15s ease;
}
.option--text:hover { border-color: #c9bfae; }
.option--text:active { transform: scale(.99); }
.option--text.is-selected { border-color: var(--red); box-shadow: var(--shadow-sel); background: #fff; }
.option--text .option__body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.option--text .option__label { font-weight: 600; line-height: 1.35; }
.option--text .option__note { font-size: 13px; color: var(--text-soft); }
.option--text .option__mark {
  flex: 0 0 auto; width: 24px; height: 24px; border: 2px solid var(--line);
  border-radius: 50%; position: relative; transition: all .15s ease;
}
.option--text.is-selected .option__mark { border-color: var(--red); background: var(--red); animation: markpop .26s ease; }
.option--text.is-selected .option__mark::after {
  content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
/* chip de término en opciones de texto */
.option--text .chip { align-self: flex-start; margin-top: 4px; }
.option--text .term { display: block; }

/* Sí/No: un punto más de presencia */
.option--bool { min-height: 64px; }
.option--bool .option__label { font-weight: 700; }

/* --- Opción TILE (imagen inmersiva) ------------------------------------------ */
.option--tile {
  border-radius: var(--tile-radius); overflow: hidden; border: 2px solid transparent;
  background: var(--line); box-shadow: var(--shadow);
  aspect-ratio: 4 / 5;
  transition: transform .12s ease, box-shadow .18s ease, border-color .15s ease;
}
.options--duo .option--tile { aspect-ratio: 3 / 4; }
.option--tile:active { transform: scale(.985); }
.option--tile .media { position: absolute; inset: 0; width: 100%; height: 100%; }
.option--tile .media img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.option--tile .option__body {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 12px 11px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: linear-gradient(to top, rgba(20,15,10,.90), rgba(20,15,10,.35) 58%, transparent);
}
.option--tile .option__label { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.25; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.option--tile .option__note { color: rgba(255,255,255,.86); font-size: 12px; margin-top: 3px; }
.option--tile .option__mark {
  position: absolute; top: 10px; right: 10px; width: 27px; height: 27px;
  border: 2px solid rgba(255,255,255,.92); border-radius: 50%;
  background: rgba(0,0,0,.28); backdrop-filter: blur(2px); transition: all .15s ease;
}
.option--tile.is-selected { border-color: var(--red); box-shadow: 0 0 0 3px var(--red), var(--shadow-sel); }
.option--tile.is-selected .media img { transform: scale(1.07); }
.option--tile.is-selected .option__mark { background: var(--red); border-color: #fff; animation: markpop .26s ease; }
.option--tile.is-selected .option__mark::after {
  content: ''; position: absolute; left: 9px; top: 4px; width: 6px; height: 12px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
/* chip "¿Qué es?" sobre el tile (gira la tarjeta) */
.option--tile .chip {
  position: relative; z-index: 2; margin-top: 7px;
  color: #fff; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.5); backdrop-filter: blur(2px);
}

/* --- Flip 3D del tile: cara delantera ↔ trasera con la explicación ---------- */
.has-flip { perspective: 1300px; }
.tile-flip {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.option--tile.is-flipped .tile-flip { transform: rotateY(180deg); }
.tile-face {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.tile-face--back {
  transform: rotateY(180deg); color: #fff;
  background: radial-gradient(135% 135% at 100% 0%,
    color-mix(in srgb, var(--seasoncol) 42%, #1b1510), #13100b);
}
.tile-back { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 13px 13px 12px; }
.tile-back__kicker { font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: color-mix(in srgb, var(--seasoncol) 55%, #fff); }
.tile-back__term { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.1; margin: 4px 0 1px; color: #fff; }
.tile-back__lit { font-size: 11.5px; font-style: italic; color: rgba(255,255,255,.72); }
.tile-back__def { font-size: 12px; line-height: 1.4; color: rgba(255,255,255,.93); margin: 7px 0 0; flex: 1; min-height: 0; overflow-y: auto; }
.tile-back__close {
  align-self: flex-start; margin-top: 8px; cursor: pointer;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.4); color: #fff;
  border-radius: 999px; padding: 5px 12px; font: inherit; font-weight: 700; font-size: 11px;
}
.tile-back__close:hover { background: rgba(255,255,255,.26); }

@keyframes markpop { 0% { transform: scale(.55); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* --- Media (fallback a degradado tintado) ------------------------------------ */
.media { display: block; position: relative; overflow: hidden; background: var(--line); }
.media img { display: block; }
.media--empty { display: flex; align-items: center; justify-content: center; }
.media__emoji { font-size: 34px; }
.media--primavera { background: linear-gradient(135deg, #f6c1cf, var(--c-primavera)); }
.media--verano    { background: linear-gradient(135deg, #7aa6e8, var(--c-verano)); }
.media--otono     { background: linear-gradient(135deg, #f3cf78, var(--c-otono)); }
.media--invierno  { background: linear-gradient(135deg, #d4eef0, var(--c-invierno)); }
.media--neutral   { background: linear-gradient(135deg, #cfd09a, var(--olive)); }

/* Chip "¿Qué es?" */
.chip {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  color: var(--red); background: rgba(232,55,0,.08);
  border: 1px solid rgba(232,55,0,.28); border-radius: 999px; padding: 4px 11px;
}
.term { font-size: 13px; color: var(--text-soft); margin-top: 5px; }
.term[hidden] { display: none; }

/* =============================================================================
 * NAVEGACIÓN (fija abajo)
 * ========================================================================== */
.nav {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0 calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.nav__spacer { flex: 1; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 999px;
  border: 2px solid transparent; padding: 12px 22px; min-height: 48px;
  transition: background .15s ease, transform .1s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 3px solid rgba(232,55,0,.45); outline-offset: 2px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.btn--primary { background: var(--red); color: #fff; margin-left: auto; box-shadow: 0 6px 18px rgba(232,55,0,.28); }
.btn--primary:hover:not([disabled]) { background: var(--red-dark); }
.btn--lg { font-size: 17px; padding: 15px 28px; min-height: 54px; margin-left: 0; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn--ghost:hover { border-color: #c9bfae; }
.btn--link { background: transparent; color: var(--text-soft); border: none; padding: 12px 6px; }
.btn--link:hover { color: var(--text); text-decoration: underline; }

/* =============================================================================
 * CÁLCULO
 * ========================================================================== */
.calc { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.calc__orbit { display: flex; gap: 14px; }
.calc__orbit span { font-size: 32px; animation: bob 1s ease-in-out infinite; }
.calc__orbit span:nth-child(2) { animation-delay: .12s; }
.calc__orbit span:nth-child(3) { animation-delay: .24s; }
.calc__orbit span:nth-child(4) { animation-delay: .36s; }
.calc__core { display: none; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.calc__text {
  font-family: var(--font-display); font-weight: 600; font-size: 19px; color: var(--text);
  transition: opacity .16s ease, transform .16s ease;
}
.calc__text.is-swap { opacity: 0; transform: translateY(4px); }

/* =============================================================================
 * RESULTADO
 * ========================================================================== */
.result {
  width: 100%;
  background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg); border-top: 6px solid var(--season);
  animation: resultin .55s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes resultin { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }

.result__hero-wrap { position: relative; }
.result__hero { display: block; width: 100%; aspect-ratio: 16 / 10; }
.result__hero img { width: 100%; height: 100%; object-fit: cover; animation: kenburns 14s ease-out both; }
@keyframes kenburns { from { transform: scale(1.1); } to { transform: scale(1); } }
.result__emoji {
  position: absolute; left: 24px; bottom: -28px; width: 62px; height: 62px;
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  background: #fff; border-radius: 50%; border: 3px solid var(--bg-card); box-shadow: var(--shadow);
}
.result__body { padding: 40px 24px 26px; }
.result__eyebrow { font-weight: 800; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--text-soft); }
.result__title { font-size: 36px; font-weight: 800; margin: 4px 0 6px; letter-spacing: -.5px; }
.result__tagline { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: color-mix(in srgb, var(--season) 72%, #1a1a1a); margin: 0 0 16px; }
.result__blurb { color: var(--text); margin: 0 0 14px; }
.result__personal { color: var(--text-soft); font-style: italic; margin: 0 0 16px; }
.result__chips { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.result__chips li {
  background: color-mix(in srgb, var(--season) 22%, #fff);
  border: 1px solid color-mix(in srgb, var(--season) 45%, #fff);
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
}
.result__actions { display: flex; gap: 10px; }

.screen--result::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--season) 32%, var(--bg)), var(--bg));
}

/* --- Confetti ---------------------------------------------------------------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i {
  position: absolute; top: -24px; border-radius: 2px; opacity: .92;
  animation-name: fall; animation-timing-function: ease-in; animation-fill-mode: forwards;
}
@keyframes fall { to { transform: translateY(108vh) rotate(620deg); opacity: 0; } }

/* =============================================================================
 * ESCRITORIO  (mismo diseño, centrado y contenido)
 * ========================================================================== */
@media (min-width: 620px) {
  body { font-size: 18px; }
  .intro__title { font-size: 33px; }
  .qcard__title { font-size: 26px; }
  .intro__hero { height: 210px; }
}

/* =============================================================================
 * MOVIMIENTO REDUCIDO
 * ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .calc__orbit span { animation: bob 1.4s ease-in-out infinite; }
  .result__hero img { transform: none; }
}
