/* =========================================================
   Hutgrabber — Custom theme layer over Risotto
   Nord palette · Jersey 25 (display) · Literata (body)

   Surface model (IMPORTANT):
   Risotto paints .page__body with --off-bg (base01). Any
   "raised" element (code, fields, buttons, cards) must use
   --inner-bg (base02) so it always contrasts the body in
   BOTH light and dark mode. Never use raw base01 for surfaces.
   ========================================================= */

/* ---------------------------------------------------------
   1. DESIGN TOKENS
   --------------------------------------------------------- */
:root {
  /* Type families */
  --font-body: "Literata", Georgia, "Times New Roman", serif;
  --font-heading: "Jersey 25", "Courier New", monospace;
  --font-mono: "Fira Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;

  /* Fluid type scale (mobile → desktop) */
  --text-xs:  0.8rem;
  --text-sm:  0.9rem;
  --text-base: 1.0625rem;            /* 17px body */
  --text-lg:  1.2rem;
  --text-h6:  clamp(1.0rem, 0.95rem + 0.3vw, 1.15rem);
  --text-h5:  clamp(1.1rem, 1.0rem  + 0.5vw, 1.3rem);
  --text-h4:  clamp(1.3rem, 1.1rem  + 0.9vw, 1.55rem);
  --text-h3:  clamp(1.55rem, 1.25rem + 1.4vw, 2.0rem);
  --text-h2:  clamp(1.9rem, 1.4rem  + 2.2vw, 2.5rem);
  --text-h1:  clamp(2.3rem, 1.7rem  + 2.8vw, 3.2rem);

  /* Spacing scale (4 / 8pt rhythm) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  /* Shape */
  --radius: 4px;

  /* Semantic surfaces — derived from Risotto's semantic tokens
     so they flip correctly between light and dark mode. */
  --surface-raised: var(--inner-bg);   /* base02 — code, fields, cards */
  --border-subtle:  var(--muted);      /* base03 */

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur:  180ms;
}

/* ---------------------------------------------------------
   2. BASE TYPOGRAPHY
   --------------------------------------------------------- */
body {
  font-family: var(--font-body);
  font-optical-sizing: auto;
  font-size: var(--text-base);
  line-height: 1.75;
}

p { margin: 0 0 var(--space-6) 0; }

/* Headings — Jersey 25 display face, Aurora/Frost accents.
   Keep Risotto's "# " prefix (it inherits --muted + this font). */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.15;
  margin: 1.6em 0 0.5em;
}
h1:first-child { margin-top: 0; }

h1 { font-size: var(--text-h1); color: var(--base08); } /* aurora red    */
h2 { font-size: var(--text-h2); color: var(--base09); } /* aurora orange */
h3 { font-size: var(--text-h3); color: var(--base0A); } /* aurora yellow */
h4 { font-size: var(--text-h4); color: var(--base0B); } /* aurora green  */
h5 { font-size: var(--text-h5); color: var(--base0C); } /* frost teal    */
h6 { font-size: var(--text-h6); color: var(--base0D); } /* frost blue    */

/* Emphasis */
strong, b { color: var(--base0E); font-weight: 700; }
em, i     { color: var(--base0C); font-style: italic; }
u         { text-decoration-color: var(--base0D); text-underline-offset: 0.15em; }
mark      { background: var(--base0A); color: var(--base00); padding: 0 0.2em; }

/* ---------------------------------------------------------
   3. LINKS  (underline affordance, accessible focus)
   --------------------------------------------------------- */
a:link, a:visited { color: var(--base0D); }
a:hover, a:active { color: var(--base0C); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--base0D);
  outline-offset: 2px;
  border-radius: 1px;
}

/* ---------------------------------------------------------
   4. CODE  (raised surface = --inner-bg, not body bg)
   --------------------------------------------------------- */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background-color: var(--surface-raised) !important;
  color: var(--base0D);
  padding: 0.12em 0.4em;
  border-radius: var(--radius);
}

