/* ═══════════════════════════════════════════════════════════════
   components.css — study guide, flashcards, quiz.
   Clean light theme · white surfaces · crisp ink · semantic accents.
   Color is meaning, never decoration. Washes only for live feedback.
   ═══════════════════════════════════════════════════════════════ */

/* ── Study tools: search + expand/collapse ── */
.study-tools { margin-bottom: 1.1rem; }
.study-search-row { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap; }
.study-search {
  flex: 1 1 220px; min-height: 46px; padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  transition: border-color var(--dur) var(--ease);
}
.study-search:focus { outline: none; border-color: var(--brand); }
.study-tool-btn {
  flex: 0 0 auto; padding: 0.55rem 0.9rem; min-height: 46px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.study-tool-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-wash); }
.study-tool-btn:active { transform: scale(0.97); }
.study-search-status { min-height: 1.2rem; margin-top: 0.35rem; font-size: 0.8rem; font-weight: 700; color: var(--brand-ink); }
mark.study-hit { background: var(--hl); color: var(--ink); font-weight: 700; padding: 0.02em 0.14em; border-radius: 4px; }

/* ── Accordions ── */
.accordion { margin-bottom: 0.7rem; scroll-margin-top: 70px; }
.acc-header {
  width: 100%; display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.1rem; min-height: 58px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer;
  font-family: inherit; font-size: clamp(0.97rem, 2.8vw, 1.04rem); font-weight: 700;
  color: var(--ink); text-align: left;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.acc-header:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.acc-header:active { transform: scale(0.995); }
.acc-header.open { border-radius: var(--radius) var(--radius) 0 0; border-color: var(--line-strong); }
.acc-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px; overflow: hidden; padding: 2px;
}
/* Glyph sits on a white inner chip so it stays crisp; the colored tile frames it. */
.acc-icon img { width: 100%; height: 100%; object-fit: contain; display: block;
  background: #fff; border-radius: 9px; }
.acc-icon.tint-rose    { background: #F43F5E; }
.acc-icon.tint-orange  { background: #F97316; }
.acc-icon.tint-sky     { background: #0EA5E9; }
.acc-icon.tint-emerald { background: #10B981; }
.acc-icon.tint-indigo  { background: #6366F1; }
.acc-icon.tint-amber   { background: #EAB308; }
.acc-icon.tint-fuchsia { background: #D946EF; }
.acc-chevron { margin-left: auto; color: var(--ink); transition: transform var(--dur-lg) var(--ease); font-size: 0.7rem; }
.acc-header.open .acc-chevron { transform: rotate(180deg); }
.acc-body {
  max-height: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-strong); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: max-height 0.45s var(--ease);
}
.acc-body.open { max-height: 9000px; }
.acc-content { padding: 1.25rem; }

/* ── Topic labels / pills ── */
.topic-label {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.25rem 0.7rem; border-radius: var(--radius-pill); margin-bottom: 0.85rem;
}
.topic-label.bp      { background: var(--brand-wash);  color: var(--brand); }
.topic-label.bg      { background: var(--blue-wash);   color: var(--blue); }
.topic-label.hr      { background: var(--brand-wash);  color: var(--brand); }
.topic-label.bmi     { background: var(--refer-wash);  color: var(--refer); }
.topic-label.hist    { background: var(--warn-wash);   color: var(--warn); }
.topic-label.counsel { background: var(--indigo-wash); color: var(--indigo); }
.topic-label.bal     { background: var(--teal-wash);   color: var(--teal); }

h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--ink); }
h4 { font-size: 0.98rem; font-weight: 700; margin: 1.15rem 0 0.45rem; color: var(--brand-ink); }

/* ── Info boxes — clean white card + semantic left border (no tinted fill) ── */
.info-box {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  padding: 0.8rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.85rem 0; font-size: 0.9rem; font-weight: 500; color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.info-box strong { font-weight: 700; }
.info-box.green  { border-left-color: var(--good); }
.info-box.blue   { border-left-color: var(--blue); }
.info-box.orange { border-left-color: var(--refer); }
.info-box.yellow { border-left-color: var(--warn); }

/* ── Range tables (wide ones scroll horizontally on small screens) ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.85rem 0; border-radius: var(--radius-sm); }
.table-scroll.wide .range-table { min-width: 520px; }
.range-table {
  width: 100%; border-collapse: separate; border-spacing: 0; margin: 0;
  font-size: 0.85rem; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
}
.range-table th {
  background: var(--brand); color: #fff; padding: 0.6rem 0.75rem;
  text-align: left; font-weight: 600; font-size: 0.78rem;
}
.range-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.range-table tr:last-child td { border-bottom: none; }
.range-table .cat-normal   { border-left: 4px solid var(--good); }
.range-table .cat-elevated { border-left: 4px solid var(--warn); }
.range-table .cat-high1    { border-left: 4px solid var(--refer); }
.range-table .cat-high2    { border-left: 4px solid var(--stop); }
.range-table .cat-crisis   { border-left: 4px solid var(--stop); background: var(--stop-wash) !important; }
.range-table.blue-header th  { background: var(--blue); }
.range-table.green-header th { background: var(--good); }
.range-table.orange-header th { background: var(--refer); }

/* ── Lists ── */
ul.study-list { padding-left: 1.25rem; margin: 0.4rem 0; }
ul.study-list li { margin-bottom: 0.35rem; font-size: 0.9rem; }
ul.study-list li strong { color: var(--ink); font-weight: 700; }
.sub-list { padding-left: 1rem; margin-top: 0.25rem; }
.sub-list li { font-size: 0.85rem; color: var(--ink); }
.step-list { counter-reset: steps; list-style: none; padding-left: 0; margin: 0.5rem 0; }
.step-list li { counter-increment: steps; padding: 0.4rem 0 0.4rem 2.6rem; position: relative; font-size: 0.9rem; margin-bottom: 0.2rem; }
.step-list li::before {
  content: counter(steps); position: absolute; left: 0; top: 0.3rem;
  width: 1.8rem; height: 1.8rem; background: var(--brand-wash); color: var(--brand);
  font-weight: 700; font-size: 0.78rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 0.85rem 0; }
.mini-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.85rem; box-shadow: var(--shadow-sm); }
.mini-card h5 { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--brand-ink); }
.mini-card p, .mini-card li { font-size: 0.85rem; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } }

/* ── Flashcards ── */
.flash-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; max-width: 680px; margin: 0 auto 1.1rem; }
.flash-btn {
  padding: 0.6rem 0.85rem; min-height: 44px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 12px;
  font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all var(--dur) var(--ease); white-space: nowrap;
}
.flash-btn:hover { border-color: var(--brand); color: var(--brand); }
.flash-btn:active { transform: scale(0.96); }
.flash-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.flash-shuffle-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0.85rem; margin: 0 auto 1rem; }
.flash-shuffle-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.1rem; min-height: 44px;
  border: 1px solid var(--brand); background: var(--surface); color: var(--brand);
  border-radius: var(--radius-pill); font-family: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: all var(--dur) var(--ease);
}
.flash-shuffle-btn:hover { background: var(--brand); color: #fff; }
.flash-shuffle-btn:active { transform: scale(0.96); }
.flash-shuffle-btn svg { width: 16px; height: 16px; }
.flash-counter { text-align: center; font-size: 0.85rem; color: var(--ink); margin-bottom: 1rem; font-weight: 600; }
.flashcard-container { perspective: 1400px; max-width: 680px; margin: 0 auto 1.5rem; }
.flashcard { position: relative; width: 100%; min-height: 340px; cursor: pointer; transform-style: preserve-3d; transition: transform 0.5s var(--ease-spring); }
.flashcard.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.5rem 2rem; text-align: center; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.flash-front { background: var(--surface); }
.flash-front .flash-cat {
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--brand); background: var(--brand-wash); padding: 0.3rem 0.8rem; border-radius: var(--radius-pill); margin-bottom: 1.2rem;
}
.flash-front .flash-q { font-size: clamp(1.15rem, 4.5vw, 1.4rem); font-weight: 700; color: var(--ink); line-height: 1.4; }
.flash-front .flash-hint { font-size: 0.82rem; color: var(--brand); font-weight: 600; margin-top: 1.4rem; }
.flash-back { background: var(--surface); color: var(--ink); border-top: 3px solid var(--brand); transform: rotateY(180deg); }
.flash-back .flash-a { font-size: clamp(1.05rem, 4vw, 1.32rem); font-weight: 600; white-space: pre-line; line-height: 1.45; }
.flash-nav { display: flex; gap: 1rem; justify-content: center; align-items: center; }
.flash-nav-btn {
  width: 60px; height: 60px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); font-size: 1.5rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all var(--dur) var(--ease); color: var(--ink); box-shadow: var(--shadow-sm);
}
.flash-nav-btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow); }
.flash-nav-btn:active { transform: scale(0.93); }

