/* Flashcards stylesheet — screen + print. Mirrors the lessons/ design tokens. */
:root {
  --bg: #fdfbf6;
  --surface: #ffffff;
  --text: #1c1917;
  --text-sub: #57534e;
  --text-muted: #78716c;
  --border: #e7e2d8;
  --border-strong: #d6cfbe;
  --accent: #d4541c;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08);
  --font-zh: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-en: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;

  /* Card-size config — switch the whole deck by changing body[data-cardsize].
     half-letter = 5.5x8.5in portrait cards, 2-up on a LANDSCAPE Letter sheet. */
  --card-w: 5in;
  --card-h: 7.7in;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Bilingual show/hide (chrome only — card bodies are intentionally bilingual) */
.zh, .en { display: inline; }
body.zh .en { display: none; }
body:not(.zh) .zh { display: none; }
body.zh { font-family: var(--font-zh); }

/* ---- Top bar ---- */
.fc-bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; box-shadow: var(--shadow-sm);
}
.fc-bar a { color: var(--text); text-decoration: none; font-weight: 500; }
.fc-bar a:hover { color: var(--accent); }
.fc-bar .actions { display: flex; gap: 14px; align-items: center; }
.fc-bar button {
  font: inherit; cursor: pointer;
  background: var(--text); color: #fff; border: none;
  padding: 7px 16px; border-radius: var(--radius-sm); font-weight: 500;
}
.fc-bar button:hover { opacity: 0.9; }

