/* Educational materials (/educational-materials/): hub + customisable printable worksheets.
   Pages are generated by scripts/worksheets/build.py. */
:root {
  --em-accent: #0d9488;
  --em-accent-dark: #0f766e;
  --em-ink: #0f172a;
  --em-muted: #475569;
  --em-line: #e2e8f0;
  --em-bg: #f8fafc;
}
* { box-sizing: border-box; }
body.ws-page-body, body.em-hub-body {
  margin: 0; background: var(--em-bg); color: var(--em-ink); line-height: 1.55;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
[hidden] { display: none !important; }
.tp-container.ws-container { width: min(1320px, calc(100% - 32px)); }
.tp-container.em-container { width: min(1120px, calc(100% - 32px)); }
.top-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.top-link { display: inline-flex; align-items: center; border: 1px solid #d1d5db; border-radius: 8px; padding: 6px 10px; text-decoration: none; color: #334155; font-size: 12px; font-weight: 700; background: #fff; }
.top-link:hover { border-color: var(--em-accent); color: var(--em-accent-dark); }
.tp-crumbs a, .tp-related a:hover, .tp-steps li::before { color: var(--em-accent-dark); }
.tp-steps li::before { background: var(--em-accent); color: #fff; }
.tp-cta a.tp-btn { background: var(--em-accent); }
.panel { background: #fff; border: 1px solid var(--em-line); border-radius: 14px; padding: 20px; margin-bottom: 14px; }
.panel h2 { font-size: 20px; margin: 0 0 10px; line-height: 1.3; }
.panel p, .panel li { color: var(--em-muted); font-size: 15px; }
h1 { font-size: 30px; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
.tp-lead { font-size: 16px; margin: 0; }
.tp-lead a { color: var(--em-accent-dark); }
.md-faq-q { margin: 0 0 14px; }
.md-faq-q h3 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.md-faq-q p { margin: 0; }

/* ---------- worksheet page ---------- */
.ws-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.ws-badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--em-accent); color: #fff; }
.ws-badge-soft { background: #f0fdfa; color: #115e59; border: 1px solid #99f6e4; }
.ws-app { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 14px; }
.ws-panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; background: #fff; border: 1px solid var(--em-line); border-radius: 14px; padding: 16px; }
.ws-ph { font-size: 16px; margin: 0 0 12px; }
.ws-field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 12px; font-weight: 700; color: #334155; }
.ws-field input[type=text] { width: 100%; height: 38px; border: 1px solid #cbd5e1; border-radius: 9px; padding: 0 10px; font: inherit; font-size: 14px; font-weight: 400; color: var(--em-ink); }
.ws-field input[type=text]:focus { outline: 2px solid var(--em-accent); outline-offset: 0; border-color: var(--em-accent); }
.ws-field input[type=range] { width: 100%; accent-color: var(--em-accent); }
.ws-field output { font-weight: 600; color: var(--em-muted); margin-left: 4px; }
.ws-fs { border: 0; padding: 0; margin: 0 0 12px; }
.ws-fs legend { font-size: 12px; font-weight: 700; color: #334155; margin-bottom: 4px; padding: 0; }
.ws-check { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; color: #334155; padding: 3px 0; cursor: pointer; line-height: 1.35; }
.ws-check input { margin: 2px 0 0; accent-color: var(--em-accent); flex: none; width: 15px; height: 15px; }
.ws-fs > .ws-check { display: inline-flex; margin-right: 12px; }
.ws-seg { display: flex; border: 1px solid #cbd5e1; border-radius: 9px; overflow: hidden; }
.ws-seg label { flex: 1; position: relative; }
.ws-seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.ws-seg span { display: block; text-align: center; font-size: 12px; font-weight: 700; padding: 8px 4px; color: #334155; border-left: 1px solid #cbd5e1; }
.ws-seg label:first-child span { border-left: 0; }
.ws-seg input:checked + span { background: var(--em-accent); color: #fff; }
.ws-seg input:focus-visible + span { outline: 2px solid var(--em-accent-dark); outline-offset: -3px; }
.ws-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ws-psec { border-top: 1px solid var(--em-line); padding: 8px 0 4px; }
.ws-check-sec { font-weight: 700; color: var(--em-ink); }
.ws-count { margin-left: auto; font-weight: 600; font-size: 11px; color: #64748b; white-space: nowrap; padding-left: 6px; }
.ws-pitems { padding-left: 22px; }
.ws-pitems .ws-check { font-size: 12.5px; }
.ws-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--em-accent); background: var(--em-accent); color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ws-btn:hover { background: var(--em-accent-dark); }
.ws-btn-ghost { background: #fff; color: #334155; border-color: #cbd5e1; }
.ws-btn-ghost:hover { background: #f1f5f9; }
.ws-stage { min-width: 0; }
.ws-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.ws-pages { font-size: 13px; color: #64748b; margin-left: auto; }
.ws-hint { font-size: 12.5px; color: #64748b; margin: 0 0 10px; }
.ws-preview { background: #e2e8f0; border-radius: 14px; padding: 18px; overflow: hidden; }
.ws-doc { width: 210mm; margin: 0 auto; }
.ws-page { background: #fff; width: 210mm; min-height: 297mm; padding: 14mm 15mm 12mm; margin: 0 0 18px; box-shadow: 0 2px 10px rgba(15, 23, 42, .12); position: relative; }
.ws-page:last-child { margin-bottom: 0; }

/* ---------- the printed sheet ---------- */
.ws-doc { --ws-fs: 11.5pt; font-family: Inter, Arial, sans-serif; color: #000; font-size: var(--ws-fs); line-height: 1.4; }
.ws-doc.fs-s { --ws-fs: 10pt; }
.ws-doc.fs-l { --ws-fs: 13.5pt; }
.ws-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; border-bottom: 1.5pt solid #000; padding-bottom: 3mm; margin-bottom: 5mm; }
.ws-titles { min-width: 0; }
.ws-school { margin: 0 0 1mm; font-size: .8em; color: #333; text-transform: uppercase; letter-spacing: .04em; }
.ws-title, .ws-title-key { margin: 0; font-size: 1.55em; line-height: 1.2; font-weight: 800; color: #000; }
.ws-subtitle { margin: 1mm 0 0; font-size: .95em; color: #333; }
.ws-fields { display: grid; gap: 2.5mm; flex: none; width: 62mm; font-size: .85em; }
.ws-fields span { display: flex; gap: 2mm; align-items: flex-end; white-space: nowrap; }
.ws-fields i { flex: 1; border-bottom: .75pt solid #000; height: 1.1em; }
.ws-sec { margin: 0 0 5mm; }
.ws-h { font-size: 1.1em; margin: 0 0 1mm; font-weight: 750; color: #000; break-after: avoid; page-break-after: avoid; }
.ws-instr { margin: 0 0 2.5mm; font-style: italic; color: #222; font-size: .95em; }
.ws-items { display: grid; gap: 4mm 5mm; }
.ws-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ws-grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ws-grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ws-list, .ws-full { grid-template-columns: minmax(0, 1fr); }
.ws-item, .ws-kitem { display: flex; gap: 2mm; break-inside: avoid; page-break-inside: avoid; min-width: 0; }
.ws-num { font-weight: 750; flex: none; min-width: 1.6em; }
.ws-unnum .ws-num { display: none; }
.ws-body { flex: 1; min-width: 0; }
.ws-grid2 .ws-item, .ws-grid3 .ws-item, .ws-grid4 .ws-item { border: .75pt solid #bbb; border-radius: 2mm; padding: 2mm; }
.ws-grid2 .ws-item .ws-body, .ws-grid3 .ws-item .ws-body, .ws-grid4 .ws-item .ws-body { display: flex; flex-direction: column; }
.ws-mols { display: flex; flex-wrap: wrap; gap: 2mm 5mm; align-items: center; margin: 1mm 0; }
.ws-mols .ws-mol { margin: 0; }
.ws-mol { display: block; text-align: center; margin: 1mm 0; }
.ws-mol img { width: calc(var(--w) * var(--ws-scale) * 1px); max-width: 100%; height: auto; display: inline-block; vertical-align: middle; }
.ws-grid2 .ws-k-structure-to-name .ws-mol, .ws-grid3 .ws-k-structure-to-name .ws-mol, .ws-grid4 .ws-k-structure-to-name .ws-mol { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 22mm; }
.ws-write { border-bottom: .75pt solid #000; height: 7mm; margin-top: 2mm; }
.ws-name { margin: 0 0 2mm; font-weight: 600; }
.ws-box { border: .75pt dashed #888; border-radius: 1.5mm; min-height: calc(32mm * var(--ws-scale)); }
.ws-prompt { margin: 0 0 1mm; }
.ws-k-question .ws-mol, .ws-list .ws-k-name-to-structure .ws-mol { text-align: left; }
.ws-lines { height: calc(var(--n) * 8mm); background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(8mm - .75pt), #777 calc(8mm - .75pt), #777 8mm); }
.ws-table { border-collapse: collapse; width: 100%; font-size: .95em; }
.ws-table th, .ws-table td { border: .75pt solid #000; padding: 1.5mm 2mm; text-align: left; vertical-align: top; }
.ws-table th { background: #f1f1f1; font-weight: 700; }
.ws-blank { height: 8mm; min-width: 20mm; }
.ws-fig { margin: 0; text-align: center; }
.ws-img { max-width: 100%; height: auto; }
.ws-fig figcaption { font-size: .85em; color: #333; margin-top: 1mm; }
.ws-html { min-width: 0; }
.ws-html img { max-width: 100%; height: auto; }
.ws-ans { display: none; }
.ws-doc.ans-inline .ws-qpage .ws-ans { display: block; color: #0f766e; font-weight: 600; margin-top: 1.5mm; }
.ws-doc.ans-inline .ws-qpage .ws-blank .ws-ans { display: inline; margin: 0; }
.ws-doc.ans-inline .ws-qpage .ws-ans::before { content: "Answer: "; font-weight: 700; }
.ws-doc.ans-inline .ws-qpage .ws-blank .ws-ans::before { content: none; }
.ws-keypage .ws-kitem .ws-body > .ws-mol { margin: 0; text-align: left; }
.ws-keypage .ws-kitem { align-items: flex-start; }
.ws-keypage .ws-items { gap: 2.5mm 5mm; }
.ws-ans-text { display: block; }
.ws-doc:not(.ans-key) .ws-keypage { display: none; }
.ws-foot { position: absolute; bottom: 5mm; right: 15mm; margin: 0; font-size: 7.5pt; color: #777; }
.ws-mol[data-smiles] { cursor: pointer; }
.ws-mol[data-smiles]:hover img { outline: 1px dashed var(--em-accent); outline-offset: 2px; }

/* thumbnail capture mode (?thumb=1): only the first page at 100 % */
body.ws-thumb { background: #fff; }
body.ws-thumb > *:not(main), body.ws-thumb main > *:not(.ws-app), body.ws-thumb .ws-panel, body.ws-thumb .ws-toolbar, body.ws-thumb .ws-hint, body.ws-thumb .ws-keypage { display: none !important; }
body.ws-thumb .ws-app { display: block; margin: 0; }
body.ws-thumb main.tp-container { width: auto; padding: 0; margin: 0; }
body.ws-thumb .ws-preview { padding: 0; background: #fff; border-radius: 0; }
body.ws-thumb .ws-doc { zoom: 1 !important; margin: 0; }
body.ws-thumb .ws-page { box-shadow: none; margin: 0; height: 297mm; overflow: hidden; }
body.ws-thumb .ws-foot { display: none; }

@media (max-width: 900px) {
  .ws-app { grid-template-columns: minmax(0, 1fr); }
  .ws-panel { position: static; max-height: none; }
  .ws-preview { padding: 10px; }
  .ws-pages { margin-left: 0; width: 100%; }
  h1 { font-size: 25px; }
  .panel { padding: 16px; }
}

/* ---------- print: only the A4 sheet(s) ---------- */
@page { size: A4; margin: 14mm 15mm 14mm; }
@media print {
  html, body.ws-page-body { background: #fff !important; }
  body.ws-page-body > *:not(main) { display: none !important; }
  body.ws-page-body main > *:not(.ws-app) { display: none !important; }
  body.ws-page-body main.tp-container { width: auto !important; padding: 0 !important; margin: 0 !important; }
  .ws-app { display: block !important; margin: 0 !important; }
  .ws-panel, .ws-toolbar, .ws-hint { display: none !important; }
  .ws-preview { padding: 0 !important; background: none !important; border-radius: 0 !important; overflow: visible !important; }
  .ws-doc { zoom: 1 !important; width: auto !important; margin: 0 !important; }
  .ws-page { width: auto !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; position: static; }
  .ws-keypage { break-before: page; page-break-before: always; }
  .ws-foot { position: static; text-align: right; margin-top: 4mm; }
  .ws-mol[data-smiles]:hover img { outline: none; }
  .ws-doc.ans-inline .ws-qpage .ws-ans { color: #000; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- hub ---------- */
.em-sub { font-size: 18px; font-weight: 600; color: var(--em-accent-dark) !important; margin: 0 0 10px; }
.em-group h2 { font-size: 22px; }
.em-cat { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin: 16px 0 10px; }
.em-group h2 + .em-cat { margin-top: 4px; }
.em-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.em-card { position: relative; display: flex; flex-direction: column; border: 1px solid var(--em-line); border-radius: 12px; background: #fff; text-decoration: none; color: var(--em-ink); transition: border-color .15s, box-shadow .15s; }
.em-card:hover, .em-card:focus-visible { border-color: var(--em-accent); box-shadow: 0 6px 20px rgba(15, 23, 42, .1); outline: none; }
.em-card:focus-visible { outline: 2px solid var(--em-accent); outline-offset: 2px; }
.em-thumb { display: block; aspect-ratio: 210 / 150; overflow: hidden; border-bottom: 1px solid var(--em-line); border-radius: 12px 12px 0 0; background: #f1f5f9; }
.em-thumb img { display: block; width: 100%; height: auto; }
.em-text { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px 14px; }
.em-text strong { font-size: 15px; line-height: 1.3; }
.em-level { font-size: 12px; font-weight: 600; color: var(--em-accent-dark); }
.em-desc { font-size: 13px; color: var(--em-muted); line-height: 1.45; }
.em-zoom { display: none; }
@media (hover: hover) and (min-width: 900px) {
  .em-zoom { display: block; position: absolute; z-index: 20; left: 50%; top: 50%; width: 320px; transform: translate(-50%, -50%) scale(.9); opacity: 0; visibility: hidden; pointer-events: none; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 18px 50px rgba(15, 23, 42, .28); overflow: hidden; transition: opacity .15s, transform .15s, visibility .15s; }
  .em-zoom img { display: block; width: 100%; height: auto; }
  .em-card:hover .em-zoom, .em-card:focus-visible .em-zoom { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); transition-delay: .25s; }
}
