/* The Mains descriptive bank (mains.html). The template's own blue palette
   restated in the site's tokens, so it follows light/dark like every other
   page. Every rule is scoped under .mains: the template's bare table/th/td and
   .chip/.hidden selectors would otherwise leak into app.css's. */

/* Page frame, as the hub sets it in its own <style>: a column that pushes
   the footer down, and the same footer band. */
body { margin: 0; font-family: var(--font-ui); background: var(--surface-page); color: var(--text-main); min-height: 100vh; display: flex; flex-direction: column; }
body > footer {
  width: 100%; box-sizing: border-box; padding: 24px; text-align: center;
  border-top: 1px solid var(--border-color); font-size: 0.8rem; color: var(--text-muted);
  font-weight: 500; background: var(--surface-card);
}

.mains { max-width: var(--page-max, 1080px); margin: 0 auto; padding: 12px 24px 32px; width: 100%; box-sizing: border-box; flex: 1; }
/* display:flex on the offer would otherwise beat the hidden attribute. */
.mains [hidden] { display: none !important; }
.mains .mains-head h1 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin: 8px 0 4px; }
.mains .mains-head ul { margin: 0 0 10px; padding-left: 16px; color: var(--text-muted-on-page); font-size: 0.76rem; line-height: 1.45; }

/* The one offer, shown only to a reader without Mains. */
.mains .mains-offer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  background: var(--primary-glow); border: 1px solid var(--primary-tint);
  border-radius: var(--radius-lg); padding: 10px 14px; margin: 8px 0 12px;
}
.mains .offer-copy { flex: 1 1 240px; display: flex; flex-direction: column; gap: 3px; }
.mains .offer-copy strong { color: var(--primary-text); font-size: 0.9rem; }
.mains .offer-points { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 0.78rem; color: var(--text-muted); }
.mains .offer-points li::before { content: "✓ "; color: var(--primary-text); font-weight: 600; }
.mains .mains-offer strong { color: var(--primary-text); }
.mains .mains-offer .cta-btn { width: auto; margin: 0; min-height: 38px; padding: 8px 16px; font-size: 0.88rem; }
.mains .mains-notice { color: var(--accent-red); font-size: 0.9rem; margin: 6px 0; }

/* Filled controls take --primary-text, as .cta-btn does (app.css): white on
   the logo teal fails AA. In dark mode that teal lightens, so the label
   takes the dark ink instead — the same swap .cta-btn makes. */
