/* =========================================================================
   Mariam Khan — personal site
   Design system: tokens, base, nav, footer, cards, buttons, utilities.
   Single source of truth for tokens is BUILD-SPEC.md section 3 — mirrored
   here as CSS custom properties. Do not introduce a second accent color,
   a third typeface/weight, a third radius value, or a one-off spacing
   value — see BUILD-SPEC.md before changing this file.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Color */
  --accent: #C58EA1;        /* muted dusty-rose — the ONE accent color */
  --accent-light: #D6BFC9;  /* lighter tint, for layering/blobs only */
  --page-bg: #FAF9F6;
  --card-bg: #FFFFFF;
  --line: #E3E1D9;
  --text-primary: #1A1A18;
  --text-secondary: #706E64;

  /* NOTE on accent + accessibility (verified, see README):
     #C58EA1 on #FAF9F6/#FFFFFF is ~2.6:1 contrast — below WCAG AA even for
     large text. Never use --accent as a text color for body copy, links, or
     small UI labels. Safe uses: decorative fills/blobs, icon glyphs inside
     the glass tiles, borders/backgrounds paired with --text-primary on top
     (6.4:1, passes AA), and thick (>=3px) decorative underlines. */

  /* Type — BUILD-SPEC.md "Type scale": exactly these five sizes, nothing else */
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-h1: 40px;   /* Fraunces 500, line-height 1.15 */
  --text-h2: 28px;   /* Fraunces 500, line-height 1.25 */
  --text-h3: 16px;   /* DM Sans 500, line-height 1.3 */
  --text-body: 16px; /* DM Sans 400, line-height 1.6 */
  --text-meta: 13px; /* DM Sans 400, line-height 1.5 */

  /* Spacing scale — 8px base unit. Every margin/padding/gap uses one of these. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius — exactly two values, no more */
  --radius-sm: 8px;   /* buttons, inputs, tags, small controls */
  --radius-lg: 24px;  /* cards, the glass icon tile */

  /* Motion — one easing curve everywhere */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;

  --max-width: 1080px;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  margin: 0 0 var(--space-3);
}
/* Serif is reserved for editorial headlines — never nav/buttons/labels. */

h1 { font-size: var(--text-h1); line-height: 1.15; }
h2 { font-size: var(--text-h2); line-height: 1.25; }
/* Card titles (h3) are DM Sans, not the editorial serif — set per-component
   below, since the global h1/h2/h3 rule above defaults to the serif. */
h3.card-title {
  font-family: var(--font-sans);
  font-size: var(--text-h3);
  font-weight: 500;
  line-height: 1.3;
}

p { margin: 0 0 1rem; color: var(--text-primary); }
p.meta { font-size: var(--text-meta); line-height: 1.5; color: var(--text-secondary); }

a { color: inherit; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

section { padding: var(--space-8) 0; }

/* Visible, consistent focus state everywhere — nav, cards, buttons, form
   fields. Never rely on browser default alone, and never remove it. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--text-primary);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
  top: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 13px 26px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
/* Hover lift capped at 2-4px, per BUILD-SPEC.md motion rules — no dramatic
   jump, no glow/shadow-bloom. */
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { cursor: not-allowed; opacity: 0.7; }

/* Accent background + dark text = 6.4:1 contrast, passes AA. White text on
   accent fails contrast (~2.7:1) — never pair accent bg with white text. */
.btn-primary {
  background: var(--accent);
  color: var(--text-primary);
}
.btn-primary:hover:not(:disabled) { background: #b87c92; }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--text-secondary); }

/* Inline spinner for async button states (contact form submit) */
.btn .spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(26,26,24,0.25);
  border-top-color: var(--text-primary);
  animation: mk-spin 0.7s linear infinite;
  display: none;
}
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.85; }
@keyframes mk-spin { to { transform: rotate(360deg); } }

/* ---------- Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 249, 246, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.site-nav .wordmark {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 19px;
  text-decoration: none;
  color: var(--text-primary);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text-primary);
  border-color: var(--accent);
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  margin: 5px 0;
  transition: transform var(--dur-base) var(--ease-standard), opacity var(--dur-base) var(--ease-standard);
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--page-bg);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: var(--space-3) var(--space-5) var(--space-5);
    display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: var(--space-3) 0; }
  body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ---------- Cards ----------
   One recipe, everywhere a plain card is used (Work/Case Studies, Community,
   What I'm Learning): white background, hairline border, --radius-lg, no
   shadow, no blur. Never a per-page variant. */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: transform var(--dur-fast) var(--ease-standard);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-5);
}

/* Cards that are also filter targets get a lightweight hidden state */
.card[hidden] { display: none; }

/* ---------- Page header (non-home pages) ---------- */
.page-header {
  padding: var(--space-8) 0 var(--space-6);
}
.page-header .eyebrow {
  font-size: var(--text-meta);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}
.page-header p.lede {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 60ch;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: var(--space-6) 0;
  margin-top: var(--space-8);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}
.site-footer p {
  margin: 0;
  font-size: var(--text-meta);
  color: var(--text-secondary);
}

/* ---------- Utilities ---------- */
.text-secondary { color: var(--text-secondary); }
.mt-0 { margin-top: 0; }
.center-cta { text-align: center; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  background: #fff;
}

/* Filter chips — functional (see js/filters.js on Work / Case Studies).
   Radius-sm per BUILD-SPEC.md ("tags, small controls"). */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.chip[aria-pressed="true"] {
  color: var(--text-primary);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, white);
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* Photo placeholder blocks — Creative/Community pages, where the spec's own
   open decisions flag real photography as not supplied yet (this is the one
   kind of placeholder still legitimate — everything else on the site now
   has real copy). */
.photo-block {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-sm);
  background: linear-gradient(155deg, #F0EAE4, #E7DFE1);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: var(--text-meta);
  text-align: center;
  padding: var(--space-3);
}
