/* Flashcards - shared by /flashcards/ (hub) and every deck page under it.
 *
 * Every rule is nested under .flashcards-page, the wrapper class on
 * <section id="main">, so nothing here can collide with another page's
 * stylesheet. Generated pages (scripts/build_flashcards.py) provide the
 * static markup; js/components/flashcards.js builds the interactive player
 * into [data-fc-mount] and adds .is-enhanced to the root.
 *
 * Colours are the practice-questions palette, restated locally exactly as
 * quiz.css restates the notes palette: the :root tokens in
 * revision-notes-textbook.css belong to the notes pages and are not loaded
 * here. Question face and structure carry the navy; the answer face carries
 * the green; brand red is kept for "Again" and the CTA buttons.
 *
 * The 3D card flip degrades twice over: prefers-reduced-motion swaps it for
 * a plain opacity change, and with no JavaScript at all the sample cards
 * show both faces statically.
 */

.flashcards-page {
  --fc-primary: #1a3e72;
  --fc-secondary: #2a5c8d;
  --fc-teal: #2a8998;
  --fc-teal-text: #1f7080;
  --fc-correct: #27ae60;
  --fc-correct-text: #1e8449;
  --fc-wrong: #d52349;
  --fc-light-bg: #f8fafc;
  --fc-tint: #eef3f9;
  --fc-border: #e2e8f0;
  --fc-muted: #5b6b7f;
}

.flashcards-page .breadcrumb {
  margin: 0 0 1.5em 0;
  font-size: 0.9em;
}

.flashcards-page .breadcrumb a {
  color: var(--fc-muted);
}

.flashcards-page .breadcrumb .separator {
  margin: 0 0.4em;
  color: #999999;
}

.flashcards-page header.major {
  margin: 0 0 1em 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  text-align: center;
}

.flashcards-page header.major h1 {
  display: inline-block;
  margin-bottom: 0.4em;
  padding-bottom: 0.4em;
  font-size: 2.2em;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fc-primary);
  border-bottom: 3px solid var(--fc-teal);
}

.flashcards-page .fc-intro {
  max-width: 72ch;
  font-size: 1.05em;
}

.flashcards-page .fc-deck-stats {
  color: var(--fc-muted);
  font-size: 0.95em;
  margin-bottom: 1.5em;
}

/* ------------------------------------------------------- player panel */

.flashcards-page .fc-player {
  background: var(--fc-light-bg);
  border: 1px solid var(--fc-border);
  border-radius: 14px;
  padding: 1.5em 1.75em;
  margin-bottom: 2.5em;
}

/* ------------------------------------------------------- sample cards */

.flashcards-page .fc-samples h2 {
  margin-bottom: 0.75em;
  color: var(--fc-primary);
}

.flashcards-page .fc-sample {
  border: 1px solid var(--fc-border);
  border-top: 4px solid var(--fc-primary);
  border-radius: 10px;
  padding: 1.25em 1.5em;
  margin-bottom: 1.25em;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(26, 62, 114, 0.06);
}

.flashcards-page .fc-sample-front::before,
.flashcards-page .fc-sample-back::before {
  display: block;
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5em;
}

.flashcards-page .fc-sample-front::before {
  content: "Question";
  color: var(--fc-secondary);
}

.flashcards-page .fc-sample-back::before {
  content: "Answer";
  color: var(--fc-correct-text);
}

.flashcards-page .fc-sample-front {
  font-weight: 700;
}

.flashcards-page .fc-sample-back {
  border-top: 1px dashed var(--fc-border);
  margin-top: 0.75em;
  padding-top: 0.75em;
}

.flashcards-page .fc-sample-back p:last-child,
.flashcards-page .fc-sample-back ul:last-child {
  margin-bottom: 0;
}

.flashcards-page .fc-sample-diagram {
  display: block;
  max-width: 420px;
  width: 100%;
  height: auto;
  margin: 0 auto 0.75em auto;
}

.flashcards-page .fc-sample-note {
  color: var(--fc-muted);
  font-size: 0.95em;
}

.flashcards-page .fc-noscript {
  border-left: 4px solid var(--fc-wrong);
  padding: 0.75em 1em;
  background: #fdf1f4;
}

/* Once the player is running, the samples hand over to it. */
.flashcards-page .fc-player.is-enhanced .fc-samples {
  display: none;
}

/* ------------------------------------------------------------ toolbar */

.flashcards-page .fc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75em;
  align-items: center;
  margin-bottom: 1em;
}

.flashcards-page .fc-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.95em;
  color: var(--fc-muted);
}

.flashcards-page .fc-toolbar select {
  max-width: 18em;
  border: 1px solid var(--fc-border);
  border-radius: 6px;
  background: #ffffff;
}

/* main.css gives every button `color: #fff !important` (line ~1770), so any
 * button here that is not white-on-dark must fight back with !important of
 * its own. Scoped under .flashcards-page, the damage is contained. */
