/* ===========================================================
   Mfumo wa Matokeo ya Mitihani — pinboard theme
   Palette nods to the Tanzanian flag: deep green, gold, blue,
   ink-black, on a warm linen board.
   =========================================================== */

:root {
  --ink: #221b15;
  --ink-soft: rgba(34, 27, 21, 0.65);

  --board-bg: #f3ecdd;
  --board-dot: #ddceac;

  --tz-green: #12664f;
  --tz-green-dark: #0b4a39;
  --tz-gold: #f2b705;
  --tz-blue: #0b5fa5;
  --tz-red: #b3261e;

  --note-yellow: #ffe9a0;
  --note-yellow-tape: #f4d35e;
  --note-mint: #c8f0dd;
  --note-mint-tape: #6fcf97;
  --note-coral: #ffd0be;
  --note-coral-tape: #f4845f;
  --note-sky: #cfe6fb;
  --note-sky-tape: #6fb3e8;
  --note-lilac: #e4d8fb;
  --note-lilac-tape: #a78bfa;

  --radius-note: 4px 4px 14px 14px;
  --shadow-rest: 0 10px 20px -10px rgba(34, 27, 21, 0.35), 0 2px 4px rgba(34, 27, 21, 0.15);
  --shadow-hover: 0 22px 30px -12px rgba(34, 27, 21, 0.45), 0 6px 10px rgba(34, 27, 21, 0.2);

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-hand: "Kalam", "Segoe Print", cursive;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--board-bg);
  background-image: radial-gradient(circle at 1px 1px, var(--board-dot) 1px, transparent 0);
  background-size: 24px 24px;
}

a { color: inherit; }

body.page-results, body.page-schools { padding-bottom: 90px; }

.title-stacked { display: flex; flex-direction: column; gap: 2px; }
.title-line1 { }
.title-line2 {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 0.62em;
  color: var(--tz-green);
}

.board {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(20px, 5vw, 48px) 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */

.board__header { margin-bottom: clamp(28px, 5vw, 44px); }

.eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tz-green);
  margin: 0 0 8px;
}

.board__header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.05;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 1.02rem;
  color: var(--ink-soft);
  margin: 0;
  max-width: 46ch;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--tz-green-dark);
  background: #fff;
  border: 1px solid rgba(34, 27, 21, 0.12);
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 10px -6px rgba(34, 27, 21, 0.3);
  margin-bottom: 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.back-link:hover { transform: translateX(-3px); box-shadow: 0 6px 14px -6px rgba(34, 27, 21, 0.35); }
.back-link:focus-visible { outline: 3px solid var(--tz-blue); outline-offset: 2px; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.stat-chip {
  font-size: 0.85rem;
  color: var(--tz-green-dark);
  background: rgba(18, 102, 79, 0.08);
  border: 1px solid rgba(18, 102, 79, 0.18);
  padding: 6px 14px;
  border-radius: 999px;
}
.stat-chip strong { font-family: var(--font-display); font-weight: 700; }

/* ---------- Ward grid (post-its) ---------- */

.pin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(20px, 3vw, 34px);
  padding-top: 12px;
}

.postit {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 190px;
  padding: 30px 22px 20px;
  text-decoration: none;
  color: var(--ink);
  border-radius: var(--radius-note);
  box-shadow: var(--shadow-rest);
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  will-change: transform;
}

.postit:hover,
.postit:focus-visible {
  transform: rotate(0deg) translateY(-6px) scale(1.015);
  box-shadow: var(--shadow-hover);
  z-index: 2;
}
.postit:focus-visible { outline: 3px solid var(--tz-blue); outline-offset: 3px; }

.postit--yellow { background: var(--note-yellow); }
.postit--mint   { background: var(--note-mint); }
.postit--coral  { background: var(--note-coral); }
.postit--sky    { background: var(--note-sky); }
.postit--lilac  { background: var(--note-lilac); }

.postit__pin {
  position: absolute;
  top: 10px;
  right: 16px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff9, var(--tz-gold) 60%, #a97a00 100%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
}

.postit__tape {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 84px;
  height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.55));
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.postit--yellow .postit__tape { background: linear-gradient(to bottom, rgba(244,211,94,.85), rgba(244,211,94,.55)); }
.postit--mint   .postit__tape { background: linear-gradient(to bottom, rgba(111,207,151,.75), rgba(111,207,151,.45)); }
.postit--coral  .postit__tape { background: linear-gradient(to bottom, rgba(244,132,95,.75), rgba(244,132,95,.45)); }
.postit--sky    .postit__tape { background: linear-gradient(to bottom, rgba(111,179,232,.75), rgba(111,179,232,.45)); }
.postit--lilac  .postit__tape { background: linear-gradient(to bottom, rgba(167,139,250,.75), rgba(167,139,250,.45)); }

.postit__title {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.15;
  margin: 6px 0 0;
}

.postit__meta {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
}

.postit__arrow {
  margin-top: auto;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--tz-green-dark);
  transition: transform 0.2s ease;
}
.postit:hover .postit__arrow { transform: translateX(4px); }

