/* Case Prep (case-prep.html). Builds on ../style.css tokens and adds dark mode for this page. */

:root { --on-accent: #ffffff; --good: #5f7f3a; --bad: #b5502e; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1612;
    --fg: #eee4d6;
    --muted: #c2b19a;
    --muted2: #a4937d;
    --border: #3a3029;
    --tint1: #241d18;
    --tint2: #2a221c;
    --tint3: #2f261f;
    --tint-border: #4b3c30;
    --placeholder: #85735e;
    --rust: #e58d68;
    --maroon: #e39a92;
    --ochre: #dcae6c;
    --amber: #e8b46a;
    --on-accent: #1b1612;
    --good: #a7c47c;
    --bad: #e58d68;
  }
  .pill:hover { color: var(--on-accent); }
  .brand img { border-color: var(--tint-border); }
}

:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

.cp-studying .page-title,
.cp-studying .cp-hide-studying { display: none; }
.cp-studying .cp-toolbar { padding-top: 0; }

kbd {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.7;
  margin-left: 6px;
}

@media (hover: none) { kbd { display: none; } }

/* Toolbar */
.cp-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 24px;
  padding: 26px 0 10px;
}

.cp-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 13px; }
.cp-nav a { color: var(--maroon); border-bottom: 1px solid transparent; padding: 10px 0; }
.cp-nav a:hover, .cp-nav a.current { border-bottom-color: currentColor; }

.cp-searchbar { flex: 0 1 320px; min-width: 0; }
@media (max-width: 700px) { .cp-searchbar { flex: 1 1 100%; } }

.cp-input,
.cp-field input,
.cp-field select,
.cp-field textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  font: inherit;
  font-size: 15px;
  color: var(--fg);
  background: var(--tint1);
  border: 1px solid var(--tint-border);
  border-radius: 3px;
  padding: 9px 11px;
}
.cp-input:focus, .cp-field input:focus, .cp-field select:focus, .cp-field textarea:focus {
  outline: none;
  border-color: var(--ochre);
  background: var(--bg);
}
.cp-input::placeholder, .cp-field ::placeholder { color: var(--placeholder); }
.cp-input-inline { display: inline-block; width: auto; max-width: 100%; }

.cp-app { padding: 20px 0 70px; min-height: 50vh; }

/* Type */
.cp-h2 { margin: 10px 0 14px; font-size: 32px; font-weight: 400; color: var(--ochre); }
.cp-h3 { margin: 30px 0 12px; font-size: 20px; font-weight: 500; color: var(--maroon); }
.cp-eyebrow { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber); }
.cp-eyebrow em { text-transform: none; letter-spacing: 0; font-style: italic; color: var(--muted2); margin-left: 6px; }
.cp-note { margin: 0 0 16px; max-width: 720px; font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.cp-note code, .cp-prose code { font-size: 0.88em; background: var(--tint2); padding: 1px 4px; border-radius: 3px; }
.cp-crumb { margin: 0; font-size: 12px; color: var(--muted2); }
.cp-crumb a { color: var(--maroon); border-bottom: 1px solid currentColor; }
.cp-sub { margin: 4px 0 18px; font-size: 12px; color: var(--muted2); }
.cp-warn { padding: 12px 14px; border: 1px solid var(--rust); border-radius: 3px; color: var(--rust); background: var(--tint1); }

/* Buttons */
.cp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.03em;
  padding: 10px 18px;
  border: 1px solid var(--rust);
  border-radius: 3px;
  background: var(--bg);
  color: var(--rust);
  cursor: pointer;
  text-align: center;
}
.cp-btn:hover { background: var(--tint1); }
.cp-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.cp-btn-primary { background: var(--rust); color: var(--on-accent); }
.cp-btn-primary:hover:not(:disabled) { background: var(--maroon); border-color: var(--maroon); }
.cp-btn-lg { font-size: 13.5px; padding: 13px 26px; }
.cp-btn-sm { min-height: 44px; padding: 8px 12px; font-size: 11.5px; }
.cp-btn-danger { border-color: var(--bad); color: var(--bad); margin-left: auto; }
.cp-link { font: inherit; background: none; border: 0; padding: 0; color: var(--maroon); border-bottom: 1px solid currentColor; cursor: pointer; }
.cp-row-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0; }
.cp-file-btn { position: relative; overflow: hidden; }
.cp-file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cp-file-btn:focus-within { outline: 2px solid var(--rust); outline-offset: 2px; }

