/* =========================================
   CSS Entrypoint

   Files are concatenated in include order. Cascade order is governed by
   @layer (declared in foundation/layers.css), so include order here is
   only relevant for @import statements at the top of layers.css.
   ========================================= */

/* Layer order + font @imports (must come first) */
/* =========================================
   Cascade layer order

   Declared once, in priority order (last layer wins). Files that follow
   wrap their contents in @layer <name> { ... } so cascade order is
   independent of include order in src/css/index.css.

   reset       -> normalize / box-sizing / body baseline
   foundation  -> design tokens, base typography
   layouts     -> page chrome (header/main/footer rhythm, container)
   components  -> reusable UI patterns
   utilities   -> small helper classes
   pages       -> page-specific tweaks
   overrides   -> escape hatch (avoid)
   ========================================= */
@import "@fontsource-variable/inter";
@import "@fontsource-variable/jetbrains-mono";

@layer reset, foundation, layouts, components, utilities, pages, overrides;


/* Foundation */
/* =========================================
   1. Design Tokens & Theme Variables

   Structure: raw palette -> semantic vars (light) -> dark overrides.
   Dark mode only redeclares the semantic vars whose values change;
   anything still pointing at a var() is inherited unchanged.

   Breakpoint scale (used as @media literals; document with the bp name
   in a comment when adding new media queries):
     bp-sm  36em   small handheld
     bp-md  48em   tablet (current default toggle, --spacing scales here)
     bp-lg  64em   desktop / max-width container
     bp-xl  80em   wide
     bp-xxl 96em   extra wide
   ========================================= */
