/* Ashton Education Services — shared design system.
   Loaded by every site at /shared/base.css. Each property sets only --accent. */

/* ===== Inter (self-hosted) ===== */
@font-face { font-family: Inter; font-weight: 400; font-style: normal; font-display: swap; src: url("/shared/fonts/Inter-400.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 400; font-style: italic; font-display: swap; src: url("/shared/fonts/Inter-400-Italic.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-style: normal; font-display: swap; src: url("/shared/fonts/Inter-500.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-style: normal; font-display: swap; src: url("/shared/fonts/Inter-600.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 700; font-style: normal; font-display: swap; src: url("/shared/fonts/Inter-700.woff2") format("woff2"); }

/* ===== Design tokens ===== */
:root {
  /* accent is supplied per-property; this is a fallback (org-home slate). */
  --accent: #4a5b66;
  --accent-strong: color-mix(in srgb, var(--accent) 82%, black);
  --on-accent: #ffffff;
  --link: var(--accent);
  --link-hover: color-mix(in srgb, var(--accent) 78%, black);
  --focus: color-mix(in srgb, var(--accent) 60%, transparent);

  /* neutrals — light is the default; dark set below */
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  /* scale */
  --maxw: 1100px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: Consolas, ui-monospace, "Cascadia Code", monospace;
}

/* dark = device preference, unless a data-theme override wins */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a; --surface: #1e293b; --border: #334155;
    --text: #f8fafc; --text-muted: #94a3b8; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f172a; --surface: #1e293b; --border: #334155;
  --text: #f8fafc; --text-muted: #94a3b8; --shadow: none;
}
:root[data-theme="light"] {
  --bg: #f8fafc; --surface: #ffffff; --border: #e2e8f0;
  --text: #0f172a; --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

/* ===== Base elements ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.5rem; } h2 { font-size: 2rem; } h3 { font-size: 1.5rem; } h4 { font-size: 1.25rem; }
p { margin: 0.5rem 0; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, pre { font-family: var(--mono); }
.sub { color: var(--text-muted); margin: 0.5rem 0 1.5rem; }
.org { text-transform: uppercase; letter-spacing: 0.3em; font-size: 0.72rem; color: var(--accent); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; font: inherit; font-size: 0.95rem; font-weight: 500;
  border-radius: var(--radius); padding: 0.55rem 1.1rem; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); color: var(--on-accent); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent); color: var(--on-accent); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); text-decoration: underline; }

/* ===== Forms, cards, tables ===== */
input, select, textarea { font: inherit; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.7rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ===== Public site: header, hero, footer ===== */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border); background: var(--surface); }
.brand-row { display: flex; align-items: center; gap: 0.7rem; }
.brand-logo { width: 42px; height: 42px; border-radius: 9px; background: #fff;
  border: 1px solid var(--border); padding: 3px; flex-shrink: 0; }
.wordmark { font-weight: 700; letter-spacing: -0.01em; color: var(--text); line-height: 1.1; }
.wordmark small { display: block; font-weight: 500; font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.hero { min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--sp-12) var(--sp-4); }
/* Landing pages that carry content below the title need a shorter hero. */
.hero-compact { min-height: 0; padding: var(--sp-8) var(--sp-4) var(--sp-6); }
.section-page { max-width: var(--maxw); margin: 0 auto; padding: var(--sp-12) var(--sp-6); }
.section-page h1 { margin-bottom: var(--sp-4); }
.back-link { margin-top: var(--sp-8); }

/* Subject domains: icon + subtitle + body text, in a two-column grid with
   subtle rules between the cells (borders sit in the gutters). */
.domain-list { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: var(--sp-8); }
.domain { display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-8); }
.domain:nth-child(odd) { padding-left: 0; border-right: 1px solid var(--border); }
.domain:nth-child(even) { padding-right: 0; }
.domain:not(:nth-last-child(-n + 2)) { border-bottom: 1px solid var(--border); }
.domain-icon { width: 64px; height: 64px; border-radius: 12px; background: #fff;
  border: 1px solid var(--border); padding: 6px; flex-shrink: 0; }
