/* Study Notes section - extends styles.css with the same tokens/patterns
   (top-rule accent cards, no flat borders, mono metadata chips). Only new
   rules for the interactive flashcard/quiz widgets and long-form guide
   typography live here. */

/* A long unbroken string with no spaces (a URL/path example, e.g. a
   directory-traversal attack example in Domain 2) has no natural wrap
   point. overflow-wrap: break-word alone didn't force a break inside the
   flex-laid-out flashcard/quiz text on a narrow phone (confirmed via a
   real mobile-viewport check - the container measured overflow-wrap
   correctly but the string still pushed 86px past the viewport);
   word-break: break-all does, since code snippets have no readability
   cost from an arbitrary mid-string break the way prose would. */
code {
  overflow-wrap: break-word;
  word-break: break-all;
}

.study-hero {
  padding: 3.5rem 0 2.5rem;
}

.study-hero h1 {
  font-size: 2.4rem;
}

.study-page {
  padding-top: 0;
}

.study-intro {
  max-width: 62ch;
  color: var(--muted);
  margin-bottom: 2.5rem;
}

/* --- index grid --- */
.study-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.study-index-card {
  display: block;
  background: var(--surface);
  border-top: 2px solid var(--accent-dim);
  border-radius: 4px;
  padding: 1.5rem;
  color: var(--text);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.study-index-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.5);
}

.study-index-tag {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
  font-size: 0.75rem;
  display: block;
  margin-bottom: 0.6rem;
}

.study-index-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.study-index-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- diagrams (RoughJS, rendered client-side) --- */
.diagram-wrap {
  margin: 1.5rem 0 2rem;
  background: var(--surface);
  border-top: 2px solid var(--accent-dim);
  border-radius: 4px;
  padding: 1rem 1rem 0.75rem;
}

.diagram-canvas {
  display: block;
  width: 100%;
  height: 220px;
}