@layer foundation {
:root {
  /* Brand (theme-invariant) */
  --brand-green: #00BB68;
  --brand-green-dim: #00a35a;
  --brand-green-bright: #00DF81;

  /* Light palette (raw) */
  --color-white: #fff;
  --color-ink-900: #01112D;
  --color-ink-700: #1F2021;
  --color-ink-500: #646b79;
  --color-ink-200: #e7eaef;
  --color-ink-50:  #f7f9fc;
  --color-light-backdrop: rgba(180, 186, 196, 0.75);
  --color-light-underline: rgba(31, 32, 33, 0.3);

  /* Dark palette (raw) */
  --color-dark-bg: #11191f;
  --color-dark-text: #c2c7d0;
  --color-dark-heading: #f0f1f3;
  --color-dark-muted: #838994;
  --color-dark-border: #2d3748;
  --color-dark-card: #1a2329;
  --color-dark-backdrop: rgba(8, 12, 16, 0.85);
  --color-dark-underline: rgba(194, 199, 208, 0.3);

  /* Typography */
  --font-family: 'Inter Variable', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono Variable', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-size-base: 17px;
  --line-height: 1.6;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Radius scale */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-pill: 999px;
  --radius-circle: 50%;

  /* Default rhythm aliases (tighter on mobile; --spacing scales at bp-md).
     Components should reference the named scale directly when adding new
     values; these aliases are kept for back-compat during migration. */
  --spacing: var(--space-4);
  --border-radius: var(--radius-md);

  /* Focus ring (theme-invariant) */
  --primary-focus: rgba(0, 187, 104, 0.5);
}

:root,
[data-theme="light"] {
  color-scheme: light;

  /* Surfaces & text */
  --bg-color: var(--color-white);
  --text-color: var(--color-ink-700);
  --h1-color: var(--color-ink-900);
  --muted-color: var(--color-ink-500);
  --muted-border-color: var(--color-ink-200);
  --card-bg-color: var(--color-ink-50);
  --lightbox-backdrop: var(--color-light-backdrop);

  /* Primary (links / default buttons) */
  --primary-color: var(--text-color);
  --primary-bg: var(--text-color);
  --primary-border: var(--text-color);
  --primary-underline: var(--color-light-underline);
  --primary-hover: var(--brand-green);
  --primary-hover-bg: var(--brand-green);
  --primary-hover-border: var(--brand-green);
  --primary-hover-underline: var(--brand-green);
  --primary-inverse: var(--bg-color);

  /* Contrast (accent / call-to-action) */
  --contrast-color: var(--brand-green);
  --contrast-bg: var(--brand-green);
  --contrast-border: var(--brand-green);
  --contrast-inverse: var(--bg-color);
  --contrast-hover-bg: var(--brand-green-dim);
  --contrast-hover-border: var(--brand-green-dim);

  /* Secondary (muted buttons) */
  --secondary-bg: var(--muted-border-color);
  --secondary-border: var(--muted-border-color);
  --secondary-inverse: var(--text-color);
  --secondary-hover-bg: var(--muted-color);
  --secondary-hover-border: var(--muted-color);
  --secondary-hover-inverse: var(--color-white);

  /* Syntax highlighting */
  --syntax-bg: #f6f8fa;
  --syntax-text: #24292f;
  --syntax-comment: #6e7781;
  --syntax-keyword: #cf222e;
  --syntax-function: #8250df;
  --syntax-string: #0a3069;
  --syntax-number: #0550ae;
  --syntax-class: #116329;
  --syntax-operator: #24292f;
  --syntax-punctuation: #24292f;
  --syntax-property: #0550ae;
}

[data-theme="dark"] {
  color-scheme: dark;

  /* Only the semantic vars whose values actually change in dark.
     Everything else (primary-*, contrast-color/bg/border, secondary-*) is
     defined via var() above and inherits without redeclaration. */
  --bg-color: var(--color-dark-bg);
  --text-color: var(--color-dark-text);
  --h1-color: var(--color-dark-heading);
  --muted-color: var(--color-dark-muted);
  --muted-border-color: var(--color-dark-border);
  --card-bg-color: var(--color-dark-card);
  --lightbox-backdrop: var(--color-dark-backdrop);

  --primary-underline: var(--color-dark-underline);
  --contrast-hover-bg: var(--brand-green-bright);
  --contrast-hover-border: var(--brand-green-bright);

  /* Dark syntax theme */
  --syntax-bg: #0d1117;
  --syntax-text: #c9d1d9;
  --syntax-comment: #8b949e;
  --syntax-keyword: #ff7b72;
  --syntax-function: #d2a8ff;
  --syntax-string: #a5d6ff;
  --syntax-number: #79c0ff;
  --syntax-class: #7ee787;
  --syntax-operator: #c9d1d9;
  --syntax-punctuation: #c9d1d9;
  --syntax-property: #79c0ff;
}

/* SCALE UP SPACING FOR TABLET & DESKTOP (bp-md: 48em) */
@media (min-width: 48em) {
  :root {
    --spacing: var(--space-5);
  }
}

/* Accent colors for form elements */
progress,
[type="checkbox"],
[type="radio"],
[type="range"] {
  accent-color: var(--brand-green);
}

} /* end @layer foundation */

/* =========================================
   2. Layout & Containers
   ========================================= */
@layer layouts {
header,
main,
footer {
  padding-top: calc(var(--spacing) * 0.5);
  padding-bottom: calc(var(--spacing) * 0.5);
}

main {
  padding-top: calc(var(--spacing) * 1.5);
}

@media (min-width: 48em) {
  header,
  main,
  footer {
    padding-top: var(--spacing);
    padding-bottom: var(--spacing);
  }
}

section {
  margin-bottom: var(--spacing);
}

.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: var(--spacing);
  padding-left: var(--spacing);
}
@media (min-width: 36em) {
  .container {
    max-width: 540px;
  }
}

@media (min-width: 48em) {
  .container {
    max-width: 720px;
  }
}

/* The sweet spot for blog layouts; container caps at 850px from bp-lg up. */
@media (min-width: 64em) {
  .container {
    max-width: 850px;
  }
}

} /* end @layer layouts */

/* =========================================
   3. Modern Reset & Typography Base
   ========================================= */
@layer reset {
*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ul,
ol,
pre,
li {
  margin: 0;
  padding: 0;
}

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

body {
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text-color);
  background-color: var(--bg-color);
}

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

