/* ==========================================================================
   Printable Scholar — shared site chrome ("Academic Clarity" design system)
   Single hand-rolled stylesheet (no Tailwind) for all non-homepage pages.
   Mirrors the tokens used by the Tailwind homepage so the whole site is one brand.

   Contains:
     1. Design tokens (:root) — Academic Clarity (emerald + Material-3 surfaces)
     2. Legacy var compat layer — maps old /shared/style.css vars onto the new
        palette so existing inline component CSS re-renders in the new design
        without a per-component rewrite.
     3. Base typography
     4. Chrome: .appbar (header), nav, mobile drawer, .site-footer-v2
   ========================================================================== */

/* ---------- 1. Academic Clarity tokens ---------- */
:root {
  --primary: #006a45;
  --primary-container: #25845b;
  --primary-fixed: #9af5c4;
  --on-primary: #ffffff;
  --primary-dark: #00583a;
  --secondary: #0060ac;
  --tertiary: #805200;

  --surface: #fbf9f8;
  --surface-low: #f5f3f3;
  --surface-container: #efeded;
  --surface-high: #eae8e7;
  --on-surface: #1b1c1c;
  --on-surface-variant: #3f4942;
  --outline: #6f7a72;
  --outline-variant: #bec9c0;
  --hairline: #e2e8f0;          /* slate-200, used for borders site-wide */
  --slate-600: #475569;

  --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --r: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;
  --r-2xl: 1.5rem;
  --r-full: 9999px;

  --maxw: 1280px;       /* max-w-7xl */
  --pad-x: 24px;        /* px-6 */
}

/* ---------- 2. Legacy compat layer ----------
   Existing inline component CSS (passage-card, gallery-card, tool-card, blog
   chrome, etc.) references these var names. Remapping them onto the new palette
   re-skins every legacy component to Academic Clarity with zero per-page edits. */
:root {
  --accent: var(--primary);
  --accent-dark: var(--primary-dark);
  --accent-light: #e7f3ed;
  --accent-border: #b6e2c8;
  /* warm secondary kept (emerald + mustard reads classroom-warm) */
  --accent-secondary: #e5a220;
  --accent-secondary-light: #fef7e6;
  --accent-secondary-dark: #c88a10;

  --body-bg: var(--surface);
  --card-bg: #ffffff;
  --text-primary: var(--on-surface);
  --text-secondary: var(--on-surface-variant);
  --text-muted: var(--outline);
  --border: var(--hairline);

  --green-bg: #f0fdf4; --green-border: #bbf7d0; --green-text: #166534;
  --blue-bg: #eff6ff; --blue-border: #bfdbfe; --blue-text: #1e40af;
  --yellow-bg: #fffbeb; --yellow-border: #fde68a; --yellow-text: #92400e;

  --container-width: 1080px;
  --container-narrow: 900px;
  --font-stack: var(--font-sans);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.10);
}

/* ---------- 3. Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--on-surface);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .font-display { font-family: var(--font-display); letter-spacing: -0.01em; }
a { color: var(--primary); }

/* ---------- 4a. App bar (header) ---------- */
.appbar {
  background: #fff;
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 40;
}
.appbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad-x);
  height: 64px;
}
.appbar-left { display: flex; align-items: center; gap: 40px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { width: 28px; height: 28px; }
.nav-primary { display: flex; align-items: center; gap: 28px; font-size: 14px; }
.nav-primary a {
  color: var(--slate-600);
  font-weight: 500;
  text-decoration: none;
  padding-bottom: 4px;
  transition: color .15s;
}
.nav-primary a:hover { color: var(--primary); }
.nav-primary a.active {
  color: var(--on-surface);
  font-weight: 600;
  border-bottom: 2px solid var(--primary);
}
.appbar-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-lg);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background .15s;
}
.appbar-cta:hover { background: var(--primary-container); }

/* hamburger — mobile only */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--on-surface);
}
.menu-toggle svg { width: 26px; height: 26px; display: block; }

/* ---------- 4b. Mobile drawer (sibling of header, never nested) ---------- */
.drawer-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0; visibility: hidden;
  transition: opacity .2s;
  z-index: 50;
}
.drawer-scrim.open { opacity: 1; visibility: visible; }
.mobile-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(82vw, 320px);
  background: #fff;
  z-index: 51;
  transform: translateX(100%);
  transition: transform .22s ease;
  padding: 20px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: -8px 0 24px rgba(0,0,0,.12);
}
.mobile-drawer.open { transform: translateX(0); }
.mobile-drawer .drawer-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.mobile-drawer a {
  padding: 12px 8px;
  color: var(--on-surface);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  border-radius: var(--r);
}
.mobile-drawer a:hover, .mobile-drawer a.active { background: var(--surface-low); color: var(--primary); }
.mobile-drawer .drawer-close { background:none; border:none; cursor:pointer; padding:6px; color:var(--on-surface); }
.mobile-drawer .drawer-close svg { width:24px; height:24px; display:block; }

@media (max-width: 767px) {
  .nav-primary, .appbar-cta { display: none; }
  .menu-toggle { display: inline-flex; }
}

/* ---------- 4c. Footer ---------- */
.site-footer-v2 {
  border-top: 1px solid var(--hairline);
  background: var(--surface-low);
  margin-top: 56px;
}
.site-footer-v2 .footer-inner-v2 { max-width: var(--maxw); margin: 0 auto; padding: 48px var(--pad-x); }
.site-footer-v2 .footer-cols {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 40px;
}
.site-footer-v2 .footer-brand { font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--primary); text-decoration: none; display: inline-block; margin-bottom: 12px; }
.site-footer-v2 .footer-blurb { font-size: 14px; color: var(--on-surface-variant); margin: 0; max-width: 32ch; }
.site-footer-v2 h4 { font-family: var(--font-display); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--on-surface); margin: 0 0 12px; }
.site-footer-v2 ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.site-footer-v2 ul a { font-size: 14px; color: var(--on-surface-variant); text-decoration: none; }
.site-footer-v2 ul a:hover { color: var(--primary); }
.site-footer-v2 .footer-bottom {
  padding-top: 24px; border-top: 1px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-size: 14px; color: var(--on-surface-variant); flex-wrap: wrap;
}
.site-footer-v2 .footer-bottom a { color: var(--on-surface-variant); }
.site-footer-v2 .footer-bottom a:hover { color: var(--primary); }
@media (max-width: 767px) {
  .site-footer-v2 .footer-cols { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 480px) {
  .site-footer-v2 .footer-cols { grid-template-columns: 1fr; }
}
