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

  /* 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);

  /* Colors - Light Theme */
  --color-bg-primary: hsl(0, 0%, 99%);
  --color-bg-secondary: hsl(0, 0%, 97.3%);
  --color-border: hsl(0, 0%, 93%);
  --color-text-primary: hsl(0, 0%, 9%);
  --color-text-muted: hsl(0, 0%, 43.5%);
  --color-text-code: hsl(0, 0%, 20%);
  --color-selection-bg: hsl(0, 0%, 85.8%);

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

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

/* Dark Theme */
@media (prefers-color-scheme: dark) {
  :root {
    /* Colors - Dark Theme */
    --color-bg-primary: hsl(0, 0%, 8%);
    --color-bg-secondary: hsl(0, 0%, 12%);
    --color-border: hsl(0, 0%, 20%);
    --color-text-primary: hsl(0, 0%, 92%);
    --color-text-muted: hsl(0, 0%, 65%);
    --color-text-code: hsl(0, 0%, 85%);
    --color-selection-bg: hsl(0, 0%, 25%);
  }

  /* Dark theme specific adjustments */
  pre {
    background: hsl(0, 0%, 15%);
  }

  body {
    color: var(--color-text-primary);
  }

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

  h1, h2, h3, h4, h5 {
    color: var(--color-text-primary);
  }

  .path-nav li.current a {
    color: var(--color-text-primary);
  }

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

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

/* Common component styles */
.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);
}

* {
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  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);
  text-align: justify;
}

a {
  display: inline-block;
  margin-left: -0.16666em;
  text-decoration: none;
  border-bottom: 1px dotted;
}

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 {
  /* background: var(--color-bg-secondary); */
  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: nowrap;
}

.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; /* Limit maximum width on small screens */
}

.path-nav li.current {
  max-width: none; /* Allow full width for current page */
}

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

.path-nav li.current a {
  color: var(--color-text-primary);
}

.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;
}

.time-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--gap-base);
  align-items: start;
  padding: var(--spacing-sm) 0;
}

@media (max-width: var(--breakpoint-mobile)) {
  .time-list li {
    grid-template-columns: 1fr;
    gap: var(--gap-small);
  }

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

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

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

.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;
  border-radius: var(--pre-border-radius);
}

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;
}

@media (max-width: 600px) {
  .path-nav li {
    max-width: 100px; /* More aggressive truncation on mobile */
  }

  .path-nav li:first-child {
    max-width: none; /* Don't truncate site title */
  }

  .path-nav li.current {
    max-width: 150px; /* Allow slightly more width for current page on mobile */
  }
}

/* Post list styles */
.post-preview h3::before {
  content: none;
}

/* Post meta styles */
.post-meta {
  margin: calc(var(--spacing-base) * 0.5) 0 var(--spacing-base) 0;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

/* Post navigation styles */
.post-nav {
  margin: calc(var(--spacing-base) * 2) 0;
  padding: var(--spacing-base) 0;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-base);
}

.post-nav-prev {
  flex: 1;
  text-align: left;
}

.post-nav-next {
  flex: 1;
  text-align: right;
}

.post-nav a {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  border-bottom: none;
  text-decoration: none;
}

.post-nav a:hover {
  color: var(--color-text-primary);
}

/* Banner styles */
.banner {
  margin: 0 0 var(--spacing-base) 0;
  text-align: center;
  width: 100%;
}

.banner a {
	border-bottom: none;
}

.banner-image {
  width: min(95ch, 100vw - 4em);
  max-width: 100%;
  height: auto;
  border-radius: var(--pre-border-radius);
  margin: 0 auto;
  display: block;
}

@media (max-width: var(--breakpoint-mobile)) {
  .banner-image {
    width: min(75ch, 100vw - 2em);
  }
}

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

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