/* Defaults */
/* UCHU Color System - OKLCH-based color palette */
/* Provides perceptually uniform colors across light and dark themes */

:root {
  color-scheme: light dark;

  /* Raw OKLCH values for color mixing and opacity */
  --uchu-yang-raw: 98% 0.005 106;
  --uchu-yin-raw: 0% 0 0;

  /* Gray scale - Neutral colors */
  --uchu-gray-1-raw: 96% 0.008 106;
  --uchu-gray-2-raw: 87% 0.012 106;
  --uchu-gray-3-raw: 78% 0.015 106;
  --uchu-gray-4-raw: 65% 0.02 106;
  --uchu-gray-5-raw: 52% 0.025 106;
  --uchu-gray-6-raw: 39% 0.03 106;
  --uchu-gray-7-raw: 26% 0.02 106;
  --uchu-gray-8-raw: 13% 0.015 106;

  /* Yin scale - True grays to black */
  --uchu-yin-1-raw: 95% 0 0;
  --uchu-yin-2-raw: 85% 0 0;
  --uchu-yin-3-raw: 75% 0 0;
  --uchu-yin-4-raw: 65% 0 0;
  --uchu-yin-5-raw: 55% 0 0;
  --uchu-yin-6-raw: 45% 0 0;
  --uchu-yin-7-raw: 35% 0 0;
  --uchu-yin-8-raw: 25% 0 0;
  --uchu-yin-9-raw: 15% 0 0;

  /* Blue scale */
  --uchu-blue-1-raw: 95% 0.05 240;
  --uchu-blue-2-raw: 88% 0.08 240;
  --uchu-blue-3-raw: 75% 0.12 240;
  --uchu-blue-4-raw: 65% 0.15 240;
  --uchu-blue-5-raw: 55% 0.18 240;
  --uchu-blue-6-raw: 45% 0.2 240;
  --uchu-blue-7-raw: 35% 0.15 240;
  --uchu-blue-8-raw: 25% 0.1 240;

  /* Green scale */
  --uchu-green-1-raw: 95% 0.05 140;
  --uchu-green-2-raw: 88% 0.08 140;
  --uchu-green-3-raw: 75% 0.12 140;
  --uchu-green-4-raw: 65% 0.15 140;
  --uchu-green-5-raw: 55% 0.18 140;
  --uchu-green-6-raw: 45% 0.2 140;
  --uchu-green-7-raw: 35% 0.15 140;
  --uchu-green-8-raw: 25% 0.1 140;

  /* Orange scale */
  --uchu-orange-1-raw: 95% 0.05 60;
  --uchu-orange-2-raw: 88% 0.08 60;
  --uchu-orange-3-raw: 75% 0.12 60;
  --uchu-orange-4-raw: 65% 0.15 60;
  --uchu-orange-5-raw: 55% 0.18 60;
  --uchu-orange-6-raw: 45% 0.2 60;
  --uchu-orange-7-raw: 35% 0.15 60;
  --uchu-orange-8-raw: 25% 0.1 60;

  /* Red scale */
  --uchu-red-1-raw: 95% 0.05 25;
  --uchu-red-2-raw: 88% 0.08 25;
  --uchu-red-3-raw: 75% 0.12 25;
  --uchu-red-4-raw: 65% 0.15 25;
  --uchu-red-5-raw: 55% 0.18 25;
  --uchu-red-6-raw: 45% 0.2 25;
  --uchu-red-7-raw: 35% 0.15 25;
  --uchu-red-8-raw: 25% 0.1 25;

  /* Purple scale */
  --uchu-purple-1-raw: 95% 0.05 300;
  --uchu-purple-2-raw: 88% 0.08 300;
  --uchu-purple-3-raw: 75% 0.12 300;
  --uchu-purple-4-raw: 65% 0.15 300;
  --uchu-purple-5-raw: 55% 0.18 300;
  --uchu-purple-6-raw: 45% 0.2 300;
  --uchu-purple-7-raw: 35% 0.15 300;
  --uchu-purple-8-raw: 25% 0.1 300;

  /* Convert raw values to usable OKLCH colors */
  --uchu-yang: oklch(var(--uchu-yang-raw));
  --uchu-yin: oklch(var(--uchu-yin-raw));

  /* Gray scale */
  --uchu-gray-1: oklch(var(--uchu-gray-1-raw));
  --uchu-gray-2: oklch(var(--uchu-gray-2-raw));
  --uchu-gray-3: oklch(var(--uchu-gray-3-raw));
  --uchu-gray-4: oklch(var(--uchu-gray-4-raw));
  --uchu-gray-5: oklch(var(--uchu-gray-5-raw));
  --uchu-gray-6: oklch(var(--uchu-gray-6-raw));
  --uchu-gray-7: oklch(var(--uchu-gray-7-raw));
  --uchu-gray-8: oklch(var(--uchu-gray-8-raw));

  /* Yin scale */
  --uchu-yin-1: oklch(var(--uchu-yin-1-raw));
  --uchu-yin-2: oklch(var(--uchu-yin-2-raw));
  --uchu-yin-3: oklch(var(--uchu-yin-3-raw));
  --uchu-yin-4: oklch(var(--uchu-yin-4-raw));
  --uchu-yin-5: oklch(var(--uchu-yin-5-raw));
  --uchu-yin-6: oklch(var(--uchu-yin-6-raw));
  --uchu-yin-7: oklch(var(--uchu-yin-7-raw));
  --uchu-yin-8: oklch(var(--uchu-yin-8-raw));
  --uchu-yin-9: oklch(var(--uchu-yin-9-raw));

  /* Blue scale */
  --uchu-blue-1: oklch(var(--uchu-blue-1-raw));
  --uchu-blue-2: oklch(var(--uchu-blue-2-raw));
  --uchu-blue-3: oklch(var(--uchu-blue-3-raw));
  --uchu-blue-4: oklch(var(--uchu-blue-4-raw));
  --uchu-blue-5: oklch(var(--uchu-blue-5-raw));
  --uchu-blue-6: oklch(var(--uchu-blue-6-raw));
  --uchu-blue-7: oklch(var(--uchu-blue-7-raw));
  --uchu-blue-8: oklch(var(--uchu-blue-8-raw));

  /* Green scale */
  --uchu-green-1: oklch(var(--uchu-green-1-raw));
  --uchu-green-2: oklch(var(--uchu-green-2-raw));
  --uchu-green-3: oklch(var(--uchu-green-3-raw));
  --uchu-green-4: oklch(var(--uchu-green-4-raw));
  --uchu-green-5: oklch(var(--uchu-green-5-raw));
  --uchu-green-6: oklch(var(--uchu-green-6-raw));
  --uchu-green-7: oklch(var(--uchu-green-7-raw));
  --uchu-green-8: oklch(var(--uchu-green-8-raw));

  /* Orange scale */
  --uchu-orange-1: oklch(var(--uchu-orange-1-raw));
  --uchu-orange-2: oklch(var(--uchu-orange-2-raw));
  --uchu-orange-3: oklch(var(--uchu-orange-3-raw));
  --uchu-orange-4: oklch(var(--uchu-orange-4-raw));
  --uchu-orange-5: oklch(var(--uchu-orange-5-raw));
  --uchu-orange-6: oklch(var(--uchu-orange-6-raw));
  --uchu-orange-7: oklch(var(--uchu-orange-7-raw));
  --uchu-orange-8: oklch(var(--uchu-orange-8-raw));

  /* Red scale */
  --uchu-red-1: oklch(var(--uchu-red-1-raw));
  --uchu-red-2: oklch(var(--uchu-red-2-raw));
  --uchu-red-3: oklch(var(--uchu-red-3-raw));
  --uchu-red-4: oklch(var(--uchu-red-4-raw));
  --uchu-red-5: oklch(var(--uchu-red-5-raw));
  --uchu-red-6: oklch(var(--uchu-red-6-raw));
  --uchu-red-7: oklch(var(--uchu-red-7-raw));
  --uchu-red-8: oklch(var(--uchu-red-8-raw));

  /* Purple scale */
  --uchu-purple-1: oklch(var(--uchu-purple-1-raw));
  --uchu-purple-2: oklch(var(--uchu-purple-2-raw));
  --uchu-purple-3: oklch(var(--uchu-purple-3-raw));
  --uchu-purple-4: oklch(var(--uchu-purple-4-raw));
  --uchu-purple-5: oklch(var(--uchu-purple-5-raw));
  --uchu-purple-6: oklch(var(--uchu-purple-6-raw));
  --uchu-purple-7: oklch(var(--uchu-purple-7-raw));
  --uchu-purple-8: oklch(var(--uchu-purple-8-raw));

  /* Font families */
  --font-family: "Bricolage Grotesque", -apple-system, system-ui, sans-serif;
  --font-family-monospace:
    "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", Menlo,
    Consolas, "DejaVu Sans Mono", monospace;

  /* Brand accent - constant across themes */
  --brand-color: #eb3f00;

  --color-gray-20: rgb(0 0 0 / 0.1);
  --color-gray-90: rgb(5 5 5 / 0.55);

  /* Theme application - (light) */
  --background-color: #ffffff;
  --background-color-secondary: #f6f6f6;
  --text-color: rgb(3 9 17 / 0.92);
  --text-color-secondary: rgb(5 5 5 / 0.7);
  /* Links carry the accent in the underline, not the text, so the orange
     stays reserved for the active nav item and link affordance. */
  --text-color-link: var(--text-color);
  --text-color-link-active: var(--text-color);
  --text-color-link-visited: var(--text-color);
  --link-underline: color-mix(in oklch, var(--brand-color) 30%, transparent);
  --link-underline-active: var(--brand-color);

  /* Semantic colors - (light) */
  --color-accent: #b83200;
  --color-success: oklch(52% 0.14 150);
  --color-warning: oklch(62% 0.14 85);
  --color-error: oklch(53% 0.2 27);

  /* Border and UI colors - (light) */
  --color-border: rgb(0 0 0 / 0.1);
  --color-shadow: rgb(3 9 17 / 0.14);
  --color-selection: var(--brand-color);
  --color-selection-text: #ffffff;

  /* Code-specific colors - (light) */
  --color-code-bg: #f6f6f6;
  --color-code-border: rgb(0 0 0 / 0.1);
  --color-code-text: rgb(3 9 17 / 0.92);

  /* Shared surface tokens */
  --surface-elevated: color-mix(
    in oklch,
    var(--background-color-secondary) 86%,
    var(--background-color)
  );
  --surface-muted: color-mix(
    in oklch,
    var(--background-color-secondary) 72%,
    var(--background-color)
  );
  --surface-accent: color-mix(
    in oklch,
    var(--color-accent) 12%,
    var(--background-color-secondary)
  );
  --focus-ring-color: color-mix(
    in oklch,
    var(--color-accent) 84%,
    var(--background-color)
  );
  --focus-ring-halo: color-mix(
    in oklch,
    var(--background-color) 65%,
    var(--color-accent)
  );
}

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-gray-20: hsl(0 0% 100% / 0.12);
    --color-gray-90: hsl(0 0% 100% / 0.45);

    /* Dark theme colors - */
    --background-color: #17191e;
    --background-color-secondary: #1e2127;
    --text-color: hsl(0 0% 100% / 0.85);
    --text-color-secondary: hsl(0 0% 100% / 0.65);
    /* Links carry the accent in the underline, not the text */
    --text-color-link: var(--text-color);
    --text-color-link-active: var(--text-color);
    --text-color-link-visited: var(--text-color);
    --link-underline: color-mix(in oklch, var(--brand-color) 40%, transparent);
    --link-underline-active: #ff5a1f;

    /* Semantic colors - (dark) */
    --color-accent: #ff7040;
    --color-success: oklch(76% 0.12 150);
    --color-warning: oklch(82% 0.14 85);
    --color-error: oklch(72% 0.17 27);

    /* Border and UI colors - (dark) */
    --color-border: hsl(0 0% 100% / 0.12);
    --color-shadow: rgb(0 0 0 / 0.6);
    --color-selection: var(--brand-color);
    --color-selection-text: #ffffff;

    /* Code-specific colors - (dark) */
    --color-code-bg: #101216;
    --color-code-border: hsl(0 0% 100% / 0.08);
    --color-code-text: hsl(0 0% 100% / 0.85);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-gray-20: hsl(0 0% 100% / 0.12);
  --color-gray-90: hsl(0 0% 100% / 0.45);

  /* Dark theme colors - */
  --background-color: #17191e;
  --background-color-secondary: #1e2127;
  --text-color: hsl(0 0% 100% / 0.85);
  --text-color-secondary: hsl(0 0% 100% / 0.65);
  /* Links carry the accent in the underline, not the text */
  --text-color-link: var(--text-color);
  --text-color-link-active: var(--text-color);
  --text-color-link-visited: var(--text-color);
  --link-underline: color-mix(in oklch, var(--brand-color) 40%, transparent);
  --link-underline-active: #ff5a1f;

  /* Semantic colors - (dark) */
  --color-accent: #ff7040;
  --color-success: oklch(76% 0.12 150);
  --color-warning: oklch(82% 0.14 85);
  --color-error: oklch(72% 0.17 27);

  /* Border and UI colors - (dark) */
  --color-border: hsl(0 0% 100% / 0.12);
  --color-shadow: rgb(0 0 0 / 0.6);
  --color-selection: var(--brand-color);
  --color-selection-text: #ffffff;

  /* Code-specific colors - (dark) */
  --color-code-bg: #101216;
  --color-code-border: hsl(0 0% 100% / 0.08);
  --color-code-text: hsl(0 0% 100% / 0.85);
}

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