.domain-text { flex: 1; min-width: 0; }
.domain-text h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; }
.domain-text p { margin: 0; }
@media (max-width: 820px) {
  .domain-list { grid-template-columns: 1fr; }
  .domain { padding: var(--sp-6) 0; border-right: none !important; }
  .domain:not(:last-child) { border-bottom: 1px solid var(--border); }
  .domain:last-child { border-bottom: none; }
}

/* Subject rows: name left, qualification pills flushed right */
.subject-list { list-style: none; margin: 0; padding: 0; }
.subject-row { display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: 0.35rem 0; }
.subject-row > a { font-size: 0.95rem; }
.pill-group { display: flex; gap: 0.3rem; flex-shrink: 0; margin-left: auto; }

/* Qualification pills */
.pill { display: inline-block; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill-igcse  { background: #dcfce7; color: #166534; border-color: #166534; }
.pill-alevel { background: #dbeafe; color: #1e3a8a; border-color: #1e3a8a; }
.pill-preu   { background: #fef9c3; color: #854d0e; border-color: #854d0e; }
/* PD levels: same dark purple text/border; background steps light -> darker */
.pill-l3     { background: #f6effc; color: #581c87; border-color: #581c87; }
.pill-l5     { background: #e3cdf6; color: #581c87; border-color: #581c87; }
.pill-l7     { background: #c9a3ec; color: #581c87; border-color: #581c87; }
/* Read-only badge shown in a module's top bar */
.pill-readonly { background: var(--bg); color: var(--text-muted); border-color: var(--border);
  font-size: 0.7rem; vertical-align: middle; margin-left: 0.5rem; }

/* Professional development qualifications: full-width subject blocks.
   Layout: icon on the left; to its right a column holding the title row
   (linked subject title, pills flushed right) and the description, so the
   description aligns with the title, not the icon. */
/* Full content width — wraps at the right edge, in line with the pills. */
.pd-intro { margin: var(--sp-2) 0 var(--sp-8); }
.pd-subject { display: flex; align-items: flex-start; gap: var(--sp-4);
  margin-bottom: var(--sp-8); }
.pd-icon { width: 64px; height: 64px; border-radius: 12px; background: #fff;
  border: 1px solid var(--border); padding: 6px; flex-shrink: 0; }
.pd-body { flex: 1; min-width: 0; }
.pd-title-row { display: flex; align-items: center; gap: var(--sp-4); min-height: 64px; }
.pd-title { margin: 0; font-size: 1.35rem; font-weight: 700; }
.pd-pills { margin-left: auto; display: flex; gap: 0.4rem; flex-shrink: 0; }
.pd-desc { margin: 0.35rem 0 0; max-width: 75ch; }
@media (max-width: 640px) {
  .pd-title-row { flex-wrap: wrap; min-height: 0; }
  .pd-pills { margin-left: 0; }
}

/* Page title with pills beside it */
.title-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-4);
  margin-bottom: var(--sp-4); }
.title-bar h1 { margin: 0; }
.title-bar .pill { font-size: 0.8rem; padding: 0.25rem 0.7rem; }
.hero h1 { border-bottom: 3px solid var(--accent); padding-bottom: 0.5rem; }
.tagline { margin-top: 0.9rem; font-size: clamp(1rem, 2.5vw, 1.35rem); color: var(--text-muted); }
.site-footer { border-top: 1px solid var(--border); padding: var(--sp-6); color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }

/* ===== Theme toggle ===== */
.theme-toggle { background: transparent; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer; padding: 0.4rem 0.6rem; font-size: 1rem; line-height: 1; }
.theme-toggle:hover { color: var(--text); }

/* ===== App shell (authenticated portals) ===== */
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: var(--sp-6) var(--sp-4); gap: var(--sp-4); }
/* Brand lockup: logo and site name side by side, then a rule. */
.brand-block { display: flex; flex-direction: row; align-items: center; gap: 0.7rem; }
.brand-mark { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; flex-shrink: 0; }
.brand-mark:hover { text-decoration: none; }
.sidebar-logo { width: 75px; height: 75px; border-radius: 16px; background: #fff;
  border: 1px solid var(--border); padding: 6px; flex-shrink: 0; }
.brand-acronym { font-weight: 800; font-size: 4.5rem; line-height: 1; color: var(--text); letter-spacing: -0.03em; }
.brand-name { font-weight: 700; font-size: 1.4rem; color: var(--text); line-height: 1.2;
  min-width: 0; overflow-wrap: break-word; }
.brand-name a { color: inherit; text-decoration: none; }
.sidebar-rule { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.brand-accent { font-weight: 700; color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar nav a { padding: 0.5rem 0.6rem; border-radius: var(--radius); color: var(--text-muted); font-size: 0.95rem; }
.sidebar nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: var(--on-accent); }
.sidebar nav a.disabled { opacity: 0.45; pointer-events: none; }
/* Sidebar: top-level module (accented + bold) and grouped accordions */
.sidebar nav a.nav-top { font-weight: 700; color: var(--accent); }
.sidebar nav a.nav-top:hover { background: var(--bg); }
.sidebar nav a.nav-top.active { color: var(--on-accent); background: var(--accent); }
.nav-group { margin-top: 0.15rem; }
.nav-group > summary { cursor: pointer; list-style: none; display: flex; align-items: center;
  justify-content: space-between; gap: 0.4rem; padding: 0.45rem 0.6rem; border-radius: var(--radius);
  color: var(--text); font-size: 0.9rem; font-weight: 600; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { content: "›"; color: var(--text-muted); font-size: 1.1rem;
  line-height: 1; transition: transform .15s; }
.nav-group[open] > summary::after { transform: rotate(90deg); }
.nav-group > summary:hover { background: var(--bg); }
/* Module links sit tighter and smaller than their accordion headers (85% of
   the 0.9rem summary), each with a right-aligned chevron. Needs to out-specify
   `.sidebar nav a` above, which would otherwise win and restore the larger
   size and padding. */
.nav-group-items { display: flex; flex-direction: column; gap: 0; padding: 0.1rem 0 0.35rem; }
.sidebar nav .nav-group-items a { display: flex; align-items: center;
  justify-content: space-between; gap: 0.4rem;
  padding: 0.18rem 0.6rem 0.18rem 1.1rem; font-size: 0.77rem; line-height: 1.35; }
/* inherits the link colour, so it stays legible on the active (accent) row */
.sidebar nav .nav-group-items a::after { content: "›"; font-size: 1rem; line-height: 1;
  opacity: 0.55; flex-shrink: 0; }
/* Console links pinned to the bottom of the sidebar (role-gated by the caller) */
.admin-links { margin-top: auto; display: flex; flex-direction: column; gap: 0.4rem; }
.admin-link { display: block; text-align: center; padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); font-size: 0.9rem; }
.admin-link:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.userbox { margin-top: auto; display: flex; align-items: center; gap: 0.6rem; border-top: 1px solid var(--border); padding-top: var(--sp-4); }
/* When console links are present they take the auto margin (pushing both to the
   bottom); a second auto margin here would split the free space between them. */
.admin-links + .userbox { margin-top: var(--sp-4); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.9rem; flex-shrink: 0; }
.userbox .who { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; }
.userbox .who .email { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.userbox button { background: none; border: none; color: var(--text-muted); cursor: pointer; text-decoration: underline; font-size: 0.78rem; padding: 0; }
.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border); }
.content { padding: var(--sp-8) var(--sp-6); max-width: var(--maxw); width: 100%; flex: 1; }
.footer { padding: var(--sp-6); color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }

.sidebar a.brand { text-decoration: none; color: var(--text); display: block; }
.sidebar a.brand:hover { text-decoration: none; color: var(--accent); }

/* ===== Org homepage: floating actions + intro + property cards ===== */
.home-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem;
  max-width: var(--maxw); margin: 0 auto; padding: var(--sp-4) var(--sp-6) 0; }
.home-intro { max-width: var(--maxw); margin: 0 auto; padding: var(--sp-6) var(--sp-6); }
.home-title { display: flex; align-items: center; gap: 1rem; margin-bottom: var(--sp-4); }
.home-title h1 { margin: 0; }
.home-logo { width: 64px; height: 64px; border-radius: 14px; background: #fff;
  border: 1px solid var(--border); padding: 6px; flex-shrink: 0; }
.home-intro .lead { color: var(--text-muted); max-width: 70ch; }
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4);
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-6) var(--sp-12); }
.link-card { display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow);
  text-decoration: none; transition: border-color .15s, transform .15s; }
