/* ==========================================================================
   Algebridge Directory
   Layout and interaction language follows doq.world: warm paper background,
   white cards with a hairline border, pill filters, one bold accent block.
   Colour comes from Algebridge (bridge-600 #2563eb / bridge-700 #1d4ed8).
   ========================================================================== */

:root {
  --paper: #fbfaf9;
  --card: #ffffff;
  --ink: #1a1614;
  --ink-soft: #57534e;
  --ink-faint: #8a827c;
  --line: rgba(224, 219, 210, 0.85);
  --line-strong: #e0dbd2;

  --bridge-50: #eff6ff;
  --bridge-100: #dbeafe;
  --bridge-200: #bfdbfe;
  --bridge-500: #3b82f6;
  --bridge-600: #2563eb;
  --bridge-700: #1d4ed8;
  --bridge-900: #1e3a8a;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-flat: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-raised: 0 4px 16px rgba(26, 22, 20, 0.07);

  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

  --max: 1180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The browser's own [hidden] rule is `display: none` at user-agent level, so
   ANY author `display` declaration silently beats it — .topic-card sets
   `display: flex`, which left filtered-out cards fully visible even though the
   script had marked them hidden. Keep this rule above everything that sets a
   display value. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.12;
}

a {
  color: var(--bridge-700);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
}

.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;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bridge-700);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 14px 0;
  background: rgba(251, 250, 249, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  padding: 10px 16px;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--radius-pill);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
  border: 1px solid transparent;
}
.header-link:hover {
  background: #f5f2ee;
  color: var(--ink);
  text-decoration: none;
}
.header-link.is-active {
  background: var(--card);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-flat);
  color: var(--ink);
}
.header-link .count-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--bridge-600);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.header-link .count-badge.is-visible {
  display: inline-flex;
}

.header-cta {
  background: var(--bridge-700);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font-size: 14.5px;
  font-weight: 600;
}
.header-cta:hover {
  background: var(--bridge-900);
  text-decoration: none;
  color: #fff;
}

/* ---- Hero ---------------------------------------------------------------- */

.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  margin-top: 6px;
  overflow: hidden;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 34px;
  padding: 38px 36px 30px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(30px, 4.4vw, 44px);
  margin-bottom: 14px;
}

.hero p.lede {
  color: var(--ink-soft);
  font-size: 16.5px;
  margin: 0 0 12px;
  max-width: 54ch;
}

.hero-note {
  font-size: 14.5px;
  color: var(--bridge-700);
  font-weight: 500;
  margin: 0;
}

.stat-block {
  background: var(--bridge-700);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: center;
}
.stat-block .stat-number {
  font-family: var(--serif);
  font-size: 66px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  display: block;
}
.stat-block .stat-label {
  font-size: 15px;
  opacity: 0.92;
  margin-top: 8px;
  display: block;
}
.stat-block .stat-sub {
  font-size: 12.5px;
  opacity: 0.72;
  margin-top: 3px;
  display: block;
}

/* ---- Search + filter row ------------------------------------------------- */

.finder {
  display: flex;
  gap: 12px;
  padding: 0 36px 30px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
}
.search-box:focus-within {
  border-color: var(--bridge-500);
  box-shadow: 0 0 0 3px var(--bridge-100);
}
.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 15.5px;
  color: var(--ink);
  min-width: 0;
}
.search-box input::placeholder {
  color: var(--ink-faint);
}
.search-box svg {
  flex: none;
  color: var(--ink-faint);
}

.pill-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(245, 242, 238, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.pill {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-pill);
  padding: 9px 15px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover {
  color: var(--ink);
}
/* Sort + level row. Native selects so every option is visible at a glance,
   which the old cycle-through button hid. */
.select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-basis: 100%;
}

