/* =========================================================================
   VLA English Placement Test — hoja de estilos
   CSS puro, sin dependencias externas (funciona sin internet).
   ========================================================================= */

:root {
  /* Paleta oficial VLA Academy (tomada del logo full color) */
  --vla-orange:      #E9511D;
  --vla-coral:       #EC6550;
  --vla-yellow:      #FCBF00;
  --vla-yellow-soft: #FFD979;
  --vla-gray:        #575550;

  --vla-blue:      #0067B2;
  --vla-blue-dark: #004E88;
  --vla-blue-soft: #EAF2FA;
  --accent:        #0067B2;
  --ok:            #1f8a4c;
  --warn:          #C88A00;
  --danger:        #E9511D;

  /* Franja tricolor que replica las barras del logo */
  --vla-stripe: linear-gradient(90deg,
      var(--vla-orange) 0%, var(--vla-coral) 26%,
      var(--vla-yellow) 50%, var(--vla-blue) 78%, var(--vla-blue-dark) 100%);

  --bg:        #f4f6fa;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --text:      #17202b;
  --text-soft: #5b6878;
  --border:    #dde3ec;
  --shadow:    0 2px 4px rgba(16, 33, 56, .06), 0 12px 28px rgba(16, 33, 56, .08);
  --radius:    14px;
  --font: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --vla-blue-soft: #16283f;
    --vla-blue:  #1E88E5;
    --vla-blue-dark: #0067B2;
    --bg:        #0f151d;
    --surface:   #161e28;
    --surface-2: #1b242f;
    --text:      #e7edf5;
    --text-soft: #9fb0c3;
    --border:    #2a3644;
    --shadow:    0 2px 4px rgba(0,0,0,.3), 0 12px 28px rgba(0,0,0,.35);
    --accent:    #4d9ae8;
  }
}

* { box-sizing: border-box; }

/* Las reglas con display explícito (.btn, .nav-overlay…) ganan al UA stylesheet;
   sin esto el atributo hidden no oculta nada. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------- Pantallas ---------------------------- */
.screen { display: none; }
.screen.active { display: block; }

.center-card,
.login-wrap,
.results-wrap {
  min-height: 100vh;
  min-height: 100dvh;          /* en celular descuenta la barra del navegador */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 16px;
}

.center-card { flex-direction: column; text-align: center; gap: 14px; }

/* ---------------------------- Spinner ---------------------------- */
.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------- Marca ---------------------------- */
.brand { text-align: center; }
.brand h1 { font-size: 1.2rem; margin: 10px 0 0; line-height: 1.25; }
.brand-sub { margin: 2px 0 0; color: var(--text-soft); font-size: .85rem; }

.logo { width: 132px; max-width: 55%; height: auto; display: block; margin: 0 auto; }
.logo.sm { width: 76px; margin: 0; }
.logo.res { width: 140px; margin: 0 0 14px; }

/* Franja de marca en la cabecera de las tarjetas */
.striped { position: relative; overflow: hidden; }
.striped::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0;
  height: 5px; background: var(--vla-stripe);
}

/* ---------------------------- Login ---------------------------- */
.login-card {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.login-card label {
  display: block; margin: 12px 0 5px;
  font-size: .86rem; font-weight: 600; color: var(--text-soft);
}
.login-card input {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: .96rem;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 119, 209, .16);
}
.req { color: var(--danger); }
.opt { color: var(--text-soft); font-weight: 400; }

.form-error {
  margin: 14px 0 0; padding: 9px 12px;
  background: rgba(192, 57, 43, .1); color: var(--danger);
  border-radius: 8px; font-size: .87rem;
}

.exam-facts {
  margin: 18px 0 0; padding: 12px 14px;
  background: var(--vla-blue-soft);
  border-radius: 10px; font-size: .84rem;
}
.exam-facts b { color: var(--text); }
.exam-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }

.fineprint {
  margin: 14px 0 0; text-align: center;
  font-size: .76rem; color: var(--text-soft);
}

/* ---------------------------- Botones ---------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px;
  border: 1px solid transparent; border-radius: 9px;
  font: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--vla-blue); color: #fff; }
.btn-primary:hover { background: var(--vla-blue-dark); }
.btn-ghost {
  background: transparent; color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; margin-top: 14px; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------------------- Portada de sección ---------------------------- */