.diagram-caption {
  margin-top: 0.5rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

/* Definition-dump sentences ("Label: Term (def), Term (def), Term (def).")
   converted into an actual scannable list instead of a wall of nested
   parens - see tryTermList() in build-study.js. Thin left-rule accent per
   item (the site's existing "annotation, not a border box" pattern) so
   each term reads as its own scannable unit without a heavy card grid. */
.term-group {
  margin: 0 0 1.15rem;
}

.term-group-label {
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* auto-fill instead of the implicit single column every item defaulted to
   before - a 4-item list (Categories, Types) was taking 4 full-width rows,
   same footprint as an 11-item list, which is most of why a full domain
   page read as one long monotonous stack of identical boxes end to end.
   Grid rows still size to their own content, so a long item just wraps to
   more lines in its own cell without breaking the layout. */
.term-list {
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.45rem;
  align-items: start;
}

.term-list li {
  background: rgba(56, 189, 248, 0.05);
  border-left: 2px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.term-list li strong {
  color: var(--accent);
}

/* --- guide prose --- */
.study-guide h2 {
  font-size: 1.5rem;
  margin: 2.5rem 0 1rem;
}

.study-guide h2:first-child {
  margin-top: 0;
}

/* Confusables / Exam Traps - the highest-value "here's where people get
   this wrong" content, pulled out of the prose flow so it reads as
   deliberate warning rather than blending into everything else. Two hues
   only (amber = watch closely, red = common exam trap), both used nowhere
   else on the site, so they stay legible as a distinct signal. */
.callout {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border-radius: 4px;
  border-left: 3px solid;
}

.callout h2 {
  margin-top: 0 !important;
  font-size: 1.25rem !important;
}

.callout-confusables {
  background: rgba(251, 191, 36, 0.06);
  border-left-color: #fbbf24;
}

.callout-confusables h2 {
  color: #fbbf24;
}

.callout-examtraps {
  background: rgba(248, 113, 113, 0.06);
  border-left-color: #f87171;
}

.callout-examtraps h2 {
  color: #f87171;
}

.callout .table-wrap {
  border-top-color: rgba(251, 191, 36, 0.5);
}

.study-guide h3 {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 1.75rem 0 0.75rem;
}

.study-guide h4 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.study-guide p {
  color: var(--text);
  margin-bottom: 1rem;
  max-width: 74ch;
  /* A long unbroken string (e.g. a URL/path example with no spaces, like a
     directory-traversal example in Domain 2) has no natural wrap point and
     will push past the viewport on narrow phones without this - confirmed
     via a real mobile-viewport overflow check. */
  overflow-wrap: break-word;
}

.study-guide ul,
.study-guide ol {
  margin: 0 0 1rem 1.25rem;
  color: var(--text);
}

.study-guide li {
  margin-bottom: 0.4rem;
}

.study-guide pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.study-guide code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.88em;
  color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-top: 2px solid var(--accent-dim);
  border-radius: 4px;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table-wrap th,
.table-wrap td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table-wrap th {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--surface);
}

.table-wrap tr:last-child td {
  border-bottom: none;
}

/* --- drills section --- */
.study-drills {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.study-drills h2 {
  font-size: 1.4rem;
  margin: 2rem 0 0.5rem;
}

.drills-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

/* --- progress trackers (flashcard flip count / quiz score) --- */
.progress-tracker {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  margin-bottom: 1rem;
}

.progress-tracker span {
  font-weight: 600;
}

.callout-examtraps-tone {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}

.flashcard-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* --- flashcards --- */
.flashcard-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  perspective: 1000px;
}

.flashcard {
  position: relative;
  min-height: 140px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border-top: 2px solid var(--accent-dim);
  border-radius: 4px;
  font-size: 0.92rem;
  backface-visibility: hidden;
  transition: transform 0.5s ease, box-shadow 0.25s ease;
  overflow-wrap: break-word;
}

.flashcard-front {
  transform: rotateY(0deg);
}

.flashcard-back {
  transform: rotateY(180deg);
  border-top-color: var(--accent);
  background: var(--bg-alt);
}

.flashcard[data-flipped='true'] .flashcard-front {
  transform: rotateY(180deg);
}

.flashcard[data-flipped='true'] .flashcard-back {
  transform: rotateY(360deg);
}

.flashcard:hover .flashcard-face {
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.5);
}

.flashcard:focus-visible .flashcard-face {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flashcard-tag {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
  font-size: 0.72rem;
  margin-bottom: 0.4rem;
}

.flashcard-item {
  display: flex;
  flex-direction: column;
}

.flashcard-rate {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.rate-btn {
  flex: 1;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.35rem 0.5rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.rate-btn:hover {
  border-color: var(--accent-dim);
}

.rate-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rate-btn[data-active='true'][data-rate='again'] {
  border-color: #f87171;
  color: #f87171;
}

.rate-btn[data-active='true'][data-rate='hard'] {
  border-color: #fbbf24;
  color: #fbbf24;
}

.rate-btn[data-active='true'][data-rate='good'] {
  border-color: var(--accent);
  color: var(--accent);
}

.rate-btn[data-active='true'][data-rate='easy'] {
  border-color: #34d399;
  color: #34d399;
}

.card-due-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.due-filter-btn {
  cursor: pointer;
  font: inherit;
}

.due-filter-btn[data-active='true'] {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(56, 189, 248, 0.1);
}

/* --- quiz / self-check --- */
.quiz-deck {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.quiz-item {
  background: var(--surface);
  border-top: 2px solid var(--accent-dim);
  border-radius: 4px;
  padding: 1.25rem;
  overflow-wrap: break-word; /* inherited by question/options/explanation */
}

.quiz-question {
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
}

.quiz-num {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
  margin-right: 0.5rem;
}

.quiz-difficulty {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-right: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.quiz-option,
.reveal-btn {
  text-align: left;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.85rem;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.reveal-btn {
  display: inline-block;
  color: var(--accent);
}

.quiz-option:hover,
.reveal-btn:hover {
  border-color: var(--accent-dim);
}

.quiz-option:focus-visible,
.reveal-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quiz-option[data-state='correct'] {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.1);
}

.quiz-option[data-state='incorrect'] {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.quiz-option[disabled] {
  cursor: default;
}

.quiz-explanation {
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* --- missed-questions review panel (built client-side by study.js) --- */
.review-panel {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: rgba(248, 113, 113, 0.06);
  border-left: 3px solid #f87171;
  border-radius: 4px;
  overflow-wrap: break-word;
}

.review-panel h3 {
  color: #f87171;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.review-panel-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.review-item {
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.review-item:first-of-type {
  border-top: none;
}

.review-item-q {
  margin-bottom: 0.4rem;
}

.review-item-a {
  color: var(--muted);
}

.review-clear-btn {
  margin-top: 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.35rem 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
}

.review-clear-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

@media (max-width: 640px) {
  .study-hero h1 {
    font-size: 1.9rem;
  }
}
