/* ══════════════════════════════════════════════════
   UASD · Autoevaluación · Sistemas Operativos
   INF-3240-14 · Lic. José Binet González · Virtual
   ══════════════════════════════════════════════════ */

:root {
  --navy:       #0a1f44;
  --blue:       #1a3a6e;
  --blue-lt:    #2756a8;
  --gold:       #c9a227;
  --gold-lt:    #e8c55a;
  --gold-bg:    rgba(201,162,39,.08);
  --white:      #ffffff;
  --off:        #f4f6fb;
  --text:       #1c2742;
  --muted:      #6b7a99;
  --border:     #dde3f0;
  --correct:    #1a7f55;
  --wrong:      #b92d2d;
  --correct-bg: #edfaf3;
  --wrong-bg:   #fdf0f0;
  --r:          14px;
  --shadow:     0 8px 32px rgba(10,31,68,.10);
  --tr:         .26s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
  background: var(--off);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ══ HEADER ══════════════════════════════════════════ */
.inst-header {
  background: var(--navy);
  color: var(--white);
  padding: 1.2rem 1.5rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.3);
}
.inst-header__inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding-bottom: 1.1rem;
  flex-wrap: wrap;
}

/* Escudo real */
.escudo-wrap { flex-shrink: 0; position: relative; }
.escudo-img  { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.escudo-fallback {
  display: none;
  width: 56px; height: 56px;
  background: var(--gold);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px rgba(201,162,39,.35);
}
.escudo-ring {
  width: 44px; height: 44px;
  border: 2px solid var(--navy);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.escudo-text {
  font-family: 'Playfair Display', serif;
  font-size: .65rem; font-weight: 700;
  color: var(--navy); letter-spacing: .05em;
}

.inst-header__info { flex: 1; min-width: 0; }
.inst-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(.9rem, 2.5vw, 1.15rem);
  font-weight: 700; line-height: 1.25;
}
.inst-sub { font-size: clamp(.68rem, 1.8vw, .78rem); color: #b0bcd4; margin-top: .15rem; }
.inst-header__stripe {
  height: 4px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-lt) 50%, var(--gold) 100%);
}

/* ══ CONTAINER ═══════════════════════════════════════ */
.container {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ══ SCREENS ══════════════════════════════════════════ */
.screen { animation: fadeUp .42s ease both; }
.screen.hidden  { display: none !important; }
.screen.active  { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══ CARD ═════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 4vw, 2.4rem) clamp(1.2rem, 4vw, 2.4rem);
  border-top: 4px solid var(--gold);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 140px; height: 140px;
  background: radial-gradient(circle at top right, rgba(201,162,39,.07), transparent 70%);
  pointer-events: none;
}
.card__badge {
  display: inline-block;
  background: var(--navy); color: var(--gold);
  font-size: .7rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .25rem .7rem; border-radius: 4px;
  margin-bottom: .85rem;
}
.card__title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.3rem, 3.5vw, 1.8rem);
  color: var(--navy); line-height: 1.25;
}
.card__subtitle { font-size: .92rem; color: var(--muted); margin-top: .3rem; }
.divider { height: 1px; background: var(--border); margin: 1.4rem 0; }

/* ══ META GRID ════════════════════════════════════════ */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px,1fr));
  gap: .55rem .8rem;
}
.meta-item { display: flex; flex-direction: column; gap: .1rem; }
.meta-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.meta-val   { font-size: .88rem; color: var(--text); font-weight: 600; }

/* ══ FORM ═════════════════════════════════════════════ */
.form-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem; color: var(--blue);
  margin-bottom: .9rem;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.field input {
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .94rem; font-family: inherit;
  color: var(--text); background: var(--off);
  transition: border-color var(--tr), box-shadow var(--tr);
  outline: none; width: 100%;
  -webkit-appearance: none;
}
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,162,39,.18);
  background: #fff;
}

.timer-notice {
  margin-top: 1.1rem;
  font-size: .83rem;
  color: var(--muted);
  background: #fffbf0;
  border: 1px solid #f0d890;
  border-radius: 8px;
  padding: .65rem 1rem;
  line-height: 1.5;
}

.error-msg { color: var(--wrong); font-size: .83rem; margin-top: .6rem; font-weight: 600; }
.hidden    { display: none !important; }