.intro-card {
  width: 100%; max-width: 720px;
  max-height: calc(100dvh - 36px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px 20px;
}
.intro-banner {
  max-width: 190px; max-height: 92px; width: auto;
  height: auto; margin: 0 auto 10px; object-fit: contain;
}
.intro-card h2 { margin: 0 0 10px; font-size: 1.3rem; text-align: center; }
/* solo las instrucciones se desplazan: el boton nunca queda fuera de pantalla */
.intro-scroll {
  flex: 1 1 auto; overflow-y: auto; min-height: 0;
  text-align: left; color: var(--text-soft); font-size: .93rem;
  padding-right: 6px;
}
.intro-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.intro-meta {
  display: inline-block; padding: 6px 13px;
  background: var(--vla-blue-soft); border-radius: 999px;
  font-size: .82rem; font-weight: 600;
}


/* ------------- Login: dos columnas cuando hay ancho de sobra ------------- */
.login-grid { display: grid; gap: 0; }

@media (min-width: 880px) {
  .login-card { max-width: 840px; padding: 30px 34px; }
  .login-grid {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 34px;
    align-items: center;
  }
  .login-aside {
    border-right: 1px solid var(--border);
    padding-right: 32px;
  }
  .login-main .fineprint { text-align: left; }
  .logo { width: 168px; max-width: 100%; }
  .brand h1 { font-size: 1.3rem; }
}

/* Pantallas de poca altura (portátiles de 768 px): todo un punto mas compacto */
@media (max-height: 780px) {
  .login-card label { margin: 9px 0 4px; font-size: .82rem; }
  .login-card input { padding: 9px 12px; font-size: .92rem; }
  .exam-facts { margin-top: 14px; padding: 10px 13px; font-size: .8rem; }
  .logo { width: 118px; }
  .brand h1 { font-size: 1.1rem; }
  .intro-card { padding: 18px 22px 16px; }
  .intro-banner { max-height: 70px; }
  .intro-card h2 { font-size: 1.15rem; }
  .intro-scroll { font-size: .89rem; }
}

/* ---------------------------- Barra superior ---------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.section-label { font-weight: 600; font-size: .92rem; }

.timer {
  min-width: 76px; padding: 6px 12px;
  background: var(--vla-blue-soft); color: var(--vla-blue);
  border-radius: 8px; font-variant-numeric: tabular-nums;
  font-weight: 700; text-align: center;
}
@media (prefers-color-scheme: dark) { .timer { color: #9ecbff; } }
.timer.warning { background: rgba(184, 134, 11, .16); color: var(--warn); }
.timer.danger  { background: rgba(192, 57, 43, .16); color: var(--danger); }

/* ---------------------------- Progreso ---------------------------- */
.progress { height: 5px; background: var(--border); }
.progress-fill {
  height: 100%; width: 0;
  background: var(--vla-stripe);
  background-size: 340px 100%;
  transition: width .25s ease;
}
.progress-text {
  margin: 6px 18px 0; font-size: .78rem; color: var(--text-soft);
}

/* ---------------------------- Cuerpo del examen ---------------------------- */
.exam-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 18px 96px;
}
.exam-main.two-col { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }

.context-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* el pasaje queda fijo mientras se responden sus preguntas */
.two-col .context-panel { position: sticky; top: 76px; max-height: calc(100dvh - 215px); }
.context-inner { padding: 20px 22px; overflow-y: auto; max-height: inherit; }
.context-title {
  margin: 0 0 12px; font-size: 1.02rem; color: var(--vla-blue);
  border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
@media (prefers-color-scheme: dark) { .context-title { color: #9ecbff; } }
.passage { font-size: .97rem; }
.passage p { margin: 0 0 12px; }

.audio-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px; margin-bottom: 14px;
}
.audio-box audio { width: 100%; display: block; }
.audio-plays { margin: 8px 0 0; font-size: .8rem; color: var(--text-soft); }

.question-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  align-self: start;
}
.question-inner { padding: 24px 26px; }
.q-number {
  margin: 0 0 10px;
  font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-soft);
}
.q-stem { font-size: 1.08rem; font-weight: 600; margin-bottom: 20px; }