.link-card:hover { border-color: var(--card-accent, var(--accent)); text-decoration: none; transform: translateY(-2px); }
.link-card h3 { margin-bottom: 0.4rem; color: var(--card-accent, var(--accent)); }
.link-card p { color: var(--text-muted); font-size: 0.95rem; margin: 0; }
.link-card.disabled { opacity: 0.55; pointer-events: none; }
/* Cards with a photo: narrow image strip on the left (25% of the card width,
   aspect ratio preserved) with the title and text aligned to its right edge. */
.link-card.has-photo { display: flex; align-items: flex-start; gap: var(--sp-6); }
.card-photo { width: 25%; height: auto; flex-shrink: 0; border-radius: var(--radius);
  display: block; }
.card-text { flex: 1; min-width: 0; }
/* A "button" inside a whole-card link: styled as a button, not separately clickable. */
.card-btn { margin-top: var(--sp-4); pointer-events: none; }
.link-card:hover .card-btn { background: var(--card-accent, var(--accent)); color: var(--on-accent); }
.link-card .card-btn { color: var(--card-accent, var(--accent)); border-color: var(--card-accent, var(--accent)); }
.link-card .soon { display: inline-block; margin-top: 0.6rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); }
@media (max-width: 768px) { .card-grid { grid-template-columns: 1fr; } }

