/* ==========================================================================
   SaigonNezumi Theme - Design Tokens & Stylesheet
   Fusion of Vietnamese (Đỏ son, Vàng hoàng, Chàm) & Japanese (Sumi, Washi, Ai)
   WCAG 2.2 Level AAA Compliant (Normal text >= 7:1, Large >= 4.5:1, UI >= 3:1)
   ========================================================================== */

/*
================================================================================
CONTRAST PAIRS TABLE (checked by tools/check_contrast.py for WCAG 2.2 AAA)
Format: FOREGROUND | BACKGROUND | MIN_RATIO | ROLE | DESCRIPTION
--------------------------------------------------------------------------------
--color-text | --color-bg-page | 7.0 | normal-text | Body text on page canvas
--color-text | --color-bg-card | 7.0 | normal-text | Body text on card surface
--color-text | --color-bg-header | 7.0 | normal-text | Site title/header text
--color-text | --color-bg-footer | 7.0 | normal-text | Footer text on footer surface
--color-text-muted | --color-bg-page | 7.0 | normal-text | Muted text (dates/meta) on page
--color-text-muted | --color-bg-card | 7.0 | normal-text | Muted text on card surface
--color-text-muted | --color-bg-footer | 7.0 | normal-text | Muted text on footer surface
--color-heading | --color-bg-page | 4.5 | large-text | Headings on page canvas
--color-heading | --color-bg-card | 4.5 | large-text | Headings on card surface
--color-link | --color-bg-page | 7.0 | normal-text | Links on page canvas
--color-link | --color-bg-card | 7.0 | normal-text | Links on card surface
--color-link | --color-bg-footer | 7.0 | normal-text | Links on footer surface
--color-link-visited | --color-bg-page | 7.0 | normal-text | Visited links on page canvas
--color-link-visited | --color-bg-card | 7.0 | normal-text | Visited links on card surface
--color-link-hover | --color-bg-page | 7.0 | normal-text | Link hover state on page canvas
--color-link-hover | --color-bg-card | 7.0 | normal-text | Link hover state on card surface
--color-link-focus | --color-bg-page | 7.0 | normal-text | Link focus state on page canvas
--color-link | --color-bg-header | 7.0 | normal-text | Links on header surface
--color-link-visited | --color-bg-header | 7.0 | normal-text | Visited links on header surface
--color-link-visited | --color-bg-footer | 7.0 | normal-text | Visited links on footer surface
--color-link-hover | --color-bg-header | 7.0 | normal-text | Link hover state on header surface
--color-link-hover | --color-bg-footer | 7.0 | normal-text | Link hover state on footer surface
--color-link-focus | --color-bg-card | 7.0 | normal-text | Link focus state on card surface
--color-link-focus | --color-bg-header | 7.0 | normal-text | Link focus state on header surface
--color-link-focus | --color-bg-footer | 7.0 | normal-text | Link focus state on footer surface
--color-link | --color-bg-quote | 7.0 | normal-text | Links inside a blockquote
--color-link-visited | --color-bg-quote | 7.0 | normal-text | Visited links inside a blockquote
--color-link-hover | --color-bg-quote | 7.0 | normal-text | Link hover state inside a blockquote
--color-code-text | --color-bg-code | 7.0 | normal-text | Code text on code background
--color-quote-text | --color-bg-quote | 7.0 | normal-text | Quote text on quote background
--color-tag-text | --color-bg-tag | 7.0 | normal-text | Tag text on tag chip surface
--color-button-text | --color-bg-button | 7.0 | normal-text | Button text on button background
--color-button-hover-text | --color-bg-button-hover | 7.0 | normal-text | Button hover text on hover background
--color-input-text | --color-bg-input | 7.0 | normal-text | Form input text on input field
--color-text-disabled | --color-bg-disabled | 4.5 | disabled-text | Disabled input/button text
--color-focus | --color-bg-page | 3.0 | focus-indicator | Focus outline against page canvas
--color-focus | --color-bg-card | 3.0 | focus-indicator | Focus outline against card surface
--color-focus | --color-bg-header | 3.0 | focus-indicator | Focus outline against header
--color-focus | --color-bg-footer | 3.0 | focus-indicator | Focus outline against footer
--color-border | --color-bg-page | 3.0 | ui-border | General divider/rule on page
--color-border-card | --color-bg-page | 3.0 | ui-border | Card boundary on page canvas
--color-border-input | --color-bg-page | 3.0 | ui-border | Form input border against page
--color-border-input | --color-bg-input | 3.0 | ui-border | Form input border against input field
--color-border-quote | --color-bg-quote | 3.0 | ui-border | Blockquote decorative border
--color-border-tag | --color-bg-page | 3.0 | ui-border | Tag chip border against page
--color-border-table | --color-bg-card | 3.0 | ui-border | Table cell border against table surface
--color-border-disabled | --color-bg-disabled | 3.0 | disabled-border | Disabled control border
--color-bg-button | --color-bg-page | 3.0 | ui-component | Button surface boundary on page
--color-bg-button-hover | --color-bg-page | 3.0 | ui-component | Button hover surface boundary on page
--color-heading | --color-bg-header | 4.5 | large-text | Headings on header surface
--color-heading | --color-bg-footer | 4.5 | large-text | Headings on footer surface
--color-heading | --color-bg-footer | 4.5 | large-text | Headings on table header
--color-text-placeholder | --color-bg-input | 7.0 | normal-text | Placeholder text on input field
--color-text-selection | --color-bg-selection | 7.0 | normal-text | Selection text on selection background
--color-focus | --color-focus-inner | 3.0 | focus-indicator | Outer focus ring on inner ring
--color-focus-inner | --color-bg-button | 3.0 | focus-indicator | Inner focus ring on button surface
--color-focus-inner | --color-bg-button-hover | 3.0 | focus-indicator | Inner focus ring on button hover
--color-focus | --color-bg-tag | 3.0 | focus-indicator | Focus ring against tag chip
--color-focus | --color-bg-input | 3.0 | focus-indicator | Focus ring against input field
--color-focus | --color-bg-code | 3.0 | focus-indicator | Focus ring against code block
--color-focus | --color-bg-quote | 3.0 | focus-indicator | Focus ring against quote callout
--color-link-hover | --color-bg-tag | 7.0 | normal-text | Tag link hover on tag chip
--color-border | --color-bg-code | 3.0 | ui-border | Code block border against code surface
--color-border | --color-bg-card | 3.0 | ui-border | Border against card surface for frames
--color-border-table | --color-bg-footer | 3.0 | ui-border | Table cell border against table header
--color-text | --color-bg-tag | 7.0 | normal-text | Sidebar and nav hover or current item
--color-text-muted | --color-bg-tag | 7.0 | normal-text | Sidebar counts on a hovered or current item
--color-heading | --color-bg-tag | 4.5 | large-text | Current nav item heading colour on tag surface
================================================================================
*/