/* ---------------------------- Opciones ---------------------------- */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--accent); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option .key {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); border-radius: 50%;
  background: var(--surface);
  font-size: .8rem; font-weight: 700; color: var(--text-soft);
}
.option .label { flex: 1; }
.option.selected {
  border-color: var(--accent);
  background: var(--vla-blue-soft);
}
.option.selected .key {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ---------------------------- Barra inferior ---------------------------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.answered-count { font-size: .82rem; color: var(--text-soft); }

/* ---------------------------- Navegador ---------------------------- */
.nav-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 20, 34, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px;
  overflow-y: auto;
}
.nav-panel {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.nav-head { display: flex; align-items: center; justify-content: space-between; }
.nav-head h3 { margin: 0; font-size: 1.05rem; }
.nav-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px;
  margin: 16px 0;
}
.nav-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface-2);
  font-size: .78rem; font-weight: 600;
  cursor: pointer;
}
.nav-cell:hover { border-color: var(--accent); }
.nav-cell.done { background: var(--vla-blue-soft); border-color: var(--accent); }
.nav-cell.current { background: var(--vla-blue); border-color: var(--vla-blue); color: #fff; }

.nav-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: .78rem; color: var(--text-soft); margin-bottom: 6px;
}
.nav-legend span { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 12px; height: 12px; border-radius: 4px;
  border: 1.5px solid var(--border); background: var(--surface-2);
  display: inline-block;
}
.dot.done { background: var(--vla-blue-soft); border-color: var(--accent); }
.dot.current { background: var(--vla-blue); border-color: var(--vla-blue); }

/* ---------------------------- Resultados ---------------------------- */
.results-card {
  width: 100%; max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 34px;
}
.results-eyebrow {
  margin: 0; font-size: .76rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft);
}
.results-card h2 { margin: 4px 0 22px; font-size: 1.55rem; }

.level-badge {
  display: flex; align-items: center; gap: 20px;
  padding: 22px 24px;
  background: linear-gradient(135deg, var(--vla-blue-dark), #4A8AC9);
  color: #fff; border-radius: 12px;
}
.level-cefr { font-size: 2.9rem; font-weight: 800; line-height: 1; }
.level-program { margin: 0; font-size: 1.12rem; font-weight: 700; }
.level-content { margin: 2px 0 0; opacity: .9; font-size: .92rem; }

.score-row {
  display: flex; align-items: center; gap: 24px;
  margin: 24px 0 8px; padding: 18px 22px;
  background: var(--surface-2); border-radius: 12px;
}
.score-big { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.score-big small { font-size: 1.1rem; color: var(--text-soft); font-weight: 600; }
.score-meta p { margin: 0; }
.muted { color: var(--text-soft); font-size: .87rem; }

.breakdown-title { margin: 28px 0 12px; font-size: 1.05rem; }
.breakdown { display: flex; flex-direction: column; gap: 14px; }
.bd-item { }
.bd-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .9rem; margin-bottom: 6px;
}
.bd-head b { font-size: .95rem; }
.bd-bar { height: 9px; background: var(--border); border-radius: 999px; overflow: hidden; }
.bd-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bd-fill.low  { background: var(--danger); }
.bd-fill.mid  { background: var(--warn); }
.bd-fill.high { background: var(--ok); }

.res-note {
  margin: 24px 0 0; padding: 16px 18px;
  background: var(--vla-blue-soft); border-radius: 10px;
  font-size: .92rem;
}
.results-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 26px;
}

/* ---------------------------- Contenido enriquecido ---------------------------- */
.rich img { max-width: 100%; height: auto; }
.rich p:first-child { margin-top: 0; }
.rich p:last-child { margin-bottom: 0; }

/* ---------------------------- Responsivo ---------------------------- */
@media (max-width: 900px) {
  .exam-main.two-col { grid-template-columns: 1fr; }
  .two-col .context-panel { position: static; max-height: 340px; }
  .context-inner { max-height: 340px; }
  .question-inner { padding: 20px 18px; }
  .nav-grid { grid-template-columns: repeat(8, 1fr); }
  .level-badge { flex-direction: column; align-items: flex-start; gap: 10px; }
  .results-card, .login-card { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .nav-grid { grid-template-columns: repeat(6, 1fr); }
  .section-label { display: none; }
  .btn { padding: 10px 14px; }
}

/* ---------------------------- Impresión ---------------------------- */
@media print {
  .results-actions, .fineprint { display: none; }
  body { background: #fff; }
  .results-card { box-shadow: none; border: none; max-width: 100%; }
  .level-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
