/* ==========================================================================
   Ruta Gamificada · Vía Verde del Aceite
   Tokens de color portados del catálogo Assets.xcassets/colors de la app iOS.
   ========================================================================== */

/* Tema claro: valores por defecto. El tema oscuro se aplica por preferencia del
   sistema o, si el usuario ha pulsado el botón, por el atributo data-theme del
   elemento raíz (que siempre gana sobre la preferencia del sistema). */

:root {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-bg-alt: #e3f5ee;
  --color-text-primary: #1a1a1a;
  --color-button-featured: #178f61;
  --color-buttons-secondary: #006f71;
  --btn-background: #000000;
  --btn-text: #ffffff;
  --color-sombra: #7b3fa0;
  --color-ok: #1f8a3b;
  --color-ko: #c62828;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --color-bg: #121212;
    --color-bg-alt: #16241e;
    --color-text-primary: #f5f5f5;
    --color-button-featured: #1a9466;
    --color-buttons-secondary: #0c8082;
    --btn-background: #ffffff;
    --btn-text: #000000;
    --color-sombra: #b07ad0;
    --color-ok: #4caf6a;
    --color-ko: #ef6c6c;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --color-bg: #121212;
  --color-bg-alt: #16241e;
  --color-text-primary: #f5f5f5;
  --color-button-featured: #1a9466;
  --color-buttons-secondary: #0c8082;
  --btn-background: #ffffff;
  --btn-text: #000000;
  --color-sombra: #b07ad0;
  --color-ok: #4caf6a;
  --color-ko: #ef6c6c;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
}

button[disabled] {
  cursor: default;
}

/* --------------------------------------------------------------------------
   Botones (AppButton)
   -------------------------------------------------------------------------- */

.vv-btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.vv-btn:active {
  transform: scale(0.98);
}

.vv-btn--primary {
  background: var(--btn-background);
  color: var(--btn-text);
}

.vv-btn--secondary {
  background: transparent;
  color: var(--color-buttons-secondary);
  border: 2px solid var(--color-buttons-secondary);
}

.vv-btn--block {
  display: block;
  width: 100%;
}

.vv-icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: none;
  border-radius: 50%;
  background: var(--color-bg-alt);
  color: var(--color-text-primary);
  font-size: 15px;
  line-height: 1;
}

/* Interruptor de tema claro / oscuro */
.vv-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  border: 1.5px solid rgba(128, 128, 128, 0.35);
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-primary);
  font-size: 15px;
  line-height: 1;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.vv-theme-btn:hover {
  border-color: var(--color-button-featured);
  background: var(--color-bg-alt);
}

/* --------------------------------------------------------------------------
   Tipografía compartida
   -------------------------------------------------------------------------- */

.vv-eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-button-featured);
}

.vv-title {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 900;
  line-height: 1.15;
}

.vv-lead {
  margin: 0;
  font-size: 0.98rem;
  opacity: 0.85;
}

.vv-card {
  background: var(--color-bg-alt);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.vv-card__title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
}

