/* ==========================================================================
   NESPL Portal — Assessment flow
   Intro screen, exam runner, question palette, results.
   Built on the token system in style.css.
   ========================================================================== */

/* ---------- Shared entrance (CSS-only — never gated on scroll position) ---------- */
@keyframes asRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.as-in { animation: asRise .45s cubic-bezier(.2,.8,.2,1) both; }
.as-in-1 { animation-delay: .05s; }
.as-in-2 { animation-delay: .10s; }
.as-in-3 { animation-delay: .15s; }

/* ==========================================================================
   1. Assessment intro / landing
   ========================================================================== */
.as-hero {
  border-radius: var(--radius); padding: 2rem; color: #fff; position: relative; overflow: hidden;
  background: var(--grad-blue);
}
.as-hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px;
  border-radius: 50%; background: rgba(255,255,255,.10);
}
.as-hero::before {
  content: ""; position: absolute; right: 60px; bottom: -90px; width: 180px; height: 180px;
  border-radius: 50%; background: rgba(255,255,255,.07);
}
.as-hero__eyebrow {
  font-family: var(--font-display); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  opacity: .85; margin-bottom: .5rem;
}
.as-hero h1 { color: #fff; font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0 0 .5rem; }
.as-hero p { color: rgba(255,255,255,.88); margin: 0; max-width: 60ch; }
.as-hero__meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; position: relative; z-index: 2; }
.as-pill {
  display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: 999px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.24);
  font-size: .82rem; font-weight: 500; font-family: var(--font-display); backdrop-filter: blur(6px);
}

/* Spec list */
.as-specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.as-spec { text-align: center; padding: 1.1rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.as-spec i { font-size: 1.4rem; color: var(--blue-600); display: block; margin-bottom: .45rem; }
.as-spec b { display: block; font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); line-height: 1.2; }
.as-spec small { color: var(--muted); font-size: .76rem; }