/* Lexend (SIL OFL 1.1, see ../fonts/OFL.txt), self-hosted variable font, weights 300-700.
   Three unicode-range subsets so a page only downloads what it uses; Vietnamese gets its own. */
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/lexend-vietnamese.e3c313092df5.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/lexend-latin-ext.a981ad4865c7.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/lexend-latin.7e692144d823.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;
}

:root {
  color-scheme: light dark;

  /* Typography: self-hosted Lexend first, system stack as the fallback (and for CJK glyphs) */
  --font-body: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --font-heading: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Hiragino Kaku Gothic ProN", monospace;

  /* Font sizing & rhythm: body at least 18px (1.125rem), line-height at least 1.5 */
  --font-size-base: 1.125rem; /* 18px */
  --line-height-base: 1.6;

  /* --------------------------------------------------------------------------
     LIGHT SCHEME TOKENS (Washi & Sumi Editorial Palette)
     -------------------------------------------------------------------------- */
  /* Surfaces */
  --color-bg-page: #faf7f2;         /* Washi / Kinari off-white paper */
  --color-bg-card: #ffffff;         /* Crisp white card surface */
  --color-bg-header: #faf7f2;       /* Header surface matching washi canvas */
  --color-bg-footer: #f2ece1;       /* Aged washi / subtle tea-wash footer */
  --color-bg-code: #f2ece1;         /* Code block background */
  --color-bg-quote: #f6f1e8;        /* Blockquote callout background */
  --color-bg-tag: #ede6d8;          /* Tag chip background */
  --color-bg-button: #0f3d68;       /* Chàm / Ai deep indigo dye */
  --color-bg-button-hover: #701515; /* Sơn son / Shu deep lacquer vermilion */
  --color-bg-input: #ffffff;        /* Form input background */
  --color-bg-disabled: #e8e2d8;     /* Disabled background */
  --color-bg-selection: #0f3d68;    /* Deep indigo selection highlight */

  /* Text & Typography */
  --color-text: #161514;            /* Sumi ink charcoal black (17.07:1 on washi) */
  --color-text-muted: #44403c;      /* Deep nezumi ink wash (9.61:1 on washi) */
  --color-heading: #161514;         /* Sumi ink black headings */
  --color-link: #0f3d68;            /* Chàm indigo link (10.41:1 on washi) */
  --color-link-visited: #5c2070;    /* Tử quy / Murasaki violet (10.37:1 on washi) */
  --color-link-hover: #881313;      /* Sơn son lacquer red hover (9.14:1 on washi) */
  --color-link-focus: #881313;      /* Link focus state */
  --color-button-text: #ffffff;     /* White text on indigo button (11.12:1) */
  --color-button-hover-text: #ffffff;/* White text on lacquer red button (11.62:1) */
  --color-code-text: #161514;       /* Code monospace sumi ink */
  --color-quote-text: #161514;      /* Quote text */
  --color-tag-text: #161514;        /* Tag chip text */
  --color-input-text: #161514;      /* Input field text */
  --color-text-disabled: #484542;   /* Disabled control text (7.39:1) */
  --color-text-placeholder: #57534e;/* Muted placeholder text (7.63:1 on white) */
  --color-text-selection: #ffffff;  /* High contrast selection text (11.12:1) */

  /* Borders & UI Indicators */
  --color-border: #78716c;          /* Warm stone / nezumi divider (4.49:1) */
  --color-border-card: #78716c;     /* Card container border */
  --color-border-input: #78716c;    /* Form input boundary (4.49:1) */
  --color-border-quote: #881313;    /* Sơn son lacquer red accent bar (8.68:1) */
  --color-border-tag: #78716c;      /* Tag chip border (4.49:1) */
  --color-border-table: #78716c;    /* Table border (4.80:1 on card) */
  --color-border-disabled: #78716c; /* Disabled border (3.72:1) */
  --color-focus: #854d0e;           /* Vàng hoàng / Kintsugi lacquer gold (6.41:1) */
  --color-focus-inner: #ffffff;     /* Inner focus contrast ring for buttons (11.12:1) */
}