/* Focus ring for accessibility */
:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--focus-ring-halo);
}

/* Blockquote styling */
blockquote {
  border-left: 4px solid var(--color-accent);
  background-color: var(--surface-accent);
  padding: 0.6rem 1rem;
  margin: 1.25rem 0;
  border-radius: 0 0.5rem 0.5rem 0;
  color: var(--text-color);
  font-style: italic;
}

blockquote > :first-child {
  margin-top: 0;
}

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

/* Disclosure widget styling */
details {
  margin: 1rem 0;
  padding: 0.35rem 0.85rem 0.85rem;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: 4px;
  background: var(--surface-elevated);
  box-shadow: 0 12px 28px -24px var(--color-shadow);
}

details[open] {
  background: var(--surface-accent);
}

details > summary {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--text-color);
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "▸";
  flex: 0 0 auto;
  line-height: 1.2;
  color: var(--color-accent);
  transform-origin: 50% 52%;
  transition: transform 0.2s ease;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

details > summary:hover {
  color: var(--color-accent);
}

details[open] > summary {
  margin-bottom: 0.5rem;
}

details > :last-child {
  margin-bottom: 0;
}

details details {
  margin: 0.75rem 0 0.25rem;
}

/* Message box styling */
.message-box {
  background-color: color-mix(
    in oklch,
    var(--color-warning) 18%,
    var(--surface-elevated)
  );
  border: 1px solid
    color-mix(in oklch, var(--color-warning) 42%, var(--color-border));
  border-left: 4px solid var(--color-warning);
}

