/* Amethyst Recovery Academy — CPRS Prep Center. Mobile-first. Palette from style-and-branding-rules.md */
:root {
  --deep: #523A8E;      /* deep purple: wordmark, primary (8.6:1 on white) */
  --mid: #7C6FB8;       /* medium purple: accents only (not body text) */
  --peri: #8895C9;      /* periwinkle: borders, decoration */
  --mint: #86C7AD;      /* mint: accents, focus ring on dark */
  --white: #FFFFFF;
  --ink: #1F1A2E;       /* body text */
  --muted: #4A4560;     /* secondary text (≥ 7:1 on white) */
  --tint: #F3F1FA;      /* light purple surface */
  --mint-tint: #EAF6F0;
  --line: #D7D3E8;
  --ok: #1E6B4A;  --ok-bg: #E3F4EC;
  --bad: #9A1F2E; --bad-bg: #FBE9EC;
  --radius: 12px;
  --font: "Avenir Next", Avenir, "Century Gothic", Futura, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--white); font-size: 1.0625rem; line-height: 1.6; }
img { max-width: 100%; }
a { color: var(--deep); text-underline-offset: 2px; }
a:hover { color: #3B2868; }
:focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .5rem; top: -3rem; background: var(--deep); color: var(--white); padding: .5rem .9rem; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: .5rem; color: var(--white); outline-color: var(--mint); }