/* ----------------------------------------------------------------------------
   DARK SCHEME TOKENS - DATA-THEME EXPLICIT OVERRIDE
   Urushi Night & Silk Palette (Vietnamese & Japanese Heritage)
   ---------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  /* Surfaces */
  --color-bg-page: #121211;         /* Deep Sumi / Urushi warm black lacquer canvas */
  --color-bg-card: #1c1b19;         /* Elevated slate lacquer card surface */
  --color-bg-header: #121211;       /* Header surface matching canvas */
  --color-bg-footer: #181716;       /* Subtly elevated footer */
  --color-bg-code: #242220;         /* Smoked bamboo code background */
  --color-bg-quote: #191817;        /* Quote callout surface */
  --color-bg-tag: #272522;          /* Tag chip surface */
  --color-bg-button: #70ade6;       /* Chàm / Ai botanical indigo silk tint */
  --color-bg-button-hover: #b6d5f2; /* Highlighted botanical indigo button hover */
  --color-bg-input: #1c1b19;        /* Input background */
  --color-bg-disabled: #22201e;     /* Disabled control surface */
  --color-bg-selection: #70ade6;    /* Selection highlight (botanical indigo silk) */

  /* Text & Typography */
  --color-text: #faf7f2;            /* Washi cream / raw silk (17.54:1) */
  --color-text-muted: #d6d3cd;      /* River stone pale washi (12.55:1) */
  --color-heading: #faf7f2;         /* Silk ivory headings */
  --color-link: #70ade6;            /* Chàm / Ai botanical indigo silk link */
  --color-link-visited: #ddb6fc;    /* Tử Quy / Murasaki wisteria violet */
  --color-link-hover: #fca89b;      /* Sơn son lacquer vermilion glow */
  --color-link-focus: #fca89b;      /* Link focus state */
  --color-button-text: #121211;     /* Sumi black on indigo silk button */
  --color-button-hover-text: #121211;/* Sumi black on button hover */
  --color-code-text: #faf7f2;       /* Monospace silk text */
  --color-quote-text: #faf7f2;      /* Quote text */
  --color-tag-text: #faf7f2;        /* Tag text */
  --color-input-text: #faf7f2;      /* Input field text */
  --color-text-disabled: #c4beba;   /* Disabled control text (8.83:1) */
  --color-text-placeholder: #bcb6af;/* Muted placeholder text (8.56:1 on input) */
  --color-text-selection: #121211;  /* Sumi ink selection text (7.86:1) */

  /* Borders & UI Indicators */
  --color-border: #a8a29e;          /* Light slate / nezumi border (7.43:1) */
  --color-border-card: #a8a29e;     /* Card border */
  --color-border-input: #a8a29e;    /* Input border */
  --color-border-quote: #fca89b;    /* Vermilion lacquer accent bar (9.45:1) */
  --color-border-tag: #a8a29e;      /* Tag border */
  --color-border-table: #a8a29e;    /* Table border */
  --color-border-disabled: #78716c; /* Disabled border (3.38:1) */
  --color-focus: #f5c968;           /* Vàng Hoàng Kim / Kintsugi warm gold focus ring */
  --color-focus-inner: #121211;     /* Sumi ink inner focus ring for buttons (7.86:1) */
}

/* ----------------------------------------------------------------------------
   DARK SCHEME TOKENS - SYSTEM MEDIA QUERY (TOKEN-FOR-TOKEN IDENTICAL)
   ---------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    /* Surfaces */
    --color-bg-page: #121211;         /* Deep Sumi / Urushi warm black lacquer canvas */
    --color-bg-card: #1c1b19;         /* Elevated slate lacquer card surface */
    --color-bg-header: #121211;       /* Header surface matching canvas */
    --color-bg-footer: #181716;       /* Subtly elevated footer */
    --color-bg-code: #242220;         /* Smoked bamboo code background */
    --color-bg-quote: #191817;        /* Quote callout surface */
    --color-bg-tag: #272522;          /* Tag chip surface */
    --color-bg-button: #70ade6;       /* Chàm / Ai botanical indigo silk tint */
    --color-bg-button-hover: #b6d5f2; /* Highlighted botanical indigo button hover */
    --color-bg-input: #1c1b19;        /* Input background */
    --color-bg-disabled: #22201e;     /* Disabled control surface */
    --color-bg-selection: #70ade6;    /* Selection highlight (botanical indigo silk) */

    /* Text & Typography */
    --color-text: #faf7f2;            /* Washi cream / raw silk (17.54:1) */
    --color-text-muted: #d6d3cd;      /* River stone pale washi (12.55:1) */
    --color-heading: #faf7f2;         /* Silk ivory headings */
    --color-link: #70ade6;            /* Chàm / Ai botanical indigo silk link */
    --color-link-visited: #ddb6fc;    /* Tử Quy / Murasaki wisteria violet */
    --color-link-hover: #fca89b;      /* Sơn son lacquer vermilion glow */
    --color-link-focus: #fca89b;      /* Link focus state */
    --color-button-text: #121211;     /* Sumi black on indigo silk button */
    --color-button-hover-text: #121211;/* Sumi black on button hover */
    --color-code-text: #faf7f2;       /* Monospace silk text */
    --color-quote-text: #faf7f2;      /* Quote text */
    --color-tag-text: #faf7f2;        /* Tag text */
    --color-input-text: #faf7f2;      /* Input field text */
    --color-text-disabled: #c4beba;   /* Disabled control text (8.83:1) */
    --color-text-placeholder: #bcb6af;/* Muted placeholder text (8.56:1 on input) */
    --color-text-selection: #121211;  /* Sumi ink selection text (7.86:1) */

    /* Borders & UI Indicators */
    --color-border: #a8a29e;          /* Light slate / nezumi border (7.43:1) */
    --color-border-card: #a8a29e;     /* Card border */
    --color-border-input: #a8a29e;    /* Input border */
    --color-border-quote: #fca89b;    /* Vermilion lacquer accent bar (9.45:1) */
    --color-border-tag: #a8a29e;      /* Tag border */
    --color-border-table: #a8a29e;    /* Table border */
    --color-border-disabled: #78716c; /* Disabled border (3.38:1) */
    --color-focus: #f5c968;           /* Vàng Hoàng Kim / Kintsugi warm gold focus ring */
    --color-focus-inner: #121211;     /* Sumi ink inner focus ring for buttons (7.86:1) */
  }
}

