/* =========================================================
   Theme tokens + system/default behavior
   ========================================================= */
html {
  color-scheme: light dark;
} /* proper UI controls in both themes */

/* Base reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}
img,
video,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}
p,
li {
  overflow-wrap: anywhere;
}

:root {
  /* LIGHT (default) */
  --bg: #f7f9ff;
  --fg: #101424;
  --muted: #51608b;
  --card: #fff;
  --accent: #7c9cff;
  --accent-2: #6fe3ff;
  --border: #dbe2f7;
  --radius: 16px;
  --maxw: 1200px;
  --shadow: 0 12px 28px rgba(10, 22, 70, 0.08);

  /* Derived helpers */
  --brand: var(--accent);
  --surface-weak: color-mix(in srgb, var(--bg) 92%, var(--fg));
  --surface-mid: color-mix(in srgb, var(--bg) 85%, var(--fg));
  --accent-weak: color-mix(in srgb, var(--accent) 18%, var(--bg));
  --accent-mid: color-mix(in srgb, var(--accent) 40%, var(--bg));
}

@media (prefers-color-scheme: dark) {
  :root {
    /* DARK */
    --bg: #0b1020;
    --fg: #e9ecf1;
    --muted: #b5bed1;
    --card: #121938;
    --border: #233056;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);

    /* Recompute derived helpers for dark */
    --brand: var(--accent);
    --surface-weak: color-mix(in srgb, var(--bg) 92%, var(--fg));
    --surface-mid: color-mix(in srgb, var(--bg) 85%, var(--fg));
    --accent-weak: color-mix(in srgb, var(--accent) 18%, var(--bg));
    --accent-mid: color-mix(in srgb, var(--accent) 40%, var(--bg));
  }
}

/* Manual override support (optional toggle sets data-theme on :root) */
:root[data-theme="light"] {
  --bg: #f7f9ff;
  --fg: #101424;
  --muted: #51608b;
  --card: #fff;
  --border: #dbe2f7;
  --shadow: 0 12px 28px rgba(10, 22, 70, 0.08);

  --brand: var(--accent);
  --surface-weak: color-mix(in srgb, var(--bg) 92%, var(--fg));
  --surface-mid: color-mix(in srgb, var(--bg) 85%, var(--fg));
  --accent-weak: color-mix(in srgb, var(--accent) 18%, var(--bg));
  --accent-mid: color-mix(in srgb, var(--accent) 40%, var(--bg));
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --fg: #e9ecf1;
  --muted: #b5bed1;
  --card: #121938;
  --border: #233056;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);

  --brand: var(--accent);
  --surface-weak: color-mix(in srgb, var(--bg) 92%, var(--fg));
  --surface-mid: color-mix(in srgb, var(--bg) 85%, var(--fg));
  --accent-weak: color-mix(in srgb, var(--accent) 18%, var(--bg));
  --accent-mid: color-mix(in srgb, var(--accent) 40%, var(--bg));
}

/* =========================================================
   Base styles
   ========================================================= */
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter,
    "Helvetica Neue", Arial;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}
.container {
  max-width: var(--maxw);
  margin-inline: auto;
  padding: clamp(16px, 4vw, 28px);
}

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

.btn {
  display: inline-block;
  padding: 0.9rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #031230; /* contrast on bright gradient */
  font-weight: 700;
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) {
  .btn {
    color: #05112a;
  }
}
.btn:hover {
  filter: brightness(1.05);
}
.btn.secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}

.section {
  padding-block: clamp(36px, 7vw, 80px);
}

.grid {
  display: grid;
  gap: clamp(14px, 2.4vw, 28px);
}
.grid-2 {
  grid-template-columns: 1fr;
}
.grid-3 {
  grid-template-columns: 1fr;
}
@media (min-width: 860px) {
  .grid-2 {
    grid-template-columns: 1.1fr 1fr;
  }
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.25rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    border-color 0.12s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--brand);
}
.card h2, .card h3 {
  margin: 0 0 0.35rem 0;
  font-size: 1.05rem;
  line-height: 1.35;
}
.card-meta {
  font-size: 0.85rem;
  opacity: 0.75;
  margin-bottom: 0.5rem;
}
.card-desc {
  font-size: 0.95rem;
  margin: 0.25rem 0 0.75rem 0;
}
.card-actions a {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--brand);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

/* Badges now theme-aware */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  background: var(--accent-weak);
  color: var(--fg);
  border: 1px solid var(--accent-mid);
  border-radius: 999px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0 0 0.6rem;
}
h1 {
  font-size: clamp(2rem, 7vw, 3rem);
}
h2 {
  font-size: clamp(1.4rem, 4.2vw, 2rem);
}
h3 {
  font-size: clamp(1.05rem, 2.6vw, 1.2rem);
}
p {
  margin: 0.4rem 0 1rem;
}

