/**
 * Quiz de Perfil IPCH - Estilos (tipo juego, atractivo)
 * Colores alineados con IPCH. Soporta tema claro y oscuro.
 */

/* Tema oscuro (por defecto) */
:root,
[data-theme="dark"] {
  --ipch-red: #A60000;
  --ipch-red-dark: #7A0000;
  --ipch-red-light: #D32F2F;
  --ipch-green: #0a9e5c;
  --bg: #0f0f12;
  --bg-card: #1a1a1f;
  --bg-card-hover: #222228;
  --text: #f0f0f2;
  --text-muted: #9a9aa3;
  --border: #2d2d35;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema claro */
[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f2;
  --text: #1a1a1f;
  --text-muted: #5c5c66;
  --border: #e0e0e5;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .header-logo--dark { display: none !important; }
[data-theme="light"] .header-logo--light { display: block !important; }
[data-theme="dark"] .header-logo--light { display: none !important; }
[data-theme="dark"] .header-logo--dark { display: block !important; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
.header {
  text-align: center;
  padding: 1rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
}

.header-logo-img {
  max-height: 48px;
  width: auto;
  object-fit: contain;
}

.theme-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--ipch-red);
}

.theme-toggle-icon {
  width: 22px;
  height: 22px;
  position: absolute;
  opacity: 0;
  transition: opacity var(--transition);
}

.theme-icon-sun { opacity: 0; }
.theme-icon-moon { opacity: 1; }
[data-theme="light"] .theme-icon-sun { opacity: 1; }
[data-theme="light"] .theme-icon-moon { opacity: 0; }

.theme-icon-sun {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%231a1a1f'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.theme-icon-moon {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23f0f0f2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.header-sub {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Iconos */
.icon-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: middle;
}

.icon-wrap svg {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.icon-wrap--btn svg {
  width: 1.25em;
  height: 1.25em;
}

.icon-wrap--sm svg {
  width: 0.95em;
  height: 0.95em;
}

.result-card .result-icon,
.result-card .result-icon-emoji {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ipch-red);
}

.result-icon-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.result-card .result-icon svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
}