/* ── Quiz ── */
/* Level 1: question-type selector — a neutral segmented control with a solid
   red "thumb" for the active type. Visually the primary tab group. */
.quiz-sub-nav {
  display: flex; gap: 3px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: 100%; margin: 0 auto 1.4rem;
  background: var(--line); border-radius: var(--radius-pill); padding: 4px;
}
.quiz-sub-btn {
  padding: 0.55rem 1.15rem; min-height: 42px; border: none; background: transparent;
  border-radius: var(--radius-pill); font-family: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: all var(--dur) var(--ease); color: var(--ink);
}
.quiz-sub-btn:hover { color: var(--brand); }
.quiz-sub-btn:active { transform: scale(0.97); }
.quiz-sub-btn.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }

/* Level 2: topic filter — outlined chips. Active is a soft red tint (not a
   solid fill) so it reads as a sub-level distinct from the type selector above. */
.quiz-filter-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; max-width: 680px; margin: 0 auto 1.1rem; }
.quiz-filter-btn {
  padding: 0.5rem 0.75rem; min-height: 40px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 12px; font-family: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: all var(--dur) var(--ease); white-space: nowrap;
}
.quiz-filter-btn:hover { border-color: var(--brand); color: var(--brand); }
.quiz-filter-btn:active { transform: scale(0.96); }
.quiz-filter-btn.active { background: var(--brand-wash); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.sa-controls { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.85rem; margin: 0 auto 1.25rem; }
.quiz-section { display: none; }
.quiz-section.active { display: block; }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 0.75rem; box-shadow: var(--shadow-sm); transition: border-color var(--dur) var(--ease); }
.q-card.correct { border-color: var(--good); border-left: 4px solid var(--good); }
.q-card.incorrect { border-color: var(--stop); border-left: 4px solid var(--stop); }
.q-num { font-size: 0.68rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.q-text { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--ink); }
.q-options { display: flex; flex-direction: column; gap: 0.45rem; }
.q-option {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.85rem; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9rem; transition: all var(--dur) var(--ease); background: var(--surface); color: var(--ink);
}
.q-option:hover { border-color: var(--brand); background: var(--brand-wash); }
.q-option.selected { border-color: var(--brand); background: var(--brand-wash); font-weight: 600; }
.q-option.revealed-correct { border-color: var(--good); background: var(--good-wash); font-weight: 600; }
.q-option.revealed-wrong { border-color: var(--stop); background: var(--stop-wash); opacity: 0.8; }
.q-radio { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all var(--dur) var(--ease); }
.q-option.selected .q-radio { border-color: var(--brand); }
.q-option.selected .q-radio::after { content: ''; width: 8px; height: 8px; background: var(--brand); border-radius: 50%; }
.q-option.revealed-correct .q-radio { border-color: var(--good); }
.q-option.revealed-correct .q-radio::after { content: ''; width: 8px; height: 8px; background: var(--good); border-radius: 50%; }
.q-feedback { margin-top: 0.6rem; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; display: none; }
.q-feedback.show { display: block; }
.q-feedback.correct { background: var(--good-wash); color: var(--good); }
.q-feedback.incorrect { background: var(--stop-wash); color: var(--stop); }
.q-tf-options { display: flex; gap: 0.5rem; }
.q-tf-btn {
  flex: 1; padding: 0.7rem; min-height: 46px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all var(--dur) var(--ease); -webkit-appearance: none; appearance: none;
}
.q-tf-btn:hover { border-color: var(--brand); }
.q-tf-btn:active { transform: scale(0.97); }
.q-tf-btn.selected { border-color: var(--brand); background: var(--brand-wash); color: var(--brand); }
.q-tf-btn.revealed-correct { border-color: var(--good); background: var(--good-wash); color: var(--good); }
.q-tf-btn.revealed-wrong { border-color: var(--stop); background: var(--stop-wash); color: var(--stop); opacity: 0.8; }
.sa-textarea {
  width: 100%; min-height: 84px; padding: 0.75rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 16px; resize: vertical; transition: border-color var(--dur) var(--ease); line-height: 1.5; background: var(--surface); color: var(--ink);
}
.sa-textarea:focus { outline: none; border-color: var(--brand); }
.sa-reveal-btn {
  margin-top: 0.5rem; padding: 0.6rem 1rem; min-height: 42px; background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius-pill); font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.sa-reveal-btn:hover { background: var(--brand-ink); }