/* ══ BUTTONS ══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .72rem 1.5rem;
  border: none; border-radius: 8px;
  font-size: .93rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: transform var(--tr), box-shadow var(--tr), background var(--tr);
  letter-spacing: .02em; text-align: center;
  -webkit-appearance: none;
}
.btn--primary {
  background: var(--navy); color: var(--gold);
  margin-top: 1.4rem;
  box-shadow: 0 4px 14px rgba(10,31,68,.18);
}
.btn--primary:hover { background: var(--blue); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(10,31,68,.22); }
.btn--outline {
  background: transparent; color: var(--navy);
  border: 2px solid var(--navy); margin-top: 1.4rem;
}
.btn--outline:hover { background: var(--navy); color: var(--gold); transform: translateY(-2px); }
.btn-arrow { font-size: 1.05rem; transition: transform var(--tr); }
.btn:hover .btn-arrow { transform: translateX(4px); }
.btn--next { margin-top: 1.3rem; width: 100%; justify-content: center; }

/* ══ TIMER ════════════════════════════════════════════ */
.timer-box {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 7px;
  padding: 4px 10px;
  font-size: clamp(12px,2.5vw,14px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: var(--gold);
  white-space: nowrap;
}
.timer-box.warning {
  background: rgba(185,45,45,.2);
  border-color: #e57373;
  color: #ff8a80;
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.5} }
.timer-icon { font-size: 13px; }

/* ══ PROGRESS ════════════════════════════════════════ */
.progress-bar-wrap {
  height: 5px; background: var(--border);
  border-radius: 10px; margin-bottom: 1.4rem; overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-lt));
  border-radius: 10px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
  width: 0%;
}

/* ══ QUESTION HEADER ═════════════════════════════════ */
.q-header {
  display: flex; justify-content: space-between;
  align-items: center; gap: .5rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.q-counter {
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted);
}
.q-tags { display: flex; gap: .4rem; flex-wrap: wrap; }
.q-type-label {
  font-size: .68rem; background: var(--navy); color: var(--gold);
  padding: .18rem .55rem; border-radius: 4px;
  font-weight: 700; letter-spacing: .04em;
}
.q-topic {
  font-size: .68rem; background: var(--gold-bg); color: #7a5a00;
  padding: .18rem .55rem; border-radius: 4px;
  font-weight: 700; letter-spacing: .04em;
}
.q-text {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1rem, 2.8vw, 1.12rem);
  color: var(--navy); line-height: 1.55;
  margin-bottom: 1.2rem;
}
.q-hint {
  font-size: .8rem; color: var(--muted);
  background: #fffbf0;
  border-left: 3px solid var(--gold);
  padding: .5rem .8rem;
  border-radius: 0 6px 6px 0;
  margin-bottom: .85rem;
}

/* ══ OPTIONS ═════════════════════════════════════════ */
.options-list { display: flex; flex-direction: column; gap: .55rem; }
.option-btn {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .82rem 1rem;
  background: var(--off);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: inherit; font-size: .9rem;
  color: var(--text); cursor: pointer; text-align: left;
  transition: border-color var(--tr), background var(--tr), transform var(--tr);
  -webkit-appearance: none; width: 100%;
}
.option-btn:hover { border-color: var(--gold); background: #fffbf0; transform: translateX(3px); }
.option-btn.selected { border-color: var(--blue); background: #eef2fb; color: var(--navy); font-weight: 600; }

.option-letter {
  flex-shrink: 0; width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
}
.option-btn.selected .option-letter { background: var(--blue); }

.option-checkbox {
  flex-shrink: 0; width: 20px; height: 20px;
  border-radius: 5px; border: 2px solid var(--border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--tr); margin-top: 2px;
}
.option-checkbox.checked { background: var(--navy); border-color: var(--navy); }
.option-checkbox.checked::after { content: '✓'; color: var(--gold); font-size: .72rem; font-weight: 700; }

/* ══ VERDADERO/FALSO (vof1) ══════════════════════════ */
.vof1-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--off);
  padding: 1.3rem 1.3rem 1.1rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.vof1-enun { font-size: .96rem; line-height: 1.6; color: var(--text); }
.vof1-btns { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.vof1-btn {
  flex: 1; max-width: 200px; min-width: 120px;
  padding: .85rem 1rem; border-radius: 9px;
  border: 2px solid var(--border);
  font-family: inherit; font-size: .95rem; font-weight: 700;
  cursor: pointer; background: #fff;
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  transition: all var(--tr); -webkit-appearance: none;
}
.vof1-icon { font-size: 1rem; }
.vof1-btn--verdadero:hover { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); }
.vof1-btn--falso:hover      { border-color: var(--wrong);   background: var(--wrong-bg);   color: var(--wrong); }
.vof1-btn.selected.vof1-btn--verdadero { background: var(--correct); color: #fff; border-color: var(--correct); box-shadow: 0 4px 12px rgba(26,127,85,.25); }
.vof1-btn.selected.vof1-btn--falso     { background: var(--wrong);   color: #fff; border-color: var(--wrong);   box-shadow: 0 4px 12px rgba(185,45,45,.25); }

/* ══ APAREAMIENTO ════════════════════════════════════ */
.aparea-container {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .9rem; margin-bottom: .7rem;
}
.aparea-col { display: flex; flex-direction: column; gap: .45rem; }
.aparea-btn {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .85rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--off); font-family: inherit;
  font-size: .86rem; color: var(--text);
  cursor: pointer; text-align: left;
  transition: all var(--tr); -webkit-appearance: none;
}
.aparea-btn:hover:not(.matched) { border-color: var(--gold); background: #fffbf0; }
.aparea-btn.active-sel { border-color: var(--blue); background: #eef2fb; box-shadow: 0 0 0 2px rgba(26,58,110,.18); }
.aparea-btn.matched    { border-color: var(--correct); background: var(--correct-bg); cursor: default; opacity: .85; }
.aparea-letter {
  flex-shrink: 0; width: 22px; height: 22px;
  border-radius: 50%; background: var(--navy); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700;
}
.aparea-btn.matched .aparea-letter { background: var(--correct); }
.aparea-estado {
  font-size: .76rem; color: var(--muted); background: var(--off);
  padding: .4rem .7rem; border-radius: 6px; margin-top: .3rem;
  min-height: 1.5rem; border: 1px dashed var(--border);
}

/* ══ STUDENT RESULT CARD ═════════════════════════════ */
.student-result-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  border-radius: 12px;
  padding: 1.1rem 1.4rem;
  margin: 1rem 0;
  display: flex; flex-direction: column; gap: .7rem;
}
.src-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px,1fr));
  gap: .6rem;
}
.src-row--meta { border-top: 1px solid rgba(255,255,255,.15); padding-top: .7rem; }
.src-item { display: flex; flex-direction: column; gap: .15rem; }
.src-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.55); }
.src-val   { font-size: .88rem; font-weight: 700; color: var(--gold-lt); word-break: break-word; }

