/*
 * Wabi Sphinx Theme - A warm, minimal theme inspired by Scandinavian and Japanese aesthetics
 * Named after wabi-sabi - finding beauty in simplicity and imperfection
 * Matches the Hugo Wabi theme exactly for visual consistency
 */

/* ===== CSS Custom Properties ===== */
:root {
  /* Warm color palette - cream, sand, terracotta */
  --color-bg: #faf8f5;
  --color-bg-subtle: #f5f2ed;
  --color-bg-accent: #ebe6de;

  --color-text: #2d2a26;
  --color-text-muted: #6b6560;
  --color-text-subtle: #9a948d;

  --color-accent: #b8574c;
  --color-accent-hover: #a04a40;
  --color-accent-subtle: #d4a59e;

  --color-border: #e5e0d8;
  --color-border-subtle: #ebe6de;

  /* Typography - distinctive, characterful fonts */
  --font-display: "Fraunces", Georgia, serif;  /* Quirky soft serif - headlines */
  --font-body: "Newsreader", Georgia, serif;   /* Elegant editorial serif - reading */
  --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, sans-serif;  /* Warm humanist sans - UI */
  --font-mono: "IBM Plex Mono", Consolas, Monaco, monospace;

  /* Type scale - slightly larger for better reading */
  --text-xs: 0.8rem;
  --text-sm: 0.9rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --text-4xl: 2.75rem;
  --text-5xl: 3.25rem;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --max-width-content: 52rem;
  --max-width-wide: 72rem;
  --max-width-full: 84rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Line heights */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 1.75;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-text);
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}

h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
  margin-bottom: var(--space-6);
  letter-spacing: -0.03em;
}

