/* =========================================================================
   thekidsaredrivingmecrazy.com — the whole stylesheet.
   Hand-written, no build step, no framework, zero third-party requests.

   Implements "Home Feed v4" from MATERIALS/ (the approved design), with a
   small set of deliberate accessibility deltas. WHY those deltas exist: the
   v4 palette put several tokens below WCAG AA at the sizes it uses them
   (12px meta at 3.31:1, the Kids category label at 3.63:1, and others). The
   colours below are the ORIGINAL HUES darkened by the smallest amount that
   reaches 4.5:1 on their real backgrounds. Every delta is listed in
   CLAUDE.md under "Accessibility deltas" — do not "restore" them to the
   prototype values without re-running the contrast check.
   ========================================================================= */

/* ---- fonts (self-hosted; the house rule is no third-party requests) ---- */
@font-face {
  font-family: 'Ephesis'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/ephesis-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Ephesis'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/ephesis-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Instrument Sans is a VARIABLE font: one roman file serves 400/500/600. */
@font-face {
  font-family: 'Instrument Sans'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/instrumentsans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/instrumentsans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Sans'; font-style: italic; font-weight: 400 600; font-display: swap;
  src: url(/fonts/instrumentsans-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans'; font-style: italic; font-weight: 400 600; font-display: swap;
  src: url(/fonts/instrumentsans-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- tokens ---- */
:root {
  --cream:      #f6f2ea;   /* page ground */
  --sage:       #dde0cd;   /* masthead band */
  --terracotta: #d9a06b;   /* 3px masthead rule (decorative, non-text) */
  --ink:        #33302a;
  --body-2:     #55503f;   /* article excerpts */
  --body-3:     #444034;   /* quick-post text */
  --muted:      #766e61;   /* AA delta: v4 #8d8474 was 3.31:1 at 12px */
  --muted-warm: #6e675a;   /* project notes at 13px — passes as-is */
  --tagline:    #666351;   /* AA delta: v4 #7a7660 was 3.40:1 on sage */
  --nav-idle:   #66634e;   /* AA delta: v4 #6e6a54 was 4.05:1 on sage */
  --olive:      #4f5a44;   /* wordmark + active nav */
  --nav-rule:   #b57a45;   /* active-nav underline (decorative) */
  --link-hover: #7d5a3c;
  --hairline:   #e2dac9;
  --accent:     #906641;   /* AA delta: v4 #a4744a — buttons + reading links */
  --focus:      #2f5d8a;   /* focus ring; distinct from every category colour */

  --container: 1100px;
  --pad-x: 28px;
  --radius-photo: 4px;
  --radius-card: 6px;
}

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

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

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Long single words (a pasted URL) must not force a sideways scroll at
     320px — this is the cheap global guard for WCAG 1.4.10 reflow. */
  overflow-wrap: break-word;
}

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

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* Every interactive thing gets a visible, high-contrast focus ring. The
   design never specified one; without it keyboard users are lost. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip link — first thing in the tab order, invisible until focused. */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--cream);
  padding: 12px 18px; font-size: 14px; font-weight: 600;
}
.skip-link:focus { left: 0; color: var(--cream); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* =========================================================================
   Masthead
   ========================================================================= */
.masthead-band { background: var(--sage); }

.masthead {
  max-width: var(--container); margin: 0 auto;
  padding: 48px var(--pad-x) 32px;
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 20px;
}

.wordmark {
  font-family: 'Ephesis', 'Apple Chancery', cursive;
  /* clamp() bounds, both deliberate:
     LOWER — the design's flat 64px overflows a 320px viewport, so it scales
     down to a still-legible 34px on the narrowest phones.
     UPPER — 60px, not the brief's 64px. Measured: at 64px this wordmark is
     744px wide and the nav is 314px, needing 1058px inside a 1100px container
     that offers 1040px, so the nav wrapped BELOW the wordmark instead of
     sitting bottom-right as v4 shows. 64px / 26px nav gap / 1100px container
     cannot all hold at once; 60px is the smallest change that restores the
     intended composition. Re-measure before raising it. */
  font-size: clamp(34px, 8.2vw, 60px);
  line-height: 0.9;
  color: var(--olive);
  margin: 0;
  font-weight: 400;
}
.wordmark a { color: inherit; }
.wordmark a:hover { color: var(--link-hover); }

.masthead__tagline {
  font-size: 12px; letter-spacing: 0.06em; color: var(--tagline); margin-top: 10px;
}

.masthead__nav {
  display: flex; flex-wrap: wrap; gap: 26px;
  font-size: 14px; font-weight: 500; padding-bottom: 8px;
}
.masthead__nav a {
  color: var(--nav-idle);
  padding-bottom: 4px;
  /* ≥44px tap targets on touch devices without disturbing the desktop look. */
  display: inline-flex; align-items: center; min-height: 24px;
}
.masthead__nav a[aria-current="page"] {
  color: var(--olive);
  border-bottom: 2px solid var(--nav-rule);
  font-weight: 600;
}
.masthead-rule { height: 3px; background: var(--terracotta); }

/* =========================================================================
   Layout: two columns that collapse to one
   ========================================================================= */
.layout {
  display: flex; flex-wrap: wrap; gap: 64px;
  margin-top: 48px; align-items: flex-start;
}
.layout__main { flex: 1 1 520px; min-width: 0; }
.layout__side { flex: 1 1 300px; max-width: 360px; min-width: 0;
                display: flex; flex-direction: column; gap: 56px; }
.page { padding-bottom: 96px; }
.page--single { max-width: 720px; }

/* =========================================================================
   Blog articles (main column)
   ========================================================================= */
.article { margin-bottom: 72px; }
.article:last-child { margin-bottom: 0; }

.article__hero,
.hero-photo {
  width: 100%;
  /* The design says a flat 400px. aspect-ratio keeps the same shape while
     letting the photo shrink on a phone instead of cropping to a letterbox. */
  aspect-ratio: 16 / 10; max-height: 400px;
  object-fit: cover; border-radius: var(--radius-photo);
  background: var(--hairline);
}

.meta-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 20px 0 10px;
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.meta-row .cat { font-weight: 600; }
.meta-row .sep { color: var(--muted); }
.meta-row time,
.meta-row .date { color: var(--muted); white-space: nowrap; }

.article__title {
  font-size: clamp(26px, 4.4vw, 32px); font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 14px;
  text-wrap: pretty;
}
.article__title a { color: inherit; }

.article__excerpt {
  font-size: 16px; line-height: 1.7; margin: 0 0 16px;
  color: var(--body-2); max-width: 60ch; text-wrap: pretty;
}

.readmore {
  display: inline-block;
  font-size: 14px; font-weight: 600; color: var(--accent);
  border-bottom: 1px solid #cbb9a2; padding-bottom: 2px;
}
.readmore:hover { color: var(--link-hover); }

/* =========================================================================
   Sidebar
   ========================================================================= */
.side-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 24px;
}
.side-head h2,
.side-title {
  font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 600; margin: 0;
}
.side-head .all { font-size: 12px; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 24px; }
.stack--tight { gap: 20px; }

/* --- quick posts --- */
.quick {
  border-top: 1px solid var(--hairline); padding-top: 16px;
}
.quick__meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 8px;
}
.quick__meta .dot { width: 6px; height: 6px; }
.quick__meta .cat { font-weight: 600; }
.quick__meta time { color: var(--muted); white-space: nowrap; }
.quick__body {
  font-size: 14px; line-height: 1.6; margin: 0 0 12px;
  color: var(--body-3); text-wrap: pretty;
}
.quick__body :first-child { margin-top: 0; }
.quick__body :last-child { margin-bottom: 0; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.thumbs img {
  width: 88px; height: 88px; object-fit: cover;
  border-radius: var(--radius-photo); background: var(--hairline);
}
.thumbs--lg img { width: 120px; height: 120px; }

/* --- projects --- */
.project-row {
  display: flex; gap: 16px; align-items: flex-start;
  border-top: 1px solid var(--hairline); padding-top: 16px;
}
.project-row__img {
  width: 64px; height: 64px; flex: none; object-fit: cover;
  border-radius: var(--radius-photo); background: var(--hairline);
}
.project-row__head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 4px;
}
.project-row__name { font-size: 15px; font-weight: 600; }
.status { font-size: 11px; font-weight: 600; white-space: nowrap; }
.project-row__note {
  font-size: 13px; line-height: 1.55; color: var(--muted-warm); text-wrap: pretty; margin: 0;
}

