:root {
  color-scheme: light;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 84px;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-alt: #e7edf4;
  --text: #142033;
  --muted: #56627a;
  --accent: #0a7c66;
  --accent-strong: #075c4c;
  --border: #c8d2df;
  --max-width: 1040px;
  --radius: 16px;
  --shadow: 0 10px 24px rgba(20, 32, 51, 0.08);
  --bg-spot-a: #d4f3ec;
  --bg-spot-b: #e0ebff;
  --header-bg: rgba(242, 244, 248, 0.88);
  --footer-bg: rgba(231, 237, 244, 0.55);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-alt: #e7edf4;
  --text: #142033;
  --muted: #56627a;
  --accent: #0a7c66;
  --accent-strong: #075c4c;
  --border: #c8d2df;
  --shadow: 0 10px 24px rgba(20, 32, 51, 0.08);
  --bg-spot-a: #d4f3ec;
  --bg-spot-b: #e0ebff;
  --header-bg: rgba(242, 244, 248, 0.88);
  --footer-bg: rgba(231, 237, 244, 0.55);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1420;
  --surface: #121b2a;
  --surface-alt: #1a2639;
  --text: #e7edf7;
  --muted: #a9b7cb;
  --accent: #38b597;
  --accent-strong: #59d7b8;
  --border: #2b3a51;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  --bg-spot-a: #10322c;
  --bg-spot-b: #1a2f4f;
  --header-bg: rgba(13, 20, 32, 0.86);
  --footer-bg: rgba(18, 27, 42, 0.75);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1420;
    --surface: #121b2a;
    --surface-alt: #1a2639;
    --text: #e7edf7;
    --muted: #a9b7cb;
    --accent: #38b597;
    --accent-strong: #59d7b8;
    --border: #2b3a51;
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
    --bg-spot-a: #10322c;
    --bg-spot-b: #1a2f4f;
    --header-bg: rgba(13, 20, 32, 0.86);
    --footer-bg: rgba(18, 27, 42, 0.75);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  padding-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 15% -10%, var(--bg-spot-a) 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, var(--bg-spot-b) 0%, transparent 35%),
    var(--bg);
  line-height: 1.65;
  transition: padding-left 180ms ease;
}

main {
  flex: 1;
}

body.nav-collapsed {
  padding-left: var(--sidebar-collapsed-width);
}

h1,
h2,
h3 {
  margin-top: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  margin-bottom: 0.8rem;
}

h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 0.08em;
}

a:hover {
  text-decoration-thickness: 0.14em;
}

.container {
  width: min(92%, var(--max-width));
  margin: 0 auto;
}

.site-header {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(10px);
  background: var(--header-bg);
  z-index: 10;
  transition: width 180ms ease;
}

body.nav-collapsed .site-header {
  width: var(--sidebar-collapsed-width);
}

.site-header .container {
  width: 100%;
  margin: 0;
  padding: 1rem;
}

.nav-wrap {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 1rem;
  height: 100%;
  padding: 0;
  position: relative;
}

.nav-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  flex: 1;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0.2rem;
  right: -20px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  cursor: pointer;
  z-index: 12;
}

.menu-toggle:hover {
  border-color: var(--accent);
}

.menu-toggle::before {
  content: "\2630";
  line-height: 1;
}

.menu-toggle[aria-expanded="true"]::before {
  content: "\2715";
  font-size: 0.9rem;
}

.nav-scrim {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(8, 16, 28, 0.3);
  z-index: 9;
  cursor: pointer;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}

.nav-list a {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
}

.nav-list a[aria-current="page"] {
  background: var(--surface-alt);
  color: var(--accent-strong);
}

.nav-controls nav {
  display: none;
}

.nav-controls.is-open nav {
  display: block;
}

body.nav-collapsed .brand {
  font-size: 0;
  margin-bottom: 0;
}

