/* Map projection class 11 practice: an atlas-sheet look. Pale blue-grey paper, deep ocean-blue ink, survey orange for
   the standard parallel, central meridian and equator, figures in a monospaced face like a calculation sheet. */
:root {
  --bg: #edf1f6;
  --paper: #fcfdfe;
  --ink: #121a2b;
  --muted: #465166;
  --line: #cdd6e2;
  --edge: #78849a;
  --accent: #1c4f8c;
  --accent-ink: #ffffff;
  --accent-soft: #dde7f4;
  --hot: #b4481a;
  --grid: rgba(28, 79, 140, 0.09);
  --ok: #17663a;
  --ok-soft: #dcefe2;
  --close: #845500;
  --close-soft: #f5ead2;
  --bad: #a32424;
  --bad-soft: #f7e1df;
  --focus: #0b63c9;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1520; --paper: #171f2e; --ink: #e4e9f2; --muted: #a8b3c6; --line: #2c3850; --edge: #6d7a92;
    --accent: #8db8ec; --accent-ink: #0d1626; --accent-soft: #1e3150; --hot: #f08b5a; --grid: rgba(141, 184, 236, 0.08);
    --ok: #7fd49e; --ok-soft: #173627; --close: #e7bf6a; --close-soft: #3a2f16; --bad: #f19a92; --bad-soft: #3d1f1d; --focus: #8cc8ff;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
a { color: var(--accent); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 8px 12px; z-index: 9; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* hero over a faint graticule */
.hero { padding: 26px 0 14px; position: relative; }
.hero::before { content: ""; position: absolute; inset: 0 -16px; z-index: -1;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: linear-gradient(#000 40%, transparent); -webkit-mask-image: linear-gradient(#000 40%, transparent); }
h1 { font: 700 clamp(1.75rem, 5.2vw, 2.6rem)/1.1 var(--head); letter-spacing: -0.01em; margin: 0 0 8px; }
.lede { margin: 0; max-width: 62ch; color: var(--muted); }
h2 { font: 700 1.45rem/1.2 var(--head); margin: 0 0 10px; }
h3 { font: 700 1.15rem/1.25 var(--head); margin: 0; }

/* setup */
.setup { border-top: 3px solid var(--accent); padding: 12px 0 6px; }
.ctl { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.fld { display: grid; gap: 3px; font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.fld.off { opacity: 0.55; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--edge); border-radius: var(--r); min-height: 44px; padding: 6px 10px; }
select { padding-right: 28px; max-width: 100%; }
.f-level select { min-width: 13.5rem; }
.btn { font: 600 16px var(--sans); min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--accent); background: var(--paper); color: var(--accent); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 40px; padding: 6px 14px; }
.btn:hover { filter: brightness(1.06); }
.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 8px 2px; min-height: 44px; cursor: pointer; text-decoration: underline; }
.more { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 8px; }
.tdet { min-width: 0; max-width: 100%; }
.tdet[open] { flex-basis: 100%; }
.convs select { width: 100%; }
.tdet > summary { flex-wrap: wrap; cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.tsum { font-weight: 400; color: var(--muted); font-size: 0.9rem; }
.topics { border: 0; padding: 0 0 8px; margin: 0; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.tg { display: flex; gap: 8px; align-items: center; min-height: 44px; }
.tg input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.convs { display: grid; gap: 10px; padding: 2px 0 10px; max-width: 34rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }
.note { border: 1px solid var(--bad); background: var(--bad-soft); padding: 8px 12px; margin: 10px 0; font-size: 16px; border-radius: var(--r); }
#store-note { overflow-wrap: anywhere; }
.note.info { border-color: var(--accent); background: var(--accent-soft); }

/* the sheet */
.sheet { margin: 14px 0 0; }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.score { margin: 0; color: var(--muted); font-size: 0.95rem; }
.sline { margin: 0 0 6px; color: var(--muted); font-size: 0.92rem; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { background: var(--paper); border: 1px solid var(--line); border-top: 3px double var(--accent); border-radius: 0 0 var(--r) var(--r); padding: 14px 16px 12px; margin: 0 0 18px; }
.q h3 { display: flex; gap: 10px; align-items: center; }
.qn { flex: none; display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1.5px solid var(--hot); font-family: var(--mono); color: var(--hot); font-size: 0.95rem; }
.scen { margin: 6px 0 4px; }
.conv { margin: 0 0 10px; font-size: 0.88rem; color: var(--muted); }
.calc { border-top: 1px solid var(--line); max-width: 700px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 12.5rem; gap: 4px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.prompt { font-size: 0.97rem; }
.ain { display: flex; align-items: center; gap: 6px; }
.ain input { width: 100%; font-family: var(--mono); }
.unit { width: 1.8rem; color: var(--muted); font-size: 0.92rem; }
.fbwrap { grid-column: 1 / -1; }
.fbwrap:empty { display: none; }
.fb { margin: 2px 0 0; font-size: 0.93rem; padding: 4px 8px; border-radius: 4px; }
.fb.right { background: var(--ok-soft); color: var(--ok); }
.fb.close { background: var(--close-soft); color: var(--close); }
.fb.wrong, .fb.unread { background: var(--bad-soft); color: var(--bad); }
.row.is-right input { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.row.is-close input { border-color: var(--close); box-shadow: inset 4px 0 0 var(--close); }
.row.is-wrong input, .row.is-unread input { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.qfoot { margin: 10px 0 2px; }
.work > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--accent); }
.keyt { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 4px 0 12px; }
.keyt th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--edge); padding: 4px 6px; }
.keyt td { border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: top; }
.keyt .ka { font-family: var(--mono); white-space: nowrap; font-weight: 600; }
.keyt .kw { color: var(--muted); font-family: var(--mono); font-size: 0.82rem; }
.gfig { margin: 0; }
.gfig figcaption { font-size: 0.88rem; color: var(--muted); margin-top: 4px; }
svg.grat { display: block; width: 100%; max-width: 640px; height: auto; background: var(--paper); }
.grat :not(text).par, .grat :not(text).mer { stroke: var(--ink); stroke-width: 0.22; fill: none; }
.grat :not(text).sp, .grat :not(text).cm, .grat :not(text).eq { stroke: var(--hot); stroke-width: 0.5; fill: none; }
.grat .cons { stroke: var(--edge); stroke-width: 0.18; stroke-dasharray: 1 0.8; }
.grat .dot { fill: var(--hot); }
.grat text { fill: var(--ink); font-family: var(--sans); }
.grat text.sp, .grat text.cm, .grat text.eq { fill: var(--hot); font-weight: 600; }
.grat text.small { fill: var(--muted); }
.grat text.halo { paint-order: stroke; stroke: var(--paper); stroke-width: 0.8; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 4px 0 0; }
.ask { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--close-soft); padding: 6px 10px; border-radius: var(--r); }
.share { margin: 22px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.print-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.print-row label { display: grid; gap: 3px; font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.share-out label { display: grid; gap: 3px; font-size: 0.9rem; }
.share-out input { width: 100%; font-size: 15px; }
.recent { margin-top: 12px; }
.recent > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.recent ul { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.recent small { display: block; color: var(--muted); }

/* content */
.content { margin: 34px 0 20px; max-width: 72ch; }
.content h2 { margin-top: 28px; }
.formulas { padding-left: 1.1rem; }
.formulas li { margin: 0 0 8px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 10px 0; min-height: 44px; font-weight: 600; }
.faq p { margin: 0 0 12px; }
.sources { font-size: 0.88rem; color: var(--muted); margin-top: 24px; }
footer { border-top: 1px solid var(--line); padding: 18px 0 30px; font-size: 0.9rem; color: var(--muted); }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 0 0 8px; }
.sb-more { line-height: 1.8; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); max-width: calc(100% - 32px); transition: transform 0.2s; z-index: 20; }
.toast.on { transform: translate(-50%, 0); }
.print-root { display: none; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 560px) {
  .sline { display: none; } /* the level and projections already show in the setup above */
  .sheet { margin-top: 8px; }
  #conv-sum { display: none; } /* each problem prints its conventions, so Projections and Conventions share a row */
  body { font-size: 16px; }
  .row { grid-template-columns: minmax(0, 1fr) 8.6rem; gap: 4px 10px; }
  .unit { width: 1.3rem; }
  .ain input { padding: 6px 8px; }
  .q { padding: 12px 12px 10px; }
  .f-level, .f-level select { width: 100%; min-width: 0; }
  /* the working drops under its step and answer instead of being hidden */
  .keyt thead { display: none; }
  .keyt tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-bottom: 1px solid var(--line); padding: 4px 0; }
  .keyt td { border-bottom: 0; padding: 2px 4px; }
  .keyt .kw { grid-column: 1 / -1; font-size: 0.8rem; overflow-wrap: anywhere; }
}

/* ---------- print ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font: 10.5pt/1.36 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  svg { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  table.pt { width: 100%; border-collapse: collapse; }
  table.pt > tbody > tr > td, table.pt > thead > tr > td { padding: 0; }
  .prun { font: 8.5pt var(--sans); color: #444; padding-bottom: 5pt !important; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 10pt; border-bottom: 2pt solid #000; margin-bottom: 5pt; }
  .ph h2 { font: 700 17pt var(--head); margin: 0; white-space: nowrap; }
  .ph p { margin: 0; font-size: 9pt; text-align: right; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 6pt 0; }
  .pnote { font-size: 9.5pt; margin: 0 0 6pt; }
  .pq { list-style: none; margin: 0; padding: 0; }
  .pq > li { padding: 6pt 0 8pt; border-bottom: 0.75pt solid #999; break-inside: avoid; }
  .pq h3, .pkey h3 { font: 700 12.5pt var(--head); margin: 0 0 2pt; }
  .pscen { margin: 0 0 2pt; font-size: 10.3pt; }
  .pconv { margin: 0 0 4pt; font-size: 8.8pt; color: #333; }
  .pcalc { width: 100%; border-collapse: collapse; font-size: 9.6pt; }
  .pcalc td { padding: 3.5pt 0 1.5pt; border-bottom: 0.5pt solid #ccc; vertical-align: bottom; }
  .pcalc .pl { width: 46mm; white-space: nowrap; }
  .uline { display: inline-block; width: 34mm; border-bottom: 0.75pt solid #000; }
  .pkeys { break-before: page; }
  .pkey.brk { break-before: page; }
  .pkt { width: 100%; border-collapse: collapse; font-size: 9pt; margin: 3pt 0 4pt; }
  .pkt td { border-bottom: 0.5pt solid #bbb; padding: 2pt 4pt 2pt 0; vertical-align: top; }
  .pkt tr { break-inside: avoid; }
  .pka { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
  .pkw { font-family: var(--mono); font-size: 7.8pt; color: #333; }
  .ptol { font-size: 7.8pt; color: #333; margin: 0 0 6pt; }
  .pfig { margin: 0; break-inside: avoid; }
  .pfig.brk { break-before: page; }
  .pfig figcaption { font-size: 8.5pt; margin-top: 4pt; display: grid; gap: 2pt; }
  .pfh { font-size: 8.5pt; color: #444; margin: 2pt 0 3pt; border-top: 0.5pt solid #999; padding-top: 3pt; }
  .tile { font-size: 9pt; font-weight: 700; margin: 0 0 3pt; }
  svg.grat { width: auto; max-width: none; background: #fff; }
  .grat :not(text).par, .grat :not(text).mer { stroke: #000; stroke-width: 0.2; }
  .grat :not(text).sp, .grat :not(text).cm, .grat :not(text).eq { stroke: #b4481a; stroke-width: 0.4; }
  .grat .cons { stroke: #777; }
  .grat text { fill: #000; }
  .grat text.sp, .grat text.cm, .grat text.eq { fill: #b4481a; }
  .grat text.halo { stroke: #fff; }
  svg.bar line { stroke: #000; stroke-width: 0.3; }
  svg.bar text { font: 2.6px var(--sans); fill: #000; }
}
