/* =============================================================
   PrepSession: shared design system
   -------------------------------------------------------------
   Single source of truth for design tokens + site chrome
   (header, nav, footer, auth modal, buttons, shared sections).
   Loaded on every page AFTER the page-specific stylesheet so the
   chrome stays identical everywhere (including the legacy study
   engine), and webcore.css layers the 2000s-webcore look on top.
   Landing layout lives in assets/css/landing.css.
   ============================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Dark navy-green ("library green"): 50 = lightest, 800 = the brand colour */
  --pine-50:  #f1f6f3;
  --pine-100: #dde8e2;
  --pine-200: #b2c9bf;
  --pine-300: #7fa697;
  --pine-400: #4d8273;
  --pine-500: #2f6559;
  --pine-600: #285a4f;
  --pine-700: #1d4239;
  --pine-800: #12302b;  /* dark navy green: title bars, primary buttons */
  --pine-900: #0b1d19;
  --pine-950: #071512;

  /* Tan (the original PrepSession tan) + cream paper */
  --tan-200: #e2dcc2;
  --tan-300: #cfc6a2;
  --tan-400: #b6ad86;
  --tan-500: #9f9773;
  --tan-600: #857e5c;
  --tan-700: #6b6548;
  --paper-50:  #fdf9ec;
  --paper-100: #fbf3d5;
  --paper-200: #f2e6bd;

  /* Library accents: brass lamp, highlighter, due-date stamp red */
  --brass: #c9a227;
  --highlighter: #f2df6b;
  --stamp: #a5432f;
  --lamp: #e9c46a;
  --title-a: #12302b;
  --title-b: #3d6e5f;

  /* Ink + neutrals */
  --ink:       #1b2a25;
  --ink-soft:  #44544c;
  --ink-muted: #6e7461;
  --line:      rgba(60, 52, 28, 0.18);
  --white:     #ffffff;

  /* Semantic surfaces */
  --page-bg: linear-gradient(158deg, #15362e 0%, #0c2019 52%, #071512 100%);
  --surface: #fffdf6;
  --surface-cream: linear-gradient(180deg, var(--paper-50), var(--paper-100));
  --surface-green: linear-gradient(155deg, var(--pine-200) 0%, var(--pine-500) 100%);
  --header-bg: #f6efd6;
  --brand: var(--pine-500);
  --brand-strong: var(--pine-800);
  --danger: #a5432f;

  /* Typography */
  --font: "Poppins", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --fs-hero: clamp(2.75rem, 7vw, 5.5rem);
  --fs-h1:   clamp(1.9rem, 3.4vw, 2.6rem);
  --fs-h2:   clamp(1.45rem, 2.6vw, 2.05rem);
  --fs-h3:   1.2rem;
  --fs-body: 1.05rem;
  --fs-sm:   0.875rem;
  --lh:      1.65;

  /* Spacing scale (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px;

  /* Radii */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 28px; --r-pill: 999px;

  /* Elevation: soft, layered, warm-tinted */
  --shadow-sm: 0 1px 2px rgba(22, 30, 20, .08), 0 1px 3px rgba(22, 30, 20, .05);
  --shadow-md: 0 4px 14px rgba(22, 30, 20, .10), 0 2px 5px rgba(22, 30, 20, .06);
  --shadow-lg: 0 14px 36px rgba(22, 30, 20, .16), 0 5px 12px rgba(22, 30, 20, .08);
  --shadow-xl: 0 28px 70px rgba(5, 14, 11, .30);

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: .22s;

  /* Layout */
  --container: 1120px;
  --header-h: 74px;
}

/* ---------- Reset / base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

a { color: var(--brand-strong); }

:focus-visible {
  outline: 3px solid var(--pine-400);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden { display: none !important; }

/* ---------- Header + navigation ---------- */
header {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--header-h);
  padding: 0 clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .55) inset,
              0 10px 28px -18px rgba(22, 30, 20, .7);
  z-index: 9999999;
}

.left-nav { display: flex; align-items: center; }

.logo-container {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.logo {
  width: auto;
  height: 40px;
  display: block;
  transition: transform var(--dur) var(--ease);
}
.logo-container:hover .logo { transform: scale(1.04); }

.navigation {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  gap: clamp(12px, 2.4vw, 26px);
}

/* Text nav links with animated underline */
.nav-link,
.navigation a.nav-link {
  position: relative;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 2px;
  transition: color var(--dur) var(--ease);
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-strong);
  transition: right var(--dur) var(--ease);
}
.nav-link:hover { color: var(--brand-strong); }
.nav-link:hover::after,
.nav-link.current-page::after { right: 0; }
.nav-link.current-page { color: var(--brand-strong); font-weight: 600; }