.select-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 6px 0 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-flat);
  cursor: pointer;
}
.select-pill:focus-within {
  border-color: var(--bridge-500);
  box-shadow: 0 0 0 3px var(--bridge-100);
}
.select-pill > span {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.select-pill select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  padding: 0 26px 0 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a827c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.result-pill {
  font-size: 14px;
  color: var(--ink-faint);
  font-weight: 500;
  padding: 0 4px;
}

.pill-reset {
  border-color: var(--line-strong);
  background: var(--card);
  box-shadow: var(--shadow-flat);
  color: var(--bridge-700);
  font-weight: 600;
  padding: 8px 14px;
}
.pill-reset[hidden] {
  display: none;
}

.pill.is-active {
  background: var(--card);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-flat);
  color: var(--ink);
  font-weight: 600;
}

/* ---- Secondary nav strip ------------------------------------------------- */

.strip {
  display: flex;
  gap: 26px;
  padding: 15px 36px;
  border-top: 1px solid var(--line);
  background: rgba(245, 242, 238, 0.55);
  overflow-x: auto;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar {
  display: none;
}
.strip a {
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
}
.strip a:hover {
  color: var(--ink);
  text-decoration: none;
}
.strip a.is-active {
  color: var(--ink);
  font-weight: 600;
}

/* ---- Banner -------------------------------------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  padding: 20px 26px;
  margin-top: 18px;
}
.banner-icon {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--bridge-50);
  color: var(--bridge-700);
  display: grid;
  place-items: center;
}
.banner h2 {
  font-size: 19px;
  margin-bottom: 3px;
}
.banner p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
}
.banner .banner-action {
  margin-left: auto;
  flex: none;
}

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-primary {
  background: var(--bridge-600);
  color: #fff;
}
.btn-primary:hover {
  background: var(--bridge-700);
  text-decoration: none;
  color: #fff;
}
.btn-secondary {
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-flat);
}
.btn-secondary:hover {
  border-color: #cfc7bb;
  text-decoration: none;
}
.btn-block {
  width: 100%;
}

/* ---- Section headings ---------------------------------------------------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 34px 0 16px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: 25px;
}
.section-head .muted {
  color: var(--ink-faint);
  font-size: 14.5px;
}

/* ---- Topic cards --------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}

.topic-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  overflow: hidden;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.topic-card:hover {
  box-shadow: var(--shadow-raised);
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #ece7e0;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(15, 12, 10, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.thumb .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  background: rgba(15, 12, 10, 0.28);
  transition: opacity 0.18s ease;
}
.topic-card:hover .thumb .play {
  opacity: 1;
}
.thumb .play span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--bridge-700);
  display: grid;
  place-items: center;
}

.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #f3f0eb;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag-course {
  background: var(--bridge-700);
  color: #fff;
}
.tag-level {
  background: var(--bridge-50);
  color: var(--bridge-700);
}

.topic-card h3 {
  font-size: 18.5px;
  margin-bottom: 7px;
}
.topic-card h3 a {
  color: var(--ink);
}
.topic-card h3 a:hover {
  color: var(--bridge-700);
  text-decoration: none;
}

.card-summary {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 14px;
  flex: 1;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  margin-bottom: 13px;
}
.meta-grid div {
  min-width: 0;
}
.meta-grid dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 1px;
}
.meta-grid dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-actions .btn {
  padding: 9px 14px;
  font-size: 13.5px;
}
.card-actions .btn-secondary {
  flex: 1;
}

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--shadow-flat);
}
.icon-btn:hover {
  color: var(--ink);
  border-color: #cfc7bb;
}
.icon-btn[aria-pressed="true"] {
  background: var(--bridge-600);
  border-color: var(--bridge-600);
  color: #fff;
}
.icon-btn[aria-pressed="true"]:hover {
  background: var(--bridge-700);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty-state h3 {
  font-size: 20px;
  margin-bottom: 6px;
  color: var(--ink);
}

/* ---- Topic detail -------------------------------------------------------- */

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
  margin-top: 18px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  overflow: hidden;
}
.panel + .panel {
  margin-top: 18px;
}
.panel-head {
  padding: 17px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h2 {
  font-size: 20px;
}
.panel-body {
  padding: 22px 24px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--ink-faint);
  margin: 20px 0 12px;
}
.breadcrumb a {
  color: var(--ink-soft);
}
.breadcrumb span[aria-hidden] {
  color: #cfc7bb;
}