/* Global stylesheet */
* {
  box-sizing: border-box;
}

@view-transition {
  navigation: auto;
}

html,
body {
  padding: 0;
  margin: 0 auto;
  font-family: var(--font-family);
  color: var(--text-color);
  background-color: var(--background-color);
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html {
  overflow-y: scroll;
  font-size: 18px;
}
body {
  max-width: 44rem;
}

/* https://www.a11yproject.com/posts/how-to-hide-content/ */
.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.visually-hidden:focus-visible {
  clip: auto;
  clip-path: none;
  width: auto;
  height: auto;
  overflow: visible;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  padding: 0.6rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  background: var(--background-color);
  color: var(--text-color);
  white-space: normal;
  box-shadow: 0 4px 16px var(--color-shadow);
}

/* Fluid images via https://www.zachleat.com/web/fluid-images/ */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 2px;
}
img[width][height] {
  height: auto;
}
img[src$=".svg"] {
  width: 100%;
  height: auto;
  max-width: none;
}

/* Inline images inside paragraphs (e.g. small icons) keep inline flow */
p img:only-child {
  display: block;
  margin: 1.5rem auto;
}
p img:not(:only-child) {
  display: inline;
  margin: 0 0.25em;
  vertical-align: middle;
  border-radius: 3px;
}