/* =========================================================
   Nav (Jekyll-friendly)
   ========================================================= */
header.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: grid;
  grid-template-columns: 1fr auto; /* logo | nav/toggle */
  align-items: center;
  gap: 1rem;
  min-height: 64px;
}
.logo a {
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

/* Inline nav (desktop) */
.nav-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-left: auto;
}
.nav-links a,
.nav-links .btn {
  display: inline-block;
  text-decoration: none;
  color: var(--fg);
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
}
.nav-links a:hover {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}

/* Toggle button */
.nav-toggle {
  display: none; /* hidden on desktop */
  inline-size: 40px;
  block-size: 40px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  place-items: center;
}
.nav-toggle .icon-close {
  display: none;
}

/* --------- Mobile drawer styles --------- */
@media (max-width: 900px) {
  .nav-toggle {
    display: inline-grid;
    margin-left: auto;
  }

  /* Pull the same .nav-links into a fixed drawer */
  header.nav .nav-links {
    height: fit-content;
    position: fixed;
    top: 10px;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(92vw, 480px); /* WIDER drawer */
    max-width: none; /* kill any caps causing 15% bug */
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateX(100%);
    transition: transform 220ms ease;
    padding: 20px 18px;

    /* Two-column grid */
    display: grid;
    grid-template-columns: repeat(2, minmax(100px, 1fr));
    grid-auto-rows: minmax(44px, auto);
    gap: 8px 10px;
    align-content: start;
    overflow-y: auto;
    z-index: 1001;

    /* display: grid;
    gap: 8px;
    overflow-y: auto;
    z-index: 1001; */

    /* hide from hit-testing & a11y tree until open */
    visibility: hidden;
    pointer-events: none;
  }
  header.nav .nav-overlay {
    /* position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    opacity: 0; pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 1000; */

    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 1000;
  }

  /* Compact items */
  header.nav .nav-links a,
  header.nav .nav-links .btn {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 0.7rem 0.9rem;
    line-height: 1.2;
    border-radius: 12px;
    min-height: 44px; /* tap target */
    font-size: 0.95rem;
  }

  /* .nav-links a, .nav-links .btn {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    padding: .9rem 1rem;
  } */

  /* Open state */
  body[data-nav-open="true"] header.nav .nav-links {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  body[data-nav-open="true"] header.nav .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  body[data-nav-open="true"] .nav-toggle .icon-burger {
    display: none;
  }
  body[data-nav-open="true"] .nav-toggle .icon-close {
    display: block;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nav-links,
  .nav-overlay {
    transition: none;
  }
}

/* =========================================================
   Hero
   ========================================================= */
.hero {
  padding-block: clamp(40px, 8vw, 120px);
}

.hero-wrap {
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .hero-wrap {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
  }
}

.title {
  font-weight: 900;
}
.kickers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.6rem 0 1rem;
}
.hero-cta {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.hero-card {
  aspect-ratio: 16 / 10; /* desktop/tablet */
  border-radius: calc(var(--radius) + 6px);
  background: radial-gradient(
      1200px 500px at -10% -20%,
      color-mix(in srgb, var(--accent) 15%, transparent),
      transparent 55%
    ),
    radial-gradient(
      800px 500px at 120% 120%,
      color-mix(in srgb, var(--accent-2) 12%, transparent),
      transparent 45%
    ),
    var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* ADDED: make inner content a responsive grid of boxes */
.hero-card-inner {
  padding: clamp(16px, 4vw, 28px);
  text-align: center;
  gap: 12px;
  width: 100%;
  justify-items: stretch;
}

/* Phone: drop fixed aspect and use a fluid height */
@media (max-width: 700px) {
  .hero-card {
    aspect-ratio: auto;
    min-height: clamp(220px, 45vw, 420px);
  }
}

/* =========================================================
   Stats / Impact
   ========================================================= */
.impact {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 1rem;
}
.impact .stat {
  background: var(--surface-weak);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
.impact .num {
  font-weight: 900;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 880px) {
  .stats {
    grid-template-columns: repeat(5, 1fr);
  }
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .big {
  font-weight: 900;
  font-size: clamp(1.3rem, 4.8vw, 2rem);
}

/* =========================================================
   Footer
   ========================================================= */
footer {
  border-top: 1px solid var(--border);
  padding-block: 28px;
  color: var(--muted);
}

/* =========================================================
   Breadcrumbs
   ========================================================= */
.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.breadcrumbs li::after {
  content: "/";
  margin-left: 0.5rem;
  color: var(--muted);
}
.breadcrumbs li:last-child::after {
  content: "";
}
.breadcrumbs a {
  color: var(--muted);
}

/* =========================================================
   A11y skip link
   ========================================================= */
.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 9999;
  background: var(--accent);
  color: #05112a;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
}

/* =========================================================
   Utilities
   ========================================================= */
.pt-0 {
  padding-top: 0;
}
.icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}
.row {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}

/* =========================================================
   Clients grid
   ========================================================= */
.clients {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: center;
}
@media (min-width: 680px) {
  .clients {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
.logo-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 12px;
  height: 72px;
  box-shadow: var(--shadow);
}

/* =========================================================
   Timeline
   ========================================================= */
.timeline {
  position: relative;
  margin: 2rem 0;
  padding-left: 0;
  list-style: none;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--border);
  transform: translateX(-50%);
}
.timeline-item {
  position: relative;
  width: 50%;
  padding: 1.5rem;
}
.timeline-item h3 {
  margin-top: 0;
}
.timeline-item p {
  margin: 0;
  color: var(--muted);
}
.timeline-item.left {
  left: 0;
  text-align: right;
}
.timeline-item.right {
  left: 50%;
  text-align: left;
}
.timeline-item::before {
  content: "";
  position: absolute;
  top: 1.5rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--card);
  box-shadow: var(--shadow);
}
.timeline-item.left::before {
  right: -8px;
}
.timeline-item.right::before {
  left: -8px;
}

/* =========================================================
   Misc
   ========================================================= */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem auto;
  width: 60%;
}

/* ===== Books layout ===== */
.book-cover {
  display: block;
  max-width: 180px;
  height: auto;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.book-card {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
  margin-bottom: 24px;
}
.book-media {
  flex: 0 0 190px;
}
.book-body {
  flex: 1;
  min-width: 0;
}
@media (max-width: 720px) {
  .book-card {
    flex-direction: column;
  }
  .book-media {
    flex: none;
  }
}

/* Real cover images */
img.book-cover {
  display: block;
  width: 190px;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* Themed CSS-only placeholder cover */
.book-cover.placeholder {
  width: 190px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  color: var(--fg);
  background: radial-gradient(
      600px 300px at -20% -20%,
      color-mix(in srgb, var(--accent) 18%, transparent),
      transparent 60%
    ),
    radial-gradient(
      500px 260px at 120% 120%,
      color-mix(in srgb, var(--accent-2) 16%, transparent),
      transparent 50%
    ),
    var(--card);
}
.book-cover.placeholder .ph-title {
  font-weight: 800;
  line-height: 1.2;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}
.book-cover.placeholder .ph-sub {
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--muted);
}

/* Media list/grid */
.media-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}
.media-thumb {
  width: 120px;
  height: auto;
  border-radius: 8px;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

/* =======================
   Mobile polish
   ======================= */

/* Very small screens */
@media (max-width: 360px) {
  .container {
    padding: 14px;
  }
  .btn {
    padding: 0.8rem 1rem;
  }
}

/* Phones */
@media (max-width: 640px) {
  .section {
    padding-block: 28px;
  }

  /* Nav breathing room — (REMOVED conflicting .nav-links flex overrides) */

  /* Theme toggle button (if it sits in nav) */
  #themeToggle {
    padding: 0.5rem 0.7rem;
    border-radius: 999px;
    line-height: 1;
  }

  /* Hero spacing */
  .hero {
    padding-block: 36px;
  }
  .hero-wrap {
    gap: 16px;
  }
  .hero-cta {
    gap: 0.5rem;
  }

  /* Cards and grids */
  .cards {
    gap: 1rem;
  }
  .grid {
    gap: 16px;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  } /* force single column */

  /* Stats & Impact */
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* Timeline → single column */
  .timeline {
    margin: 1.5rem 0;
  }
  .timeline::before {
    left: 12px;
    transform: none;
  }
  .timeline-item {
    width: 100%;
    left: 0 !important;
    text-align: left !important;
    padding-left: 2.25rem;
  }
  .timeline-item::before {
    left: 4px;
  }

  /* Media grid cards */
  .media-grid {
    grid-template-columns: 1fr;
  }

  /* Book cards */
  .book-card {
    gap: 0.9rem;
  }
  img.book-cover,
  .book-cover.placeholder {
    width: 160px;
  }
}

/* Small tablets */
@media (min-width: 641px) and (max-width: 880px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
  .impact {
    grid-template-columns: 1fr 1fr;
  }
}

/* Clients grid: keep readable at phone sizes */
@media (max-width: 520px) {
  .clients {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .logo-tile {
    height: 64px;
  }
}

/* Scroll-to-top button safe placement on iOS/Android */
#scrollTopBtn {
  bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
  right: 16px;
  padding: 12px 14px;
  font-size: 18px;
}

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