input,
button,
textarea,
select {
  font: inherit;
}

::selection {
  background-color: var(--brand-green);
  color: var(--primary-inverse);
}

} /* end @layer reset */

/* =========================================
   4. Base HTML Elements
   ========================================= */
@layer foundation {
h1, h2, h3, h4, h5, h6 {
  color: var(--h1-color);
  font-weight: 800;
  --heading-weight: 800;
  line-height: 1.2;
  margin-bottom: calc(var(--spacing) * 1.5);
  clear: both;
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

p,
ul,
ol,
table,
blockquote,
details {
  margin-bottom: var(--spacing);
}

ul,
ol {
  padding-left: calc(var(--spacing) * 1.5);
}

li {
  margin-bottom: calc(var(--spacing) * 0.25);
}

.task-list-item {
  list-style-type: none;
}

a {
  color: var(--primary-color);
  text-decoration: underline;
  text-decoration-color: var(--primary-underline);
  text-underline-offset: 0.25rem;
  transition: all 0.2s ease-in-out;
}

a:hover {
  color: var(--primary-hover);
  text-decoration-color: var(--primary-hover-underline);
}

/* Base Link Resets (Keeps buttons from acting like links) */
a.secondary:not([role="button"]) {
  color: var(--muted-color);
}

a.secondary:not([role="button"]):hover {
  color: var(--primary-hover);
}

/* Contrast links (like blog/project headers) */
a.contrast:not([role="button"]) {
  color: var(--contrast-color);
  font-weight: var(--heading-weight, 500);
}

a.contrast:not([role="button"]):hover {
  color: var(--primary-color);
  text-decoration-color: var(--primary-color);
}

small {
  font-size: 0.875em;
  color: var(--muted-color);
}

hr {
  border: none;
  border-top: 1px solid var(--muted-border-color);
  margin: calc(var(--spacing) * 2) 0;
  clear: both;
}

blockquote {
  border-left: 0.25rem solid var(--muted-border-color);
  padding-left: var(--spacing);
  color: var(--muted-color);
}

/* Tables (markdown-rendered) */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95em;
}

table thead th {
  background-color: var(--card-bg-color);
  border-bottom: 2px solid var(--muted-border-color);
  font-weight: 700;
  text-align: left;
  padding: 0.5rem 0.75rem;
}

table tbody td {
  border-bottom: 1px solid var(--muted-border-color);
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* Allow long monospace strings inside table cells to wrap */
table code {
  overflow-wrap: anywhere;
  white-space: normal;
}

} /* end @layer foundation */


/* Components */
@layer components {
/* =========================================
   5. Syntax Highlighting & Code Blocks
   ========================================= */

/* Base Code Block Styling */
pre[class*="language-"],
code[class*="language-"] {
  color: var(--syntax-text);
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-variant-ligatures: contextual;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  line-height: 1.6;
  tab-size: 4;
  hyphens: none;
}

/* The outer `<pre>` container (covers both highlighted and plain fenced blocks) */
pre {
  padding: 1.25rem;
  margin-bottom: var(--spacing);
  overflow-x: auto;
  background-color: var(--syntax-bg);
  border: 1px solid var(--muted-border-color);
  border-radius: var(--border-radius);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05);
  clear: both;
  font-family: var(--font-mono);
  font-size: 0.875em;
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Inline code inside paragraphs (not in a pre block) */
:not(pre) > code[class*="language-"],
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
  color: var(--text-color);
  border-radius: 0.25rem;
  white-space: normal;
}

/* Ensure code blocks inside links inherit the link's color and hover state */
a code {
  color: inherit;
}

/* Tint the code background green when the link is hovered */
a:hover code {
  background-color: color-mix(in srgb, var(--primary-hover) 8%, transparent);
}

/* Token Colors */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--syntax-comment);
  font-style: italic;
}

.token.punctuation {
  color: var(--syntax-punctuation);
}

