:root {
  /* Typography */
  --spacing-base: 1.5em;
  --font-family-mono: monospace;
  --font-size-base: 1em;
  --font-size-small: 0.9em;
  --font-size-code: 0.95em;

  /* Spacing */
  --spacing-xs: calc(var(--spacing-base) * 0.25);
  --spacing-sm: calc(var(--spacing-base) * 0.5);
  --spacing-md: var(--spacing-base);
  --spacing-lg: calc(var(--spacing-base) * 2);

  /* Base theme knobs - fixed for light mode only */
  --bg-h: 0;
  --bg-s: 0%;
  --bg-l: 99%;

  /* Background colors */
  --color-bg-primary: hsl(var(--bg-h) var(--bg-s) var(--bg-l));
  --color-bg-secondary: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) - 2%));
  --color-border: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) - 6%));
  --color-selection-bg: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) - 13%));

  /* Text colors */
  --color-text-primary: hsl(var(--bg-h) var(--bg-s) 8%);
  --color-text-muted: hsl(var(--bg-h) var(--bg-s) 50%);
  --color-text-code: hsl(var(--bg-h) var(--bg-s) 30%);

  /* Layout */
  --container-width: 60ch;
  --pre-border-radius: 0.75rem;
  --inline-border-radius: 0.375rem;
  --gap-base: 1em;
  --gap-small: 0.5rem;

  /* Breakpoints */
  --breakpoint-mobile: 600px;

  color-scheme: light;
}

.no-scrollbar {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.no-scrollbar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.list-unstyled {
  list-style: none;
  margin-left: 0;
}

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

.no-underline {
  text-decoration: none;
  border-bottom: none;
}

::selection {
  background: var(--color-selection-bg);
  color: var(--color-text-primary);
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.skip-link:focus {
  position: fixed;
  top: var(--spacing-sm);
  left: var(--spacing-sm);
  opacity: 1;
}

/* Focus styles for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-text-primary);
  outline-offset: 2px;
}

* {
  margin: 0;
  padding: 0;
  font: inherit;
  color: var(--color-text-primary);
  box-sizing: border-box;
}

ul {
  list-style-type: disc;
  margin-left: 1.5rem;
}

ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
}

html {
  margin: 0 0 0 calc(100vw - 100%);
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font: var(--font-size-base) / var(--spacing-base) var(--font-family-mono);
  background: var(--color-bg-primary);
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(auto, var(--container-width));
  justify-content: center;
  padding: var(--spacing-lg);
  gap: var(--spacing-lg);
}

a {
  display: inline-block;
  margin-left: -0.16666em;
  text-decoration: none;
  border-bottom: 1px dotted;
  white-space: pre-wrap;
  word-wrap: break-word;
}

a:hover {
  border-bottom: 1px solid;
}

p,
pre {
  margin: var(--spacing-base) 0;
}

h1,
h2,
h3,
h4,
h5 {
  margin: var(--spacing-base) 0;
  font-weight: bold;
}

h2 {
  counter-increment: h2;
  counter-reset: h3;
}

h3 {
  counter-increment: h3;
  counter-reset: h4;
}

h4 {
  counter-increment: h4;
  counter-reset: h5;
}

h5 {
  counter-increment: h5;
}

/* nested counters */
h2::before {
  content: counter(h2) ". ";
}

h3::before {
  content: counter(h2) "." counter(h3) ". ";
}

h4::before {
  content: counter(h2) "." counter(h3) "." counter(h4) ". ";
}

h5::before {
  content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". ";
}

time {
  color: var(--color-text-muted);
}

footer {
  padding: calc(var(--spacing-base) * 2) 0;
  text-align: center;
}
footer p {
  margin-bottom: 0;
}

pre {
  border: 1px solid var(--color-border);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--pre-border-radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-code);
  line-height: 1.6;
  color: var(--color-text-code);
  overflow-x: auto;
  box-shadow: 0 1px 2px 0 var(--color-border);
}

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

p > code,
li > code,
h1 > code,
h2 > code,
h3 > code,
h4 > code,
h5 > code {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--inline-border-radius);
  padding: 0.2em 0.4em;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-code);
  color: var(--color-text-code);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.terms-list {
  padding-bottom: var(--spacing-base);
}

.terms-list ul {
  list-style-type: none;
  margin-left: 0;
}

.terms-list ul li {
  display: inline-block;
  font-style: italic;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  padding: 0 3px;
}

/* Path navigation styles */
.path-nav {
  font-family: var(--font-family-mono);
  padding: var(--spacing-base) 0;
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  width: 100%;
}