.flashcards-page .fc-tool {
  appearance: none;
  border: 1px solid #c9d8ea;
  border-radius: 999px;
  background: var(--fc-tint);
  color: var(--fc-primary) !important;
  padding: 0.45em 1.2em;
  font-size: 0.95em;
  font-weight: 400;
  cursor: pointer;
  height: auto;
  line-height: 1.4;
}

.flashcards-page .fc-tool:hover {
  background: var(--fc-secondary);
  border-color: var(--fc-secondary);
  color: #ffffff !important;
}

/* ----------------------------------------------------------- progress */

.flashcards-page .fc-progress {
  margin-bottom: 1em;
}

.flashcards-page .fc-progress-label {
  font-size: 0.9em;
  font-weight: 700;
  color: var(--fc-secondary);
}

.flashcards-page .fc-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--fc-border);
  overflow: hidden;
  margin-top: 0.35em;
}

.flashcards-page .fc-bar-fill {
  height: 100%;
  width: 0;
  background: var(--fc-teal);
  transition: width 0.25s ease;
}

/* -------------------------------------------------------------- stage */

.flashcards-page .fc-stage {
  max-width: 680px;
  margin: 0 auto;
}

.flashcards-page .fc-card {
  display: block;
  width: 100%;
  min-height: 340px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  text-align: left;
  font: inherit;
  font-weight: 300;
  color: #5d5d5d !important;
}

.flashcards-page .fc-card-inner {
  display: block;
  position: relative;
  width: 100%;
  min-height: 340px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.flashcards-page .fc-card.is-flipped .fc-card-inner {
  transform: rotateY(180deg);
}

.flashcards-page .fc-face {
  display: block;
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--fc-border);
  border-top: 4px solid var(--fc-secondary);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(26, 62, 114, 0.1);
  padding: 1.5em 1.75em;
  overflow-y: auto;
}

.flashcards-page .fc-front {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.flashcards-page .fc-face-label {
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75em;
}

.flashcards-page .fc-front .fc-face-label {
  color: var(--fc-secondary);
}

.flashcards-page .fc-back .fc-face-label {
  color: var(--fc-correct-text);
}

.flashcards-page .fc-back {
  transform: rotateY(180deg);
  border-top-color: var(--fc-correct);
}

.flashcards-page .fc-back p:last-child,
.flashcards-page .fc-back ul:last-child {
  margin-bottom: 0;
}

.flashcards-page .fc-card:focus-visible {
  outline: 3px solid var(--fc-secondary);
  outline-offset: 3px;
  border-radius: 12px;
}

.flashcards-page .fc-diagram {
  display: block;
  max-width: 380px;
  width: 100%;
  height: auto;
  margin: 0 auto 0.75em auto;
}

.flashcards-page .fc-formula {
  display: block;
  text-align: center;
  margin: 0.5em 0 1em 0;
}

.flashcards-page .fc-hint {
  text-align: center;
  color: var(--fc-muted);
  font-size: 0.85em;
  margin: 0.75em 0;
}

/* --------------------------------------------------- nav and ratings */

.flashcards-page .fc-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75em;
}

.flashcards-page .fc-nav button {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.6em 1.1em;
  min-height: 44px;
  height: auto;
  line-height: 1.3;
}

.flashcards-page .fc-step {
  border: 0;
  background: var(--fc-secondary);
  color: #ffffff !important;
  font-weight: 400;
}

.flashcards-page .fc-step:hover {
  background: var(--fc-primary);
}

.flashcards-page .fc-rate {
  display: flex;
  gap: 0.75em;
}

.flashcards-page .fc-again {
  border: 0;
  background: var(--fc-wrong);
  color: #ffffff !important;
  font-weight: 700;
}

.flashcards-page .fc-again:hover {
  background: #b51d3e;
}

.flashcards-page .fc-got {
  border: 0;
  background: var(--fc-correct);
  color: #ffffff !important;
  font-weight: 700;
}

.flashcards-page .fc-got:hover {
  background: var(--fc-correct-text);
}

.flashcards-page .fc-meta {
  text-align: center;
  color: var(--fc-muted);
  font-size: 0.9em;
  margin-top: 1em;
}

.flashcards-page .fc-meta a {
  color: var(--fc-teal-text);
}

.flashcards-page .fc-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 0.05em 0.8em;
  margin: 0 0.25em;
  font-size: 0.9em;
  background: var(--fc-tint);
  color: var(--fc-secondary);
}

.flashcards-page .fc-chip-foundation {
  background: #e9f7ef;
  color: var(--fc-correct-text);
}

.flashcards-page .fc-chip-standard {
  background: var(--fc-tint);
  color: var(--fc-secondary);
}

.flashcards-page .fc-chip-stretch {
  background: #fbeaee;
  color: #a81b39;
}

/* ------------------------------------------------------------ summary */

.flashcards-page .fc-summary {
  border: 1px solid var(--fc-border);
  border-left: 4px solid var(--fc-correct);
  border-radius: 10px;
  background: #ffffff;
  padding: 1.5em 1.75em;
  max-width: 680px;
  margin: 0 auto;
}