.postit--soon {
  display: flex;
  background: #e7e2d6;
  color: var(--ink-soft);
  cursor: default;
  filter: grayscale(0.15);
}
.postit--soon .postit__pin { background: radial-gradient(circle at 32% 30%, #fff9, #b9ad8f 60%, #8a7f63 100%); }
.postit--soon .postit__tape { background: linear-gradient(to bottom, rgba(255,255,255,.6), rgba(255,255,255,.35)); }
.postit--soon:hover { transform: rotate(var(--rot, 0deg)); box-shadow: var(--shadow-rest); }

.postit__badge {
  margin-top: auto;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(34, 27, 21, 0.08);
  padding: 4px 12px;
  border-radius: 999px;
}

/* ---------- Exam grid (exam-slip cards) ---------- */

.exam-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(18px, 3vw, 28px);
  padding-top: 4px;
}

.exam-card {
  position: relative;
  text-decoration: none;
  color: var(--ink);
  background-color: #fffdf8;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    rgba(34, 27, 21, 0.07) 27px,
    rgba(34, 27, 21, 0.07) 28px
  );
  border-left: 6px solid var(--tz-red);
  border-radius: 4px;
  padding: 22px 20px 20px 24px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 18px -10px rgba(34, 27, 21, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.exam-card:hover { transform: translateY(-4px); box-shadow: 0 16px 24px -12px rgba(34, 27, 21, 0.32); }
.exam-card:focus-visible { outline: 3px solid var(--tz-blue); outline-offset: 3px; transform: translateY(-4px); }

.exam-card__clip {
  position: absolute;
  top: -12px;
  left: 22px;
  width: 22px;
  height: 34px;
  border: 3px solid #9aa0a6;
  border-radius: 10px;
  background: transparent;
  transform: rotate(-8deg);
  box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.15);
}

.exam-card__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tz-blue);
  margin: 6px 0 0;
}

.exam-card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.25;
  margin: 0;
}

.exam-card__pill {
  margin-top: auto;
  align-self: flex-start;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tz-green-dark);
  background: rgba(242, 183, 5, 0.22);
  border: 1px solid rgba(242, 183, 5, 0.4);
  padding: 4px 12px;
  border-radius: 999px;
}

/* ---------- Floating print/download toolbar ---------- */

.floating-toolbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(34, 27, 21, 0.92);
  border-radius: 999px;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.45);
  z-index: 100;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.toolbar-btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-2px); }
.toolbar-btn:focus-visible { outline: 3px solid var(--tz-gold); outline-offset: 2px; }

.toolbar-btn--accent {
  background: var(--tz-gold);
  color: #4a3600;
  border-color: transparent;
}
.toolbar-btn--accent:hover { background: #ffcb1f; }

/* ---------- Print ---------- */

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .results-table-wrap { box-shadow: none; }
  .results-table thead th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.school-link {
  color: var(--tz-blue);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
}
.school-link:hover { border-bottom-color: currentColor; }
.school-link:focus-visible { outline: 3px solid var(--tz-blue); outline-offset: 2px; }

/* ---------- Results table ---------- */

.results-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.results-search {
  width: 100%;
  max-width: 320px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(34, 27, 21, 0.16);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 10px -6px rgba(34, 27, 21, 0.2);
}
.results-search:focus-visible { outline: 3px solid var(--tz-blue); outline-offset: 2px; }

.results-table-wrap {
  background: #fffdf8;
  border-radius: 12px;
  box-shadow: var(--shadow-rest);
  overflow-x: auto;
  overflow-y: hidden;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 640px;
}

.results-table thead th {
  position: sticky;
  top: 0;
  background: var(--tz-green);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  padding: 14px 16px;
  white-space: nowrap;
}

.results-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(34, 27, 21, 0.08);
  white-space: nowrap;
}

.results-table tbody tr:nth-child(even) { background: rgba(18, 102, 79, 0.04); }
.results-table tbody tr:hover { background: rgba(242, 183, 5, 0.14); }

.col-sno { width: 56px; text-align: center; font-family: var(--font-display); color: var(--ink-soft); }
.col-mark { text-align: center; font-variant-numeric: tabular-nums; }

.col-position { text-align: center; width: 84px; }
.col-gender { text-align: center; width: 64px; }

.position-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(34, 27, 21, 0.06);
  color: var(--ink);
}
.position-badge--1 { background: linear-gradient(135deg, #ffe9a0, var(--tz-gold)); color: #5a4200; box-shadow: 0 3px 6px -2px rgba(242, 183, 5, 0.6); }
.position-badge--2 { background: linear-gradient(135deg, #eef0f2, #c3c9cf); color: #45494d; box-shadow: 0 3px 6px -2px rgba(154, 160, 166, 0.5); }
.position-badge--3 { background: linear-gradient(135deg, #e7c39a, #b08d57); color: #4a3419; box-shadow: 0 3px 6px -2px rgba(176, 141, 87, 0.5); }

.col-total {
  text-align: center;
  background: rgba(242, 183, 5, 0.1);
}
.results-table thead .col-total { background: var(--tz-green-dark); }

.total-value {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}
.gpa-value {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

/* ---------- Empty state ---------- */

.empty-note {
  position: relative;
  max-width: 420px;
  background: var(--note-yellow);
  border-radius: var(--radius-note);
  padding: 30px 26px 24px;
  box-shadow: var(--shadow-rest);
  transform: rotate(-1.5deg);
}
.empty-note__pin {
  position: absolute;
  top: 10px;
  right: 16px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff9, var(--tz-gold) 60%, #a97a00 100%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
}
.empty-note p { margin: 0 0 8px; font-family: var(--font-hand); font-size: 1.15rem; }
.empty-note__hint { font-family: var(--font-body); font-size: 0.85rem; color: var(--ink-soft); }
.empty-note code { background: rgba(34, 27, 21, 0.08); padding: 2px 6px; border-radius: 4px; }

/* ---------- Footer ---------- */

.board__footer {
  margin-top: auto;
  padding-top: 40px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Responsive grid breakpoints ---------- */

@media (max-width: 1100px) {
  .pin-grid, .exam-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .pin-grid, .exam-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .pin-grid, .exam-grid { grid-template-columns: 1fr; }
  .postit { min-height: 160px; }
}

/* ---------- Motion & accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  .postit, .exam-card, .back-link { transition: none; }
  .postit:hover, .postit:focus-visible { transform: none; }
}