.detail-title {
  font-size: clamp(27px, 3.6vw, 37px);
  margin-bottom: 10px;
}
.detail-lede {
  color: var(--ink-soft);
  font-size: 16.5px;
  margin: 0 0 16px;
  max-width: 62ch;
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #17130f;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 24px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.video-credit strong {
  color: var(--ink);
  font-weight: 600;
}

/* Explanation tabs */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(245, 242, 238, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--card);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-flat);
  color: var(--ink);
  font-weight: 600;
}

.prose {
  font-size: 16px;
  color: var(--ink);
}
.prose p {
  margin: 0 0 14px;
}
.prose p:last-child {
  margin-bottom: 0;
}
.prose ul {
  margin: 0 0 14px;
  padding-left: 20px;
}
.prose li {
  margin-bottom: 5px;
}
.prose strong {
  font-weight: 600;
}
.prose .math {
  font-family: var(--mono);
  font-size: 0.93em;
  background: #f5f2ee;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1.5px 5px;
  white-space: nowrap;
}
.prose .math-block {
  display: block;
  white-space: pre-wrap;
  padding: 12px 14px;
  margin: 0 0 14px;
  overflow-x: auto;
}

.callout {
  border-radius: var(--radius-sm);
  padding: 15px 17px;
  margin-bottom: 18px;
  font-size: 15px;
}
.callout-key {
  background: var(--bridge-50);
  border: 1px solid var(--bridge-200);
  color: var(--bridge-900);
}
.callout-key strong {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
  color: var(--bridge-700);
}

.steps {
  counter-reset: step;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 36px;
  margin-bottom: 11px;
  font-size: 15px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bridge-50);
  color: var(--bridge-700);
  border: 1px solid var(--bridge-200);
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.answer-line {
  background: #f5f2ee;
  border-left: 3px solid var(--bridge-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  font-size: 15px;
}
.answer-line strong {
  color: var(--bridge-700);
}

.mistake-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mistake-list li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 11px;
  font-size: 15px;
  color: var(--ink);
}
.mistake-list li::before {
  content: "✕";
  position: absolute;
  left: 0;
  top: 0;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fdeceb;
  color: #b4372c;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Practice CTA */
.practice-card {
  background: var(--bridge-700);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.practice-card h3 {
  color: #fff;
  font-size: 21px;
  margin-bottom: 7px;
}
.practice-card p {
  margin: 0 0 16px;
  font-size: 14.5px;
  opacity: 0.9;
}
.practice-card .btn {
  background: #fff;
  color: var(--bridge-700);
}
.practice-card .btn:hover {
  background: var(--bridge-50);
  color: var(--bridge-900);
}
.practice-card .fine {
  display: block;
  margin-top: 11px;
  font-size: 12px;
  opacity: 0.75;
}

.side-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.side-list li + li {
  border-top: 1px solid var(--line);
}
.side-list a {
  display: block;
  padding: 12px 24px;
  color: var(--ink);
  font-size: 14.5px;
}
.side-list a:hover {
  background: #faf8f5;
  text-decoration: none;
  color: var(--bridge-700);
}
.side-list .side-meta {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 1px;
}

.pager {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}
.pager a {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  padding: 15px 18px;
  color: var(--ink);
}
.pager a:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}
.pager .pager-label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 2px;
}
.pager .pager-next {
  text-align: right;
}

/* ---- Course index / unit list -------------------------------------------- */

.unit-block + .unit-block {
  margin-top: 30px;
}
.unit-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.unit-head h3 {
  font-size: 22px;
}
.unit-head .unit-count {
  font-size: 13.5px;
  color: var(--ink-faint);
}
.unit-blurb {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 14px;
  max-width: 70ch;
}