.flashcards-page .fc-summary h2 {
  margin-bottom: 0.5em;
  color: var(--fc-primary);
}

.flashcards-page .fc-summary .fc-nav {
  justify-content: flex-start;
  margin-top: 1em;
}

/* ------------------------------------------------- topics and CTA */

.flashcards-page .fc-topics h2 {
  color: var(--fc-primary);
}

.flashcards-page .fc-topics ul {
  list-style: none;
  padding-left: 0;
}

.flashcards-page .fc-topics li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
  padding: 0.5em 0.5em;
  border-bottom: 1px solid var(--fc-border);
}

.flashcards-page .fc-topics li:hover {
  background: var(--fc-light-bg);
}

.flashcards-page .fc-topic-count {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 0.1em 0.8em;
  background: var(--fc-tint);
  color: var(--fc-secondary);
  font-size: 0.85em;
  white-space: nowrap;
}

.flashcards-page .fc-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  margin-top: 2em;
}

/* ------------------------------------------------------------ hub */

.flashcards-page .fc-board {
  margin-top: 1.5em;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25em;
  align-items: stretch;
}

.flashcards-page .fc-board h2 {
  grid-column: 1 / -1;
  justify-self: start;
  color: var(--fc-primary);
  border-bottom: 3px solid var(--fc-teal);
  padding-bottom: 0.2em;
  margin-bottom: 0;
}

.flashcards-page .fc-deck-card {
  border: 1px solid var(--fc-border);
  border-top: 4px solid var(--fc-teal);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(26, 62, 114, 0.06);
  padding: 1.25em 1.5em;
  margin: 0;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.flashcards-page .fc-deck-card:hover {
  box-shadow: 0 6px 18px rgba(26, 62, 114, 0.14);
  transform: translateY(-2px);
}

.flashcards-page .fc-deck-card h3 {
  margin-bottom: 0.25em;
}

.flashcards-page .fc-deck-card h3 a {
  color: var(--fc-secondary);
  text-decoration: none;
  border-bottom: none;
}

.flashcards-page .fc-deck-card p {
  margin-bottom: 0;
  color: var(--fc-muted);
  font-size: 0.95em;
}

/* ------------------------------------------------------------ mobile */

@media screen and (max-width: 736px) {
  .flashcards-page header.major h1 {
    font-size: 1.6em;
  }

  .flashcards-page .fc-board {
    grid-template-columns: 1fr;
  }

  .flashcards-page .fc-player {
    padding: 1em 0.9em;
  }

  .flashcards-page .fc-card,
  .flashcards-page .fc-card-inner {
    min-height: 300px;
  }

  .flashcards-page .fc-face {
    padding: 1.1em 1.2em;
  }

  .flashcards-page .fc-diagram {
    max-width: 100%;
  }

  .flashcards-page .fc-nav {
    flex-wrap: wrap;
  }

  .flashcards-page .fc-rate {
    order: -1;
    width: 100%;
    justify-content: center;
  }

  .flashcards-page .fc-rate button {
    flex: 1;
  }
}

/* ----------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .flashcards-page .fc-card-inner {
    transition: none;
    transform-style: flat;
  }

  .flashcards-page .fc-card.is-flipped .fc-card-inner {
    transform: none;
  }

  .flashcards-page .fc-back {
    transform: none;
    opacity: 0;
  }

  .flashcards-page .fc-card.is-flipped .fc-back {
    opacity: 1;
  }

  .flashcards-page .fc-card.is-flipped .fc-front {
    opacity: 0;
  }

  .flashcards-page .fc-bar-fill {
    transition: none;
  }

  .flashcards-page .fc-deck-card {
    transition: none;
  }

  .flashcards-page .fc-deck-card:hover {
    transform: none;
  }
}

/* -------------------------------------------------------------- print */

/* "Print this deck": js/components/flashcards.js fills [data-fc-printsheet]
 * with every card and unhides it before window.print(). Printing without
 * JavaScript simply prints the page as it stands - samples and topic list. */

@media print {
  .flashcards-page .fc-printsheet:not([hidden]) {
    display: block;
  }

  .flashcards-page .fc-player {
    background: none;
    border: 0;
    padding: 0;
  }

  .flashcards-page .fc-player.is-printing .fc-mount,
  .flashcards-page .fc-player.is-printing ~ .fc-topics,
  .flashcards-page .fc-player.is-printing ~ .fc-cta {
    display: none;
  }

  .flashcards-page .fc-print-item {
    border: 1px solid #999999;
    border-radius: 6px;
    padding: 0.75em 1em;
    margin-bottom: 0.75em;
    break-inside: avoid;
  }

  .flashcards-page .fc-print-front {
    font-weight: 700;
    border-bottom: 1px dashed #999999;
    padding-bottom: 0.5em;
    margin-bottom: 0.5em;
  }

  .flashcards-page .fc-print-item img {
    max-width: 300px;
    height: auto;
  }
}

.flashcards-page .fc-printsheet[hidden] {
  display: none;
}