/* Figure element for captioned images */
figure {
  margin: 1.75rem 0;
  text-align: center;
}
figure img {
  margin: 0 auto 0.5rem auto;
}
figcaption {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-color-secondary);
  line-height: 1.45;
  padding: 0 0.5rem;
}

/* Float utilities — for wrapping text around an image */
img.float-left,
figure.float-left {
  float: left;
  margin: 0.4rem 1.25rem 0.75rem 0;
  max-width: 45%;
}
img.float-right,
figure.float-right {
  float: right;
  margin: 0.4rem 0 0.75rem 1.25rem;
  max-width: 45%;
}

/* Clear floats after a figure so following content doesn't wrap */
figure.float-left::after,
figure.float-right::after {
  content: "";
  display: table;
  clear: both;
}

video,
iframe {
  width: 100%;
  height: auto;
}
iframe {
  aspect-ratio: 16/9;
}

p:last-child {
  margin-bottom: 0;
}
p {
  line-height: 1.68;
}

li {
  line-height: 1.62;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.018em;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.05rem;
}

a[href] {
  color: var(--text-color-link);
  text-decoration: none;
}
a[href]:visited {
  color: var(--text-color-link-visited);
}
a[href]:hover,
a[href]:active {
  color: var(--text-color-link-active);
}