/* Rules list */
.as-rules { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.as-rules li { display: flex; gap: .7rem; align-items: flex-start; font-size: .9rem; color: var(--body); line-height: 1.5; }
.as-rules i { color: var(--blue-600); flex: 0 0 auto; margin-top: .15rem; }
.as-rules li.warn i { color: var(--orange); }

/* ==========================================================================
   2. Exam runner shell
   ========================================================================== */
.exam-bar {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
  padding: .8rem clamp(1rem, 3vw, 1.8rem);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.exam-bar__name { font-family: var(--font-display); font-weight: 700; color: var(--ink); font-size: 1rem; margin: 0; }
.exam-bar__sub  { font-size: .76rem; color: var(--muted); }
.exam-bar__grow { flex: 1; min-width: 60px; }

/* Countdown */
.timer {
  display: inline-flex; align-items: center; gap: .55rem; padding: .5rem .95rem; border-radius: 12px;
  background: var(--blue-50); color: var(--blue-700); border: 1.5px solid var(--blue-100);
  font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums;
  transition: background .3s, color .3s, border-color .3s;
}
.timer small { font-weight: 500; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.timer.warn   { background: var(--orange-soft); color: #b45309; border-color: #fed7aa; }
.timer.danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; animation: timerPulse 1s ease-in-out infinite; }
@keyframes timerPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* Thin progress strip under the bar */
.exam-progress { height: 4px; background: var(--line); position: relative; overflow: hidden; }
.exam-progress i { position: absolute; inset: 0 auto 0 0; background: var(--grad-green); transition: width .4s cubic-bezier(.2,.8,.2,1); display: block; }

/* Layout: question + palette */
.exam-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.25rem; align-items: start; }
.exam-layout > * { min-width: 0; }

/* ---------- Question card ---------- */
.q-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.q-num {
  font-family: var(--font-display); font-weight: 700; color: var(--ink); font-size: 1.05rem; margin: 0;
}
.q-text { font-size: 1.02rem; color: var(--ink); line-height: 1.6; margin: 0 0 1.2rem; font-weight: 500; }

/* Code snippet inside a question */
.q-code {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm); padding: 1rem 1.15rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem;
  line-height: 1.65; overflow-x: auto; margin: 0 0 1.2rem; tab-size: 2;
}
.q-code .k { color: #c4b5fd; }   /* keyword */
.q-code .n { color: #7dd3fc; }   /* number  */
.q-code .c { color: #94a3b8; }   /* comment */

/* ---------- Answer options ---------- */
.opt-list { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1.4rem; }
.opt-a {
  display: flex; align-items: flex-start; gap: .85rem; padding: .95rem 1.1rem; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.opt-a:hover { border-color: var(--blue-400); background: var(--blue-50); }
.opt-a input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt-a__key {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center;
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--body);
  font-family: var(--font-display); font-weight: 700; font-size: .82rem; transition: .18s;
}
.opt-a__text { font-size: .94rem; color: var(--body); line-height: 1.5; padding-top: .25rem; }
.opt-a__text code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: .1rem .4rem; font-size: .88em; color: var(--ink);
}
.opt-a.sel { border-color: var(--blue-500); background: var(--blue-50); box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.opt-a.sel .opt-a__key { background: var(--grad-blue); border-color: transparent; color: #fff; }
.opt-a input:focus-visible + .opt-a__key { box-shadow: var(--ring); }

/* ---------- Question palette ---------- */
.pal { position: sticky; top: 92px; }
.pal__legend { display: flex; flex-direction: column; gap: .45rem; margin-bottom: 1rem; }
.pal__legend span { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--body); }
.dotc { width: 15px; height: 15px; border-radius: 50%; flex: 0 0 15px; border: 1.5px solid var(--line); background: #fff; }
.dotc.answered { background: var(--grad-green); border-color: transparent; }
.dotc.review   { background: var(--grad-orange); border-color: transparent; }
.dotc.current  { background: var(--grad-blue); border-color: transparent; }

.pal__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.pal__btn {
  aspect-ratio: 1; border-radius: 10px; border: 1.5px solid var(--line); background: #fff;
  color: var(--body); font-family: var(--font-display); font-weight: 600; font-size: .84rem;
  cursor: pointer; transition: .18s; display: grid; place-items: center; position: relative;
}
.pal__btn:hover { border-color: var(--blue-400); color: var(--blue-700); }
.pal__btn.answered { background: var(--grad-green); border-color: transparent; color: #fff; }
.pal__btn.review   { background: var(--grad-orange); border-color: transparent; color: #fff; }
.pal__btn.current  { box-shadow: 0 0 0 3px rgba(37,99,235,.28); border-color: var(--blue-500); }
.pal__btn.current:not(.answered):not(.review) { background: var(--grad-blue); color: #fff; }

/* Mobile: palette becomes a bottom sheet */
.pal__toggle { display: none; }
.pal__scrim { display: none; }

/* ---------- Nav buttons ---------- */
.q-nav { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.q-nav .grow { flex: 1; min-width: 8px; }

/* ==========================================================================
   3. Blocking overlays (terminated / submitted)
   ========================================================================== */
.block-x {
  position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center;
  padding: 1.2rem; background: rgba(10,18,38,.72); backdrop-filter: blur(8px);
}
.block-x.open { display: flex; animation: fadeIn .25s; }
.block-card {
  background: #fff; border-radius: var(--radius); width: min(520px, 100%); text-align: center;
  padding: 2.2rem 1.8rem; box-shadow: var(--shadow-lg); animation: slideUp .35s;
}
.block-card__ico {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 1.2rem; display: grid; place-items: center;
  font-size: 2.1rem; color: #fff;
}
.block-card__ico.red   { background: linear-gradient(135deg,#f87171,#dc2626); }
.block-card__ico.green { background: var(--grad-green); }
.block-card__ico.blue  { background: var(--grad-blue); }
.block-card h4 { margin: 0 0 .6rem; }
.block-card p  { color: var(--body); margin: 0 0 1.5rem; line-height: 1.6; }

/* Result score ring */
.score-ring {
  width: 132px; height: 132px; margin: 0 auto 1.2rem; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--line) 0);
  position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 11px; background: #fff; border-radius: 50%; }
.score-ring b { position: relative; font-family: var(--font-display); font-size: 1.9rem; color: var(--ink); line-height: 1; }
.score-ring small { position: relative; display: block; font-size: .72rem; color: var(--muted); margin-top: .2rem; }

/* Result breakdown */
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1.5rem; }
.res-cell { padding: .8rem .5rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.res-cell b { display: block; font-family: var(--font-display); font-size: 1.3rem; color: var(--ink); }
.res-cell small { font-size: .72rem; color: var(--muted); }

/* ==========================================================================
   4. Assessment list cards (Take assessment tab)
   ========================================================================== */
.as-card {
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 1.2rem;
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  transition: border-color .2s, box-shadow .2s, transform .2s; background: #fff;
}
.as-card:hover { border-color: var(--blue-200); box-shadow: var(--shadow); transform: translateY(-2px); }
.as-card__ico {
  width: 52px; height: 52px; border-radius: 14px; flex: 0 0 52px; display: grid; place-items: center;
  background: var(--grad-blue); color: #fff; font-size: 1.3rem;
}
.as-card__body { flex: 1; min-width: 180px; }
.as-card__body h6 { margin: 0 0 .25rem; font-size: 1rem; }
.as-card__meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }

/* ==========================================================================
   5. Responsive
   ========================================================================== */
@media (max-width: 992px) {
  .exam-layout { grid-template-columns: 1fr; }

  /* Palette docks to a bottom sheet */
  .pal {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 120;
    background: #fff; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px rgba(10,18,38,.18);
    padding: 1.1rem 1.2rem 1.4rem; transform: translateY(100%);
    transition: transform .3s cubic-bezier(.2,.8,.2,1); max-height: 70vh; overflow-y: auto;
  }
  .pal.open { transform: none; }
  .pal::before {
    content: ""; display: block; width: 42px; height: 4px; border-radius: 4px;
    background: var(--line); margin: -.3rem auto 1rem;
  }
  .pal__grid { grid-template-columns: repeat(6, 1fr); }
  .pal__toggle {
    display: inline-flex; align-items: center; gap: .5rem; position: fixed; right: 1rem; bottom: 1rem;
    z-index: 110; border: none; border-radius: 999px; padding: .8rem 1.15rem; cursor: pointer;
    background: var(--grad-blue); color: #fff; font-family: var(--font-display); font-weight: 600;
    font-size: .86rem; box-shadow: 0 10px 26px rgba(37,99,235,.35);
  }
  .pal__scrim { position: fixed; inset: 0; background: rgba(10,18,38,.45); z-index: 115; display: none; }
  .pal__scrim.open { display: block; animation: fadeIn .2s; }
}

@media (max-width: 700px) {
  .as-hero { padding: 1.5rem; }
  .res-grid { grid-template-columns: 1fr; }
  .exam-bar { padding: .7rem 1rem; gap: .6rem; }
  .exam-bar__name { font-size: .9rem; }
  .q-nav .btn { flex: 1 1 auto; }
  .pal__grid { grid-template-columns: repeat(5, 1fr); }
  .block-card { padding: 1.7rem 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .as-in, .timer.danger { animation: none; }
  .as-card:hover { transform: none; }
  .pal { transition: none; }
}

/* ---------- Segmented tabs: never overflow their toolbar ---------- */
.table-tools .seg { max-width: 100%; flex: 0 1 auto; min-width: 0; }
.table-tools .seg button { min-width: 0; }
@media (max-width: 560px) {
  .table-tools .seg { width: 100%; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
  .table-tools .seg::-webkit-scrollbar { display: none; }
  .table-tools .seg button { white-space: nowrap; padding: .7rem .8rem; font-size: .84rem; }
  .table-tools .input-x { width: 100% !important; }
}

/* ==========================================================================
   Exam page shell
   The reference carries this in a <style> block on the exam document, because
   that page has no portal chrome. The app routes the exam outside the shell
   for the same reason, so the rule belongs here.
   ========================================================================== */
.exam-page { max-width: 1180px; margin: 0 auto; padding: clamp(1rem, 3vw, 1.8rem); }
