/* =====================================================================
   components.css: pieces used on many pages.
   Header, footer, buttons, cards, grids, tabs, results charts.
   ===================================================================== */

/* ---------- header (white, sticky) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand-logo { width: 2.75rem; height: 2.75rem; object-fit: contain; flex: none; }
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.15;
}

.site-nav ul { display: flex; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.site-nav a {
  display: block;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.site-nav a:hover { background: var(--mist); }
.site-nav a[aria-current="page"] {
  color: var(--brand);
  box-shadow: inset 0 -3px 0 var(--accent); /* underline marks the current page */
  border-radius: 8px 8px 0 0;
}

/* the Menu button only exists on small screens */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after { top: 6px; }

@media (max-width: 899px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;                     /* hidden drop-down menu */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0.5rem 1rem 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav a { padding: 0.85rem 0.5rem; border-radius: 0; box-shadow: none; }
  .site-nav a[aria-current="page"] { box-shadow: inset 4px 0 0 var(--accent); padding-left: 0.9rem; }
}

/* ---------- footer ---------- */
.site-footer { background: var(--brand-dark); color: #f3e3e5; }
.site-footer a { color: #fff; }
.footer-grid {
  display: grid;
  gap: 2rem;
  padding-block: 3rem 2rem;
}
@media (min-width: 700px) { .footer-grid { grid-template-columns: 1.4fr 1fr; } }
.footer-name { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; color: #fff; margin-bottom: 0.4rem; }
.footer-head { font-family: var(--font-display); font-size: 1.1rem; color: #fff; margin-bottom: 0.5rem; }
.footer-text { margin: 0 0 0.6em; line-height: 1.7; }
.footer-bottom { padding-block: 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.18); font-size: 0.95rem; }
.footer-bottom p { margin: 0; }

/* ---------- buttons and links ---------- */
.button {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button--outline { background: transparent; color: var(--brand); }
.button--outline:hover { background: var(--brand-tint); color: var(--brand-dark); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.section-head h2 { margin: 0; }
.section-link { font-weight: 600; white-space: nowrap; }

.empty { padding: 2rem 0; color: var(--ink-soft); }

/* ---------- badges ---------- */
.badge {
  align-self: flex-start;
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
}
.badge--news { background: var(--brand-tint); color: var(--brand-dark); }
.badge--event { background: var(--accent-tint); color: #6b4208; }
.badge--achievement { background: #e7ebf1; color: #2b3a4d; }

/* ---------- cards and grids ---------- */
.card-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: inherit;
  text-decoration: none;
}
.card:hover { border-color: var(--brand); }
.card-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--mist); }
.card-body { display: flex; flex-direction: column; gap: 0.45rem; flex: 1; padding: 1rem 1.1rem 1.2rem; }
.card-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; line-height: 1.25; color: var(--ink); }
.card:hover .card-title { color: var(--brand); }
.card-summary {
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { margin: 0; font-size: 0.95rem; color: var(--ink-soft); }
.card-body .card-meta { margin-top: auto; }

/* Phones: cards in the long grids become compact rows (small picture on the left)
   so a list of 8 does not mean 8 screens of scrolling. The Home swipe rows keep
   the large cards. To go back to tall cards, delete this block. */
@media (max-width: 639px) {
  .card-grid { gap: 0.9rem; }
  .card-grid .card { flex-direction: row; align-items: stretch; }
  .card-grid .card-img { flex: none; width: 34%; height: auto; min-height: 7.5rem; aspect-ratio: auto; }
  .card-grid .card-body { padding: 0.75rem 0.9rem; gap: 0.3rem; min-width: 0; }
  .card-grid .card-title { font-size: 1.05rem; }
  .card-grid .card-summary { -webkit-line-clamp: 2; font-size: 0.97rem; }
}

/* The last cell of a grid. The cell is as big as a card, but only holds a SMALL
   button ("More...") in the middle. load-more.js puts the new cards before the cell. */
.more-cell { display: grid; place-items: center; min-height: 6rem; }
.more-button {
  max-width: 100%;
  padding: 0.4rem 1.1rem;
  border: 2px solid var(--brand);
  border-radius: 999px;
  background: var(--paper);
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}
.more-button:hover { background: var(--brand-tint); }
.more-button[aria-busy="true"] { opacity: 0.6; cursor: progress; }

/* Home rows with 3 cards: swipe sideways on phones, a 3-column grid on desktop */
.swipe {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.75rem;
  /* let cards touch the screen edge so the next one visibly peeks in */
  margin-inline: -1rem;
  padding-inline: 1rem;
  scroll-padding-inline: 1rem;
}
.swipe > * { flex: 0 0 85%; scroll-snap-align: start; }
@media (min-width: 640px) { .swipe > * { flex-basis: 46%; } }
@media (min-width: 960px) {
  .swipe {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }
}

/* Pillars of the school: large cards. The Home section around them fills the screen. */
.pillar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: clamp(15rem, 44vh, 24rem);
  padding: clamp(1.5rem, 3vw, 2.4rem);
  border: 1px solid var(--line);
  border-top: 6px solid var(--brand);
  border-radius: var(--radius);
  background: var(--mist);
  color: inherit;
  text-decoration: none;
}
.pillar:hover { border-top-color: var(--accent); background: var(--brand-tint); }
.pillar-title { font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 600; line-height: 1.15; color: var(--ink); }
.pillar-text { font-size: 1.1rem; color: var(--ink-soft); }
.pillar-link { margin-top: auto; padding-top: 1rem; font-weight: 700; color: var(--brand); }
.pillar:hover .pillar-link { text-decoration: underline; text-underline-offset: 0.2em; }

/* ---------- tabs ----------
   The tab changer fills the whole width of the page content, split equally between
   its tabs (2 tabs = two halves). The selected tab is filled with the theme colour.
   No overflow scrolling here: that is what used to show a stray scroll bar. */
.tabs { margin-top: 0.5rem; }
.tab-list {
  display: flex;
  margin-bottom: 1.75rem;
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  overflow: hidden;            /* only rounds the corners; nothing here scrolls */
  background: var(--paper);
}
.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 1rem 0.75rem;
  border: 0;
  background: var(--paper);
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  text-align: center;
  cursor: pointer;
}
.tab + .tab { border-left: 2px solid var(--brand); }
.tab:hover { background: var(--brand-tint); }
.tab[aria-selected="true"] { background: var(--brand); color: #fff; }
.tab:focus-visible { outline-offset: -5px; outline-color: var(--accent); }

/* the smaller "pill" choice for the year inside Results keeps its own look */
.tab-list--pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; border: 0; border-radius: 0; overflow: visible; background: none; }
.tab-list--pills .tab {
  flex: 0 0 auto;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
}
.tab-list--pills .tab + .tab { border-left: 1px solid var(--line); }
.tab-list--pills .tab[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab-list--pills .tab:focus-visible { outline-offset: 2px; }

/* year pills on the left, small "In detail" button on the same row at the right */
.tabs--action { display: grid; grid-template-columns: 1fr auto; column-gap: 1rem; align-items: start; }
.tabs--action > .tab-list { grid-column: 1; }
.tabs--action > .tab-action { grid-column: 2; grid-row: 1; align-self: start; white-space: nowrap; }
.tabs--action > .tab-panel { grid-column: 1 / -1; }
.button--small { padding: 0.45rem 1.1rem; font-size: 1rem; font-weight: 600; border-radius: 999px; }
@media (max-width: 430px) {
  .tab-list--pills { gap: 0.35rem; }
  .tab-list--pills .tab { padding: 0.45rem 0.8rem; font-size: 0.95rem; }
  .button--small { padding: 0.4rem 0.85rem; font-size: 0.95rem; }
}

/* ---------- results: donut, numbers, notes ---------- */
.result-grid { display: grid; gap: 1.25rem; }
@media (min-width: 800px) { .result-grid { grid-template-columns: 1fr 1fr; } }

.result {
  padding: 1.4rem 1.4rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.result h3 { margin-bottom: 1rem; }
.result-body { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }

/* The ring is a CSS gradient. --rate (0 to 100) is set by the template. */
.donut {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 8rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--rate) * 1%), var(--track) 0);
}
.donut::before {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background: var(--paper);
}
.donut-value {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
}

.result-stats { margin: 0; display: grid; gap: 0.5rem; }
.result-stats div { display: flex; gap: 0.75rem; align-items: baseline; }
.result-stats dt { color: var(--ink-soft); min-width: 8.5rem; }
.result-stats dd { margin: 0; font-weight: 700; font-size: 1.1rem; }

.result-change { margin: 0.9rem 0 0; font-weight: 600; }
.result-change--up { color: #1b6b3a; }
.result-change--down { color: #9a3a1a; }
.result-change--flat { color: var(--ink-soft); }

.result-note {
  margin: 1rem 0 0;
  padding-left: 0.9rem;
  border-left: 4px solid var(--accent);
  color: var(--ink);
}
.results-note { max-width: 62ch; margin: 2rem 0 0; color: var(--ink-soft); }


/* ---------- Achievements > Academic: year tree + details ---------- */
.result-tree { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 800px) { .result-tree { grid-template-columns: 17rem 1fr; gap: 2.5rem; } }
.tree-title { margin: 0 0 0.75rem; font-size: 1.25rem; }
.tree, .tree-children { margin: 0; padding: 0; list-style: none; }
.tree-children { margin: 0.15rem 0 0.4rem 1.1rem; padding-left: 0.6rem; border-left: 2px solid var(--line); }
.tree-children[hidden] { display: none; }
.tree-toggle, .tree-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tree-toggle { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.tree-toggle--sub { font-family: inherit; font-size: 1.05rem; font-weight: 700; color: var(--brand); }
.tree-toggle::before {            /* the small triangle: points right when closed, down when open */
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.tree-toggle[aria-expanded="true"]::before { transform: rotate(45deg); }
.tree-item { font-size: 1.05rem; font-weight: 600; color: var(--ink-soft); padding-left: 1.3rem; }
.tree-toggle:hover, .tree-item:hover { background: var(--brand-tint); }
.tree-item[aria-current="true"] { background: var(--brand); color: #fff; }
.tree-toggle:focus-visible, .tree-item:focus-visible { outline-offset: -3px; }

.res-panel { padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--mist); scroll-margin-top: 6rem; }
.res-panel[hidden] { display: none; }
.res-year { margin: 0 0 0.2rem; font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; color: var(--brand); }
.res-panel h3 { margin-bottom: 1.25rem; }
.res-stream { margin-left: 0.4rem; padding: 0.1rem 0.7rem; border-radius: 999px; background: var(--brand-tint); color: var(--brand-dark); font-size: 0.95rem; font-weight: 700; vertical-align: middle; }

/* ---------- line chart: pass rate by year (SVG made by queries.line_chart) ---------- */
.chart { margin-top: 2.5rem; }
.line-chart { display: block; width: 100%; height: auto; margin-top: 1rem; font-family: inherit; }
.line-chart--narrow { display: none; }
@media (max-width: 699px) {
  .line-chart--wide { display: none; }
  .line-chart--narrow { display: block; }
}
.lc-grid { stroke: var(--line); stroke-width: 1; }
.lc-axis { stroke: var(--ink-soft); stroke-width: 1.5; }
.lc-ytick, .lc-xtick { fill: var(--ink-soft); font-size: 14px; }
.lc-xtick { font-weight: 600; }
.lc-line { fill: none; stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.lc-line--ol, .lc-dot--ol { stroke: var(--brand); }
.lc-line--al, .lc-dot--al { stroke: var(--al-line); }
.lc-dot { stroke-width: 0; }
.lc-dot--ol { fill: var(--brand); }
.lc-dot--al { fill: var(--al-line); }
.lc-value { fill: var(--ink); font-size: 14px; font-weight: 600; }
.lc-label { font-size: 16px; font-weight: 700; }
.lc-label--ol { fill: var(--brand); }
.lc-label--al { fill: var(--al-text); }

/* ---------- detail page body ---------- */
.prose { max-width: 70ch; }
.prose p { margin-bottom: 1.1em; }
.prose h2 { margin-top: 1.6em; font-size: 1.5rem; }
.prose figure { margin: 1.5rem 0; }
.prose img { width: 100%; border-radius: var(--radius); }
.prose figcaption { margin-top: 0.5rem; font-size: 0.95rem; color: var(--ink-soft); }
.prose .link-block { margin: 1.25rem 0; }
.gallery { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); margin: 1.5rem 0; }
.gallery img { aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); }

/* ---------- admin preview banner (shown only when an admin previews a draft) ---------- */
.preview-bar {
  padding: 0.7rem 1rem;
  background: #fff3cd;
  border-bottom: 2px solid var(--accent);
  color: #4d3a05;
  text-align: center;
}
.preview-bar a { margin-left: 0.5rem; font-weight: 700; color: inherit; }