/* Sliding underline only on inline prose links */
main p a[href]:not(.post-tag),
main li a[href]:not(.postlist-link):not(.post-tag),
main blockquote a[href],
main figcaption a[href],
.links-nextprev a[href] {
  /* Faint accent rule at rest; the solid one slides across it on hover. */
  background-image: linear-gradient(
      var(--link-underline-active),
      var(--link-underline-active)
    ),
    linear-gradient(var(--link-underline), var(--link-underline));
  background-position:
    0% 100%,
    0% 100%;
  background-repeat: no-repeat, no-repeat;
  background-size:
    0% 2px,
    100% 2px;
  transition: background-size 0.25s ease;
}
main p a[href]:not(.post-tag):hover,
main p a[href]:not(.post-tag):active,
main li a[href]:not(.postlist-link):not(.post-tag):hover,
main li a[href]:not(.postlist-link):not(.post-tag):active,
main blockquote a[href]:hover,
main blockquote a[href]:active,
main figcaption a[href]:hover,
main figcaption a[href]:active,
.links-nextprev a[href]:hover,
.links-nextprev a[href]:active {
  background-size:
    100% 2px,
    100% 2px;
}

main,
footer {
  padding: 1rem;
}
main :first-child {
  margin-top: 0;
}

header {
  border-bottom: 1px dashed var(--color-border);
}

.links-nextprev {
  display: flex;
  justify-content: space-between;
  gap: 0.5em 1em;
  list-style: "";
  border-top: 1px dashed var(--color-border);
  padding: 1em 0;
}
.links-nextprev > * {
  flex-grow: 1;
}
.links-nextprev-next {
  text-align: right;
}