/* ══ SCORE ═══════════════════════════════════════════ */
.score-circle-wrap { display: flex; justify-content: center; margin: 1.4rem 0 1rem; }
.score-circle {
  width: clamp(120px,20vw,148px);
  height: clamp(120px,20vw,148px);
  border-radius: 50%;
  border: 6px solid var(--gold);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  box-shadow: 0 0 0 10px rgba(201,162,39,.09);
  background: #fff;
  animation: popIn .5s cubic-bezier(.34,1.56,.64,1) both;
  transition: border-color .5s;
}
@keyframes popIn { from{transform:scale(.5);opacity:0} to{transform:scale(1);opacity:1} }
.score-num   { font-family: 'Playfair Display', serif; font-size: clamp(1.5rem,4vw,2rem); font-weight: 700; color: var(--navy); line-height: 1; transition: color .5s; }
.score-pct   { font-size: clamp(.85rem,2vw,1rem); font-weight: 700; color: var(--muted); margin-top: .1rem; transition: color .5s; }
.score-label { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .15rem; }

.score-msg {
  text-align: center; font-size: .92rem; font-weight: 600;
  background: var(--off); border-radius: 10px;
  padding: .9rem 1.1rem; line-height: 1.6;
  border-left: 4px solid var(--gold);
  transition: color .5s; margin-bottom: .5rem;
}
.review-heading {
  font-family: 'Playfair Display', serif;
  font-size: 1rem; color: var(--navy); margin-bottom: .9rem;
}

/* ══ REVIEW LIST ══════════════════════════════════════ */
.review-list { display: flex; flex-direction: column; gap: .8rem; }
.review-item {
  padding: .9rem 1.1rem; border-radius: 10px; border-left: 4px solid;
  animation: fadeUp .3s ease both;
}
.review-item.correct { border-color: var(--correct); background: var(--correct-bg); }
.review-item.wrong   { border-color: var(--wrong);   background: var(--wrong-bg); }