body.nav-collapsed .brand::after {
  content: "SRE";
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

body.nav-collapsed .theme-toggle {
  display: none;
}

body.nav-collapsed .nav-wrap {
  gap: 0;
}

.nav-divider {
  margin-top: 0.35rem;
  padding: 0.35rem 0.6rem 0.1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Hierarchical blog submenu */
.nav-submenu {
  list-style: none;
  margin: 0.15rem 0 0 0.75rem;
  padding: 0;
}

.nav-submenu details {
  margin: 0;
}

.nav-submenu summary.nav-submonth {
  cursor: pointer;
  list-style: none;
  padding: 0.2rem 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}

.nav-submenu summary.nav-submonth::-webkit-details-marker {
  display: none;
}

.nav-submenu summary.nav-submonth::before {
  content: "\25B8\00A0";
  font-size: 0.65em;
}

.nav-submenu details[open] > summary.nav-submonth::before {
  content: "\25BE\00A0";
}

.nav-submenu summary.nav-submonth:hover {
  color: var(--text);
}

.nav-submenu-posts {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.5rem;
}

.nav-submenu-posts a {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: auto;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle::before {
  content: "\25CC";
  font-size: 0.9rem;
  line-height: 1;
}

.theme-toggle[data-theme-mode="light"]::before {
  content: "\2600";
}

.theme-toggle[data-theme-mode="dark"]::before {
  content: "\263D";
}

.theme-toggle[data-theme-mode="system"]::before {
  content: "\25CC";
}

.hero {
  padding: 5rem 0 3rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.intro {
  max-width: 74ch;
  color: var(--muted);
}

.hero-actions {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  display: inline-block;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  text-decoration: none;
  font-weight: 500;
  border: 1px solid transparent;
}

.button.primary {
  color: #fff;
  background: var(--accent);
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.ghost {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}

.section {
  padding: 2rem 0 4rem;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.card,
.post-card,
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card,
.post-card {
  padding: 1.2rem;
}

.article {
  padding: 1.5rem;
}

.clean-list {
  margin: 0;
  padding-left: 1rem;
}

.resume-entry {
  display: grid;
  gap: 0.5rem;
}

.resume-entry-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
}

.resume-entry-header strong {
  font-size: 1.05rem;
}

.posts {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.blog-tools {
  display: grid;
  gap: 0.4rem;
  margin: 1rem 0;
}

.search-input {
  width: min(100%, 460px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-family: "Space Grotesk", sans-serif;
}

.search-input:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.blog-archive {
  display: grid;
  gap: 1rem;
}

.archive-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.2rem;
}

.archive-month {
  margin-bottom: 0.6rem;
  font-size: 1rem;
  color: var(--muted);
}

.archive-post-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.35rem;
}

.archive-post-item a {
  color: var(--text);
}

.post-question-card {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.post-question-card h2 {
  margin-bottom: 0.4rem;
  font-size: 1.2rem;
}

.post-question-card p {
  margin: 0.45rem 0;
}

.ask-question-link {
  color: var(--accent-strong);
  font-weight: 500;
  text-decoration: underline;
}

.post-switcher {
  margin-top: 1.2rem;
}

.post-jump-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.small {
  font-size: 0.86rem;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--footer-bg);
}

.footer-wrap {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
}

.fade-up {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeUp 700ms ease forwards;
}

.fade-up:nth-of-type(2) {
  animation-delay: 120ms;
}

.fade-up:nth-of-type(3) {
  animation-delay: 220ms;
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: min(86vw, 300px);
    --sidebar-collapsed-width: 12px;
  }

  body {
    padding-left: var(--sidebar-collapsed-width);
  }

  .site-header {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  }

  .site-header .container {
    width: 100%;
    margin: 0;
    padding: 1rem;
  }

  .nav-wrap {
    flex-direction: column;
    align-items: stretch;
    height: 100%;
    padding: 0;
  }

  .nav-controls {
    width: 100%;
    align-items: stretch;
    flex: 1;
  }

  body.nav-collapsed .site-header {
    backdrop-filter: none;
    background: transparent;
    box-shadow: none;
  }

  body.nav-collapsed .site-header .container {
    padding: 0;
  }

  body.nav-collapsed .brand::after {
    content: "";
  }

  .theme-toggle {
    margin-top: auto;
  }

  .nav-list {
    flex-direction: column;
    gap: 0.35rem;
    padding-top: 0;
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .footer-wrap {
    flex-direction: column;
    align-items: flex-start;
  }
}