table {
  width: 100%;
  margin: 1.25em 0;
  border-collapse: collapse;
  border: 1px solid var(--color-border);
  background-color: var(--surface-elevated);
  border-radius: 0.5rem;
  overflow: hidden;
}
table td,
table th {
  padding: 0.6em 0.75em;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}
table th {
  background-color: var(--surface-accent);
  color: var(--text-color);
  font-weight: 600;
}
table tr:nth-child(even) td {
  background-color: var(--surface-muted);
}
table tr:last-child td {
  border-bottom: 0;
}

pre,
code {
  font-family: var(--font-family-monospace);
}
pre:not([class*="language-"]) {
  margin: 0.5em 0;
  line-height: 1.375; /* 22px /16 */
  -moz-tab-size: var(--syntax-tab-size);
  -o-tab-size: var(--syntax-tab-size);
  tab-size: var(--syntax-tab-size);
  -webkit-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  overflow-x: auto;
  background-color: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: 8px;
  padding: 1em;
  color: var(--color-code-text);
}
code {
  word-break: break-all;
}

/* Header */
header {
  display: flex;
  gap: 1em;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  padding: 1em;
}
header nav {
  margin-left: auto;
}
header .theme-toggle {
  flex-shrink: 0;
}
.home-link {
  flex-grow: 1;
  font-size: 1em; /* 16px /16 */
  font-weight: 700;
}
.home-link:link:not(:hover) {
  text-decoration: none;
}

/* Header links sit in the foreground text colour rather than the link
   colour; the accent is reserved for hover and the active page. */
header a[href],
header a[href]:visited {
  color: var(--text-color);
}
header a[href]:hover,
header a[href]:active {
  color: var(--color-accent);
}

/* Nav */
.nav {
  display: flex;
  gap: 0.5em 1em;
  padding: 0;
  margin: 0;
  list-style: none;
}
.nav-item {
  display: inline-block;
}
/* Underline is reserved for the active page, so hover shifts colour only. */
.nav-item a[href] {
  text-decoration: none;
}
.nav a[href][aria-current="page"],
.nav a[href][aria-current="page"]:visited {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* On phones the header needs ~427px to sit on one line but only has 390.
   Tightening the padding and gaps reclaims enough without shrinking type. */
@media (max-width: 480px) {
  header {
    padding: 0.75em 0.6em;
    gap: 0.5em;
  }
  .nav {
    gap: 0.4em 0.6em;
  }
}

/* Compact theme cycle button */
.theme-toggle {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.45rem;
  background: var(--surface-elevated);
  color: var(--text-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover {
  background: var(--surface-muted);
  border-color: color-mix(in oklch, var(--color-accent) 35%, var(--color-border));
}
.theme-icon {
  display: none;
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
}
:root:not([data-theme-mode]) .theme-icon--system,
:root[data-theme-mode="system"] .theme-icon--system,
:root[data-theme-mode="light"] .theme-icon--light,
:root[data-theme-mode="dark"] .theme-icon--dark {
  display: block;
}

/* Posts list */
.postlist {
  list-style: none;
  padding: 0;
  padding-left: 1.5rem;
}
.postlist-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  counter-increment: start-from -1;
  margin-bottom: 1em;
}
.postlist-item:before {
  display: inline-block;
  pointer-events: none;
  content: "" counter(start-from, decimal-leading-zero) ". ";
  line-height: 100%;
  text-align: right;
  margin-left: -1.5rem;
}
.postlist-date,
.postlist-item:before {
  font-size: 0.8125em; /* 13px /16 */
  color: var(--color-gray-90);
}
.postlist-date {
  word-spacing: -0.5px;
}
.postlist-link {
  font-size: 1.1875em; /* 19px /16 */
  font-weight: 700;
  flex-basis: calc(100% - 1.5rem);
  padding-left: 0.25em;
  padding-right: 0.5em;
  text-wrap: balance;
  transition: color 0.2s ease;
}
.postlist-item-active .postlist-link {
  font-weight: bold;
}
/* Post titles are excluded from the sliding underline, so the accent
   carries the hover state instead — the row's number lights with it so
   the entry reads as one unit. */
/* [href] is needed to outweigh the global a[href]:hover rule. */
.postlist-link[href]:hover,
.postlist-link[href]:active {
  color: var(--color-accent);
}
.postlist-item:has(.postlist-link:hover)::before {
  color: var(--color-accent);
}
.postlist-item::before,
.postlist-date {
  transition: color 0.2s ease;
}

/* Tags */
.post-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: capitalize;
  font-style: normal;
  font-size: 0.7rem;
  line-height: 1.1;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid
    color-mix(in oklch, var(--color-accent) 30%, var(--color-border));
  background-color: color-mix(
    in oklch,
    var(--color-accent) 10%,
    var(--background-color-secondary)
  );
  color: var(--text-color-secondary);
}
.postlist-item > .post-tag {
  align-self: center;
}

/* Post header: title tight to its metadata, then a clear gap before the
   body copy. Long titles break on meaning rather than on the margin. */
.post > h1 {
  margin-top: 0;
  margin-bottom: 0.3em;
  text-wrap: balance;
}
.post > .post-metadata {
  margin-bottom: 2.5rem;
  color: var(--text-color-secondary);
}

.table-of-contents {
  margin: 0 0 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--surface-elevated);
}
.table-of-contents h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.table-of-contents ol {
  margin: 0;
  padding-left: 1.25rem;
}
.table-of-contents li + li {
  margin-top: 0.2rem;
}