/* header / logo */
.site-header { background: var(--white); border-bottom: 4px solid var(--deep); }
.header-inner { max-width: 60rem; margin: 0 auto; padding: .75rem 1rem .5rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; justify-content: space-between; }
.wordmark { text-decoration: none; display: inline-flex; flex-direction: column; align-items: flex-start; gap: .2rem; line-height: 1.05; color: var(--deep); }
.wordmark img.logo { display: block; height: 88px; width: auto; max-width: min(220px, 70vw); }
@media (min-width: 40rem) {
  .wordmark img.logo { height: 104px; max-width: 260px; }
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.site-nav a { display: inline-block; padding: .55rem .75rem; min-height: 44px; border-radius: 8px; text-decoration: none; font-weight: 600; color: var(--deep); }
.site-nav a:hover { background: var(--tint); }
.site-nav a[aria-current="page"] { background: var(--deep); color: var(--white); }
.site-nav a[aria-current="page"]:focus-visible { outline-color: var(--mint); }
.site-nav a.ext { display: inline-flex; align-items: center; gap: .35rem; background: var(--mint); color: var(--ink); border: 2px solid var(--deep); padding: .45rem .85rem; font-weight: 700; }
.site-nav a.ext:hover { background: var(--mint-tint); color: var(--deep); }
.site-nav a.ext .ext-icon { flex: none; }

main { max-width: 60rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
main:focus { outline: none; }
h1, h2, h3, h4 { line-height: 1.25; color: var(--deep); }
h1 { font-size: 1.6rem; margin: .75rem 0 .5rem; }
h2 { font-size: 1.3rem; margin-top: 1.75rem; }
h3 { font-size: 1.1rem; }
.lede { color: var(--muted); font-size: 1.05rem; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-footer .inner { max-width: 60rem; margin: 0 auto; padding: 1rem; }

/* cards & buttons */
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.card { border: 1px solid var(--line); border-top: 5px solid var(--peri); border-radius: var(--radius); padding: 1rem; background: var(--white); }
.card h2, .card h3 { margin-top: 0; }
.card.accent { border-top-color: var(--mint); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .6rem 1.1rem; border-radius: 10px; border: 2px solid var(--deep); background: var(--deep); color: var(--white); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: #3F2C70; color: var(--white); }
.btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; box-shadow: 0 0 0 5px var(--deep); }
.btn.secondary { background: var(--white); color: var(--deep); }
.btn.secondary:hover { background: var(--tint); }
.btn.secondary:focus-visible { outline-color: var(--deep); box-shadow: none; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.note { background: var(--tint); border-left: 5px solid var(--mid); padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0; }
.note.mint { background: var(--mint-tint); border-left-color: var(--mint); }
.small { font-size: .92rem; color: var(--muted); }
.badge { display: inline-block; font-size: .8rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; background: var(--tint); color: var(--deep); border: 1px solid var(--peri); margin-right: .3rem; }
.badge.tag { background: var(--mint-tint); color: #1F4D3B; border-color: var(--mint); }
.badge.done { background: var(--ok-bg); color: var(--ok); border-color: #9BD2B8; }
.badge.draft { background: #FFF4DB; color: #6B4A00; border-color: #E6C46A; }

/* progress bars */
.bar { height: .7rem; background: var(--tint); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--deep); }

/* study */
.breadcrumb { font-size: .92rem; margin: .5rem 0; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.breadcrumb li + li::before { content: "›"; margin: 0 .35rem; color: var(--muted); }
.lesson-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.lesson-list li { border-bottom: 1px solid var(--line); }
.lesson-list a { display: flex; gap: .6rem; align-items: baseline; padding: .6rem .25rem; text-decoration: none; min-height: 44px; }
.lesson-list a:hover { background: var(--tint); }
.lesson-list .lid { font-weight: 700; min-width: 4.2rem; color: var(--deep); }
.lesson-list .ltitle { flex: 1; color: var(--ink); }
.lesson-body { overflow-wrap: anywhere; }
.lesson-body table { border-collapse: collapse; width: 100%; min-width: 28rem; font-size: .97rem; }
.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: 8px; }
.lesson-body th, .lesson-body td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
.lesson-body th { background: var(--tint); color: var(--deep); }
.lesson-body blockquote.md-note { margin: 1rem 0; padding: .6rem 1rem; background: var(--mint-tint); border-left: 5px solid var(--mint); border-radius: 8px; }
.lesson-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.lesson-body ul, .lesson-body ol { padding-left: 1.4rem; }
.lesson-body li { margin: .25rem 0; }
.lesson-actions { border-top: 2px solid var(--line); margin-top: 2rem; padding-top: 1rem; }
.mark-done[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.pager { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* practice */
.form-row { margin: .75rem 0; }
label.block { display: block; font-weight: 700; margin-bottom: .3rem; }
select, input[type="number"] { font: inherit; min-height: 44px; padding: .4rem .6rem; border: 2px solid var(--peri); border-radius: 8px; background: var(--white); color: var(--ink); width: 100%; max-width: 28rem; }
.check { display: flex; gap: .55rem; align-items: center; min-height: 44px; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--deep); }
.runner-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; position: sticky; top: 0; background: var(--white); padding: .5rem 0; border-bottom: 1px solid var(--line); z-index: 5; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--deep); background: var(--tint); padding: .25rem .6rem; border-radius: 8px; }
.timer.low { background: var(--bad-bg); color: var(--bad); }
.question fieldset { border: 0; padding: 0; margin: 1rem 0; }
.question legend { font-size: 1.15rem; font-weight: 600; padding: 0; margin-bottom: .75rem; color: var(--ink); }
.choice { display: flex; gap: .7rem; align-items: flex-start; border: 2px solid var(--line); border-radius: 10px; padding: .75rem .85rem; margin: .55rem 0; cursor: pointer; min-height: 48px; background: var(--white); }
.choice:hover { border-color: var(--peri); background: var(--tint); }
.choice input { margin-top: .3rem; width: 1.2rem; height: 1.2rem; flex: none; accent-color: var(--deep); }
.choice .letter { font-weight: 800; color: var(--deep); min-width: 1.3rem; }
.choice:has(input:checked) { border-color: var(--deep); background: var(--tint); }
.choice:has(input:focus-visible) { outline: 3px solid var(--deep); outline-offset: 2px; }
.choice.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.feedback { border-radius: 10px; padding: .85rem 1rem; margin: 1rem 0; border: 2px solid; }
.feedback.ok { border-color: var(--ok); background: var(--ok-bg); }
.feedback.bad { border-color: var(--bad); background: var(--bad-bg); }
.feedback h3 { margin: 0 0 .3rem; color: inherit; }
.feedback.ok h3 { color: var(--ok); } .feedback.bad h3 { color: var(--bad); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); gap: .35rem; margin: .5rem 0 1rem; }
.palette button { min-height: 44px; border: 2px solid var(--line); background: var(--white); border-radius: 8px; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }
.palette button.answered { background: var(--tint); border-color: var(--peri); color: var(--deep); }
.palette button[aria-current="true"] { border-color: var(--deep); box-shadow: inset 0 0 0 2px var(--deep); }

/* report card */
.score-big { font-size: 2.4rem; font-weight: 800; color: var(--deep); line-height: 1.1; }
table.report { border-collapse: collapse; width: 100%; margin: .75rem 0; }
table.report th, table.report td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.report th { color: var(--deep); background: var(--tint); }
table.report td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.report .bar { min-width: 4rem; }
@media (max-width: 480px) { table.report th, table.report td { padding: .45rem .3rem; } table.report .bar { min-width: 2.5rem; } }
.review-item { border: 1px solid var(--line); border-left: 6px solid var(--peri); border-radius: 10px; padding: .85rem 1rem; margin: .9rem 0; break-inside: avoid; }
.review-item.missed { border-left-color: var(--bad); }
.review-item.right { border-left-color: var(--ok); }
.review-item ol { list-style: none; padding: 0; margin: .5rem 0; }
.review-item li { padding: .3rem .5rem; border-radius: 6px; margin: .2rem 0; }
.review-item li.key { background: var(--ok-bg); font-weight: 600; }
.review-item li.picked-wrong { background: var(--bad-bg); }
.history-list { list-style: none; padding: 0; }
.history-list li { border-bottom: 1px solid var(--line); padding: .6rem 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; justify-content: space-between; }
.resource { border: 1px solid var(--line); border-left: 6px solid var(--deep); border-radius: 10px; padding: .9rem 1rem; margin: .9rem 0; }
.resource h2 { margin: 0 0 .25rem; font-size: 1.15rem; }
.resource, .resource .contact, .resource a { overflow-wrap: anywhere; word-break: break-word; }
.resource .contact a { font-weight: 700; }
.resource.emergency { border-left-color: var(--bad); }
noscript p { background: var(--bad-bg); padding: 1rem; border-radius: 8px; }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* print: report card only, clean black-on-white */
.disclaimer { background: var(--mint-tint); border-bottom: 2px solid var(--deep); color: var(--ink); }
.disclaimer p { max-width: 60rem; margin: 0 auto; padding: .6rem 1rem; font-size: .95rem; line-height: 1.5; }
@media print {
  .disclaimer { display: block !important; background: #fff !important; border: 1px solid #000; margin-bottom: 8pt; }
  .disclaimer p { padding: 4pt 6pt; font-size: 9.5pt; }
  body { font-size: 11pt; color: #000; }
  .site-nav, .site-footer, .no-print, .btn, .btn-row, .skip-link, .runner-top .timer { display: none !important; }
  .site-header { display: block !important; background: #fff; border-bottom: 2px solid var(--deep); }
  .wordmark img.logo { height: 56px !important; max-width: 160px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  main { max-width: none; padding: 0; }
  a { color: #000; text-decoration: none; }
  .print-only { display: block !important; }
  .card, .review-item, .note { border-color: #999 !important; background: #fff !important; }
  .bar { border-color: #666; } .bar > span { background: #555 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  h1, h2, h3, .score-big { color: #000; }
  details { display: block; } details > summary { list-style: none; }
  .review-item { page-break-inside: avoid; }
}
.print-only { display: none; }