.vv-question {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.vv-question__img {
  width: 100%;
  max-height: 46vh;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.vv-hint {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* --------------------------------------------------------------------------
   Portada
   -------------------------------------------------------------------------- */

.vv-intro__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.vv-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.vv-langs {
  display: flex;
  gap: 6px;
}

.vv-lang {
  border: 1.5px solid rgba(128, 128, 128, 0.35);
  background: transparent;
  color: var(--color-text-primary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.vv-lang.is-active {
  background: var(--color-button-featured);
  border-color: var(--color-button-featured);
  color: #fff;
}

.vv-characters,
.vv-pieces,
.vv-choices,
.vv-order,
.vv-grid {
  list-style: none;
  margin: 0;
  padding: 0;
}

.vv-characters {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vv-character {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vv-character__avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-bg);
}

.vv-character__name {
  margin: 0;
  font-weight: 700;
  color: var(--vv-accent, var(--color-text-primary));
}

.vv-character__desc {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.65;
}

/* Acentos por personaje (mismos colores que characterAccentColor en SwiftUI) */
.vv-accent--donMateo { --vv-accent: var(--color-button-featured); }
.vv-accent--clara { --vv-accent: var(--color-buttons-secondary); }
.vv-accent--senorSombra { --vv-accent: var(--color-sombra); }

.vv-pieces {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.vv-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  font-size: 0.72rem;
}

.vv-piece img {
  height: 52px;
  object-fit: contain;
}

.vv-piece--locked img {
  filter: grayscale(1);
  opacity: 0.4;
}

/* --------------------------------------------------------------------------
   Juego · barra superior
   -------------------------------------------------------------------------- */

.vv-game {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.vv-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
}

.vv-topbar__center {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.vv-topbar__location {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vv-topbar__step {
  margin: 4px 0 0;
  font-size: 0.7rem;
  opacity: 0.55;
}

.vv-progress {
  margin: 6px auto 0;
  max-width: 160px;
  height: 4px;
  border-radius: 4px;
  background: var(--color-bg-alt);
  overflow: hidden;
}

.vv-progress__fill {
  height: 100%;
  background: var(--color-button-featured);
  transition: width 0.3s ease;
}

.vv-passport-btn {
  position: relative;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  border: none;
  background: transparent;
}

.vv-passport-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.vv-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-button-featured);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.vv-game__content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Narrativa
   -------------------------------------------------------------------------- */

.vv-narrative {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  gap: 16px;
}

.vv-narrative__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vv-narrative__who {
  display: flex;
  align-items: center;
  gap: 16px;
}

.vv-narrative__avatar {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  background: var(--color-bg-alt);
}

.vv-narrative__name {
  margin: 0;
  font-weight: 700;
  color: var(--vv-accent, var(--color-text-primary));
}

.vv-bubble {
  background: var(--color-bg-alt);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  font-size: 0.96rem;
}

.vv-audio-btn {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--vv-accent, var(--color-button-featured));
  background: transparent;
  color: var(--vv-accent, var(--color-button-featured));
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

.vv-audio-btn.is-playing {
  background: color-mix(in srgb, var(--vv-accent, var(--color-button-featured)) 12%, transparent);
}

.vv-audio-btn__icon {
  font-size: 0.75rem;
}

.vv-narrative__footer {
  padding-top: 4px;
}

/* --------------------------------------------------------------------------
   Pruebas
   -------------------------------------------------------------------------- */

.vv-test {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.vv-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vv-choice {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(128, 128, 128, 0.3);
  background: var(--color-bg-alt);
  color: var(--color-text-primary);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.vv-choice__radio {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.35;
  position: relative;
}

.vv-choice.is-correct,
.vv-choice.is-wrong {
  opacity: 1;
}

.vv-choice.is-correct {
  border-color: var(--color-ok);
  background: color-mix(in srgb, var(--color-ok) 14%, var(--color-bg));
}

.vv-choice.is-correct .vv-choice__radio {
  border-color: var(--color-ok);
  opacity: 1;
}

.vv-choice.is-wrong {
  border-color: var(--color-ko);
  background: color-mix(in srgb, var(--color-ko) 14%, var(--color-bg));
}

.vv-choice.is-wrong .vv-choice__radio {
  border-color: var(--color-ko);
  opacity: 1;
}

.vv-choice.is-correct .vv-choice__radio::after,
.vv-choice.is-wrong .vv-choice__radio::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: currentColor;
}

.vv-choice.is-dimmed {
  opacity: 0.55;
  border-color: rgba(128, 128, 128, 0.15);
}

.vv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.vv-tile {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: var(--color-bg-alt);
  color: var(--color-text-primary);
  font-size: 0.8rem;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.vv-tile img {
  height: 90px;
  width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.vv-tile.is-selected {
  border-color: var(--color-button-featured);
  background: color-mix(in srgb, var(--color-button-featured) 15%, var(--color-bg));
}

.vv-tile.is-locked {
  opacity: 0.5;
}

.vv-tile__check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-button-featured);
  color: #fff;
  font-size: 0.75rem;
  line-height: 22px;
}

/* Ordenar secuencia */

.vv-order {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vv-order__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}

.vv-order__row.is-dragging {
  opacity: 0.4;
}

.vv-order__row.is-drop-target {
  outline: 2px dashed var(--color-button-featured);
  outline-offset: 2px;
}

.vv-order__num {
  width: 28px;
  flex: 0 0 28px;
  font-size: 1.2rem;
  font-weight: 900;
  opacity: 0.35;
  text-align: center;
}

.vv-order__img {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.vv-order__text {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 0.92rem;
}

.vv-order__moves {
  display: flex;
  flex-direction: column;
}

.vv-move {
  width: 44px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--color-button-featured);
  font-size: 0.85rem;
}

.vv-move[disabled] {
  color: rgba(128, 128, 128, 0.35);
}

.vv-order__handle {
  opacity: 0.3;
  font-size: 1.1rem;
}

/* Tocar en la imagen */

.vv-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 7;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg-alt);
}

.vv-scene__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vv-spot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  padding: 0;
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.vv-spot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 5px;
}

.vv-spot.is-correct { border-color: var(--color-ok); }
.vv-spot.is-wrong { border-color: var(--color-ko); }
.vv-spot.is-dimmed { opacity: 0.4; }

.vv-spot__mark {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 24px;
}

.vv-spot.is-correct .vv-spot__mark { color: var(--color-ok); }
.vv-spot.is-wrong .vv-spot__mark { color: var(--color-ko); }

/* --------------------------------------------------------------------------
   Feedback
   -------------------------------------------------------------------------- */

.vv-feedback {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.vv-feedback__banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 150px;
  padding: 16px;
  background: color-mix(in srgb, var(--color-button-featured) 12%, var(--color-bg));
}

.vv-feedback__banner img {
  height: 100px;
  object-fit: contain;
}

.vv-feedback__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
}

.vv-feedback__title--ok { color: var(--color-ok); }
.vv-feedback__title--ko { color: var(--color-ko); }

.vv-feedback--ko {
  align-items: center;
  justify-content: center;
  gap: 20px;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px;
  text-align: center;
}

.vv-feedback__img {
  height: 120px;
  object-fit: contain;
}

.vv-feedback__text {
  margin: 0;
  opacity: 0.7;
}

.vv-feedback--ko .vv-btn {
  max-width: 360px;
  margin-top: auto;
}

/* --------------------------------------------------------------------------
   Modales (curiosidad, recompensa, pasaporte)
   -------------------------------------------------------------------------- */

.vv-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
}

.vv-modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
  border-radius: var(--radius-xl);
  background: var(--color-bg);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.vv-modal__title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 900;
}

.vv-modal__sub {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.6;
}

.vv-modal__eyebrow {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.vv-modal__text {
  margin: 0;
  font-size: 0.95rem;
}

.vv-modal__reward {
  height: 120px;
  object-fit: contain;
}

.vv-modal__reward-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-button-featured);
}

.vv-modal__passport {
  width: 100%;
  object-fit: contain;
}

/* --------------------------------------------------------------------------
   Pantalla final
   -------------------------------------------------------------------------- */

.vv-end {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.vv-end__header {
  text-align: center;
}

.vv-end__icon {
  margin: 0 0 8px;
  font-size: 3.5rem;
  line-height: 1;
}

.vv-diploma {
  border: 2px solid var(--color-button-featured);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
}

.vv-diploma__icon {
  margin: 0 0 8px;
  font-size: 3rem;
  line-height: 1;
}

.vv-diploma__title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 700;
}

.vv-diploma__sub {
  margin: 0;
  opacity: 0.7;
  font-size: 0.95rem;
}

.vv-end__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Escritorio
   -------------------------------------------------------------------------- */

@media (min-width: 720px) {
  .vv-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .vv-btn--block {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }
}

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