.result-retry {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.result-retry-text {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.quiz-progress-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-whatsapp svg {
  width: 1.35em;
  height: 1.35em;
  flex-shrink: 0;
}

/* Screens */
.screen {
  display: none;
  flex: 1;
  padding: 1.5rem 0;
  animation: fadeIn 0.35s ease-out;
}

.screen.active {
  display: block;
}

/* Quiz screen: ligero contenedor para dar presencia */
[data-screen="quiz"] .quiz-preguntas {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Form */
.form-intro {
  margin: 0 auto 2rem;
  text-align: center;
  max-width: 32rem;
}

.form-intro h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

.form-greeting {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.form-greeting-name {
  color: var(--ipch-red-dark);
  font-weight: 700;
}

[data-theme="light"] .form-greeting-name {
  color: var(--ipch-red);
}

.form-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-error {
  display: none;
  padding: 0.75rem 1rem;
  background: rgba(180, 0, 0, 0.15);
  color: #ff8a8a;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.form-error.visible {
  display: block;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-label input,
.form-label select {
  width: 100%;
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-label input:focus,
.form-label select:focus {
  outline: none;
  border-color: var(--ipch-red);
  box-shadow: 0 0 0 3px rgba(166, 0, 0, 0.2);
}

.form-label input::placeholder {
  color: var(--text-muted);
}

.form-legal {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0 0.5rem;
}

.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.form-checkbox input {
  margin-top: 0.25rem;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  accent-color: var(--ipch-red);
}

.form-checkbox a {
  color: var(--ipch-red);
  text-decoration: underline;
}

.form-checkbox a:hover {
  color: var(--ipch-red-light);
}

#form-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Course cards: una opci¨®n debajo de la otra, 100% ancho */
.curso-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.curso-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 1rem 1.25rem;
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  color: var(--text);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.curso-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--ipch-red);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.curso-card.selected {
  border-color: var(--ipch-red);
  background: rgba(166, 0, 0, 0.08);
  box-shadow: 0 0 0 3px rgba(166, 0, 0, 0.2);
}

.curso-card-emoji {
  font-size: 2rem;
  line-height: 1;
  margin-right: 1rem;
  flex-shrink: 0;
}

.curso-card-title {
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.2rem;
}

.curso-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.curso-card-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.curso-card .curso-card-title {
  display: block;
}

.curso-card .curso-card-desc {
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.btn:active {
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.btn-primary {
  background: var(--ipch-red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(166, 0, 0, 0.4);
}

.btn-primary:hover {
  background: var(--ipch-red-light);
  box-shadow: 0 6px 20px rgba(166, 0, 0, 0.45);
}

.btn-whatsapp {
  background: var(--ipch-green);
  color: #fff;
  text-decoration: none;
  margin-top: 1rem;
}

.btn-whatsapp:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(10, 158, 92, 0.4);
}

/* Quiz ¡ª contenedor con m¨¢s presencia */
.quiz-preguntas {
  min-height: 320px;
  padding: 1.5rem 0;
}

.quiz-preguntas.saliendo {
  animation: slideOut 0.28s ease-in forwards;
}

@keyframes slideOut {
  to {
    opacity: 0;
    transform: translateX(-12px);
  }
}

.quiz-progress {
  position: relative;
  height: 12px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.75rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ipch-red-dark), var(--ipch-red) 50%, var(--ipch-red-light));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(166, 0, 0, 0.3);
}

.quiz-progress-text {
  position: absolute;
  right: 0;
  top: -1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.game-progress {
  height: 14px;
  border-radius: 999px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.12);
}

.game-progress .quiz-progress-bar {
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 14px rgba(166, 0, 0, 0.35);
}

.game-title {
  font-size: 1.5rem;
  animation: fadeIn 0.35s ease-out;
}

.quiz-pregunta-titulo {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 1.75rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
}

.quiz-opciones {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.quiz-opcion {
  width: 100%;
  padding: 1.15rem 1.4rem;
  font: inherit;
  font-size: 1.05rem;
  text-align: left;
  color: var(--text);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .quiz-opcion {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.quiz-opcion:hover {
  background: var(--bg-card-hover);
  border-color: var(--ipch-red);
  transform: translateX(6px);
  box-shadow: 0 4px 16px rgba(166, 0, 0, 0.15);
}

.quiz-opcion:focus {
  outline: none;
  border-color: var(--ipch-red);
  box-shadow: 0 0 0 3px rgba(166, 0, 0, 0.25);
}

/* Bloque "Otro" (input y bot¨®n separados, m¨¢s aire) */
.quiz-otro-wrap {
  margin-top: 1.25rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--ipch-red);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.25s ease-out;
  box-shadow: var(--shadow);
}

.quiz-otro-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.quiz-otro-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.quiz-otro-input::placeholder {
  color: var(--text-muted);
}

.quiz-otro-input:focus {
  outline: none;
  border-color: var(--ipch-red);
  box-shadow: 0 0 0 3px rgba(166, 0, 0, 0.2);
}

.quiz-otro-btn {
  align-self: flex-start;
  margin-top: 0.5rem;
}

/* Loading */
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  text-align: center;
}

.loading-box p {
  margin: 1.25rem 0 0;
  color: var(--text-muted);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--ipch-red);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Result */
.result-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 36rem;
  margin: 0 auto;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .result-card {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.result-card--hero {
  background: linear-gradient(135deg, var(--ipch-red-dark) 0%, var(--ipch-red) 100%);
  border-color: transparent;
  text-align: center;
  padding: 1.75rem 1.5rem;
}

.result-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.85);
  margin-bottom: 0.5rem;
}

.result-titulo {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.result-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ipch-red);
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-card p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  text-align: justify;
  hyphens: auto;
}

.result-card--hero p,
.result-card--cta p {
  text-align: center;
}

.result-card--mensaje {
  border-left: 4px solid var(--ipch-red);
  background: rgba(166, 0, 0, 0.04);
}

[data-theme="dark"] .result-card--mensaje {
  background: rgba(166, 0, 0, 0.08);
}

.result-mensaje {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text);
  text-align: justify;
  line-height: 1.65;
  hyphens: auto;
}

.result-card--cta {
  text-align: center;
}

.result-card--cta .btn {
  display: inline-flex;
}

.result-card--error {
  text-align: center;
}

.result-card--error .btn {
  margin-top: 1rem;
}

/* Footer */
.footer {
  padding: 1.5rem 0 0.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .app {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 1rem;
  }

  .form-intro h1 {
    font-size: 1.5rem;
  }

  .quiz-pregunta-titulo {
    font-size: 1.2rem;
  }

  [data-screen="quiz"] .quiz-preguntas {
    padding: 1.25rem 1rem;
  }
}