/* ---- Deck header ---- */
.deck-head { max-width: 1100px; margin: 0 auto; padding: 32px 24px 8px; }
.deck-num { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.deck-title { font-size: 30px; margin: 6px 0 10px; line-height: 1.2; }
.deck-hint { font-size: 15px; color: var(--text-sub); max-width: 60ch; margin: 0; }

/* ---- Deck grid (screen) ---- */
.deck { max-width: 1100px; margin: 0 auto; padding: 20px 24px 56px; display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .deck { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .deck { grid-template-columns: 1fr 1fr 1fr; } }

/* ---- Card ---- */
.flashcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--card-accent, var(--text));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.flashcard[data-card="vocab"]     { --card-accent: #d4541c; }
.flashcard[data-card="dialogue"]  { --card-accent: #0f766e; }
.flashcard[data-card="facts"]     { --card-accent: #b45309; }
.flashcard[data-card="tips"]      { --card-accent: #2d6a4f; }
.flashcard[data-card="resources"] { --card-accent: #1d4ed8; }
.flashcard[data-card="visual"]    { --card-accent: #9f1239; }

.card-face { padding: 22px 22px 24px; flex: 1; }
.card-title { font-size: 19px; line-height: 1.3; margin: 0 0 14px; color: var(--text); }
.card-sidelabel {
  display: inline-block; font-size: 12px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--card-accent); border: 1px solid var(--card-accent);
  padding: 2px 9px; border-radius: 999px; margin-bottom: 12px;
}

/* Card content typography */
.card-face ul, .card-face ol { margin: 0 0 4px; padding-left: 1.2em; }
.card-face li { margin: 7px 0; font-size: 16px; }
.card-face p { margin: 8px 0; }
.card-face strong { color: var(--text); }
.card-face blockquote {
  margin: 12px 0 0; padding: 10px 14px;
  background: #f7f3ea; border-left: 3px solid var(--card-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 14px; color: var(--text-sub);
}
.card-face table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 15px; }
.card-face th, .card-face td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.card-face th { background: #f4f1ea; font-weight: 600; }
.card-face code { background: #f4f1ea; padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }

/* Visual card SVG */
.card-svg { margin: 6px 0 10px; }
.card-svg svg { width: 100%; height: auto; display: block; }

/* ---- Flip cards ---- */
.flip-btn {
  margin-top: 14px; font: inherit; cursor: pointer;
  background: var(--card-accent); color: #fff; border: none;
  padding: 8px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
}
.flip-btn:hover { opacity: 0.92; }
.flashcard[data-flip] .card-back { display: none; }
.flashcard[data-flip].flipped .card-front { display: none; }
.flashcard[data-flip].flipped .card-back { display: block; }

/* ---- Index page ---- */
.fc-index { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.fc-index h1 { font-size: 30px; margin: 0 0 16px; }
.intro-banner {
  background: #fef3ec; border: 1px solid #f3d9c6; border-radius: var(--radius-md);
  padding: 16px 20px; margin-bottom: 28px; font-size: 15px; line-height: 1.6;
}
.fc-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .fc-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .fc-grid { grid-template-columns: 1fr 1fr 1fr; } }
.fc-card {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
}
.fc-card--featured { grid-column: 1 / -1; background: linear-gradient(135deg, #fef6ef, #fdf3e9); border-color: #f0dcc4; }
.fc-badge {
  align-self: flex-start; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: #fff; background: var(--accent); padding: 3px 10px; border-radius: 999px; margin-bottom: 10px;
}
.fc-cardnum { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.fc-cardtitle { font-size: 20px; margin: 4px 0 8px; }
.fc-cardmeta { font-size: 14px; color: var(--text-sub); margin-bottom: 16px; }
.fc-cardactions { margin-top: auto; display: flex; gap: 10px; }
.fc-cardactions a {
  text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); color: var(--text);
}
.fc-cardactions a.primary { background: var(--text); color: #fff; border-color: var(--text); }
.fc-cardactions a:hover { opacity: 0.9; }

/* ---- How-to-use activity panel (index) ---- */
.howto { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.howto h2 { font-size: 22px; margin: 0 0 8px; }
.howto-sub { font-size: 15px; color: var(--text-sub); max-width: 70ch; margin: 0 0 24px; }
.howto-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .howto-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .howto-grid { grid-template-columns: 1fr 1fr; } }
.activity { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-md); padding: 14px 18px; }
.act-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.act-name { font-weight: 700; font-size: 16px; }
.act-meta { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.act-how { margin: 6px 0 0; font-size: 14px; color: var(--text-sub); line-height: 1.5; }

/* ---- Footer ---- */
.fc-foot { text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); }

/* ============================================================
   PRINT — half-letter cards, 2-up on a LANDSCAPE Letter sheet.
   ============================================================ */
@media print {
  @page { size: letter landscape; margin: 0.3in; }
  html, body { background: #fff; }
  .fc-bar, .fc-foot, .deck-head, .flip-btn { display: none !important; }
  .card-sidelabel { font-size: 9.5pt; padding: 1px 7px; margin-bottom: 8pt; } /* keep word/meaning labels on the printed card */

  .deck {
    display: flex; flex-wrap: wrap; justify-content: center;
    align-content: flex-start; gap: 0 0.4in;
    max-width: none; margin: 0; padding: 0;
  }
  .flashcard {
    width: var(--card-w); height: var(--card-h);
    flex: 0 0 var(--card-w);
    break-inside: avoid; page-break-inside: avoid;
    border: 1px dashed #888; border-top: 5px solid var(--card-accent, #888);
    border-radius: 0; box-shadow: none; overflow: hidden;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  /* Two cards per landscape sheet: break after every 2nd (but not the last). */
  .flashcard:nth-child(2n):not(:last-child) { break-after: page; page-break-after: always; }

  .card-face { padding: 0.28in 0.3in; font-size: 13.5pt; line-height: 1.45; }
  .card-title { font-size: 17pt; margin-bottom: 10pt; }
  .card-face li { font-size: 13.5pt; margin: 5pt 0; }
  .card-face table { font-size: 12pt; }
  .card-face blockquote { font-size: 12pt; }

  /* Flip cards: show BOTH faces stacked (single-sided, photocopier-robust). */
  .flashcard[data-flip] .card-front,
  .flashcard[data-flip] .card-back { display: block !important; }
  .flashcard[data-flip] .card-back { border-top: 1px dashed #bbb; margin-top: 6pt; padding-top: 8pt; }
  .flashcard[data-flip] .card-back .card-title { display: none; } /* avoid repeating the title */

  .card-svg svg { max-height: 3.2in; }
  a { color: #000; text-decoration: none; }
}
