/* Practise With Calculator — site styles
   Layout idea: a calm reading column (max 72ch) under a slim header; the calculator's
   two-line LCD is the one recurring motif (hero, program listings, screen readouts). */
:root {
  --paper: #f5f7fa;      /* page background, blue-grey neutral */
  --surface: #ffffff;    /* cards, code panels */
  --ink: #1b222b;        /* body text */
  --muted: #4a5563;      /* secondary text */
  --line: #d3d9e1;       /* rules and borders */
  --accent: #0a58a8;     /* links, buttons, focus (blue: safe under red/green weakness) */
  --accent-ink: #ffffff; /* text on accent */
  --tint: #e3eefa;       /* accent wash */
  --mark: #f2c230;       /* yellow marker, never used for text */
  --lcd: #c8d3c1;        /* calculator display background */
  --lcd-ink: #18201a;    /* calculator display text */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial,
    "PingFang HK", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-display: var(--font-body);
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11161c; --surface: #19202a; --ink: #e5e9ef; --muted: #aab4c1; --line: #2e3845;
    --accent: #78b6ff; --accent-ink: #0c1420; --tint: #1c2c40; --mark: #e0b52c;
    --lcd: #b4c0ac; --lcd-ink: #151c16; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #11161c; --surface: #19202a; --ink: #e5e9ef; --muted: #aab4c1; --line: #2e3845;
  --accent: #78b6ff; --accent-ink: #0c1420; --tint: #1c2c40; --mark: #e0b52c;
  --lcd: #b4c0ac; --lcd-ink: #151c16; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: var(--step-0)/1.6 var(--font-body);
}
img, svg, iframe { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-3); letter-spacing: -0.02em; font-weight: 800; }
h2 { font-size: var(--step-2); letter-spacing: -0.01em; font-weight: 750; }
h3 { font-size: var(--step-1); font-weight: 700; }
p { margin: 0; }
.zh { font-weight: 500; color: var(--muted); }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 12px; top: 12px; z-index: 10; }

/* Review banner: remove the element before launch */
.draft { background: var(--ink); color: var(--paper); font-size: var(--step--1); text-align: center; padding: 6px 16px; }

/* Header */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.head-in { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-name span { box-shadow: inset 0 -0.32em 0 var(--mark); }
.brand-zh { font-size: var(--step--1); color: var(--muted); }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: var(--ink); text-decoration: none; font-size: 0.95rem; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { border-bottom-color: var(--line); }
.nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 650; }