/* --- browse (categories + archive) --- */
.rows { display: flex; flex-direction: column; }
.rows a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--hairline); font-size: 14px;
  min-height: 44px;   /* touch target */
}
.rows a > span:first-child { display: flex; align-items: center; gap: 10px; }
.rows .count { font-size: 12px; color: var(--muted); }
.rows + .rows { margin-top: 28px; }

/* --- subscribe card --- */
.subscribe {
  background: var(--ink); border-radius: var(--radius-card);
  padding: 28px 24px; color: var(--cream);
}
.subscribe h2 {
  font-family: 'Ephesis', 'Apple Chancery', cursive;
  font-size: 34px; line-height: 1; margin: 0 0 10px;
  color: var(--cream); font-weight: 400;
}
.subscribe p { font-size: 13px; line-height: 1.6; margin: 0 0 16px; color: #c9c2b2; }
.subscribe form { display: flex; gap: 8px; flex-wrap: wrap; }
.subscribe input[type="email"] {
  flex: 1 1 140px; min-width: 0;
  background: var(--cream); color: var(--ink);
  border: 1px solid var(--cream); border-radius: var(--radius-photo);
  padding: 12px; font-size: 13px; font-family: inherit; min-height: 44px;
}
.subscribe input::placeholder { color: #6b6558; opacity: 1; }
.subscribe button {
  background: var(--accent); color: var(--cream);
  border: 0; border-radius: var(--radius-photo);
  padding: 12px 16px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; min-height: 44px;
}
.subscribe button:hover { background: #7d5837; }

/* =========================================================================
   Flash message
   ========================================================================= */
.flash {
  margin: 24px auto 0; max-width: var(--container);
  background: #eef0e2; border-left: 4px solid var(--olive);
  padding: 12px 16px; font-size: 14px; color: var(--ink);
}

/* =========================================================================
   Single post / generic prose
   ========================================================================= */
.page-head { margin: 48px 0 40px; }
.page-head h1 {
  font-size: clamp(30px, 6vw, 44px); font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 10px; text-wrap: pretty;
}
.page-head p { color: var(--body-2); margin: 0; max-width: 60ch; }

.prose { font-size: 17px; line-height: 1.75; color: var(--body-2); max-width: 68ch; }
.prose h2 { font-size: 24px; color: var(--ink); margin: 40px 0 12px; line-height: 1.25; }
.prose h3 { font-size: 19px; color: var(--ink); margin: 32px 0 10px; }
.prose p { margin: 0 0 20px; text-wrap: pretty; }
.prose a { color: var(--accent); border-bottom: 1px solid #cbb9a2; }
.prose a:hover { color: var(--link-hover); }
.prose blockquote {
  margin: 24px 0; padding: 4px 0 4px 20px;
  border-left: 3px solid var(--hairline); color: var(--muted-warm); font-style: italic;
}
.prose img { border-radius: var(--radius-photo); margin: 24px 0; }
.prose code {
  background: #ece6da; padding: 2px 5px; border-radius: 3px; font-size: 0.9em;
}
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 24px; }
.prose li { margin-bottom: 8px; }

.post-photos { margin: 40px 0 0; display: flex; flex-direction: column; gap: 24px; }
.post-photos figure { margin: 0; }
.post-photos img { border-radius: var(--radius-photo); width: 100%; }
.post-photos figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* =========================================================================
   Gallery
   ========================================================================= */
.gallery-grid {
  display: grid; gap: 12px; margin: 0; padding: 0; list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.gallery-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius-photo); background: var(--hairline);
}
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 48px; font-size: 14px; }
.pager a { font-weight: 600; color: var(--accent); min-height: 44px; display: inline-flex; align-items: center; }

/* =========================================================================
   Card lists (blog index, archive month, category)
   ========================================================================= */
.card-list { display: flex; flex-direction: column; gap: 48px; }
.card { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.card__thumb {
  width: 200px; aspect-ratio: 3 / 2; object-fit: cover; flex: none;
  border-radius: var(--radius-photo); background: var(--hairline);
}
.card__body { flex: 1 1 260px; min-width: 0; }
.card__title { font-size: 22px; font-weight: 600; line-height: 1.25; margin: 0 0 8px; }
.card__excerpt { font-size: 15px; color: var(--body-2); margin: 0; text-wrap: pretty; }

.empty {
  border: 1px dashed var(--hairline); border-radius: var(--radius-card);
  padding: 40px 24px; text-align: center; color: var(--muted-warm); font-size: 15px;
}

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: center; gap: 16px;
  margin-top: 80px; padding-top: 28px; border-top: 1px solid var(--ink);
}
.site-footer__mark {
  font-family: 'Ephesis', 'Apple Chancery', cursive; font-size: 30px; color: var(--ink);
}
.site-footer__meta { font-size: 12px; color: var(--muted); }
.site-footer__meta a { color: var(--muted); }
.site-footer__meta a:hover { color: var(--link-hover); }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 900px) {
  .layout { gap: 48px; margin-top: 36px; }
  .layout__side { max-width: none; }
  .masthead { padding: 32px var(--pad-x) 24px; }
  .article { margin-bottom: 56px; }
}

@media (max-width: 600px) {
  :root { --pad-x: 18px; }
  .masthead { align-items: flex-start; flex-direction: column; gap: 16px; }
  .masthead__nav { gap: 18px; padding-bottom: 0; }
  /* Nav links become real tap targets once they are the only way around. */
  .masthead__nav a { min-height: 44px; }
  .card__thumb { width: 100%; }
  .thumbs img { width: 72px; height: 72px; }
  .site-footer { margin-top: 56px; }
}

/* At 320px the tightest constraint is the two-up thumb row and the subscribe
   form; both are already flex-wrap, so only padding needs to give. */
@media (max-width: 360px) {
  :root { --pad-x: 14px; }
  .subscribe { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
