:root {
  --red-ink: #C21B27;
  --red-tint: #fef2f2;
  --red-tint-strong: #fde3e6;
  --header-from: #C21B27;
  --header-to: #99151F;
  --surface: #e9edf3;
  --surface-raised: #ffffff;
  --hairline: #d3dae4;
  --divider: #e2e8f0;
  --dashed: #b6c0cf;
  --dot: rgba(100, 116, 139, 0.22);
  --ink-faint: #94a3b8;
  --pv-track: #e9edf3;
  --pv-lec: #fde3e6;
  --pv-lab: #dbe7fd;
  --pv-lab-edge: #bfd3fb;
  --pv-lunch: #fbecc0;
  --pv-lec-ink: #7a1f26;
  --pv-lab-ink: #1d4ed8;
  --break-ink: #854d0e;
  --pv-c1: #C21B27; --pv-c2: #2563eb; --pv-c3: #d97706; --pv-c4: #7c3aed; --pv-c5: #0891b2;
  --ink: #0f172a;
  --ink-body: #334155;
  /* 4.76:1 on white but under AA on --surface: anything sitting on the page
     background takes --ink-soft instead. */
  --ink-muted: #64748b;
  --ink-soft: #475569;
  /* Neutral on purpose: red read as a warning, and needing a login is not one. */
  --login-bg: rgba(71, 85, 105, 0.12);
  --login-ink: #334155;
  --open-bg: rgba(21, 128, 61, 0.12);
  --open-ink: #166534;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.10), 0 1px 1px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 20px -6px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

/* data-theme is always set, by the inline script in index.php's <head>, so one
   selector covers both the saved choice and the system setting. */
:root[data-theme="dark"] {
    --red-ink: #f87171;
    --red-tint: rgba(248, 113, 113, 0.14);
    --red-tint-strong: rgba(248, 113, 113, 0.28);
    --header-from: #7e1620;
    --header-to: #4c0d14;
    --surface: #0c1117;
    --surface-raised: #151c25;
    --hairline: #26313f;
    --divider: #26313f;
    --dashed: #3a4757;
    --dot: rgba(159, 176, 194, 0.14);
    --ink-faint: #5b6879;
    --pv-track: #1f2935;
    --pv-lec: rgba(248, 113, 113, 0.22);
    --pv-lab: rgba(96, 165, 250, 0.22);
    --pv-lab-edge: rgba(96, 165, 250, 0.35);
    --pv-lunch: rgba(251, 191, 36, 0.16);
    --pv-lec-ink: #fecdd3;
    --pv-lab-ink: #bfdbfe;
    --break-ink: #fcd34d;
    --pv-c1: #ef4444; --pv-c2: #3b82f6; --pv-c3: #f59e0b; --pv-c4: #8b5cf6; --pv-c5: #06b6d4;
    --ink: #e7edf4;
    --ink-body: #c3cfdc;
    --ink-muted: #9fb0c2;
    --ink-soft: #9fb0c2;
    --login-bg: rgba(159, 176, 194, 0.16);
    --login-ink: #c3cfdc;
    --open-bg: rgba(74, 222, 128, 0.14);
    --open-ink: #4ade80;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.wrap { max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* The academic dashboard's header (.app-header there): crest in a white chip,
   the name in the serif, on the red gradient. */
.app-header {
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; min-width: 0; }
.brand-logo {
  background: #fff; border-radius: 10px; padding: 5px 8px;
  display: flex; align-items: center; box-shadow: var(--shadow-sm); flex-shrink: 0;
}
/* Crest only, cropped by ratio off the full lockup: the crest is x=0..182 of 481. */
.brand-logo img {
  display: block; height: 46px; width: auto;
  aspect-ratio: 190 / 139; object-fit: cover; object-position: left center;
}
/* The product's own mark beside the university's crest: a thin rule keeps the
   two apart, so the crest still reads as the university and the compass as
   this site. */
.brand-mark {
  display: flex; align-items: center; gap: 10px;
  padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, 0.28);
}
.brand-mark svg { width: 38px; height: 38px; flex: none; color: #fff; overflow: visible; }
/* The one moment of motion on the page: the needle swings past north-east,
   back, and settles, as a real compass does when you pick it up. */
.needle {
  transform-box: view-box; transform-origin: 32px 34px; transform: rotate(40deg);
  animation: needle-settle 1.6s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
@keyframes needle-settle {
  0%   { transform: rotate(-70deg); }
  45%  { transform: rotate(62deg); }
  70%  { transform: rotate(30deg); }
  85%  { transform: rotate(45deg); }
  100% { transform: rotate(40deg); }
}
.brand-name {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 20px; font-weight: 700; color: #fff;
}

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  background: rgba(0, 0, 0, 0.15); border: none; border-radius: 10px;
  color: rgba(255, 255, 255, 0.85); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.theme-toggle:hover { background: rgba(0, 0, 0, 0.28); color: #fff; }
.theme-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.theme-toggle svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
/* The icon shows the destination: a moon while light, a sun while dark. */
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

/* Red stops at the header, as on the academic dashboard: the heading sits on
   the page in ink. One red, not two. */
.band .wrap { padding-top: 32px; padding-bottom: 24px; }
.band-inner { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.band-text { min-width: 0; }

/* The hero compass (js/compass.js turns the needle). An instrument, so its
   readout is set like one: a bearing in figures over the tool it points at. */
.dial { flex: none; display: flex; align-items: center; gap: 16px; margin-block: -6px; }
.dial svg { width: 104px; height: 104px; overflow: visible; }
.dial-face { fill: var(--surface-raised); stroke: var(--hairline); stroke-width: 1.5; }
.tick { stroke: var(--ink-faint); stroke-width: 1; }
.tick-major { stroke: var(--ink-muted); stroke-width: 1.6; }
.dial-north { fill: #FBBF24; }
.dial-letter {
  font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: 15px;
  fill: var(--ink-muted); text-anchor: middle;
}
.dial-letter.is-north { fill: var(--red-ink); }
.dial-needle { transform-box: view-box; transform-origin: 100px 100px; transform: rotate(40deg); }
.needle-n { fill: var(--red-ink); }
.needle-s { fill: var(--ink-faint); }
.dial-cap { fill: var(--surface-raised); stroke: var(--ink); stroke-width: 2.5; }
.dial-readout { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
.dial-bearing {
  font-family: "IBM Plex Mono", monospace; font-size: 20px; font-weight: 600;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.dial-target { font-size: 14px; color: var(--ink-soft); }
@media (max-width: 860px) {
  .dial { display: none; }
}
.band h1 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif; color: var(--ink);
  font-size: 38px; line-height: 1.1; font-weight: 700;
}
.intro { margin: 10px 0 0; max-width: 720px; text-wrap: balance; font-size: 17px; line-height: 1.5; color: var(--ink-body); }


.cards-area { padding-bottom: 48px; display: flex; flex-direction: column; gap: 20px; }
/* Always two across: auto-fit left a lone fourth card on wide screens. */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface-raised); border: 1px solid var(--hairline);
  border-radius: 14px; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--red-ink); }
.card:focus-visible { outline: 3px solid var(--red-ink); outline-offset: 3px; }
/* The top of each card: a small drawing of the tool (includes/previews.php),
   a window rising from the bottom edge of a dotted panel. A fixed ratio keeps
   every card the same size. The dots are a texture, not a colour. */
.card-art {
  display: flex; align-items: flex-end; justify-content: center;
  aspect-ratio: 16 / 7.5; padding: 22px 28px 0; overflow: hidden;
  container-type: inline-size;
  background-color: var(--surface);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 18px 18px;
  border-bottom: 1px solid var(--hairline);
}

.pv {
  /* 6px taller than the panel and pulled down by as much, so the hover lift
     never shows a gap under it. */
  width: 100%; max-width: 440px; height: calc(100% + 6px); margin-bottom: -6px;
  display: flex; flex-direction: column; gap: 9px; overflow: hidden;
  padding: 14px 16px; background: var(--surface-raised);
  border: 1px solid var(--hairline); border-bottom: 0; border-radius: 10px 10px 0 0;
  box-shadow: var(--shadow-md);
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px; font-weight: 600; color: var(--ink-muted);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.card:hover .pv { transform: translateY(-6px); }

/* Shared pieces: text drawn as grey lines, a small pill, a top row. */
/* Real words, small: grey bars standing in for text read as a page still
   loading, which made the hub look like a placeholder. */
.pv-label {
  font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 10px; font-weight: 600;
  color: var(--ink-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.pv-title {
  font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 10.5px; font-weight: 700;
  color: var(--ink); white-space: nowrap;
}
.push { margin-left: auto; }
.pv-bar-top { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }

/* Academic Dashboard: range presets, then the school tile grid. */
.pv-schools {
  flex: 1; display: grid; gap: 7px; min-height: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.pv-school {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--hairline); border-radius: 7px;
  background: var(--surface-raised); box-shadow: var(--shadow-sm);
}
.pv-school svg {
  width: 18px; height: 18px; flex: none; fill: none; stroke: var(--red-ink);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.pv-track { display: block; width: 100%; height: 4px; border-radius: 2px; background: var(--pv-track); overflow: hidden; }
.pv-fill { display: block; height: 100%; border-radius: 2px; background: var(--red-ink); }

/* Chairman Dashboard: red banner with month pills, then a chart. */
.pv-banner {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border-radius: 8px; background: var(--header-from);
}
.pv-banner-title {
  font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 11px; font-weight: 700; color: #fff;
}
.pv-months { display: flex; gap: 5px; }
.pv-month {
  padding: 2px 6px; border-radius: 4px; font-size: 9px;
  background: rgba(0, 0, 0, 0.18); color: rgba(255, 255, 255, 0.9);
}
.pv-month.is-on { background: #fff; color: #99151F; }
.pv-month.is-off { background: transparent; color: rgba(255, 255, 255, 0.5); }
.pv-chart {
  flex: 1; display: flex; align-items: flex-end; gap: 6px;
  padding: 0 2px; border-bottom: 1px solid var(--hairline);
}
.pv-col { flex: 1; border-radius: 3px 3px 0 0; background: var(--red-tint-strong); }
.pv-col.is-now { background: var(--red-ink); }

/* Timetable Generator: a week grid in the rooms page's colours. */
.pv-days { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; text-align: center; }
.pv-grid {
  flex: 1; display: grid; gap: 4px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
}
.pv-slot, .pv-lunch {
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border-radius: 4px; font-size: 8px; font-weight: 600;
}
.pv-lec { color: var(--pv-lec-ink); }
.pv-lab { color: var(--pv-lab-ink); }
.pv-lec { background: var(--pv-lec); }
.pv-lab { background: var(--pv-lab); box-shadow: inset 0 0 0 1px var(--pv-lab-edge); }
.pv-lunch { grid-column: 1 / -1; background: var(--pv-lunch); color: var(--break-ink); letter-spacing: 0.08em; text-transform: uppercase; }

/* Research Publications: the stacked bar by type and its legend. */
.pv-stack { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 2px; flex: none; }
.pv-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.pv-key { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pv-dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.pv-export {
  padding: 2px 8px; border-radius: 5px; font-size: 9px;
  background: var(--red-ink); color: #fff;
}
.pv-tiles { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pv-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  padding: 8px; border: 1px solid var(--hairline); border-radius: 6px;
}
.pv-tile svg {
  width: 18px; height: 18px; fill: none; stroke: var(--red-ink);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.pv-stack.thin { width: 80%; height: 5px; gap: 1px; border-radius: 3px; }
.c1 { background: var(--pv-c1); } .c2 { background: var(--pv-c2); } .c3 { background: var(--pv-c3); }
.c4 { background: var(--pv-c4); } .c5 { background: var(--pv-c5); }

/* A phone-width card: fewer rows, so nothing is squeezed. */
@container (max-width: 400px) {
  .pv { padding: 11px 12px; gap: 7px; }
  .pv-label { font-size: 9px; }
  .pv-school { gap: 5px; padding: 4px 8px; }
  .pv-tile { gap: 4px; padding: 4px; }
  .pv-tile .pv-label, .pv-school .pv-label { display: none; }
  .pv-slot { font-size: 0; }
  .pv-month:nth-child(n+5) { display: none; }
}
.card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 22px 26px 20px; }
.card h2 { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 26px; font-weight: 700; }
.card-blurb { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-body); }
/* The one thing each tool can point to, said plainly as a sentence with its
   figures in bold, behind a small seal: a fact quoted, not a slogan shouted.
   Aligned with the title and blurb above it. */
.card-proof {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 4px;
  font-size: 14.5px; line-height: 1.5; color: var(--ink-soft);
}
.card-proof svg {
  width: 17px; height: 17px; flex: none; margin-top: 2px; fill: none; stroke: var(--red-ink);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.card-proof b { font-weight: 600; color: var(--ink); }
.card-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--divider);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.tag {
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.tag svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tag-open { color: var(--open-ink); background: var(--open-bg); }
.tag-login { color: var(--login-ink); background: var(--login-bg); }
.card-note { font-size: 13px; color: var(--ink-muted); }
.card-arrow {
  margin-left: auto; width: 20px; height: 20px; fill: none; stroke: var(--red-ink); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s;
}
.card:hover .card-arrow { transform: translateX(3px); }

/* The same footer as the academic dashboard's (.site-footer there). */
.site-footer { border-top: 1px solid var(--hairline); font-size: 13px; color: var(--ink-soft); }
.footer-inner {
  padding-top: 20px; padding-bottom: 28px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px 20px;
}
.footer-brand { font-weight: 700; color: var(--ink); }
.footer-links { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a { color: var(--ink-soft); font-weight: 500; }
.footer-links a:hover { color: var(--red-ink); }
.footer-links span a { color: var(--ink); font-weight: 600; }
.footer-gh { display: inline-flex; align-items: center; gap: 6px; }
.footer-gh svg { width: 15px; height: 15px; }

@media (max-width: 760px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .band .wrap { padding-top: 24px; padding-bottom: 16px; }
  .card-art { padding: 16px 16px 0; }
  .wrap { padding-left: 16px; padding-right: 16px; }
  .brand-logo img { height: 40px; }
  .brand-name { font-size: 18px; }
  .brand-mark { padding-left: 10px; gap: 8px; }
  .brand-mark svg { width: 32px; height: 32px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .band h1 { font-size: 28px; }
  .intro { font-size: 16px; }
    .cards-area { gap: 12px; }
  .cards { gap: 12px; }
  .card-body { padding: 18px 20px; }
  .card h2 { font-size: 22px; }
  .card-blurb { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .needle { animation: none; }
  .card, .card-arrow, .pv { transition: none; }
  .card:hover .pv { transform: none; }
  .card:hover { transform: none; }
}