/* ===== Site admin console: second sidebar + module matrix ===== */
.console { display: grid; grid-template-columns: 190px 1fr; gap: var(--sp-8); align-items: start; }
.console-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.console-nav a { padding: 0.45rem 0.6rem; border-radius: var(--radius);
  color: var(--text-muted); font-size: 0.95rem; }
.console-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.console-nav a.active { background: var(--accent); color: var(--on-accent); }
.console-main { min-width: 0; }
.school-picker { max-width: 360px; margin: var(--sp-4) 0 var(--sp-6); }
.scroll-x { overflow-x: auto; }
.module-matrix th:not(:first-child), .module-matrix td:not(:first-child) {
  text-align: center; width: 110px; }
.module-matrix td.module-top { font-weight: 700; color: var(--accent); }
.module-matrix tr.group-row td { font-weight: 700; background: var(--bg);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.module-matrix input[type="radio"] { cursor: pointer; }
.module-matrix input[type="radio"]:disabled { cursor: not-allowed; opacity: 0.35; }
.module-matrix input[type="checkbox"] { cursor: pointer; }
/* Global "active" switch sits apart from the per-school access columns */
.module-matrix .active-cell { border-left: 2px solid var(--border); }
.module-matrix .col-note { font-weight: 400; text-transform: none; letter-spacing: 0;
  font-size: 0.68rem; color: var(--text-muted); }
.row-actions { white-space: nowrap; }
.row-actions a + a { margin-left: 0.75rem; }
.row-actions .btn { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* Inline notice inside the app shell (e.g. module not available) */
.notice-inline { max-width: 560px; }
.notice-inline h3 { margin-bottom: 0.3rem; }

/* ===== Centered notice (chooser, no-access, onboarding) ===== */
.notice-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-6); }
.notice { width: 100%; max-width: 460px; }
.notice h1 { font-size: 1.7rem; }
.notice.wide { max-width: 560px; }

/* ===== Forms (onboarding, admin console) ===== */
.form-field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.7rem 0; text-align: left; }
.form-field label { font-size: 0.8rem; color: var(--text-muted); }
.form-field input[disabled] { opacity: 0.65; background: var(--bg); cursor: not-allowed; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; align-items: center; }
.form-error { color: var(--danger); font-size: 0.9rem; margin: 0.5rem 0; }
.form-ok { color: var(--success); font-size: 0.9rem; margin: 0.5rem 0; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .userbox { margin-top: var(--sp-4); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