/* ==========================================================================
   CSS RESET & CORE RULES
   ========================================================================== */

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

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  padding-bottom: var(--cookie-banner-height, 0px); /* the end of the page is never left under the cookie notice */
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg-page);
  text-rendering: optimizeLegibility;
  max-width: 100%;
}

/* Text Selection */
::selection {
  background-color: var(--color-bg-selection);
  color: var(--color-text-selection);
}

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   ACCESSIBILITY & FOCUS
   ========================================================================== */

/* Visible Focus Indicator (WCAG 2.2 SC 2.4.13 & SC 2.4.11) */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* Skip link: hidden offscreen until focused */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 99999;
  padding: 0.75rem 1.25rem;
  background-color: var(--color-bg-button);
  color: var(--color-button-text);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* Visually Hidden Utility */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ==========================================================================
   LINKS & INTERACTIVE STATES
   ========================================================================== */

/* Body links: underlined so colour is never the only visual cue */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

/* Global link states use :where() so they never outrank a component's own colour: a visited
   .button or .pagination-link must keep its button text colour. */
a:where(:visited) {
  color: var(--color-link-visited);
}

a:where(:hover) {
  color: var(--color-link-hover);
  text-decoration-thickness: 2.5px;
}

a:where(:focus-visible) {
  color: var(--color-link-focus);
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* ==========================================================================
   BUTTONS & FORMS (Touch targets >= 44x44px)
   ========================================================================== */

button,
.button,
input[type="submit"] {
  min-height: 44px;
  min-width: 44px;
  padding: 0.625rem 1.25rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  background-color: var(--color-bg-button);
  color: var(--color-button-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition: background-color 0.15s ease, color 0.15s ease;
}

button:focus-visible,
.button:focus-visible,
input[type="submit"]:focus-visible,
.pagination-link:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--color-focus-inner);
}

button:hover,
.button:hover,
input[type="submit"]:hover {
  background-color: var(--color-bg-button-hover);
  color: var(--color-button-hover-text);
}

button:disabled,
.button:disabled,
input[type="submit"]:disabled {
  background-color: var(--color-bg-disabled);
  color: var(--color-text-disabled);
  border-color: var(--color-border-disabled);
  cursor: not-allowed;
  text-decoration: none;
}

::placeholder {
  color: var(--color-text-placeholder);
  opacity: 1;
}

input[type="text"],
input[type="search"] {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.875rem;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  background-color: var(--color-bg-input);
  color: var(--color-input-text);
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
  box-sizing: border-box;
}

input[type="text"]:disabled,
input[type="search"]:disabled {
  background-color: var(--color-bg-disabled);
  color: var(--color-text-disabled);
  border-color: var(--color-border-disabled);
  cursor: not-allowed;
}

/* Contact form (reuses the input, border and button tokens, so no new contrast pairs) */
.contact-form {
  max-width: 36rem;
  margin: 1.5rem 0 2.5rem;
}

.contact-form .form-row {
  margin-bottom: 1.25rem;
}

.contact-form label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 600;
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea,
.contact-form select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  background-color: var(--color-bg-input);
  color: var(--color-input-text);
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
  box-sizing: border-box;
}

.contact-form textarea {
  min-height: 10rem;
  resize: vertical;
}

.contact-form input:focus-visible,
.contact-form textarea:focus-visible,
.contact-form select:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.contact-form .form-help {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.contact-form .form-error,
.contact-form .form-error-summary {
  margin: 0 0 0.375rem;
  font-weight: 600;
}

.contact-form .form-error-summary {
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border-input);
  border-radius: 4px;
}

/* Honeypot: off-screen, not display:none, so simple bots still fill it */
.form-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ==========================================================================
   DECORATIVE MOTIFS (CSS-only, never behind text, solid text background)
   ========================================================================== */

.motif-rule {
  height: 6px;
  width: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--color-link-hover) 0 12px,
    var(--color-focus) 12px 24px,
    var(--color-link) 24px 36px,
    var(--color-border) 36px 48px
  );
  border: none;
  margin: 0;
  display: block;
}

/* ==========================================================================
   LAYOUT LANDMARKS: HEADER, MAIN, FOOTER
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--color-bg-header);
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 1.25rem;
  transition: transform 0.2s ease;
}

/* Smart sticky: config.js adds .is-hidden while scrolling down, removes it on scroll up.
   Focus inside the header always shows it (WCAG 2.4.12 focus not obscured). */
.site-header.is-hidden:not(:focus-within) {
  transform: translateY(-100%);
}

/* Anchors and focused elements must never land under the sticky header. */
html {
  scroll-padding-top: calc(var(--header-height, 4.5rem) + 1rem);
  scroll-padding-bottom: calc(var(--cookie-banner-height, 0px) + 1rem); /* the cookie notice, while it shows */
}