.course-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  padding: 24px;
}
.course-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-raised);
  text-decoration: none;
}
.course-card h3 {
  font-size: 23px;
  margin-bottom: 6px;
  color: var(--ink);
}
.course-card p {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 16px;
  flex: 1;
}
.course-card .course-stats {
  display: flex;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-soft);
}
.course-card .course-stats strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---- Legal / prose pages ------------------------------------------------- */

.legal-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  margin: 22px 0;
}
.legal-nav {
  position: sticky;
  top: 92px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  padding: 8px;
}
.legal-nav a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 14px;
}
.legal-nav a:hover {
  background: #faf8f5;
  color: var(--ink);
  text-decoration: none;
}
.legal-nav a.is-active {
  background: var(--bridge-50);
  color: var(--bridge-700);
  font-weight: 600;
}

.legal-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  padding: 34px 38px;
}
.legal-body h1 {
  font-size: 33px;
  margin-bottom: 8px;
}
.legal-body .updated {
  color: var(--ink-faint);
  font-size: 13.5px;
  margin: 0 0 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.legal-body h2 {
  font-size: 21px;
  margin: 30px 0 10px;
}
.legal-body h3 {
  font-size: 17px;
  margin: 22px 0 8px;
  font-family: var(--sans);
  font-weight: 600;
}
.legal-body p,
.legal-body li {
  color: var(--ink);
  font-size: 15.5px;
}
.legal-body p {
  margin: 0 0 13px;
}
.legal-body ul,
.legal-body ol {
  margin: 0 0 16px;
  padding-left: 22px;
}
.legal-body li {
  margin-bottom: 6px;
}
.legal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 14.5px;
}
.legal-body th,
.legal-body td {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  vertical-align: top;
}
.legal-body th {
  background: #faf8f5;
  font-weight: 600;
}
.legal-body .notice {
  background: var(--bridge-50);
  border: 1px solid var(--bridge-200);
  border-radius: var(--radius-sm);
  padding: 15px 17px;
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--bridge-900);
}

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

.site-footer {
  margin-top: 46px;
  border-top: 1px solid var(--line);
  background: rgba(245, 242, 238, 0.5);
  padding: 34px 0 26px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: 26px;
  margin-bottom: 26px;
}
.footer-grid h4 {
  font-family: var(--sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 11px;
  font-weight: 600;
}
.footer-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-grid li {
  margin-bottom: 7px;
}
.footer-grid a {
  color: var(--ink-soft);
  font-size: 14px;
}
.footer-grid a:hover {
  color: var(--ink);
}
.footer-about p {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 10px 0 0;
  max-width: 40ch;
}
.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-faint);
  flex-wrap: wrap;
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 960px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 30px 24px 24px;
  }
  .stat-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 18px;
  }
  .stat-block .stat-number {
    font-size: 44px;
  }
  .stat-block .stat-label,
  .stat-block .stat-sub {
    margin-top: 0;
    text-align: left;
  }
  .finder,
  .strip {
    padding-left: 24px;
    padding-right: 24px;
  }
  .detail-grid,
  .legal-layout {
    grid-template-columns: 1fr;
  }
  .legal-nav {
    position: static;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .hide-sm {
    display: none;
  }
  .header-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  .header-nav {
    flex: none;
  }
  .header-link {
    padding: 8px 10px;
    font-size: 14px;
  }
  .brand {
    font-size: 16px;
    white-space: nowrap;
    min-width: 0;
  }
  .brand-mark {
    width: 23px;
    height: 23px;
  }
  .hero-inner,
  .finder,
  .strip {
    padding-left: 18px;
    padding-right: 18px;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .legal-body {
    padding: 24px 20px;
  }
  .panel-body {
    padding: 18px;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .banner {
    flex-wrap: wrap;
  }
  .banner .banner-action {
    margin-left: 0;
    width: 100%;
  }
}

@media print {
  .site-header,
  .site-footer,
  .card-actions,
  .pager {
    display: none;
  }
}