.review-item__header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: .45rem; flex-wrap: wrap; gap: .3rem;
}
.review-badge {
  font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: .15rem .5rem; border-radius: 4px;
  background: var(--navy); color: var(--gold);
}
.review-badge--multiple    { background: #2a6099; color: #fff; }
.review-badge--apareamiento{ background: #5a2a7a; color: #fff; }
.review-badge--vof1        { background: #7a5a00; color: #fff; }

.review-status { font-size: .78rem; font-weight: 700; }
.rs-ok  { color: var(--correct); }
.rs-bad { color: var(--wrong); }

.review-item__q   { font-weight: 700; font-size: .86rem; margin-bottom: .4rem; color: var(--navy); }
.review-item__row { font-size: .81rem; color: var(--text); display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: .25rem; }
.ri-label { font-weight: 700; color: var(--muted); flex-shrink: 0; }
.ri-fix   { color: var(--correct); font-weight: 700; font-size: .78rem; }
.tag-correct { color: var(--correct); font-weight: 700; }
.tag-wrong   { color: var(--wrong);   font-weight: 700; }

.aparea-row { align-items: center; gap: .4rem; }
.aparea-tag  { font-weight: 700; color: var(--navy); background: rgba(26,58,110,.08); padding: .13rem .45rem; border-radius: 4px; }
.aparea-arrow{ color: var(--muted); font-weight: 700; }

/* ══ RESULT ACTIONS ══════════════════════════════════ */
.result-actions { display: flex; gap: .9rem; flex-wrap: wrap; margin-top: 1.4rem; }
.result-actions .btn { flex: 1; justify-content: center; min-width: 140px; }

/* ══ FOOTER ══════════════════════════════════════════ */
.inst-footer {
  background: var(--navy); color: #7a8db0;
  text-align: center; padding: .85rem 1rem;
  font-size: .74rem; margin-top: auto;
}

/* ══ PRINT HEADER ════════════════════════════════════ */
.print-header { display: none; font-size: .82rem; line-height: 1.7; margin-bottom: 1.1rem; }
.print-header hr { border: none; border-top: 1px solid #ccc; margin: .5rem 0; }
.print-logo-row { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; }
.print-escudo   { width: 50px; height: 50px; object-fit: contain; }
.print-meta     { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .8rem; }

/* ══ GRUPO CARD ══════════════════════════════════════ */
.grupo-card {
  background: linear-gradient(135deg, #0a1f44 0%, #1a3a6e 100%);
  border-radius: 12px;
  padding: 1rem 1.3rem;
  border: 1px solid rgba(201,162,39,.3);
}
.grupo-header {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: .8rem;
}
.grupo-icon  { font-size: 1.1rem; }
.grupo-titulo {
  font-family: 'Playfair Display', serif;
  font-size: .95rem; font-weight: 700;
  color: var(--gold-lt); letter-spacing: .02em;
}
.grupo-members {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem .8rem;
}
.grupo-member {
  display: flex; align-items: baseline; gap: .5rem;
  background: rgba(255,255,255,.06);
  border-radius: 7px; padding: .45rem .7rem;
  border: 1px solid rgba(201,162,39,.15);
}
.grupo-mat {
  font-size: .68rem; font-weight: 700;
  color: var(--gold); letter-spacing: .04em;
  white-space: nowrap; flex-shrink: 0;
}
.grupo-name {
  font-size: .82rem; font-weight: 600;
  color: rgba(255,255,255,.88); line-height: 1.3;
}

/* ══ RESULT CARD — grupo rows ════════════════════════ */
.src-row--grupo {
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: .7rem;
  grid-template-columns: auto 1fr;
}
.src-item--full { grid-column: auto; }
.src-val--group {
  color: var(--gold-lt) !important;
  font-size: .9rem !important;
}
.src-val--members {
  color: rgba(255,255,255,.75) !important;
  font-size: .82rem !important;
  font-weight: 400 !important;
}

/* ══ RESPONSIVE ══════════════════════════════════════ */
@media (max-width: 640px) {
  .inst-header { padding: .9rem 1rem 0; }
  .inst-title  { font-size: .9rem; }
  .inst-sub    { font-size: .65rem; }
  .escudo-img  { width: 44px; height: 44px; }
  .card        { padding: 1.3rem 1.1rem; }
  .form-grid   { grid-template-columns: 1fr; }
  .meta-grid   { grid-template-columns: 1fr 1fr; }
  .q-header    { gap: .4rem; }
  .timer-box   { font-size: 12px; padding: 3px 8px; }
  .aparea-container { grid-template-columns: 1fr; }
  .vof1-btns   { flex-direction: row; }
  .src-row     { grid-template-columns: 1fr 1fr; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { min-width: unset; }
  .grupo-members { grid-template-columns: 1fr; }
  .src-row--grupo { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .q-tags { display: none; }   /* más espacio en pantallas muy pequeñas */
  .vof1-btn { font-size: .85rem; padding: .75rem .7rem; }
  .src-row  { grid-template-columns: 1fr; }
}

/* ══ PRINT ═══════════════════════════════════════════ */
@media print {
  body { background: #fff; }
  .inst-header, .inst-footer,
  .result-actions, .progress-bar-wrap,
  #screen-datos, #screen-pregunta { display: none !important; }
  .print-header { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; padding: 1rem; }
  #screen-resultado { display: block !important; }
  .btn { display: none !important; }
  .review-item { break-inside: avoid; }
  .student-result-card { background: #f0f4ff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .src-label { color: #444 !important; }
  .src-val   { color: #003087 !important; }
}