.token.namespace {
  opacity: 0.7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--syntax-number);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--syntax-string);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--syntax-operator);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--syntax-keyword);
}

.token.function {
  color: var(--syntax-function);
}

.token.class-name {
  color: var(--syntax-class);
}

.token.regex,
.token.important,
.token.variable {
  color: var(--syntax-property);
}

.token.important,
.token.bold {
  font-weight: 600;
}

.token.italic {
  font-style: italic;
}

.token.entity {
  cursor: help;
}

/* Annotated code blocks: per-line bands marking agent-touchability. */
.code-line {
  display: block;
  min-height: 1.6em;
  min-width: 100%;
  width: max-content;
  border-left: 3px solid transparent;
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  box-sizing: content-box;
}

.code-line-red {
  background: color-mix(in srgb, #dc2626 12%, transparent);
  border-left-color: #dc2626;
}

.code-line-yellow {
  background: color-mix(in srgb, #ca8a04 14%, transparent);
  border-left-color: #ca8a04;
}

.code-line-green {
  background: color-mix(in srgb, #16a34a 12%, transparent);
  border-left-color: #16a34a;
}

} /* end @layer components */

@layer components {
/* =========================================
   6. Articles & Buttons
   ========================================= */
article {
  padding: var(--spacing);
  margin-bottom: var(--spacing);
  background-color: var(--bg-color);
  border-radius: var(--border-radius);
}

article > header,
article > footer {
  background-color: transparent;
}

/* Default Buttons (Black/Dark) */
button,
[role="button"] {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  margin-bottom: var(--spacing);
  background-color: var(--primary-bg);
  color: var(--primary-inverse);
  border: 1px solid var(--primary-border);
  border-radius: var(--border-radius);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

button:hover,
[role="button"]:hover {
  background-color: var(--primary-hover-bg);
  border-color: var(--primary-hover-border);
  color: var(--primary-inverse);
  text-decoration: none;
}

/* Secondary Buttons (Muted Gray) */
button.secondary,
[role="button"].secondary {
  background-color: var(--secondary-bg);
  color: var(--secondary-inverse);
  border-color: var(--secondary-border);
}

button.secondary:hover,
[role="button"].secondary:hover {
  background-color: var(--secondary-hover-bg);
  border-color: var(--secondary-hover-border);
  color: var(--secondary-hover-inverse);
}

/* Contrast Buttons (Brand Green) */
button.contrast,
[role="button"].contrast {
  background-color: var(--contrast-bg);
  color: var(--contrast-inverse);
  border-color: var(--contrast-border);
}

button.contrast:hover,
[role="button"].contrast:hover {
  background-color: var(--contrast-hover-bg);
  border-color: var(--contrast-hover-border);
  color: var(--contrast-inverse);
}

.icon {
  width: 1.25em;
  height: 1.25em;
  display: inline-block;
  vertical-align: -0.225em;
  flex-shrink: 0;
}

} /* end @layer components */

@layer components {
/* =========================================
   Navigation Flexbox Layout & Mobile Menu
   ========================================= */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  position: relative; /* Context for absolute mobile menu. */
}

/* Mobile Waffle/Menu Toggle Base */
.menu-toggle {
  display: grid; /* Use grid to stack both toggle icons. */
  place-items: center;
  background: transparent;
  border: none;
  padding: 0.25rem;
  color: var(--text-color);
  cursor: pointer;
  margin-bottom: 0;
  border-radius: var(--border-radius);
  transition: background-color 0.2s ease, color 0.2s ease;
  width: 2.25rem;
  height: 2.25rem;
}

/* Keep the active/hover state when open */
.menu-toggle:hover,
nav.is-open .menu-toggle {
  background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
  color: var(--primary-hover);
}

/* Stack both icons in the same grid cell and set up the animation */
.menu-toggle svg {
  grid-area: 1 / 1;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

/* 1. Closed State (Hamburger visible, X hidden & spun left) */
.menu-toggle .icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.menu-toggle .icon-hamburger {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* 2. Open State (Hamburger hidden & spun right, X visible) */
nav.is-open .menu-toggle .icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

nav.is-open .menu-toggle .icon-hamburger {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

/* Hide navigation list on mobile, setup as dropdown */
nav ul {
  display: none; /* Hidden by default. */
  flex-direction: column;
  position: absolute;
  top: 100%;
  right: 0; /* Anchor to the right side. */
  min-width: 14rem; /* Give it a fixed width. */
  background-color: var(--bg-color);
  padding: var(--spacing);
  border: 1px solid var(--muted-border-color); /* Border all around. */
  border-radius: var(--border-radius); /* Match card styling. */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); /* Soft floating shadow. */
  margin: 0.5rem 0 0; /* Tiny gap below the header. */
  list-style: none;
  gap: var(--spacing);
  z-index: 999;
  align-items: flex-end; /* Push text links to the right. */
}

/* When a JS script toggles this class, the mobile menu appears */
nav.is-open ul {
  display: flex;
}

nav a {
  text-decoration: none;
  color: var(--text-color);
}

nav a:hover {
  text-decoration: none;
  color: var(--primary-hover);
}

nav ul li a[aria-current="page"] {
  font-weight: 700;
  color: var(--primary-hover);
}

/* =========================================
   Desktop Navigation Overrides (48em = 768px)
   ========================================= */
@media (min-width: 48em) {
  .menu-toggle {
    display: none; /* Hide toggle on desktop. */
  }

  nav ul {
    display: flex; /* Always visible horizontally. */
    flex-direction: row;
    position: static;
    width: auto;
    background-color: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    margin-top: 0; /* Reset mobile gap. */
    align-items: center; /* Reset text alignment for horizontal row. */
  }
}

/* =========================================
   Sticky nav (Home)
   ========================================= */
.sticky-nav-wrapper {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  background-color: color-mix(in srgb, var(--bg-color), transparent 5%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--muted-border-color);
}

/* =========================================
   Logo Styling
   ========================================= */
.logo-light,
.logo-dark {
  height: 2rem;
  width: auto;
  flex-shrink: 0;
  display: none;
}

[data-theme="light"] .logo-light {
  display: block;
}

[data-theme="dark"] .logo-dark {
  display: block;
}

@media (min-width: 48em) {
  .logo-light,
  .logo-dark {
    height: 3rem;
  }
}

/* =========================================
   Theme Toggle Styling
   ========================================= */
.theme-toggle .sun-icon,
.theme-toggle .moon-icon,
.theme-toggle .auto-icon {
  display: none;
}

[data-user-preference="light"] .theme-toggle .sun-icon {
  display: inline-block;
}

[data-user-preference="dark"] .theme-toggle .moon-icon {
  display: inline-block;
}

[data-user-preference="auto"] .theme-toggle .auto-icon,
:root:not([data-user-preference]) .theme-toggle .auto-icon {
  display: inline-block;
}

} /* end @layer components */

@layer components {

.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.social-list {
  list-style: none;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
  position: static;
  min-width: 0;
  background-color: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.social-list a {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem;
  color: var(--text-color);
}

.social-list a:hover {
  color: var(--primary-hover);
}

.social-list .icon {
  width: 1.1rem;
  height: 1.1rem;
}

} /* end @layer components */

@layer components {
/* =========================================
   Project Card Grid
   ========================================= */
.card-grid {
  display: grid;
  gap: calc(var(--spacing) * 1.75);
  margin-top: calc(var(--spacing) * 2);
}

.card-grid > article {
  margin-bottom: 0;
  padding: calc(var(--spacing) * 1.5) calc(var(--spacing) * 1.75);
  background-color: var(--bg-color);
  border: 1px solid var(--muted-border-color);
}

.card-grid > article > details {
  margin-bottom: 0;
}

.card-grid > article > details > summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1rem;
}

.card-grid > article > details > summary::-webkit-details-marker {
  display: none;
}

.card-grid > article > details > summary > h3 {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-grid > article > details > summary > h3 > small {
  font-weight: normal;
  color: var(--muted-color);
}

.card-grid > article > details > summary > p {
  grid-column: 1 / -1;
  margin: 0.85rem 0 0;
  color: var(--muted-color);
  line-height: 1.6;
}

.card-grid > article > details > summary::after {
  content: "";
  grid-row: 1;
  grid-column: 2;
  width: 0.6rem;
  height: 0.6rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  transition: transform 0.15s ease;
  align-self: center;
  justify-self: end;
  opacity: 0.6;
}

.card-grid > article > details[open] > summary::after {
  transform: rotate(-135deg);
}

.card-grid > article > details[open] > summary {
  margin-bottom: calc(var(--spacing) * 1.25);
}

.card-grid > article > details > footer {
  margin-top: calc(var(--spacing) * 1.5);
  padding-top: calc(var(--spacing) * 0.85);
  border-top: 1px solid var(--muted-border-color);
  color: var(--muted-color);
}

.repo-topics {
  grid-column: 1 / -1;
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.repo-topics > li {
  margin: 0;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  background-color: var(--card-bg-color);
  border-radius: var(--radius-pill);
  color: var(--muted-color);
}

} /* end @layer components */

@layer components {
/* =========================================
   Block (centered) post images & captions
   ========================================= */
.picture-block {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

.img-block {
  max-width: 80%;
  margin: auto;
  height: auto;
  border-radius: var(--radius-lg);
}

svg.diagram {
  max-width: 100%;
  height: auto;
}

.picture-theme-light,
.picture-theme-dark {
  display: none;
}
[data-theme="light"] .picture-theme-light {
  display: block;
}
[data-theme="dark"] .picture-theme-dark {
  display: block;
}

.picture-theme-light img,
.picture-theme-dark img {
  border: 1px solid var(--muted-border-color);
}

figure.has-caption {
  display: flex;
  flex-direction: column;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

figure.has-caption.picture-inline-left,
figure.has-caption.picture-inline-right {
  margin-top: 0;
  margin-bottom: 1rem;
}

figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted-color);
  text-align: center;
  line-height: 1.4;
  max-width: 80%; /* matches .img-block max-width for alignment */
}

/* Inline-floated figures should not constrain caption width */
figure.picture-inline-left figcaption,
figure.picture-inline-right figcaption {
  max-width: 100%;
}

@media (max-width: 48em) {
  .img-block {
    max-width: 100%;
  }

  figcaption {
    max-width: 100%;
  }
}

} /* end @layer components */

@layer components {
/* =========================================
   Inline (floated) post images
   ========================================= */
.picture-inline-left {
  float: left;
  margin: 0 2.5rem 1rem -3rem;
  width: 45%;
}

.picture-inline-right {
  float: right;
  margin: 0 -3rem 1rem 2.5rem;
  width: 45%;
}

.img-inline {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

/* Flush variant: float aligned with the text column edge (no bleed). */
.picture-inline-flush.picture-inline-left {
  margin: 0 2.5rem 1rem 0;
}
.picture-inline-flush.picture-inline-right {
  margin: 0 0 1rem 2.5rem;
}

@media (max-width: 48em) {
  /* Reset floats so figures stack on small screens */
  .picture-inline-left,
  .picture-inline-right {
    float: none;
    display: flex;
    justify-content: center;
    width: auto;
    max-width: 100%;
    margin: 2rem 0;
  }

  /* Compact inline figures keep their float so text wraps around them */
  .picture-inline-compact.picture-inline-left {
    float: left;
    display: block;
    max-width: 40%;
    margin: 0 0.5rem 0.25rem 0;
  }
  .picture-inline-compact.picture-inline-right {
    float: right;
    display: block;
    max-width: 40%;
    margin: 0 0 0.25rem 0.5rem;
  }
}

} /* end @layer components */

@layer components {
/* =========================================
   Cropped viewport (zoom-into-image overlay used by the image shortcode)
   ========================================= */
.img-viewport {
  display: block;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: var(--ar);
  border-radius: var(--radius-lg);
}

.img-viewport > picture {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
}

.img-viewport-img {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: var(--zoom-w);
  height: auto;
  max-width: none;
  transform: translate(var(--zoom-tx), var(--zoom-ty));
  transform-origin: 0 0;
}

@media (max-width: 48em) {
  /* On mobile the crop is dropped; full image flows in normally */
  .img-viewport {
    aspect-ratio: auto;
    overflow: visible;
    cursor: default;
    border-radius: 0;
  }
  .img-viewport > picture { height: auto; }
  .img-viewport-img {
    position: static;
    width: 100%;
    transform: none;
    border-radius: var(--radius-lg);
  }
}

} /* end @layer components */

@layer components {
/* =========================================
   Click-to-zoom trigger (applied to any zoomable figure/svg)
   ========================================= */
[data-zoomable="true"] {
  cursor: zoom-in;
  transition: transform 0.2s ease, outline-color 0.2s ease;
  outline: 3px solid transparent;
  outline-offset: -1px;
}

@media (hover: hover) {
  [data-zoomable="true"]:hover {
    transform: scale(1.015);
    outline-color: var(--contrast-bg);
  }
}

[data-zoomable="true"]:focus-visible {
  outline-color: var(--contrast-bg);
}

/* =========================================
   Lightbox dialog (rendered once in base.njk)
   ========================================= */
.img-lightbox {
  padding: 0;
  border: none;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.img-lightbox::backdrop {
  background: var(--lightbox-backdrop);
  backdrop-filter: blur(4px);
}

.img-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-lightbox-content {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-sizing: border-box;
  max-width: min(var(--cap-w, 95vw), 95vw);
  max-height: 95vh;
  cursor: zoom-out;
}

.img-lightbox-content:has(> svg) {
  border-radius: 0;
}

.img-lightbox-content > picture {
  display: contents;
}

.img-lightbox-content > img,
.img-lightbox-content > picture > img {
  width: 100%;
  height: auto;
  max-height: calc(95vh - 2rem);
  object-fit: contain;
}

.img-lightbox-content > svg {
  width: min(95vw, 1200px);
  height: auto;
  max-height: 95vh;
}

.img-lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  border-radius: var(--radius-circle);
  width: 2.5rem;
  height: 2.5rem;
  min-width: 0;
  padding: 0;
  margin: 0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.img-lightbox-close:hover,
.img-lightbox-close:focus-visible {
  background: rgba(0, 0, 0, 0.8);
  outline: none;
}

} /* end @layer components */

@layer components {
/* Inline category link in post meta lines. Inherits muted color from parent. */
.category-tag {
  color: inherit;
  text-decoration: none;
}

a.category-tag:hover {
  text-decoration: underline;
}

} /* end @layer components */

@layer components {
.author-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
}

.author-chip:hover {
  color: var(--primary-hover);
}

.author-chip-photo {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-circle);
  object-fit: cover;
  display: block;
}

} /* end @layer components */

@layer components {
.post-list {
  margin-top: 1.5rem;
}

.post-list--compact {
  margin-top: 0;
}

.post-list--compact .post-card {
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
}

.post-list--compact .post-card .post-number {
  font-size: 1.25rem;
}

.post-list--compact .post-card-title {
  font-size: 1.15rem;
}

.post-list--compact .post-card-meta {
  margin-bottom: 0.25rem;
}

.post-list--compact .post-card-description {
  font-size: 0.9rem;
  color: var(--muted-color);
}

.post-list-empty {
  color: var(--muted-color);
  font-style: italic;
}

.post-card {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--muted-border-color);
}

.post-card::after {
  content: "";
  display: block;
  clear: left;
}

.post-card:last-child {
  border-bottom: none;
}

.post-card .post-number {
  float: left;
  margin-right: 1rem;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.2;
  color: var(--muted-color);
  user-select: none;
}

.post-card-title {
  clear: none;
  margin: 0 0 0.25rem 0;
  line-height: 1.2;
}

.post-card-title a.contrast {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
  transition: all 0.2s ease-in-out;
}

.post-card-title a.contrast:hover {
  text-decoration-color: var(--primary-hover);
  color: var(--primary-hover);
}

.post-card-meta {
  display: block;
  margin-bottom: 0.5rem;
}

.post-card-description {
  margin: 0;
  line-height: 1.45;
}

} /* end @layer components */

@layer components {
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0.5rem 0 2rem;
  font-size: 0.95rem;
}

.category-nav-link {
  color: var(--muted-color);
  text-decoration: none;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.category-nav-link:hover {
  color: var(--text-color);
}

.category-nav-link.is-active {
  color: var(--text-color);
  font-weight: 600;
  border-bottom-color: var(--text-color);
}

} /* end @layer components */


/* Pages */
@layer pages {
/* =========================================
   Hero Section
   ========================================= */
.splash-hero {
  width: 100%;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  padding: var(--spacing) 0;
}

.splash-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: clamp(2rem, calc((100vw - 80em) * 0.35), 20rem);
  height: 100%;
  background-image: url('../images/hero-wave.svg');
  background-size: 100% auto;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -1;
}

/* =========================================
   Dark Theme Hero Adjustments
   ========================================= */
[data-theme="dark"] .splash-hero p {
  color: var(--h1-color);
}

[data-theme="dark"] .splash-hero small {
  /* Mixes the bright text with 15% black to dim the brightness, not the opacity */
  color: color-mix(in srgb, var(--h1-color) 85%, black);
}

[data-theme="dark"] .splash-hero::before {
  filter: brightness(0.5) contrast(1.2);
}

@media (orientation: portrait) {
  .splash-hero {
    justify-content: flex-start;
    padding-top: calc((100vw - var(--spacing)) / 1.9 + var(--spacing));
  }
  .splash-hero::before {
    right: var(--spacing);
    height: calc((100vw - var(--spacing)) / 1.9);
    background-position: top left;
  }
}

.splash-hero h1 {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 1rem;
}

} /* end @layer pages */

@layer pages {
/* =========================================
   Projects Page
   ========================================= */
/* Intentionally empty for now. Project card styles live in components/cards.css. */

} /* end @layer pages */

@layer pages {
/* =========================================
   Adjacent post pager (above title)
   ========================================= */
.post-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--muted-color);
}

.post-pager-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted-color);
  text-decoration: none;
  max-width: 48%;
}

.post-pager-link:hover {
  color: var(--primary-hover);
}

.post-pager-next {
  margin-left: auto;
  text-align: right;
}

.post-pager-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================
   Related posts (below article)
   ========================================= */
.related-posts {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--muted-border-color);
}

.related-posts h2 {
  font-size: 1.1rem;
  color: var(--muted-color);
  margin: 0 0 1rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* =========================================
   Individual Post Page (post.njk header)
   ========================================= */
.post-header {
  margin-bottom: 2rem;
}

.post-hero-image {
  width: 100%;
  height: auto;
  margin-bottom: 2rem;
}

.post-header .badge {
  margin-bottom: 0.75rem;
}

.post-header h1 {
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-color);
  font-size: 0.875rem;
}

.post-meta-separator {
  color: var(--muted-color);
}

/* =========================================
   Spoiler Text (Pure CSS Click-to-Reveal)
   ========================================= */
.spoiler {
  background-color: var(--text-color);
  color: transparent;
  border-radius: 4px;
  padding: 0 4px;
  cursor: pointer;
  user-select: none;

  /* The Magic: When returning to the hidden state, wait 11 days (999999s) */
  transition: background-color 0s 999999s, color 0s 999999s;
}

/* We use :active, which triggers the exact moment you click down */
.spoiler:active {
  background-color: color-mix(in srgb, var(--text-color) 10%, transparent);
  color: var(--text-color);
  user-select: auto;

  /* Remove the delay so it reveals instantly on click */
  transition: none;
}

} /* end @layer pages */