.path-nav::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.path-nav ol {
  display: flex;
  flex-wrap: nowrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.path-nav li {
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
  max-width: 200px;
}

.path-nav li.current {
  max-width: none;
}

.path-nav li a {
  text-decoration: none;
  border-bottom: none;
  padding: 0 0.25em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted);
}

.path-nav li.current a {
  color: var(--color-text-primary);
  font-weight: bold;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.path-nav a:hover {
  text-decoration: underline;
}

.back-nav {
  margin-bottom: var(--spacing-base);
}

.back-link {
  color: var(--color-text-muted);
  border-bottom: none;
}

.back-link:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

/* Time list */
.time-list ul {
  list-style: none;
  margin-left: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 0;
}

.time-list li {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

@media (max-width: 600px) {
  .time-list ul {
    grid-template-columns: 1fr;
  }

  .time-list time {
    font-size: var(--font-size-small);
  }
}

/* Archive styles */
.archive {
  margin: var(--spacing-base) 0;
}

.archive-year {
  margin: calc(var(--spacing-base) * 1.5) 0 var(--spacing-sm) 0;
  font-size: 1.2em;
  color: var(--color-text-primary);
}

.archive-month {
  margin: var(--spacing-md) 0 var(--spacing-sm) 0;
  font-size: 1.1em;
  color: var(--color-text-muted);
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: var(--gap-small);
  margin: var(--spacing-sm) 0;
  padding-left: 1em;
}

.archive-item time {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  min-width: 2em;
}

.archive-item a {
  font-size: var(--font-size-base);
}

/* Main menu navigation styles */
.terminal-nav {
  font-family: var(--font-family-mono);
  border-top: 1px solid var(--color-border);
  margin-top: calc(var(--spacing-base) * 2);
  padding-top: var(--spacing-base);
}

.terminal-nav nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 1em;
  justify-content: center;
}

.terminal-nav nav ul li {
  display: inline-block;
}

.terminal-nav nav ul li a,
.terminal-nav .back-link {
  color: var(--color-text-muted);
  border-bottom: none;
  text-decoration: none;
}

.terminal-nav nav ul li a:hover,
.terminal-nav .back-link:hover {
  color: var(--color-text-primary);
}

.terminal-nav nav ul li a.active {
  color: var(--color-text-primary);
  font-weight: bold;
}

.terminal-nav .back-nav {
  margin: calc(var(--spacing-base) * 0.5) 0;
}

/* Image styles */
img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: var(--spacing-base) auto;
}

figure {
  margin: var(--spacing-base) 0;
  text-align: center;
}

figure img {
  margin: 0 auto;
}

figcaption {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  margin-top: calc(var(--spacing-base) / 2);
}

/* Table styles */
table {
  width: 100%;
  margin: var(--spacing-base) 0;
  border-collapse: collapse;
}

thead th,
th {
  font-weight: bold;
  text-align: center;
  border-bottom: 2px solid var(--color-border);
  padding: var(--spacing-sm);
}

td {
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border);
}

/* Typography emphasis */
strong {
  font-weight: bold;
}

em {
  font-style: italic;
}

/* Blockquote styles */
blockquote {
  margin: var(--spacing-base) 0;
  padding: var(--spacing-sm) var(--spacing-base);
  border: 1px solid var(--color-border);
  border-radius: var(--pre-border-radius);
  background: var(--color-bg-secondary);
  box-shadow: 0 1px 2px 0 var(--color-border);
  font-style: italic;
}

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

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

/* Table of Contents */
.toc {
  margin: var(--spacing-base) 0;
  padding: var(--spacing-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  border-radius: var(--pre-border-radius);
  box-shadow: 0 1px 2px 0 var(--color-border);
}

.toc .toc-content a {
  text-decoration: none;
  color: var(--color-text-primary);
  font-size: var(--font-size-small);
}

.toc .toc-content ol li {
  list-style-type: disc !important;
}

.time {
  margin: var(--spacing-md) 0;
}

.reading-time,
.lastmod {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

@media (max-width: 600px) {
  .path-nav li {
    max-width: 100px;
  }

  .path-nav li:first-child {
    max-width: none;
  }

  .path-nav li.current {
    max-width: none;
  }
}

@media (max-width: 600px) {
  body {
    padding-top: 2em;
  }

  pre {
    max-width: calc(100vw - 4em);
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
    padding: 0;
    display: block;
  }

  header,
  footer,
  .terminal-nav,
  .skip-link,
  .toc,
  .back-nav {
    display: none !important;
  }

  main {
    max-width: 100%;
  }

  a {
    border-bottom: none;
    color: black;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: gray;
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  pre,
  blockquote,
  img {
    page-break-inside: avoid;
  }

  h1,
  h2,
  h3,
  h4,
  h5 {
    page-break-after: avoid;
  }
}