pre {
  background-color: var(--surface-raised) !important;
  border-left: 3px solid var(--base0D);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-6) 0;
  overflow-x: auto;
}
pre code {
  background: none !important;
  color: var(--off-fg);
  padding: 0;
  font-size: 0.9rem;
  border-radius: 0;
}
/* keep highlighted (Chroma) blocks scrollable, not clipped */
.highlight, .highlight pre { margin: 0 0 var(--space-6) 0; }
.highlight div { overflow-x: auto; }

/* ---------------------------------------------------------
   5. BLOCKQUOTE / HR
   --------------------------------------------------------- */
blockquote {
  margin: 0 0 var(--space-6) 0;
  padding: var(--space-1) 0 var(--space-1) var(--space-5);
  border-left: 3px solid var(--base0E);
  color: var(--base0E);
  font-style: italic;
}
blockquote::before { content: none; }        /* drop theme's ">" glyph */
blockquote p:last-child { margin-bottom: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-8) 0;
}
/* Risotto uses single-colon hr:after — must neutralise both forms */
hr:after,
hr::after {
  content: '' !important;
  display: none !important;
}

/* ---------------------------------------------------------
   6. MEDIA  (responsive images, captions, embeds)
   --------------------------------------------------------- */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--space-6) auto;
  border-radius: var(--radius);
}

figure { margin: var(--space-6) 0; }
figure img { margin: 0 auto; }

figcaption {
  margin-top: var(--space-2);
  text-align: center;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--off-fg);
}

/* Embeds (YouTube / Twitter) — never overflow on mobile */
iframe {
  max-width: 100%;
  border: 0;
}
figure > iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: var(--radius);
}

/* ---------------------------------------------------------
   7. TABLES  (scroll on mobile, no page overflow)
   --------------------------------------------------------- */
.content__body table,
.post__summary table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 var(--space-6) 0;
  font-size: var(--text-sm);
}
thead { border-bottom: 2px solid var(--base0D); }
th {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--base0D);
  text-align: left;
  padding: var(--space-2) var(--space-4);
}
td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg);
  vertical-align: top;
}
tbody tr:hover td { background-color: var(--surface-raised); }

/* ---------------------------------------------------------
   8. HEADER / NAV / BRAND
   --------------------------------------------------------- */
.page__logo-inner {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  letter-spacing: 0.04em;
}

.main-nav a {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  /* comfortable tap target on touch devices */
  display: inline-block;
  padding: var(--space-1) 0;
}
.main-nav a.active { color: var(--base0B); }

/* ---------------------------------------------------------
   9. SIDEBAR / ABOUT
   --------------------------------------------------------- */
.about__title {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  color: var(--logo);
}
.about__description { color: var(--off-fg); }

.aside__social-links a {
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
}

/* ---------------------------------------------------------
   10. POST INDEX  (home + /posts/)
   --------------------------------------------------------- */
.post-list { list-style: none; margin: 0; padding: 0; }

.post-summary {
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.post-summary:last-child { border-bottom: 0; }

.post-summary__title {
  font-size: var(--text-h3);
  color: var(--base0D);
  margin: 0 0 var(--space-2);
}
.post-summary__title::before { content: none; }       /* no "## " prefix in lists */
.post-summary__title a { color: inherit; text-decoration: none; }
.post-summary__title a:hover { color: var(--base0C); }

.post-summary__meta {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}
.post-summary__meta .tag {
  color: var(--base0B);
  background: var(--surface-raised);
  padding: 0.05em 0.5em;
  border-radius: var(--radius);
}
.post-summary__desc { margin: 0; color: var(--fg); }

/* ---------------------------------------------------------
   11. SINGLE POST  (feature image + meta)
   --------------------------------------------------------- */
.post__feature-image {
  width: 100%;
  max-height: 22rem;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 0 var(--space-6);
}
.post__meta {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--muted);
  margin: var(--space-2) 0 var(--space-8);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}
