/* Additions: school branding, light and dark mode, topic tabs and the full-width teacher admin.
   Loaded after styles.css (see index.html). data-no-darken tells theme.js not to recolour this file, because it already
   handles dark mode itself. */

:root { --bar: #0e1b2a; }

/* ---------- Dark mode colours ---------- */
:root[data-theme="dark"] {
  --ink: #e4ebf3;
  --muted: #9db0c6;
  --paper: #0e151d;
  --panel: #16202b;
  --line: #2b3a4b;
  --primary: #4a84ec;
  --igcse: #2fb3a7;
  --alevel: #9b88f6;
  --alert: #f07560;
  --bar: #070c12;
  color-scheme: dark;
}
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { border-color: #3d4f63; }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: #7f92a8; }
:root[data-theme="dark"] .hero { background-image: linear-gradient(#1c2836 1px, transparent 1px), linear-gradient(90deg, #1c2836 1px, transparent 1px); }

/* Diagrams keep white paper and the light colours, because they are drawn with dark lines. */
:root[data-theme="dark"] main svg, :root[data-theme="dark"] main canvas, :root[data-theme="dark"] .fc-scroll, :root[data-theme="dark"] .dk-island {
  --ink: #0e1b2a; --muted: #55657a; --paper: #eef2f6; --panel: #ffffff; --line: #d3dce6;
  --primary: #1f5fd1; --igcse: #0e7c7b; --alevel: #5b3fd1; --alert: #d9391f;
  color: #0e1b2a; color-scheme: light;
}
:root[data-theme="dark"] main svg, :root[data-theme="dark"] main canvas { background-color: #fff; border-radius: 4px; }

/* ---------- Top bar: logo, site name and the dark mode switch ---------- */
.top { background: var(--bar); color: #fff; }
.brand { display: inline-flex; align-items: center; gap: .6rem; }
.brand-logo { height: 2.1rem; width: auto; max-width: 9rem; object-fit: contain; background: #fff; border-radius: 4px; padding: 2px 4px; }
.theme-btn { color: #fff; border-color: rgba(255, 255, 255, .45) !important; padding: .35rem .7rem; font-size: .85rem; white-space: nowrap; }
.theme-btn[aria-pressed="true"] { background: rgba(255, 255, 255, .12); }

/* ---------- Sign-in page branding ---------- */
.hero-logo { display: block; max-width: min(18rem, 100%); max-height: 8rem; width: auto; height: auto; object-fit: contain;
  margin-bottom: 1.1rem; background: #fff; border-radius: var(--radius); padding: .5rem .75rem; box-shadow: 0 0 0 1px var(--line); }
.hero-school { font: 600 .95rem var(--head); color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 0 0 .4rem; }
.hero .lead { font-size: 1.15rem; max-width: 38rem; }
.hero .lead p { margin: 0 0 .75em; }

/* Branding settings */
.br-logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .4rem; }
.br-logo-box { min-width: 8rem; min-height: 4rem; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: var(--radius); padding: .4rem; background: #fff; }
.br-logo-box img { max-width: 14rem; max-height: 6rem; display: block; }
.br-icon-box { display: flex; align-items: flex-end; gap: .8rem; flex-wrap: wrap; border: 1px dashed var(--line); border-radius: var(--radius); padding: .4rem .6rem; }
.br-icon-box figure { margin: 0; display: grid; justify-items: center; gap: .15rem; }
.br-icon-box figcaption { font-size: .7rem; color: var(--muted); }
.br-icon-box img { image-rendering: auto; }
.br-tab { display: flex; align-items: center; gap: .4rem; background: var(--paper); border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; padding: .3rem .7rem; font-size: .8rem; max-width: 12rem; overflow: hidden; white-space: nowrap; }
.br-preview { margin: .5rem 0 0; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); display: block; }
.br-preview h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }

/* ---------- Teacher admin uses the whole width ---------- */
body.wide main { max-width: none; }
/* Student names stay visible while the mark book scrolls sideways. */
table.mbook th[scope="row"], table.mbook thead th:first-child, table.mbook tfoot th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
table.mbook thead th:first-child { z-index: 2; }

/* Set work: tick everything */
/* Set work: two sub-tabs under the class picker. */
.aw-head { padding-bottom: 0; }
.aw-head #aw-sum { margin-bottom: .75rem; }
.ta-sub { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 -1.25rem; padding: 0 1.25rem; border-top: 1px solid var(--line); }
.ta-sub button { background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: .7rem .9rem .6rem; font-weight: 600; display: inline-flex; gap: .35rem; align-items: center; }
.ta-sub button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.ta-sub button:hover { color: var(--ink); }
/* Sub-tabs as a card of their own (subtabs.js: Rewards, Detailed results, Settings) */
.ta-subcard { padding-top: 0; padding-bottom: 0; }
.ta-subcard .ta-sub { border-top: 0; }
.ta-subhost > [hidden], .ta-subhost [data-sub-of][hidden] { display: none !important; }
/* Set work: the Set buttons stay at the bottom of the screen while the form is in view. */
.aw-go { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; margin: 0 -1.25rem -1.25rem; padding: .7rem 1.25rem; background: var(--panel); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 14px -10px rgba(0,0,0,.35); }
.aw-go #aw-n { margin-right: auto; }
.aw-go button:disabled { opacity: .45; cursor: default; }
body:has(.aw-go) .rp-btn { bottom: 5rem; }
@media (max-width: 560px) {
  .aw-go { gap: .4rem; padding: .55rem .75rem; margin: 0 -.75rem -.75rem; }
  .aw-go #aw-n { flex: 1 0 100%; font-size: .85rem; }
  .aw-go button { flex: 1 1 0; padding-inline: .5rem; }
  body:has(.aw-go) .rp-btn { bottom: 7.5rem; }
}
.ta-all { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem .75rem; margin-bottom: .5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.ta-tk { color: var(--primary); font-weight: 600; }

/* ---------- Topic page tabs ---------- */
:root:has(.tt-bar) { scroll-padding-top: 8rem; }
.tt-bar { position: sticky; z-index: 4; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 1.25rem; padding-top: .35rem;
  background: var(--paper); border-bottom: 2px solid var(--line); }
.tt-bar[hidden] { display: none; }
.tt-bar button { background: transparent; color: var(--ink); border: 0; border-bottom: 4px solid transparent; border-radius: 0; padding: .6rem 1rem; margin-bottom: -2px; }
.tt-bar button[hidden] { display: none; }
.tt-bar button[aria-selected="true"] { border-bottom-color: var(--primary); font-weight: 800; }
.tt-n:not(:empty) { margin-left: .4rem; font-size: .75rem; font-weight: 600; padding: .05rem .45rem; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.tt-jump { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; margin: 0 0 1rem; }
.tt-jump a { text-decoration: none; font-size: .88rem; font-weight: 600; padding: .2rem .65rem; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.tt-jump a:hover { border-color: var(--primary); }
.tt-exbar { margin: .25rem 0 .5rem; }
details.tt-series { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem; margin: .5rem 0; }
details.tt-series > summary { cursor: pointer; }
details.tt-series .item:first-of-type { border-top: 0; }

/* Links styled as buttons: the ghost and small variants (button.ghost and button.small are in styles.css). */
a.btn.ghost { background: transparent; color: var(--primary); border: 1px solid currentColor; }
a.btn.small { padding: .3rem .6rem; font-size: .85rem; }