/* Page body */
main { display: block; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.col { max-width: 72ch; }
.page-head { padding: 40px 0 24px; display: grid; gap: 10px; }
.page-head .lede { font-size: var(--step-1); color: var(--muted); max-width: 60ch; line-height: 1.5; }
section { padding: 28px 0; }
.stack { display: grid; gap: 14px; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; align-items: center; padding-top: 48px; padding-bottom: 36px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.tagline { font-size: var(--step-1); font-weight: 650; letter-spacing: 0.02em; }
.tagline b { box-shadow: inset 0 -0.3em 0 var(--mark); font-weight: 750; }
.hero .lede { font-size: 1.12rem; color: var(--muted); max-width: 52ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 6px; }
.btn { display: inline-block; padding: 11px 18px; border-radius: var(--radius); font-weight: 650; text-decoration: none; border: 2px solid var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { color: var(--accent); background: transparent; }
.btn[aria-disabled="true"] { border-color: var(--line); color: var(--muted); background: var(--surface); cursor: not-allowed; }

/* LCD motif */
.lcd { background: var(--lcd); color: var(--lcd-ink); border-radius: 10px; padding: 14px 18px 12px; font-family: var(--font-mono);
  border: 6px solid var(--ink); box-shadow: 0 1px 0 var(--line); }
.lcd-ind { font-size: 0.7rem; letter-spacing: 0.08em; display: flex; gap: 12px; opacity: 0.85; min-height: 1em; }
.lcd-up { font-size: 1.1rem; white-space: pre; overflow-x: auto; }
.lcd-low { font-size: 2.1rem; text-align: right; line-height: 1.15; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.lcd-caption { font-size: var(--step--1); color: var(--muted); margin-top: 8px; }
.lcd-stack { display: grid; gap: 14px; }

/* Grids and cards */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 32px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 8px; align-content: start; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.count { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); }
.point { display: grid; gap: 4px; align-content: start; }
.point h3 { font-size: 1.05rem; }
.point p, .card p { color: var(--muted); }

/* Notices */
.notice { border-left: 4px solid var(--ink); background: var(--surface); padding: 14px 18px; font-size: 0.95rem; }
.notice.zh-block { margin-top: 6px; }
.promo { background: var(--tint); border-radius: var(--radius); padding: 24px; display: grid; gap: 10px; }

/* Chips: meaning carried by fill and wording, never by hue alone */
.chip { display: inline-block; font-size: 0.78rem; font-weight: 650; padding: 2px 9px; border-radius: 999px; line-height: 1.6; white-space: nowrap; }
.chip-free { border: 1.5px solid var(--accent); color: var(--accent); background: transparent; }
.chip-paid { border: 1.5px solid var(--ink); background: var(--ink); color: var(--surface); }
.chip-tool { white-space: normal; max-width: 100%; border: 1.5px solid var(--line); color: var(--ink); background: var(--surface); font-family: var(--font-mono); font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 650; background: var(--paper); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Program listing */
.prog { display: grid; gap: 12px; padding: 24px 0; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.prog-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.prog-id { font-family: var(--font-mono); font-weight: 700; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.code-panel { position: relative; background: var(--lcd); color: var(--lcd-ink); border-radius: var(--radius); border: 4px solid var(--ink); max-width: 30rem; }
.code-panel pre { margin: 0; padding: 14px 16px; font: 1.02rem/1.55 var(--font-mono); overflow-x: auto; }
.copy { position: absolute; top: 8px; right: 8px; font: 600 0.8rem var(--font-body); padding: 5px 10px; border-radius: 4px;
  border: 1.5px solid var(--lcd-ink); background: var(--lcd); color: var(--lcd-ink); cursor: pointer; }
.copy:hover { background: var(--lcd-ink); color: var(--lcd); }
.io { display: grid; gap: 8px; }
.io dt { font-weight: 650; }
.io dd { margin: 0 0 4px; color: var(--ink); }
.keys { font-family: var(--font-mono); font-size: 0.95rem; }
.answer { font-family: var(--font-mono); font-weight: 700; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
summary { cursor: pointer; padding: 10px 14px; font-weight: 650; color: var(--accent); }
details[open] summary { border-bottom: 1px solid var(--line); }
.details-body { padding: 12px 16px; display: grid; gap: 8px; }

/* Exam questions */
.q { display: grid; gap: 10px; padding: 22px 0; border-top: 1px solid var(--line); }
.q-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.q-num { font-family: var(--font-mono); font-weight: 700; color: var(--muted); min-width: 3.2em; }
.q p { max-width: 72ch; }

/* Lessons */
.lesson { display: grid; gap: 12px; padding: 26px 0; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.lesson-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; }
.lesson-no { font-family: var(--font-mono); font-weight: 700; color: var(--muted); min-width: 2.4em; }
.lesson ol, .lesson ul { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; max-width: 72ch; }
.kbd { font-family: var(--font-mono); font-size: 0.9em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); white-space: nowrap; }
.toc { columns: 2; column-gap: 32px; padding-left: 1.2em; margin: 0; }
.toc li { break-inside: avoid; padding: 2px 0; }

/* Calculator frame */
.calc-layout { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 36px; align-items: start; padding-bottom: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 36px; align-items: start; }
.muted { color: var(--muted); }
.calc-frame { width: 100%; height: 860px; border: 1px solid var(--line); border-radius: 12px; background: #1f2328; display: block; }
.frame-note { font-size: var(--step--1); color: var(--muted); margin-top: 8px; }

/* Grid children may shrink below their content width so long code lines scroll inside their panel */
.stack, .prog, .lesson, .q, .io, .details-body, .card, .point { grid-template-columns: minmax(0, 1fr); }

/* Footer */
.site-foot { margin-top: 48px; background: var(--surface); border-top: 1px solid var(--line); font-size: var(--step--1); color: var(--muted); }
.foot-in { max-width: 1120px; margin: 0 auto; padding: 28px 20px 36px; display: grid; gap: 10px; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-nav a { color: var(--ink); }

@media (max-width: 860px) {
  .hero, .calc-layout, .split { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .toc { columns: 1; }
  .nav { margin-left: 0; }
}
@media (max-width: 480px) {
  .calc-frame { height: 780px; }
  .lcd-low { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print { .site-head nav, .copy, .draft { display: none; } body { background: #fff; } }

/* ---------------------------------------------------------------- graphics (v0.1.1) */
:root { --dot: #c3cfdd; --shadow: rgba(16, 24, 40, 0.22); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dot: #2a3646; --shadow: rgba(0, 0, 0, 0.55); } }
:root[data-theme="dark"] { --dot: #2a3646; --shadow: rgba(0, 0, 0, 0.55); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.plain-list { margin: 0; padding-left: 1.2em; }

/* Hero band with an LCD dot-matrix texture */
.hero-band { background-color: var(--tint);
  background-image: radial-gradient(var(--dot) 1.1px, transparent 1.5px); background-size: 12px 12px;
  border-bottom: 1px solid var(--line); overflow: hidden; }
.hero-band .hero { padding-top: 40px; padding-bottom: 40px; }
.hero-art { margin: 0; display: grid; gap: 10px; justify-items: center; }
.phones { position: relative; width: 100%; max-width: 440px; height: 545px; }
.phone { position: absolute; width: 230px; height: auto; border-radius: 24px; box-shadow: 0 18px 40px var(--shadow); background: #1f2328; }
.phone-front { left: 0; top: 12px; transform: rotate(-4deg); z-index: 2; }
.phone-back { right: 0; top: 0; transform: rotate(5deg); }
.art-caption { font-size: var(--step--1); color: var(--muted); max-width: 44ch; text-align: center; }

/* Press, Work, Check */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.step { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; align-items: start; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.step h3 { display: flex; align-items: baseline; gap: 8px; }
.step p { color: var(--muted); margin-top: 4px; }
.step-no { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 999px;
  width: 1.6em; height: 1.6em; display: inline-grid; place-items: center; }

/* Icons */
.ic { width: 52px; height: 52px; display: block; }
.ic-key { fill: var(--surface); stroke: var(--ink); stroke-width: 2.5; }
.ic-shadow { fill: var(--ink); }
.ic-text { fill: var(--ink); font: 800 13px var(--font-body); }
.ic-frame { fill: var(--ink); }
.ic-lcd { fill: var(--lcd); }
.ic-ink { fill: var(--lcd-ink); }
.ic-tick { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.ic-line { stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; }
.ic-curveline { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.ic-dot { fill: var(--mark); stroke: var(--ink); stroke-width: 2; }

/* Diagrams drawn from each program's example */
.dg { width: 100%; height: auto; display: block; }
.dg-bg { fill: var(--surface); }
.dg-grid { stroke: var(--line); stroke-width: 0.6; }
.dg-axis { stroke: var(--muted); stroke-width: 1; }
.dg-curve { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linejoin: round; }
.dg-curve2, .dg-curve2c { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 7 4; }
.dg-dash { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 2 4; stroke-linecap: round; }
.dg-shape { fill: var(--tint); stroke: var(--ink); stroke-width: 1.6; }
.dg-pt { fill: var(--mark); stroke: var(--ink); stroke-width: 1.5; }
.dg-ring { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.dg-label { fill: var(--ink); font: 600 11px var(--font-body); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.dg-strong { font-size: 15px; font-weight: 800; }
.dg-keytext { fill: var(--ink); font: 700 26px var(--font-body); }
.dg-wide { max-width: 420px; }

/* Program tiles */
.section-head { display: grid; gap: 6px; max-width: 72ch; padding-bottom: 14px; }
.mini-grid, .tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mini-tile, .tile { position: relative; display: grid; gap: 8px; align-content: start; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; color: var(--ink); text-decoration: none; }
.mini-tile:hover, .tile:hover, .card-link:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mini-label, .tile-label { justify-self: start; font: 700 0.8rem var(--font-mono); background: var(--ink); color: var(--surface);
  padding: 1px 7px; border-radius: 4px; }
.mini-title, .tile-title { font-weight: 650; line-height: 1.3; }
.tile-sub { color: var(--muted); font-size: 0.92rem; }
.card-link { color: var(--ink); text-decoration: none; }
.card-link h3 { color: var(--accent); }

/* Screens and figures */
.page-head-art { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 24px 40px; }
.head-shot { margin: 0; display: grid; gap: 6px; justify-items: center; }
.head-shot figcaption { font-size: var(--step--1); color: var(--muted); }
.head-icon .ic { width: 96px; height: 96px; }
.phone-sm { width: 180px; height: auto; border-radius: 18px; box-shadow: 0 10px 26px var(--shadow); background: #1f2328; }
.look-pair { display: flex; flex-wrap: wrap; gap: 20px; }
.look-pair figure { margin: 0; display: grid; gap: 6px; justify-items: center; font-size: var(--step--1); color: var(--muted); }
.lcd-shot { width: 100%; max-width: 360px; height: auto; border-radius: 6px; border: 4px solid var(--ink); background: var(--lcd); display: block; }
.lcd-shot-sm { max-width: 300px; }
.lesson-art { max-width: 420px; }

/* Program detail */
.prog h2 { font-size: var(--step-1); }
.prog-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.prog-figs { margin: 0; display: grid; gap: 12px; }
.prog-figs .dg { border: 1px solid var(--line); border-radius: var(--radius); }
.prog-figs figcaption { font-size: var(--step--1); color: var(--muted); }
.prog-list { max-width: 1000px; }

/* Manual cover */
.promo-art { grid-template-columns: minmax(0, 1fr) 200px; align-items: center; gap: 24px; }
.cover-wrap { max-width: 200px; }
.cover-wrap-lg { max-width: 240px; }
.cover { width: 100%; height: auto; display: block; filter: drop-shadow(0 12px 22px var(--shadow)); }
.cv-bg { fill: var(--ink); }
.cv-spine { fill: var(--accent); }
.cv-mark { fill: var(--mark); }
.cv-title { fill: var(--paper); font: 800 32px var(--font-body); letter-spacing: -0.5px; }
.cv-sub { fill: var(--paper); font: 500 15px var(--font-body); }
.cv-lcd-frame { fill: var(--paper); }
.cv-lcd { fill: var(--lcd); }
.cv-lcd-ink { fill: var(--lcd-ink); font: 500 17px var(--font-mono); }
.cv-lcd-big { fill: var(--lcd-ink); font: 600 40px var(--font-mono); }

@media (max-width: 860px) {
  .steps { grid-template-columns: 1fr; }
  .prog-body { grid-template-columns: 1fr; }
  .page-head-art { grid-template-columns: 1fr; }
  .head-shot, .head-icon { display: none; }
  .promo-art { grid-template-columns: 1fr; }
  .phones { height: 475px; max-width: 360px; }
  .phone { width: 200px; }
}
@media (max-width: 480px) {
  .phones { height: 430px; }
  .phone { width: 180px; }
}