body.dark-mode .mains .seg button.on,
body.dark-mode .mains .tb.on,
body.dark-mode .mains .chip.on,
body.dark-mode .mains h2.unit { color: #0B1A1C; }

/* Toolbar */
.mains .bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  box-shadow: var(--shadow-sm); font-family: var(--font-ui);
}
.mains .seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.mains .seg button { border: 0; background: var(--surface-card); color: var(--text-main); padding: 5px 10px; font: 500 0.8rem var(--font-ui); cursor: pointer; min-height: 32px; }
.mains .seg button + button { border-left: 1px solid var(--border-strong); }
.mains .seg button.on { background: var(--primary-text); color: #fff; font-weight: 600; }
.mains .tb, .mains .dd > button {
  border: 1px solid var(--border-strong); background: var(--surface-card); color: var(--text-main);
  border-radius: var(--radius); padding: 5px 9px; font: 500 0.8rem var(--font-ui); cursor: pointer; min-height: 32px;
}
.mains .tb.on { background: var(--primary-text); color: #fff; border-color: var(--primary-text); }
.mains .tot { font-size: 0.76rem; color: var(--text-muted); margin-left: auto; }

.mains .dd { position: relative; }
.mains .dd .menu {
  display: none; position: absolute; top: 110%; left: 0; z-index: 30; min-width: 220px; max-height: 60vh; overflow: auto;
  background: var(--surface-card); border: 1px solid var(--border-color); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px 4px;
}
.mains .dd.open .menu { display: block; }
.mains .dd label { display: block; padding: 5px 10px; cursor: pointer; white-space: nowrap; font-size: 0.86rem; color: var(--text-main); }
.mains .dd label.all { border-bottom: 1px solid var(--border-color); font-weight: 600; margin-bottom: 3px; }
.mains .dd label.locked { color: var(--text-faint); cursor: default; }
.mains .dd .lock { font-size: 0.78rem; color: var(--accent-amber); }

/* Bank */
.mains #main { font-family: var(--font-ui); color: var(--text-main); }
.mains .hint { color: var(--text-muted-on-page); font-size: 0.85rem; margin: 10px 0; }
.mains .hidden { display: none; }

.mains h2.unit {
  font: 600 0.92rem var(--font-ui); color: #fff; background: var(--primary-text);
  border-radius: var(--radius); padding: 7px 12px; margin: 18px 0 8px;
  cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.mains h2.unit .ua { width: 14px; }
.mains h2.unit .c { margin-left: auto; font-weight: 400; font-size: 0.8rem; opacity: 0.9; }
.mains .tap h2.unit { cursor: default; }
.mains .usb { font: 500 0.76rem var(--font-ui); border: 1px solid currentColor; background: transparent; color: inherit; border-radius: var(--radius); padding: 2px 9px; cursor: pointer; opacity: 0.9; }
.mains .usb:hover { opacity: 1; }

.mains h3.topic { font: 600 0.88rem var(--font-ui); margin: 14px 0 6px; color: var(--text-main); cursor: pointer; user-select: none; }
.mains h3.topic::before { content: "▾"; display: inline-block; width: 16px; color: var(--text-muted); }
.mains h3.topic.closed::before { content: "▸"; }
.mains h3.topic.closed + .tw { display: none; }
.mains .tap h3.topic { cursor: default; }
.mains .tap h3.topic::before { content: ""; }
.mains h3.topic .c, .mains .chipc {
  font-size: 0.74rem; background: var(--primary-glow); color: var(--primary-text);
  border-radius: 10px; padding: 0 8px; margin-left: 6px; font-weight: 600;
}
.mains .unit-h { background: var(--surface-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 8px 10px; margin: 12px 0 0; }
.mains .unit-h .mk2 { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }

.mains .addt {
  font-size: 0.68rem; font-weight: 500; color: var(--accent-blue); border: 1px solid var(--accent-blue-line);
  background: var(--accent-blue-bg); border-radius: 4px; padding: 0 4px; margin-left: 5px; vertical-align: 1px;
}
.mains .star { color: var(--accent-amber); }

/* Tables scroll inside their own box at phone width, never the page. */
.mains .tw { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.mains table { width: 100%; border-collapse: collapse; background: var(--surface-card); font-size: 0.86rem; line-height: 1.5; }
.mains th { background: var(--surface-sunken); text-align: left; padding: 6px 8px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); border: 1px solid var(--border-color); }
.mains td { padding: 6px 8px; border: 1px solid var(--border-color); vertical-align: top; }
.mains table.qt { min-width: 640px; }
.mains td.qs { color: var(--text-main); }
.mains .qno { margin-right: 6px; font-weight: 600; color: var(--primary-text); }
.mains td.kw { width: 18%; background: var(--surface-sunken); font-weight: 600; font-size: 0.8rem; }
.mains td.kw.sub { padding-left: 24px; font-weight: 500; }
.mains td.kw.sub::before { content: "↳ "; color: var(--text-faint); }
.mains td.kw .kc, .mains td.tp .kc { display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 400; }
.mains td.kw.ad .kt, .mains td.tp.ad { color: var(--accent-blue); font-style: italic; }
.mains tr.zero td, .mains tr.zero td.kw .kt { color: var(--text-faint); }
.mains td.ye { width: 96px; font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }
.mains td.mk { width: 48px; text-align: center; font-weight: 600; }
.mains tr.flash td { background: var(--primary-tint); transition: background 1.5s; }

.mains .sq { margin: 3px 0 0 10px; }
.mains .or { margin-top: 5px; padding: 4px 8px; border-left: 3px solid var(--accent-amber-line); background: var(--accent-amber-bg); }
.mains .or b { color: var(--accent-amber); font: 600 0.72rem var(--font-ui); margin-right: 4px; }
.mains .na { color: var(--text-muted); font-style: italic; }
.mains .tr { font: 0.7rem var(--font-ui); color: var(--text-muted); }

/* Syllabus view */
.mains table.sy td.tp { width: 26%; font-weight: 600; background: var(--surface-sunken); }
.mains ul.kl { margin: 0; padding-left: 18px; }
.mains ul.kl ul { padding-left: 20px; list-style: circle; margin: 2px 0; }
.mains ul.kl li { margin: 3px 0; cursor: pointer; }
.mains ul.kl li.z { color: var(--text-faint); cursor: default; }
.mains ul.kl li.ad > .kt { color: var(--accent-blue); font-style: italic; }
.mains ul.kl li:not(.z) > .kt:hover { text-decoration: underline; color: var(--primary-text); }
.mains .kn { font-size: 0.7rem; background: var(--primary-glow); color: var(--primary-text); border-radius: 9px; padding: 0 6px; margin-left: 6px; }
.mains li.z > .kn { background: var(--surface-sunken); color: var(--text-faint); }

/* Tap mode chips */
.mains .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.mains .chip { border: 1px solid var(--border-strong); background: var(--surface-card); color: var(--text-main); border-radius: 16px; padding: 4px 10px; font-size: 0.8rem; cursor: pointer; }
.mains .chip.on { background: var(--primary-text); color: #fff; border-color: var(--primary-text); }
.mains .chip.on .chipc { background: var(--surface-card); }
.mains .chip.z { color: var(--text-faint); }

@media (max-width: 640px) {
  .mains { padding: 10px 16px 28px; }
  /* The question table stacks on a phone: five columns at 390px left the
     question a sliver you scrolled sideways to read. The keyword cell only
     exists on the first row of its group (rowspan), so as a block it becomes
     that group's strip; each question follows with exam, year and marks
     under it. */
  .mains table.qt { min-width: 0; }
  .mains table.qt, .mains table.qt tbody, .mains table.qt tr, .mains table.qt td { display: block; width: auto; border: 0; }
  .mains table.qt thead { display: none; }
  .mains table.qt tr { border-top: 1px solid var(--border-color); }
  .mains table.qt td.kw { padding: 6px 10px; border-bottom: 1px solid var(--border-color); }
  .mains table.qt td.kw .kc { display: inline; margin-left: 6px; }
  .mains table.qt td.qs { padding: 8px 10px 2px; }
  .mains table.qt td.ye, .mains table.qt td.mk { display: inline-block; padding: 0 0 8px 10px; text-align: left; font-size: 0.74rem; color: var(--text-muted); }
  .mains table.qt td.mk::after { content: " marks"; font-weight: 400; }
  .mains table.qt tr.zero td.qs, .mains table.qt tr.zero td.ye, .mains table.qt tr.zero td.mk { display: none; }
  .mains td.kw { width: 26%; }
  .mains td.ye { width: auto; white-space: normal; }
  .mains .tot { width: 100%; margin: 0; }
  .mains .bar { position: static; }
}