.sa-reveal-btn:active { transform: scale(0.97); }
.sa-reveal-btn:disabled { background: var(--line); color: var(--ink); opacity: 0.55; cursor: default; }
.sa-answer { margin-top: 0.6rem; padding: 0.8rem 1rem; background: var(--good-wash); border: 1px solid var(--good); border-radius: var(--radius-sm); font-size: 0.88rem; display: none; line-height: 1.55; color: var(--ink); }
.sa-answer.show { display: block; }
.sa-note { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 0.7rem 1rem; font-size: 0.85rem; margin-bottom: 1rem; font-weight: 500; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ── Score bar ── */
.score-bar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1.1rem; margin: 0 0 1.25rem; box-shadow: var(--shadow-sm);
}
.score-bar-bottom { margin: 1.5rem 0 0; }
.score-text { font-size: 0.95rem; font-weight: 700; white-space: nowrap; color: var(--ink); }
.score-text span { color: var(--brand); }
.score-controls { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; }
.score-label { font-size: 0.82rem; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.score-select { font-family: inherit; font-size: 0.82rem; font-weight: 600; padding: 0.4rem 0.55rem; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); cursor: pointer; }
.check-all-btn { padding: 0.6rem 1.25rem; min-height: 42px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-pill); font-family: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease); }
.check-all-btn:hover { background: var(--brand-ink); }
.check-all-btn:active { transform: scale(0.97); }
.reset-btn { padding: 0.25rem 0.4rem; background: transparent; color: var(--ink); border: none; font-family: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; transition: color var(--dur) var(--ease); justify-self: end; }
.reset-btn:hover { color: var(--brand); }

@media (max-width: 600px) {
  .score-bar { grid-template-columns: 1fr auto; grid-template-areas: "score reset" "controls controls"; gap: 0.5rem 0.75rem; padding: 0.7rem 0.9rem; }
  .score-text { grid-area: score; }
  .reset-btn { grid-area: reset; }
  .score-controls { grid-area: controls; justify-content: space-between; gap: 0.5rem; }
  .flashcard { min-height: 300px; }
  .flash-face { padding: 2rem 1.5rem; }
  .range-table { font-size: 0.8rem; }
  .range-table th, .range-table td { padding: 0.5rem 0.55rem; }
}