/* Tags list */
.post-metadata {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5em;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
}
.post-metadata time {
  margin-right: 1em;
}

/* Enhanced Code Styling for Astro Blog */

/* Base code styling */
code {
  font-family: var(--font-family-monospace);
  font-size: 0.9em;
  line-height: 1.4;
  word-break: break-word;
  tab-size: 2;
}

/* Inline code */
:not(pre) > code {
  background-color: var(--surface-muted);
  border: 1px solid var(--color-code-border);
  border-radius: 4px;
  padding: 0.2em 0.4em;
  color: var(--text-color);
  font-weight: 500;
  white-space: nowrap;
  overflow-wrap: break-word;
}

/* Code blocks */
pre {
  background-color: var(--surface-elevated);
  border: 1px solid var(--color-code-border);
  border-radius: 8px;
  padding: 1.25em;
  margin: 1.5em 0;
  overflow-x: auto;
  overflow-y: hidden;
  line-height: 1.5;
  tab-size: 2;
  box-shadow: 0 20px 36px -34px var(--color-shadow);

  /* Smooth scrolling for overflow */
  scroll-behavior: smooth;

  /* Better text rendering */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

pre code {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* Code block with language label */
pre[class*="language-"] {
  position: relative;
}

/* Optional: Add language label styling if you want to show language names */
pre[class*="language-"]::before {
  content: attr(data-language);
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--color-accent);
  color: #ffffff;
  padding: 0.25em 0.5em;
  font-size: 0.75em;
  font-weight: 600;
  border-bottom-left-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Scrollbar styling for code blocks */
pre::-webkit-scrollbar {
  height: 8px;
}

pre::-webkit-scrollbar-track {
  background: transparent;
}

pre::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-color-secondary);
}