h2 {
  font-size: var(--text-2xl);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

h3 {
  font-size: var(--text-xl);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h4, h5, h6 {
  font-size: var(--text-lg);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

p {
  margin-bottom: var(--space-5);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

/* Prose links get underlines */
.body a,
.document a,
section a {
  text-decoration: underline;
  text-decoration-color: var(--color-accent-subtle);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.body a:hover,
.document a:hover,
section a:hover {
  text-decoration-color: var(--color-accent);
}

strong, b {
  font-weight: 600;
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container--wide {
  max-width: var(--max-width-wide);
}

.container--full {
  max-width: var(--max-width-full);
}

/* ===== Header & Navigation (matches Hugo Wabi theme exactly) ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border-subtle);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.5rem;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.header__logo {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.header__logo:hover {
  color: var(--color-accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.nav__link {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  position: relative;
}

.nav__link:hover,
.nav__link--active {
  color: var(--color-text);
}

.nav__link--active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--color-accent);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--color-text);
}

.nav-toggle svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-4) 0;
  }

  .nav.is-open {
    display: flex;
  }

  .nav__link {
    padding: var(--space-3) var(--space-6);
    width: 100%;
  }

  .nav__link--active::after {
    display: none;
  }
}

/* ===== Footer ===== */
.footer {
  padding: var(--space-12) 0;
  border-top: 1px solid var(--color-border-subtle);
  background-color: var(--color-bg-subtle);
  margin-top: auto;
}

.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.footer__links {
  display: flex;
  gap: var(--space-6);
}

.footer__link {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.footer__link:hover {
  color: var(--color-text);
}

.footer__copy {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* ===== Main Content Area ===== */
.documentwrapper,
.bodywrapper {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--space-12) var(--space-6) var(--space-20);
}

.body {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  font-optical-sizing: auto;
}

.body > *:first-child {
  margin-top: 0;
}

.body > *:last-child {
  margin-bottom: 0;
}

/* ===== Sphinx-specific overrides ===== */

/* Two-column layout: sidebar + content */
div.document {
  background-color: transparent;
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--max-width-content)) 1fr;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Document wrapper in center column */
div.documentwrapper {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: 0 var(--space-6);
}

/* Clean minimal sidebar - positioned in first column, right-aligned */
div.sphinxsidebar {
  grid-column: 1;
  grid-row: 1;
  padding: var(--space-8) var(--space-6) var(--space-8) var(--space-6);
  display: flex;
  justify-content: flex-end;
}

div.sphinxsidebarwrapper {
  position: sticky;
  top: calc(4.5rem + var(--space-6));
  width: 200px;
  padding-right: var(--space-8);
  border-right: 1px solid var(--color-border-subtle);
}

/* Remove the clearer div interference */
div.clearer {
  display: none;
}

/* Responsive: hide sidebar on small screens */
@media (max-width: 1100px) {
  div.document {
    grid-template-columns: 1fr;
    padding: 0 var(--space-4);
  }

  div.documentwrapper {
    grid-column: 1;
    padding: 0;
  }

  div.sphinxsidebar {
    display: none;
  }
}

/* Hide headerlinks (paragraph symbols) by default, show on hover */
a.headerlink {
  visibility: hidden;
  opacity: 0;
  margin-left: 0.5em;
  font-size: 0.8em;
  color: var(--color-text-subtle);
  text-decoration: none;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

h1:hover a.headerlink,
h2:hover a.headerlink,
h3:hover a.headerlink,
h4:hover a.headerlink,
h5:hover a.headerlink,
h6:hover a.headerlink {
  visibility: visible;
  opacity: 1;
}

a.headerlink:hover {
  color: var(--color-accent);
}

/* ===== Breadcrumbs ===== */
nav.breadcrumbs {
  /* Use same grid as document to align with content column */
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--max-width-content)) 1fr;
  padding: var(--space-4) 0;
}

.breadcrumbs__inner {
  grid-column: 2;
  padding: 0 var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* Responsive breadcrumbs */
@media (max-width: 1100px) {
  nav.breadcrumbs {
    grid-template-columns: 1fr;
    padding: var(--space-4) var(--space-4);
  }

  .breadcrumbs__inner {
    grid-column: 1;
    padding: 0;
  }
}

/* Hide the old related navigation completely */
.related {
  display: none;
}

.breadcrumbs a,
.related a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover,
.related a:hover {
  color: var(--color-accent);
}

.breadcrumbs__separator {
  margin: 0 var(--space-2);
}

/* ===== Lists ===== */
.body ul,
.body ol {
  margin-bottom: var(--space-5);
  padding-left: var(--space-6);
}

.body li {
  margin-bottom: var(--space-2);
}

.body li::marker {
  color: var(--color-text-subtle);
}

/* ===== Blockquotes ===== */
.body blockquote {
  margin: var(--space-8) 0;
  padding: var(--space-5) var(--space-6);
  border-left: 3px solid var(--color-accent-subtle);
  background-color: var(--color-bg-subtle);
  font-style: italic;
  color: var(--color-text-muted);
}

.body blockquote p:last-child {
  margin-bottom: 0;
}

/* ===== Horizontal Rules ===== */
.body hr {
  margin: var(--space-12) 0;
  border: none;
  height: 1px;
  background-color: var(--color-border);
}

/* ===== Images ===== */
.body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: var(--space-6) 0;
}

.body figure {
  margin: var(--space-8) 0;
}

.body figcaption {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-3);
}

/* ===== Tables ===== */
.body table {
  width: 100%;
  margin: var(--space-6) 0;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.body th,
.body td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.body th {
  font-weight: 600;
  background-color: var(--color-bg-subtle);
}

.body tbody tr:hover {
  background-color: var(--color-bg-subtle);
}

/* ===== Code ===== */
.body code,
code,
tt {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-bg-accent);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--color-text);
}

.body pre,
pre {
  margin: var(--space-6) 0;
  padding: var(--space-5);
  background-color: #2d2a26;
  border-radius: 6px;
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.body pre code,
pre code {
  background-color: transparent;
  padding: 0;
  color: #f5f2ed;
  font-size: inherit;
}

/* ===== Syntax Highlighting (Warm theme - matches Wabi) ===== */
.highlight {
  margin: var(--space-6) 0;
  border-radius: 6px;
  overflow: hidden;
}

.highlight pre {
  margin: 0;
  background-color: #2d2a26 !important;
}

/* Pygments token colors - warm palette */
.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs,
.highlight .ch { color: #8a8580; font-style: italic; } /* Comments */

.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr { color: #e9a872; } /* Keywords */

.highlight .kt { color: #d4a59e; } /* Keyword types */

.highlight .n,
.highlight .na,
.highlight .nb,
.highlight .nc,
.highlight .no,
.highlight .nd,
.highlight .ni,
.highlight .ne,
.highlight .nf,
.highlight .nl,
.highlight .nn,
.highlight .nt,
.highlight .nv { color: #f5f2ed; } /* Names */

.highlight .s,
.highlight .sa,
.highlight .sb,
.highlight .sc,
.highlight .dl,
.highlight .sd,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr,
.highlight .s1,
.highlight .ss { color: #a8c97f; } /* Strings */

.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .il,
.highlight .mo { color: #d4a59e; } /* Numbers */

.highlight .o,
.highlight .ow { color: #f5f2ed; } /* Operators */

.highlight .p { color: #f5f2ed; } /* Punctuation */

.highlight .err { color: #e85d5d; } /* Error */

.highlight .hll { background-color: #3d3a36; } /* Highlighted line */

.highlight .linenos,
.highlight .lineno { color: #6b6560; } /* Line numbers */

/* ===== Admonitions (Notes, Warnings, etc.) ===== */
.admonition {
  margin: var(--space-8) 0;
  padding: var(--space-5) var(--space-6);
  border-radius: 6px;
  background-color: var(--color-bg-subtle);
  border-left: 3px solid var(--color-border);
}

.admonition-title {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.admonition.note {
  border-left-color: var(--color-accent-subtle);
}

.admonition.warning {
  border-left-color: #e9a872;
  background-color: rgba(233, 168, 114, 0.1);
}

.admonition.danger,
.admonition.error {
  border-left-color: #e85d5d;
  background-color: rgba(232, 93, 93, 0.1);
}

.admonition.tip,
.admonition.hint {
  border-left-color: #a8c97f;
  background-color: rgba(168, 201, 127, 0.1);
}

.admonition p:last-child {
  margin-bottom: 0;
}

/* ===== Sidebar / Table of Contents ===== */
.sphinxsidebar {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.sphinxsidebar h3 {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  margin-bottom: var(--space-3);
  margin-top: var(--space-6);
}

.sphinxsidebar h3:first-child {
  margin-top: 0;
}

.sphinxsidebar ul {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-4) 0;
}

.sphinxsidebar li {
  margin-bottom: var(--space-1);
}

.sphinxsidebar a {
  color: var(--color-text-muted);
  text-decoration: none;
  display: block;
  padding: var(--space-1) 0;
  transition: color var(--transition-fast);
}

.sphinxsidebar a:hover {
  color: var(--color-text);
}

.sphinxsidebar a.current,
.sphinxsidebar li.current > a {
  color: var(--color-accent);
  font-weight: 500;
}

/* Nested navigation */
.sphinxsidebar ul ul {
  margin-left: var(--space-4);
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
  border-left: 1px solid var(--color-border-subtle);
  padding-left: var(--space-3);
}

.sphinxsidebar ul ul a {
  font-size: var(--text-xs);
}

/* ===== Search Box ===== */
.sphinxsidebar #searchbox {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

.sphinxsidebar #searchbox h3 {
  display: none;
}

.sphinxsidebar input[type="text"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background-color: var(--color-bg);
  color: var(--color-text);
}

.sphinxsidebar input[type="text"]::placeholder {
  color: var(--color-text-subtle);
}

.sphinxsidebar input[type="text"]:focus {
  outline: none;
  border-color: var(--color-accent);
}

.sphinxsidebar input[type="submit"] {
  display: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.btn--primary {
  color: var(--color-bg);
  background-color: var(--color-accent);
}

.btn--primary:hover {
  background-color: var(--color-accent-hover);
  color: var(--color-bg);
}

.btn--outline {
  color: var(--color-accent);
  background-color: transparent;
  border: 1px solid var(--color-accent);
}

.btn--outline:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
}

/* ===== API Documentation ===== */
dl.py.class,
dl.py.function,
dl.py.method,
dl.py.attribute,
dl.py.module {
  margin: var(--space-6) 0;
  padding: var(--space-5);
  background-color: var(--color-bg-subtle);
  border-radius: 6px;
  border-left: 3px solid var(--color-accent-subtle);
}

dl.py dt {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--color-text);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: var(--space-3);
}

dl.py dd {
  margin-left: 0;
  padding-left: var(--space-4);
}

.sig-name {
  color: var(--color-accent);
  font-weight: 600;
}

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

/* ===== Version Added/Changed/Deprecated ===== */
.versionadded,
.versionchanged,
.deprecated {
  font-style: italic;
  color: var(--color-text-muted);
  margin: var(--space-3) 0;
}

/* ===== Footnotes ===== */
.footnote {
  font-size: var(--text-sm);
}

.footnote-reference {
  font-size: 0.75em;
  vertical-align: super;
  color: var(--color-accent);
}

/* ===== Index ===== */
.genindex-jumpbox {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background-color: var(--color-bg-subtle);
  border-radius: 6px;
}

.genindex-jumpbox a {
  margin-right: var(--space-3);
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }

.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Print Styles ===== */
@media print {
  .header,
  .footer,
  .sphinxsidebar {
    display: none;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .body a {
    text-decoration: underline;
  }

  .body a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}