/* Home */
.cp-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
  flex-wrap: wrap;
  padding: 26px 28px;
  background: var(--tint1);
  border: 1px solid var(--tint-border);
  border-radius: 4px;
}
.cp-due { margin: 0; font-size: 22px; }
.cp-due-num { font-size: 64px; line-height: 1; color: var(--rust); margin-right: 6px; }
.cp-streak { display: flex; flex-direction: column; align-items: center; min-width: 140px; padding: 14px 18px; border: 1px dashed var(--tint-border); border-radius: 4px; text-align: center; }
.cp-streak .mono { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber); }
.cp-streak-num { font-size: 44px; line-height: 1.1; color: var(--ochre); }
.cp-streak-note { margin-top: 6px; font-size: 12.5px; color: var(--muted2); }
.cp-streak.is-done { border-style: solid; border-color: var(--ochre); }

.cp-cat { margin-top: 36px; }
.cp-cat-title { margin: 0 0 12px; font-size: 12px; font-family: 'Space Mono', monospace; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 400; color: var(--amber); }
.cp-deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cp-deck {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
  padding: 14px 16px;
  border: 1px solid var(--tint-border);
  border-radius: 3px;
  background: var(--bg);
}
.cp-deck:hover { border-color: var(--ochre); background: var(--tint1); }
.cp-deck-title { font-size: 16px; color: var(--fg); }
.cp-deck-meta { font-size: 11px; color: var(--muted2); }
.cp-deck-meta b { color: var(--rust); font-weight: 700; }

/* Stats */
.cp-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 6px 0 4px; font-size: 12px; color: var(--muted); }
.cp-stats b { color: var(--fg); font-size: 15px; margin-right: 4px; }
.cp-stats-lg b { font-size: 24px; color: var(--ochre); font-weight: 400; }
.cp-table { min-width: 560px; }
.cp-table td a { color: var(--maroon); border-bottom: 1px solid currentColor; }

/* Lists of cards */
.cp-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cp-item { display: block; border: 1px solid var(--tint-border); border-radius: 3px; background: var(--bg); }
.cp-item > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 14px;
  min-height: 44px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
}
.cp-item > summary::-webkit-details-marker { display: none; }
.cp-item > summary::before { content: '+'; font-family: 'Space Mono', monospace; color: var(--amber); margin-right: -6px; }
.cp-item[open] > summary::before { content: '−'; }
.cp-item[open] > summary { border-bottom: 1px solid var(--border); }
.cp-item-front { flex: 1 1 300px; font-size: 15px; }
.cp-item-meta { display: flex; flex-wrap: wrap; gap: 5px; font-size: 10.5px; }
.cp-item-body { padding: 4px 16px 12px; }
.cp-item-actions { display: flex; gap: 20px; font-size: 12px; margin: 0; }
.cp-item-actions a, .cp-item-actions .cp-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--maroon); border-bottom: 0; text-decoration: underline; text-underline-offset: 3px; }
.cp-bulk { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 0; margin-top: 8px; background: var(--bg); border-bottom: 1px solid var(--tint-border); }
.cp-bulk .cp-check { margin-right: 0; }
.cp-bulk-count { font-size: 12px; color: var(--muted); }
.cp-sel-row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 14px; cursor: pointer; border: 1px solid var(--tint-border); border-radius: 3px; background: var(--bg); }
.cp-sel-row input { flex: none; width: 18px; height: 18px; accent-color: var(--ochre); }
.cp-sel-row .cp-item-front { flex: 1; }
.cp-sel-row:has(input:checked) { background: var(--tint2); }
.cp-sel-edit { flex: none; display: inline-flex; align-items: center; min-height: 44px; font-size: 12px; color: var(--maroon); text-decoration: underline; text-underline-offset: 3px; }
.cp-chip { padding: 2px 7px; border-radius: 3px; background: var(--tint2); color: var(--muted); white-space: nowrap; }
.cp-chip-tag { background: transparent; border: 1px solid var(--tint-border); }
.cp-chip-flag { background: var(--rust); color: var(--on-accent); }
.cp-stage { color: var(--muted2); white-space: nowrap; }
.cp-stage-mature { color: var(--good); }
.cp-guide-hit { padding: 11px 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cp-guide-hit:hover { border-color: var(--ochre); }
.cp-snippet { flex-basis: 100%; font-size: 13.5px; color: var(--muted); }
.cp-search-big { font-size: 17px; margin-bottom: 8px; }

/* Rendered Markdown */
.cp-prose { font-size: 15px; line-height: 1.65; }
.cp-prose > :first-child { margin-top: 0; }
.cp-prose p, .cp-prose ul, .cp-prose ol { margin: 0 0 10px; }
.cp-prose ul, .cp-prose ol { padding-left: 22px; }
.cp-prose li { margin: 2px 0; }
.cp-prose li > ul, .cp-prose li > ol { margin: 2px 0 4px; }
.cp-prose h1 { font-size: 30px; font-weight: 400; color: var(--ochre); margin: 0 0 16px; }
.cp-prose h2 { font-size: 22px; font-weight: 500; color: var(--maroon); margin: 34px 0 10px; scroll-margin-top: 16px; }
.cp-prose h3 { font-size: 17px; font-weight: 500; color: var(--rust); margin: 24px 0 8px; scroll-margin-top: 16px; }
.cp-prose h4 { font-size: 15px; margin: 16px 0 6px; }
.cp-prose strong { font-weight: 600; }
.cp-prose a { color: var(--maroon); border-bottom: 1px solid currentColor; }
.cp-prose blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--amber); background: var(--tint1); color: var(--muted); }
.cp-prose blockquote p:last-child { margin-bottom: 0; }
.cp-prose hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.cp-prose pre { overflow-x: auto; background: var(--tint2); padding: 10px 12px; border-radius: 3px; font-size: 13px; }
.md-table { overflow-x: auto; margin: 10px 0 14px; -webkit-overflow-scrolling: touch; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md-table th, .md-table td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.md-table th { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--amber); font-weight: 400; border-bottom-color: var(--tint-border); }
.cp-hit { animation: cp-hit 1.6s ease-out; }
@keyframes cp-hit { from { background: var(--tint2); } to { background: transparent; } }