.site-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-branding {
  display: flex;
  flex-direction: column;
}

/* Notion-style header: a small logo in front of the site name, both in the one home link. */
.logo-image {
  display: block;
  border-radius: 50%;
}

/* When the links row wraps under the name (narrower than 76rem), line it up with the name, not the right edge. */
@media (max-width: 75.99rem) {
  .site-header .site-header-inner {
    justify-content: flex-start;
  }

  .site-header .site-header-actions {
    margin-left: 0;
  }
}

/* Phones: the top links stay on one row that scrolls sideways instead of wrapping onto extra lines. */
@media (max-width: 40rem) {
  .site-header .site-header-actions {
    min-width: 0;
    max-width: 100%;
  }

  .site-header .secondary-nav {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .site-header .secondary-nav-list {
    flex-wrap: nowrap;
  }

  .site-header .secondary-nav-link {
    white-space: nowrap;
  }
}

.site-title .logo-image {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
}

.site-title {
  gap: 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-heading);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-title:hover,
.site-title:focus-visible {
  color: var(--color-link-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.site-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.site-tagline {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.secondary-nav-list,
.primary-nav-list,
.subnav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.secondary-nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.secondary-nav-link,
.primary-nav-link,
.subnav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
}

.secondary-nav-link {
  font-weight: 400;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.secondary-nav-link:hover,
.primary-nav-link:hover,
.subnav-link:hover {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.secondary-nav-link[aria-current="page"],
.primary-nav-link[aria-current="page"],
.subnav-link[aria-current="page"] {
  color: var(--color-heading);
  text-decoration: underline;
  text-underline-offset: 0.3em;
  text-decoration-thickness: 2px;
}

/* Primary navigation with dropdowns (hover, focus within, or the toggle button) */
.nav-details {
  max-width: 72rem;
  margin: 0.25rem auto 0;
  border-top: 1px solid var(--color-border);
}

.nav-toggle {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.primary-nav-list {
  display: flex;
  flex-direction: column;
  padding-bottom: 0.5rem;
}

.primary-nav-item {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.subnav-toggle {
  min-width: 44px; /* WCAG 2.5.5 */
  min-height: 44px;
  padding: 0;
  background: transparent;
  color: var(--color-text-muted);
  border: 0;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

/* Keep the dropdown chevron close to its category link */
.has-sub > .primary-nav-link {
  padding-right: 0.125rem;
}


.subnav-toggle:hover {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.subnav-toggle .chevron {
  display: block;
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease;
}

.subnav-toggle[aria-expanded="true"] .chevron {
  transform: translateY(2px) rotate(225deg);
}

.subnav-list {
  display: none;
  flex-basis: 100%;
  padding: 0 0 0.25rem 1rem;
}

.has-sub.is-open > .subnav-list {
  display: block;
}

.subnav-link {
  font-weight: 400;
}

@media (min-width: 64rem) {
  .nav-toggle {
    display: none;
  }

  .primary-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0 0.125rem;
    padding-bottom: 0;
  }

  .subnav-list {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 30;
    min-width: 15rem;
    padding: 0.25rem;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
  }

  /* Without JavaScript, hover and focus open the menu. With it, config.js owns .is-open so the
     toggle button always matches what is showing, and Escape dismisses it (WCAG 1.4.13). */
  html:not(.js) .has-sub:hover > .subnav-list,
  html:not(.js) .has-sub:focus-within > .subnav-list {
    display: block;
  }

  .subnav-link {
    display: flex;
    width: 100%;
  }
}

.search-toggle,
.search-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  color: var(--color-text);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}

.search-toggle:hover,
.search-close:hover {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.search-toggle[aria-expanded="true"] {
  background-color: var(--color-bg-tag);
}

.search-panel {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 0 1rem;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-search input[type="search"] {
  flex: 1;
  min-width: 0;
  font-size: 1.125rem;
  border-radius: 999px;
  padding-left: 1.25rem;
}

.site-shell {
  max-width: 80rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.site-main {
  min-width: 0;
  container-type: inline-size;
  padding: 2rem 1.25rem 6rem;
  min-height: 60vh;
}

/* Left sidebar (Notion-style): sticky and independently scrollable on wide screens,
   a collapsed "Browse" disclosure above the content on narrow ones. */
.sidebar {
  padding: 0 1.25rem;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-heading);
}

.sidebar-heading {
  margin: 1.5rem 0 0.25rem;
  padding: 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--color-text-muted);
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: 8px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
}

.sidebar-link:hover {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.sidebar-link[aria-current="page"] {
  background-color: var(--color-bg-tag);
  font-weight: 600;
  color: var(--color-heading);
}

.sidebar-section + .sidebar-section {
  margin-top: 0.5rem;
}

.archive-year {
  margin: 0;
}

.archive-year-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  color: var(--color-heading);
  cursor: pointer;
}

.archive-year-summary:hover {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.archive-year .sidebar-list {
  padding-left: 0.75rem;
}

.sidebar-post-link {
  display: block;
  min-height: 44px; /* WCAG 2.5.5 */
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sidebar-count {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 64rem) {
  .site-shell {
    grid-template-columns: 17rem minmax(0, 1fr);
  }

  /* Breathing room between the sidebar rule and the content. */
  .site-main {
    padding-left: 3.5rem;
    padding-right: 2rem;
  }

  .sidebar {
    position: sticky;
    top: var(--sidebar-top, var(--header-height, 4.5rem));
    max-height: calc(100vh - var(--sidebar-top, var(--header-height, 4.5rem)) - var(--cookie-banner-height, 0px));
    overflow-y: auto;
    padding: 2rem 1.5rem 5rem 1.25rem;
    border-right: 1px solid var(--color-border);
    transition: top 0.2s ease, max-height 0.2s ease;
  }

  .sidebar-toggle {
    display: none;
  }
}

.site-footer {
  background-color: var(--color-bg-footer);
  border-top: 1px solid var(--color-border);
  padding: 3rem 1.25rem;
  margin-top: 2rem;
}

.site-footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.footer-brand-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.footer-brand {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--color-heading);
  text-decoration: none;
}

.footer-tagline {
  margin: 0.25rem 0 0;
}

/* Link columns, in the style of the Notion blog footer: a heading and a short list under it. */
.footer-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 2rem 1.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.footer-heading {
  margin: 0 0 0.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
}

.footer-heading-link {
  color: inherit;
  text-decoration: none;
}

.footer-heading-link:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

.footer-links,
.footer-legal-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links {
  display: flex;
  flex-direction: column;
}

.footer-links li,
.footer-legal-links li {
  margin: 0;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px; /* WCAG 2.5.5: short words such as Tags */
  padding: 0 0.5rem 0 0;
  color: var(--color-text);
  border-radius: 8px;
}

.footer-link:hover {
  color: var(--color-link-hover);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
}

.footer-copy {
  margin: 0;
}

/* Links inside the copyright sentence: no trailing padding, so punctuation sits against the word. */
.footer-copy .footer-link {
  padding: 0;
}

.footer-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.footer-legal-links .footer-link {
  padding-right: 0;
}

/* ==========================================================================
   TYPOGRAPHY & HEADINGS
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  color: var(--color-heading);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.5;
  margin: 2rem 0 1rem;
  overflow-wrap: break-word;
}

h1 {
  font-size: 2.5rem;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-top: 0;
}

h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.1875rem; }
h5, h6 { font-size: 1.0625rem; }

p {
  margin: 0 0 1.5rem;
}

/* ==========================================================================
   POSTS, CARDS & ARCHIVES
   ========================================================================== */

.home-header,
.archive-header {
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 3rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem 2rem;
}

@container (min-width: 40rem) {
  .post-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container (min-width: 62rem) {
  .post-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.post-card-thumb {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 12px;
  background-color: var(--color-bg-tag);
  margin-bottom: 1rem;
}

/* {% picture %} wraps the image: the wrapper must fill the thumbnail so the image's 100% height still works. */
.post-card-thumb picture {
  display: block;
  width: 100%;
  height: 100%;
}

.post-card-image {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  display: block;
}

.post-card-placeholder {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0.75rem;
}

.illustration {
  display: block;
  width: 100%;
  max-width: 28rem;
  aspect-ratio: 3 / 2;
  margin: 0 auto 1.5rem;
}

.empty-topic {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1rem 0 2rem;
}

.empty-topic-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-heading);
}

.empty-topic-text {
  margin: 0;
  color: var(--color-text-muted);
}

.post-card-category {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.post-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.375rem;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

/* The card title is the whole link; WCAG 2.5.5 wants a 44 x 44 px box even for a one-line title. */
.post-card-title a {
  display: block;
  min-height: 44px;
  color: var(--color-heading);
  text-decoration: none;
}

.post-card-title a:hover,
.post-card-title a:focus-visible {
  color: var(--color-link-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.post-card-meta,
.meta {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin: 0.75rem 0 0;
}

.post-card-excerpt {
  color: var(--color-text);
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

.post-card-excerpt p {
  margin: 0;
}

.empty-notice {
  padding: 1.5rem;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-card);
  border-radius: 4px;
  color: var(--color-text-muted);
}

/* ==========================================================================
   ARTICLE / POST DETAIL
   ========================================================================== */

.post {
  max-width: 100%;
  padding-bottom: 3rem;
}

.post-header {
  max-width: 46rem;
  margin: 0 auto 2.5rem;
}

.post-category {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.post-category-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  color: var(--color-text-muted);
}

.post-title {
  font-size: 2.75rem;
  letter-spacing: -0.025em;
  text-wrap: pretty;
  margin: 0 0 1rem;
}

@media (max-width: 40rem) {
  .post-title { font-size: 2rem; }
}

/* Article column: text stays narrow and centred; figures and video go wider. */
.post .body > *,
.post-footer {
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
}

.post .body > figure,
.post .body div:has(> iframe),
.post .body div:has(> .embed-gate),
.post .body div:has(> embed) {
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
}

.terms {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.terms-label {
  font-weight: 600;
  margin-right: 0.25rem;
}

.tag-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.25rem 0.875rem;
  background-color: var(--color-bg-tag);
  color: var(--color-tag-text);
  border: 1px solid var(--color-border-tag);
  border-radius: 9999px;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  font-size: 0.9375rem;
}

.tag-link:hover {
  color: var(--color-link-hover);
}

/* ==========================================================================
   PAGINATION (Touch targets >= 44x44px)
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.pagination-link {
  min-height: 44px;
  min-width: 44px;
  padding: 0.625rem 1.25rem;
  background-color: var(--color-bg-button);
  color: var(--color-button-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.pagination-link:hover {
  background-color: var(--color-bg-button-hover);
  color: var(--color-button-hover-text);
}

.pagination-current {
  color: var(--color-text-muted);
  font-size: 1rem;
}

.pagination-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.pagination-number,
.pagination-gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.5rem;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.pagination-number {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

a.pagination-number:hover {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.pagination-number-current {
  background-color: var(--color-bg-button);
  color: var(--color-button-text);
}

.pagination-gap {
  color: var(--color-text-muted);
}

/* ==========================================================================
   SEARCH RESULTS PAGE
   ========================================================================== */

.search-page-form {
  margin: 1.5rem 0 2.5rem;
}

.search-input-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-input-group input[type="text"] {
  flex: 1;
  min-width: 16rem;
}

@media (max-width: 480px) {
  .search-input-group input[type="text"] {
    min-width: 100%;
  }
  .search-input-group input[type="submit"] {
    width: 100%;
  }
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.search-result-card {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-card);
  border-left: 4px solid var(--color-link);
  border-radius: 4px;
  padding: 1.25rem;
}

.search-result-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.search-result-title a {
  display: block;
  min-height: 44px;
}

.search-result-desc {
  margin: 0;
  color: var(--color-text);
  font-size: 1rem;
}

.search-empty-notice {
  padding: 1.5rem;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-card);
  border-radius: 4px;
  color: var(--color-text-muted);
}

/* ==========================================================================
   RICH TEXT CONTENT (Importer Content Elements)
   ========================================================================== */

.richtext-body,
.body {
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: transparent;
}

/* WCAG 1.4.8: paragraph spacing at least 1.5 times the line spacing (1.6 x 1.5 = 2.4em), and a measure of at most 80
   characters (`ch` is the width of a zero; in Lexend that is 13.1 px against about 8.3 px for the average letter, so 48ch gives about 76 characters per line). */
.richtext-body p,
.body p {
  margin: 0 0 2.4em;
}

.richtext-body :is(p, li, blockquote, figcaption, h2, h3, h4, h5, h6),
.body :is(p, li, blockquote, figcaption, h2, h3, h4, h5, h6),
.post .body > :is(p, ul, ol, blockquote, h2, h3, h4, h5, h6) { /* the last selector outranks `.post .body > *` below */
  max-width: 48ch;
}

/* Images from the editor's image button (<picture>) take the paragraph width, so image and text share one column. */
.post .body > picture,
.richtext-body > picture {
  display: block;
  max-width: 48ch;
  margin: 0 auto 2.4em;
}

.post .body > picture img,
.richtext-body > picture img {
  display: block;
  width: 100%;
}

/* Blockquote */
blockquote {
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background-color: var(--color-bg-quote);
  color: var(--color-quote-text);
  border-left: 5px solid var(--color-border-quote);
  border-radius: 0 4px 4px 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Lists */
ul, ol {
  margin: 1rem 0 1.75rem 1.75rem;
  padding: 0;
}

li {
  margin-bottom: 0.5rem;
}

/* Code & Preformatted Text */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background-color: var(--color-bg-code);
  color: var(--color-code-text);
  border: 1px solid var(--color-border);
  border-radius: 3px;
}

pre {
  margin: 1.75rem 0;
  padding: 1.25rem;
  background-color: var(--color-bg-code);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow-x: auto;
  max-width: 100%;
}

pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  font-size: 0.95em;
  line-height: 1.5;
}

/* Tables */
table {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 1.75rem 0;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-table);
  font-size: 1rem;
}

table:focus-within {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

th, td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border-table);
  text-align: left;
}

th {
  background-color: var(--color-bg-footer);
  color: var(--color-heading);
  font-weight: 700;
}

td {
  color: var(--color-text);
}

/* Figures, Images & Captions */
figure {
  margin: 2rem 0;
  padding: 0;
  text-align: center;
}

figure img,
img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  display: inline-block;
}

figcaption {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Embeds & Iframes */
embed,
iframe {
  max-width: 100%;
  display: block;
  margin: 1.75rem auto;
  border: 0;
  border-radius: 12px;
}

/* Wagtail's oEmbed markup hard-codes width="200" height="113" (the thumbnail size).
   Override both so video fills its column at 16:9. */
iframe[src*="youtube.com"],
iframe[src*="youtube-nocookie.com"],
iframe[src*="player.vimeo.com"] {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* Error Pages */
.error-page {
  padding: 2rem 0;
  text-align: center;
}

.error-lead {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

/* ==========================================================================
   THEME SWITCH COMPONENT (Header Progressive Enhancement)
   ========================================================================== */

/* Hidden when JavaScript is disabled (HTML hidden attribute), revealed by config.js */
.theme-switch[hidden] {
  display: none !important;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 2px;
  background-color: var(--color-bg-card);
  margin: 0;
  gap: 2px;
}

.theme-switch-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-text-muted);
  user-select: none;
  transition: none;
}

.theme-switch-label:hover {
  color: var(--color-link-hover);
}

.theme-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.theme-switch-input:focus-visible + .theme-switch-text {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.theme-switch-input:checked + .theme-switch-text {
  background-color: var(--color-bg-button);
  color: var(--color-button-text);
  border-radius: 4px;
}

/* Icon-only options: the visible glyph is an SVG, the word is visually hidden. */
.theme-switch-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
}

/* Reduced motion guarantee */
@media (prefers-reduced-motion: reduce) {
  .site-header,
  .sidebar,
  .theme-switch,
  .theme-switch * {
    transition: none !important;
    animation: none !important;
  }
}

/* ==========================================================================
   HIGH CONTRAST & FORCED COLORS (WCAG 2.2 AAA Robustness)
   ========================================================================== */

/* Reflow (WCAG 1.4.10): a long unbroken string (URL, hash) wraps instead of forcing sideways scroll. */
.richtext-body p,
.richtext-body li,
.richtext-body figcaption,
.richtext-body blockquote,
.body p,
.body li,
.error-page,
.search-result-desc,
.post-card-excerpt p {
  overflow-wrap: anywhere;
}

@media (forced-colors: active) {
  :focus-visible,
  a:focus-visible,
  button:focus-visible,
  .button:focus-visible,
  input:focus-visible,
  .theme-switch-input:focus-visible + .theme-switch-text {
    outline: 3px solid Highlight !important;
    outline-offset: 3px !important;
    box-shadow: none !important;
  }

  a {
    text-decoration: underline !important;
  }

  button,
  .button,
  input,
  table,
  th,
  td,
  pre,
  code,
  blockquote,
  .post-card,
  .tag-link,
  .theme-switch {
    border: 1px solid ButtonText !important;
  }

  .skip-link {
    background-color: Canvas !important;
    color: LinkText !important;
    border: 2px solid ButtonText !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --color-border: var(--color-text-muted);
    --color-border-card: var(--color-text-muted);
    --color-border-input: var(--color-text-muted);
    --color-border-tag: var(--color-text-muted);
    --color-border-table: var(--color-text-muted);
  }

  :root[data-theme="dark"] {
    --color-border: var(--color-text);
    --color-border-card: var(--color-text);
    --color-border-input: var(--color-text);
    --color-border-tag: var(--color-text);
    --color-border-table: var(--color-text);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
      --color-border: var(--color-text);
      --color-border-card: var(--color-text);
      --color-border-input: var(--color-text);
      --color-border-tag: var(--color-text);
      --color-border-table: var(--color-text);
    }
  }

  a {
    text-decoration-thickness: 2px;
  }

  :focus-visible {
    outline-width: 4px;
  }
}


/* ==========================================================================
   ARCHIVES: year and month boxes
   ========================================================================== */

.archive-lead {
  margin: 0;
  color: var(--color-text-muted);
}

.breadcrumb {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.year-grid {
  list-style: none;
  margin: 2rem 0 3rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem;
}

.year-box-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  height: 100%;
  padding: 1.25rem;
  background-color: var(--color-bg-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-decoration: none;
}

.year-box-link:hover,
.year-box-link:focus-visible {
  background-color: var(--color-bg-tag);
  color: var(--color-link-hover);
}

.year-box-year {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-heading);
}

.year-box-count,
.year-box-months {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.year-box-link:hover .year-box-year,
.year-box-link:hover .year-box-count,
.year-box-link:hover .year-box-months {
  color: var(--color-link-hover);
}

.archive-lead {
  margin: 0.5rem 0 0;
  color: var(--color-text-muted);
}

.tag-card .post-card-meta a {
  color: inherit;
}

.sidebar-logo {
  display: none;
}

@media (min-width: 64rem) {
  .sidebar-logo {
    display: block;
    width: 9rem;
    margin: 0 auto 1.5rem; /* centred in the sidebar */
  }

  .sidebar-logo .logo-image {
    width: 100%;
    height: auto;
  }
}

.sidebar-more {
  margin: 0.5rem 0 0;
}


/* ==========================================================================
   COOKIE BANNER AND VIDEO CONSENT GATE
   ========================================================================== */

.cookie-banner:not([hidden]) {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background-color: var(--color-bg-card);
  border-top: 2px solid var(--color-border);
  padding: 1rem 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}

.cookie-banner-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 2rem;
}

.cookie-banner-title {
  flex-basis: 100%;
  margin: 0;
  font-size: 1.125rem;
}

.cookie-banner-text {
  flex: 1 1 28rem;
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.cookie-banner-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.a11y-note {
  max-width: 46rem;
  margin: 2rem auto 0;
  text-align: center;
  padding: 1rem 1.25rem;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-size: 0.9375rem;
}

.a11y-note-heading {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
}

.a11y-note p {
  max-width: 48ch; /* WCAG 1.4.8 measure */
  margin: 0 auto 2.4em; /* paragraph spacing 1.5 x the 1.6 line height */
}

.a11y-note p:last-child {
  margin-bottom: 0;
}

.embed-unavailable {
  max-width: 46rem;
  margin: 1.5rem auto;
  padding: 1rem 1.25rem;
  background-color: var(--color-bg-card);
  border: 1px dashed var(--color-border);
  border-radius: 12px;
  text-align: center;
}

.embed-unavailable a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.embed-unavailable p {
  margin: 0 0 0.5rem;
}

.embed-unavailable p:last-child {
  margin-bottom: 0;
}

.embed-unavailable-title {
  font-weight: 600;
  color: var(--color-heading);
}

.embed-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1.75rem auto;
  padding: 1rem;
  background-color: var(--color-bg-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-align: center;
}

.embed-gate-box {
  max-width: 34rem;
}

.embed-gate-title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.embed-gate-text {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.5;
}

.embed-gate-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.embed-gate-actions {
  margin: 0;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.cookie-settings {
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* It is a <button> that looks like a footer link. The generic button hover paints a dark fill and `.footer-link:hover` sets a
   dark link colour: together they gave dark red text on a dark red fill. Keep it a link on hover too. */
.cookie-settings:hover {
  background: none;
  color: var(--color-link-hover);
  text-decoration-thickness: 2px;
}


/* Sitemap page: one link per line, each a 44 px target (WCAG 2.5.5). */
.sitemap-list {
  list-style: none;
  margin: 0 0 1.75rem;
  padding: 0;
}

.sitemap-list li {
  margin: 0;
}

.sitemap-list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.sitemap-count {
  color: var(--color-text-muted);
}