.post__meta .tag {
  color: var(--base0B);
  background: var(--surface-raised);
  padding: 0.05em 0.5em;
  border-radius: var(--radius);
}

/* ---------------------------------------------------------
   12. SOCIAL BUTTONS  (About page) — raised pill buttons
   --------------------------------------------------------- */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-6) 0;
}
.social-links a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  background-color: var(--surface-raised);
  color: var(--base0D);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 1.05rem;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.social-links a:hover {
  background-color: var(--base0D);
  color: var(--bg);
  border-color: var(--base0D);
}

/* ---------------------------------------------------------
   13. SEARCH (Pagefind) — variables MUST be scoped to
   .pagefind-ui to beat Pagefind's own .pagefind-ui defaults.
   --------------------------------------------------------- */
.pagefind-ui {
  --pagefind-ui-scale: 1;
  --pagefind-ui-primary: var(--base0D);
  --pagefind-ui-text: var(--fg);
  --pagefind-ui-background: var(--surface-raised);
  --pagefind-ui-border: var(--border-subtle);
  --pagefind-ui-tag: var(--surface-raised);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: var(--radius);
  --pagefind-ui-image-border-radius: var(--radius);
  --pagefind-ui-image-box-shadow: none;
  --pagefind-ui-font: var(--font-body);
}

.pagefind-ui__search-input {
  background-color: var(--surface-raised);
  color: var(--fg);
  font-family: var(--font-body);
}
.pagefind-ui__search-input::placeholder { color: var(--muted); }

.pagefind-ui__search-clear { color: var(--base0D); }
.pagefind-ui__search-clear:hover { color: var(--base0C); }

.pagefind-ui__message {
  color: var(--off-fg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.pagefind-ui__result { border-color: var(--border-subtle); }
.pagefind-ui__result-title { font-family: var(--font-heading); }
.pagefind-ui__result-link { color: var(--base0D); text-decoration: none; }
.pagefind-ui__result-link:hover { color: var(--base0C); }
.pagefind-ui__result-excerpt {
  color: var(--fg) !important;
  font-family: var(--font-body);
  line-height: 1.6;
}
.pagefind-ui__result-excerpt mark {
  background: var(--base0A);
  color: var(--base00);
  font-style: normal;
}

/* ---------------------------------------------------------
   14. SIDEBAR REMOVAL
   --------------------------------------------------------- */
/* The about.html partial is empty, so the aside is empty.
   Hide it entirely and let the body fill the full grid width. */
.page__aside { display: none !important; }

/* Override Risotto's two-column grid to single column */
.page__main {
  grid-template-columns: 1fr !important;
  grid-template-areas:
    "header"
    "body"
    "footer" !important;
}

/* ---------------------------------------------------------
   15. RESPONSIVE  (mobile-first refinements)
   --------------------------------------------------------- */
@media (max-width: 45rem) {
  body { font-size: 1rem; line-height: 1.7; }

  /* roomier tap targets in the wrapped nav */
  .main-nav ul { gap: var(--space-3) var(--space-5); }
  .main-nav a { padding: var(--space-2) 0; }

  pre { padding: var(--space-3) var(--space-4); }
}

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

/* ---------------------------------------------------------
   17. LIGHT MODE  (accent remaps for contrast)
   --------------------------------------------------------- */
@media (prefers-color-scheme: light) {
  .page__logo-inner { color: inherit; }

  strong, b { color: var(--base08); }

  blockquote { border-left-color: var(--base0F); color: var(--base0F); }

  code, kbd, samp { color: var(--base0F); }
  pre { border-left-color: var(--base0F); }
  pre code { color: var(--fg); }

  .about__title { color: var(--logo); }

  .post-summary__title,
  .pagefind-ui__result-link { color: var(--base0F); }

  th, thead { color: var(--base0F); border-color: var(--base0F); }

  .social-links a { color: var(--base0F); }
  .social-links a:hover { background-color: var(--base0F); color: var(--bg); border-color: var(--base0F); }
}