/* Guide */
.cp-guide { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; margin-top: 18px; align-items: start; }
.cp-toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.cp-toc ol { list-style: none; margin: 0 0 16px; padding: 0; font-size: 13.5px; }
.cp-toc li a { display: block; padding: 5px 0; color: var(--muted); }
.cp-toc li a:hover { color: var(--rust); }
.cp-toc li.lvl3 { padding-left: 12px; font-size: 12.5px; }
.cp-guide-body { max-width: 760px; }
@media (max-width: 860px) {
  .cp-guide { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cp-toc { position: static; max-height: none; padding: 14px; background: var(--tint1); border: 1px solid var(--tint-border); border-radius: 3px; }
  .cp-toc ol { columns: 2; column-gap: 16px; }
}

/* Study session */
.cp-session-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; font-size: 12px; color: var(--muted2); margin-bottom: 14px; }
.cp-card {
  position: relative;
  max-width: 820px;
  min-height: 240px;
  margin: 0 auto;
  padding: 26px 30px 22px;
  background: var(--tint1);
  border: 1px solid var(--tint-border);
  border-radius: 6px;
  cursor: pointer;
  touch-action: pan-y;
}
.cp-card.is-flipped { cursor: default; }
.cp-card:focus { outline: none; }
.cp-card:focus-visible { outline: 2px solid var(--rust); }
.cp-card-deck { margin: 0 0 14px; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--amber); }
.cp-flag-on { color: var(--rust); }
.cp-front { font-size: 22px; line-height: 1.45; }
.cp-front p { margin: 0 0 8px; }
.cp-back { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--tint-border); }
.cp-tap-hint { margin: 30px 0 0; font-size: 11px; color: var(--placeholder); }
.cp-recall-label { display: block; margin: 20px 0 6px; font-size: 11px; color: var(--muted2); }
.cp-card textarea {
  display: block;
  width: 100%;
  font-family: 'Space Mono', monospace;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--tint-border);
  border-radius: 3px;
  padding: 10px 12px;
  resize: vertical;
  cursor: text;
}
.cp-card textarea:focus { outline: none; border-color: var(--ochre); }
.cp-compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 22px; margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--tint-border); }
.cp-typed { margin: 0; white-space: pre-wrap; word-wrap: break-word; font-family: 'Space Mono', monospace; font-size: 13px; line-height: 1.6; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 10px 12px; min-height: 80px; }
@media (max-width: 720px) { .cp-compare { grid-template-columns: minmax(0, 1fr); } }

