/* The mock VBE sitting: the chooser, the paper and the diagnosis.
   Kept in its own sheet because the paper is the one screen in the app that is not a card
   with one question on it, and folding its rules into styles.css would bury them. */

/* --- Choosing a paper ------------------------------------------------------------- */
.exam-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.exam-option {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.exam-option:last-child { border-bottom: 0; }
.exam-option-body { min-width: min(100%, 15rem); flex: 1 1 15rem; }
.exam-option-name { margin: 0 0 var(--space-1); font-weight: 650; font-size: 15px; }
.exam-option .note { margin: 0; }
.exam-option-sat { color: var(--ivaldyta-text); }
.exam-option button { flex: 0 0 auto; margin-top: 0; }

.exam-history {
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.exam-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.exam-history-name { font-weight: 650; }
.exam-history-score { text-align: end; font-variant-numeric: tabular-nums; }
.exam-history-meta { grid-column: 1 / -1; color: var(--text-mute); font-size: 12px; }

/* --- Sitting the paper ------------------------------------------------------------ */
/* The clock has to stay reachable through a 35-question scroll; on a phone it is the one
   thing that must never be a scroll away. */
/* Opaque and gutter-free on purpose: the card's own padding varies between breakpoints, so
   bleeding to its edge would mean hard-coding a number that another rule already changes. */
.exam-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.exam-clock {
  margin: 0;
  min-width: 4.5rem;
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Colour never carries the meaning alone: the countdown itself is the message. */
.exam-clock.warn { color: var(--pradzia-text); }
.exam-clock.urgent { color: var(--spraga-text); }

.exam-bar-meta { flex: 1 1 12rem; min-width: 0; }
.exam-bar-title { margin: 0; font-size: 13px; font-weight: 650; }
.exam-bar-meta .note { margin: 0; font-size: 12px; }
.exam-bar .primary { margin-top: 0; flex: 0 0 auto; }

.exam-save { margin: 0 0 var(--space-3); min-height: 1.2em; font-size: 12px; }
.exam-save.warn { color: var(--spraga-text); font-weight: 650; }

.exam-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}

.exam-nav-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-mute);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Answered is marked twice — filled and underlined — so the grid is readable without
   colour vision. */
.exam-nav-btn.answered {
  background: var(--accent-surface);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.exam-paper {
  margin: 0;
  padding: 0;
  list-style: none;
}

.exam-q {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 96px;
}

.exam-q:last-child { border-bottom: 0; }

.exam-q-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-mute);
}

.exam-q-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-secondary);
  color: var(--text);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.exam-q-points { font-weight: 650; color: var(--accent-text); }
.exam-q-topic { margin-inline-start: auto; }
.exam-q .prompt-text { margin-top: var(--space-3); }
.exam-q .formula { margin: var(--space-3) 0; padding: var(--space-4); font-size: clamp(18px, 3vw, 24px); }

.exam-choices {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.exam-choice {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  text-align: start;
  min-height: 52px;
}

.exam-choice input { width: 20px; min-height: 20px; flex: none; accent-color: var(--accent); margin: 0; }
.exam-choice-key { font-weight: 750; font-variant-numeric: tabular-nums; }
.exam-choice-text { font-weight: 600; overflow-wrap: anywhere; }
.exam-choice:focus-within { outline: 3px solid #388604; outline-offset: 4px; }

.exam-written { margin-top: var(--space-3); }
.exam-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}
.exam-written .note { margin: var(--space-2) 0 0; font-size: 12px; }

.exam-submit {
  margin-top: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--accent-surface);
}
.exam-submit .actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.exam-submit .primary, .exam-submit .secondary { margin-top: 0; flex: 1 1 12rem; }

/* --- The diagnosis ---------------------------------------------------------------- */
.exam-topics { margin: 0; padding: 0; list-style: none; }

.exam-topic {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name value" "bar bar";
  gap: var(--space-2) var(--space-4);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.exam-topic:last-child { border-bottom: 0; }
.exam-topic-name { grid-area: name; font-weight: 650; font-size: 15px; }
.exam-topic-value { grid-area: value; display: flex; flex-direction: column; align-items: flex-end; text-align: end; font-variant-numeric: tabular-nums; }
.exam-topic .bar { grid-area: bar; }
.exam-topic.spraga .bar-fill { background: var(--spraga); }
.exam-topic.pradzia .bar-fill { background: var(--pradzia); }
.exam-topic.gerai .bar-fill { background: var(--gerai); }
.exam-topic.ivaldyta .bar-fill { background: var(--ivaldyta); }

.exam-mistakes { margin: 0; padding: 0; list-style: none; }
.exam-mistake { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.6; }
.exam-mistake:last-child { border-bottom: 0; }
.exam-mistake p { margin: 0 0 var(--space-1); }

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each outcome is marked by shape as well as colour: a ring for a blank, a filled square
   for a scored question, a struck number for a wrong one. */
.exam-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.exam-cell.correct { background: var(--ivaldyta-surface); border-color: var(--ivaldyta-border); color: var(--ivaldyta-text); }
.exam-cell.wrong { background: var(--spraga-surface); border-color: var(--spraga-border); color: var(--spraga-text); text-decoration: line-through; }
.exam-cell.blank { background: transparent; border-style: dashed; color: var(--text-mute); }

/* --- Dashboard mock-exam tile ------------------------------------------------------
   At a lesson milestone (server/exam.js examMilestone) the exam tile turns into the bright
   call to sit a new paper. The title text changes too, so the state is not carried by
   colour alone. */
#home-view .tile-exam.due {
  --tint: var(--accent);
  --ink: var(--accent-ink);
  --edge: var(--accent-active);
  animation: exam-due-in 0.35s var(--ease-out, ease-out);
}

#home-view .tile-exam.due .tile-note { color: var(--accent-ink); }

/* The tile's button stretches its hit area over the whole tile; the upgrade banner's own
   link must stay clickable above it. */
.home-tile .upsell { position: relative; z-index: 1; }

@keyframes exam-due-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* --- Grid placement ---------------------------------------------------------------- */
@media (min-width: 768px) {
  #exam-result-view .dash-grid {
    grid-template-columns: minmax(0, 1.85fr) minmax(320px, 1.15fr);
    grid-template-rows: auto auto auto auto;
  }
  #exam-result-view .panel-goal { grid-column: 1 / -1; grid-row: 1; }
  #exam-result-view .panel-topics { grid-column: 1 / 2; grid-row: 2 / span 2; }
  #exam-result-view #exam-weak-panel { grid-column: 2 / 3; grid-row: 2; align-self: start; }
  #exam-result-view #exam-mistakes-panel { grid-column: 2 / 3; grid-row: 3; align-self: start; }
  #exam-result-view #exam-cells-panel { grid-column: 1 / -1; grid-row: 4; }

  #exams-view .dash-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.85fr); grid-template-rows: auto auto; }
  #exams-view #exams-active-panel { grid-column: 1 / 2; grid-row: 1; align-self: start; }
  #exams-view #exams-baseline-panel { grid-column: 1 / 2; grid-row: 2; align-self: start; }
  #exams-view .dash-grid > section:last-child { grid-column: 2 / 3; grid-row: 1 / span 2; align-self: start; }

  .exam-choices { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .exam-bar .primary { width: auto; flex: 0 0 auto; }
  .exam-nav-btn { min-width: 36px; min-height: 36px; font-size: 12px; }
  .exam-q { scroll-margin-top: 132px; }
}