/* Firefox scrollbar */
pre {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* Code highlighting improvements */
pre[class*="language-"] {
  /* Enhanced contrast for syntax highlighting - Light theme */
  --token-comment: oklch(58% 0.02 270);
  --token-keyword: oklch(48% 0.16 320);
  --token-string: oklch(48% 0.13 165);
  --token-number: oklch(55% 0.15 75);
  --token-function: oklch(52% 0.17 10);
  --token-operator: oklch(38% 0.02 280);
  --token-punctuation: oklch(48% 0.015 270);
}

@media (prefers-color-scheme: dark) {
  pre[class*="language-"] {
    /* Doom Horizon-inspired syntax colors */
    --token-comment: oklch(55% 0.03 240);
    --token-keyword: oklch(75% 0.18 350);
    --token-string: oklch(72% 0.12 200);
    --token-number: oklch(75% 0.16 80);
    --token-function: oklch(78% 0.2 10);
    --token-operator: oklch(80% 0.015 50);
    --token-punctuation: oklch(65% 0.02 245);
  }
}

:root[data-theme="dark"] pre[class*="language-"] {
  /* Doom Horizon-inspired syntax colors */
  --token-comment: oklch(55% 0.03 240);
  --token-keyword: oklch(75% 0.18 350);
  --token-string: oklch(72% 0.12 200);
  --token-number: oklch(75% 0.16 80);
  --token-function: oklch(78% 0.2 10);
  --token-operator: oklch(80% 0.015 50);
  --token-punctuation: oklch(65% 0.02 245);
}

/* Copy button styling (if you add copy functionality) */
.code-block-container {
  position: relative;
}

.copy-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  background: var(--surface-elevated);
  border: 1px solid var(--color-code-border);
  border-radius: 4px;
  padding: 0.25em 0.5em;
  font-size: 0.75em;
  color: var(--text-color-secondary);
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.code-block-container:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background-color: var(--surface-muted);
  color: var(--text-color);
}

/* Diff styling for code comparisons */
.token.deleted {
  background-color: oklch(92% 0.08 15 / 0.3);
  color: oklch(45% 0.18 15);
  text-decoration: none;
}

.token.inserted {
  background-color: oklch(92% 0.08 165 / 0.3);
  color: oklch(45% 0.14 165);
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  .token.deleted {
    background-color: oklch(35% 0.12 15 / 0.4);
    color: oklch(78% 0.16 15);
  }

  .token.inserted {
    background-color: oklch(35% 0.1 180 / 0.4);
    color: oklch(78% 0.12 190);
  }
}

:root[data-theme="dark"] .token.deleted {
  background-color: oklch(35% 0.12 15 / 0.4);
  color: oklch(78% 0.16 15);
}

:root[data-theme="dark"] .token.inserted {
  background-color: oklch(35% 0.1 180 / 0.4);
  color: oklch(78% 0.12 190);
}

/* Line numbers styling (if using a syntax highlighter that supports them) */
.line-numbers .line-numbers-rows {
  border-right: 1px solid var(--color-border);
  margin-right: 1em;
  padding-right: 1em;
}

.line-numbers-rows > span:before {
  color: var(--text-color-secondary);
  font-size: 0.9em;
}

/* Terminal/console styling */
pre.terminal {
  background-color: var(--uchu-yin-9);
  color: var(--uchu-green-2);
  border: 2px solid var(--uchu-yin-7);
}

pre.terminal::before {
  content: "$ ";
  color: var(--uchu-blue-3);
  font-weight: bold;
}

/* Responsive code blocks */
@media (max-width: 768px) {
  pre {
    padding: 1em;
    margin: 1em -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  :not(pre) > code {
    word-break: break-all;
    white-space: normal;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :not(pre) > code {
    border-width: 2px;
    font-weight: 600;
  }

  pre {
    border-width: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.mjx-container[jax="SVG"] rect[data-frame="true"] {
  fill: none !important;
  stroke: none !important;
}
/* Hide MathJax assistive MathML (should be visually hidden) */
mjx-assistive-mml {
  position: absolute !important;
  top: 0;
  left: 0;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  width: 1px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

.addendum {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-color-secondary);
}

.sub-note {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-color);
  border: 1px solid
    color-mix(in oklch, var(--color-accent) 28%, var(--color-border));
  border-left: 3px solid var(--color-accent);
  background: var(--surface-accent);
  padding: 0.5rem 0.75rem;
  margin: 1rem 0;
  border-radius: 4px;
}

.sub-note strong {
  font-style: normal;
  font-weight: 600;
}