.cp-actions { max-width: 820px; margin: 18px auto 0; }
.cp-flip-btn { width: 100%; }
.cp-rate { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cp-rate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  font: inherit;
  font-size: 15px;
  border: 1px solid var(--tint-border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}
.cp-rate-btn small { font-size: 10.5px; color: var(--muted2); }
.cp-rate-btn:hover { background: var(--tint1); }
.cp-rate-btn.r1 { border-color: var(--bad); color: var(--bad); }
.cp-rate-btn.r3 { border-color: var(--ochre); }
.cp-rate-btn.r4 { border-color: var(--good); color: var(--good); }
.cp-swipe-hint { display: none; margin: 8px 0 0; text-align: center; font-size: 10.5px; color: var(--placeholder); }
@media (hover: none) { .cp-swipe-hint { display: block; } }
.cp-secondary { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }

/* Summary bars */
.cp-bars { max-width: 520px; margin: 20px 0; }
.cp-bar-row { display: grid; grid-template-columns: 60px 1fr 36px; gap: 12px; align-items: center; margin: 6px 0; font-size: 12px; }
.cp-bar { height: 12px; background: var(--tint2); border-radius: 2px; overflow: hidden; }
.cp-bar span { display: block; height: 100%; }
.cp-bar .r1 { background: var(--bad); }
.cp-bar .r2 { background: var(--amber); }
.cp-bar .r3 { background: var(--ochre); }
.cp-bar .r4 { background: var(--good); }

/* Forms */
.cp-form { max-width: 960px; }
.cp-fs { border: 0; padding: 0; margin: 0 0 22px; }
.cp-fs-group { margin-bottom: 12px; }
.cp-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-right: 16px; font-size: 15px; cursor: pointer; }
.cp-check input { width: 18px; height: 18px; accent-color: var(--ochre); }
.cp-check-cat { font-weight: 500; color: var(--maroon); }
.cp-check-list { display: flex; flex-wrap: wrap; padding-left: 26px; }
.cp-check-list .cp-check { font-size: 14px; min-height: 40px; }
.cp-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.cp-tag { position: relative; cursor: pointer; }
.cp-tag input { position: absolute; opacity: 0; }
.cp-tag span { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 13px; font-family: 'Space Mono', monospace; font-size: 12px; border: 1px solid var(--tint-border); border-radius: 3px; color: var(--ochre); }
.cp-tag input:checked + span { background: var(--ochre); border-color: var(--ochre); color: var(--on-accent); }
.cp-tag input:focus-visible + span { outline: 2px solid var(--rust); outline-offset: 2px; }
.cp-field { display: block; margin-bottom: 16px; }
.cp-field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.cp-field > span em { font-weight: 400; font-size: 12.5px; color: var(--muted2); margin-left: 4px; }
.cp-field textarea { resize: vertical; line-height: 1.5; }
.cp-field textarea.cp-code { font-family: 'Space Mono', monospace; font-size: 12.5px; }
.cp-field-inline { max-width: 220px; }
.cp-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; }
@media (max-width: 640px) { .cp-grid2 { grid-template-columns: minmax(0, 1fr); } }
.cp-preview { min-height: 200px; max-height: 340px; overflow: auto; padding: 10px 12px; border: 1px dashed var(--tint-border); border-radius: 3px; }
.cp-form-msg { min-height: 1em; margin: 4px 0; font-size: 12px; color: var(--rust); }
.cp-panel { margin-top: 26px; padding-top: 6px; border-top: 1px solid var(--border); }

/* Dialog + flash */
.cp-dialog { width: min(960px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--tint-border); border-radius: 6px; background: var(--bg); color: var(--fg); }
.cp-dialog::backdrop { background: rgba(27, 22, 18, 0.6); }
.cp-dialog-inner { padding: 20px 24px; }
.cp-flash { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 3px; background: var(--fg); color: var(--bg); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.cp-flash.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  /* Get to the due count fast on a phone. */
  .page-title { padding: 18px 0 14px; }
  .page-title h1 { font-size: 34px; }
  .page-title .tk-intro { display: none; }
  .site-header { padding: 18px 0; }
  .cp-toolbar { padding-top: 14px; }
  .cp-hero { padding: 20px 18px; }
  .cp-due-num { font-size: 52px; }
  .cp-card { padding: 20px 18px 18px; }
  .cp-front { font-size: 19px; }
  .cp-h2 { font-size: 27px; }
  .cp-toc ol { columns: 1; }
}