/* STUDY: primary nav call to action (outlined pill that fills) */
.navigation .nav-study {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--brand-strong);
  text-decoration: none;
  background: transparent;
  border: 2px solid var(--brand-strong);
  border-radius: var(--r-pill);
  padding: 8px 26px;
  cursor: pointer;
  transition: background var(--dur) var(--ease),
              color var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.navigation .nav-study:hover {
  background: var(--brand-strong);
  color: var(--paper-50);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.navigation .nav-study.current-page {
  background: var(--brand-strong);
  color: var(--paper-50);
}
.navigation .nav-study.current-page:hover {
  background: var(--pine-700);
  color: var(--paper-50);
}

/* Auth buttons: signup = primary, login = ghost */
.navigation .btnLogin-popup,
.navigation .btnSignup-popup {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 9px 20px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--dur) var(--ease),
              color var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.navigation .btnLogin-popup {
  background: transparent;
  color: var(--brand-strong);
  border: 2px solid var(--line);
}
.navigation .btnLogin-popup:hover {
  border-color: var(--brand-strong);
  background: rgba(60, 52, 28, .06);
}
.navigation .btnSignup-popup {
  background: var(--brand-strong);
  color: var(--paper-50);
  border: 2px solid var(--brand-strong);
}
.navigation .btnSignup-popup:hover {
  background: var(--pine-700);
  border-color: var(--pine-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Logged-in controls (fix: these must read on the CREAM header) */
.right-nav {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 18px);
}
.right-nav .nav-account {
  display: inline-flex;
  align-items: center;
  color: var(--brand-strong);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.right-nav .nav-account:hover { color: var(--pine-700); text-decoration: underline; }
.right-nav .nav-greeting {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.right-nav .btnLogout {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  padding: 8px 18px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  transition: background var(--dur) var(--ease),
              color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.right-nav .btnLogout:hover {
  border-color: var(--brand-strong);
  color: var(--brand-strong);
  background: rgba(60, 52, 28, .06);
}

/* Footer: see .statusbar in assets/css/webcore.css */

/* ---------- Auth modal ---------- */
.wrapper {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -46%);
  width: min(420px, calc(100vw - 32px));
  background: var(--surface-cream);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  display: none;
  z-index: 1000000;
  padding: var(--sp-6);
  opacity: 0;
  transition: opacity var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.wrapper.active-popup {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%);
}
.wrapper .form-box { width: 100%; display: none; }
.wrapper .form-box.active { display: block; }

.wrapper .icon-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  font-size: 1.3em;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--r-pill);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.wrapper .icon-close:hover { background: rgba(60, 52, 28, .1); color: var(--ink); }

.form-box h2 {
  font-size: 1.75em;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  margin-bottom: var(--sp-2);
}

.input-box {
  position: relative;
  margin: var(--sp-4) 0;
}
.input-box .icon {
  position: absolute;
  top: 50%; left: 14px;
  transform: translateY(-50%);
  color: var(--ink-muted);
  font-size: 1.1em;
  pointer-events: none;
}
.input-box input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-family: var(--font);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input-box input::placeholder { color: var(--ink-muted); }
.input-box input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 101, 89, .18);
}

.remember-forgot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  margin: var(--sp-3) 0 var(--sp-4);
}
.remember-forgot label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.remember-forgot input[type="checkbox"] { accent-color: var(--brand); }
.remember-forgot a { color: var(--brand-strong); text-decoration: none; }
.remember-forgot a:hover { text-decoration: underline; }

/* Full-width primary button (auth modal + shared) */
.btn {
  width: 100%;
  background: var(--brand-strong);
  border: none;
  padding: 13px;
  cursor: pointer;
  font-size: var(--fs-body);
  font-weight: 600;
  font-family: var(--font);
  color: var(--paper-50);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--pine-700); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.login-register {
  text-align: center;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  margin-top: var(--sp-4);
}
.login-register a { color: var(--brand-strong); font-weight: 600; text-decoration: none; }
.login-register a:hover { text-decoration: underline; }

.auth-error {
  display: none;
  color: var(--danger);
  background: rgba(181, 64, 31, .1);
  border: 1px solid rgba(181, 64, 31, .25);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  text-align: center;
}

/* ---------- Shared surface primitives ---------- */
.container-wide {
  max-width: var(--container);
  margin-inline: auto;
}

/* ---------- Responsive header ----------
   Below 720px the fixed single-row bar can't hold logo + 4 controls,
   so it becomes a centered, wrapping sticky bar and pages drop their
   fixed-header top offset. */
@media (max-width: 720px) {
  header {
    position: sticky;
    height: auto;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 10px;
    column-gap: 10px;
    padding: 12px 14px;
  }
  .left-nav { flex-basis: 100%; justify-content: center; }
  .navigation {
    flex: 1 1 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .logo { height: 34px; }
  .navigation .nav-study,
  .navigation .btnLogin-popup,
  .navigation .btnSignup-popup,
  .right-nav .btnLogout,
  .right-nav .nav-account { padding: 7px 16px; }
  /* Header now flows inline, so remove the fixed-header spacer. */
  body { padding-top: 0; }
}

/* Reduce motion for users who ask for it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
