/* ===== Two-axis theming: color (purple/teal) × mode (light/dark) ===== */

/* Base color = PURPLE (light + dark palettes) */
:root,
.theme-purple {
  /* LIGHT palette (purple) */
  --bg-light: #e8d5f9;
  --text-light: #2d0034;
  --muted-text-light: color-mix(in srgb, var(--text-light) 70%, transparent);

  --accent-light: #7d2da8;
  --accent-contrast-light: #ffffff;
  --accent-hover-light: #7d2da8;

  --border-light: #9c67c2;
  --box-bg-light: #f6e8ff;
  --quote-bg-light: rgba(255,255,255,0.1);
  --code-bg-light: #f3e6fb;
  --code-border-light: #c49aff;
  --heading-light: #7d2da8;
  --heading-underline-light: var(--border-light);
  --alt-text-light: #673a83;

  /* DARK palette (purple) */
  --bg-dark: #1a0e1f;
  --text-dark: #f1e6f6;
  --muted-text-dark: color-mix(in srgb, var(--text-dark) 60%, transparent);

  --accent-dark: #ccabd6;
  --accent-contrast-dark: #1a0e1f;
  --accent-hover-dark: #b494c0;

  --border-dark: #8a5cab;
  --box-bg-dark: #2a1633;
  --quote-bg-dark: rgba(255,255,255,0.06);
  --code-bg-dark: #2a1633;
  --code-border-dark: #764b92;
  --heading-dark: #ccabd6;
  --heading-underline-dark: var(--border-dark);
  --alt-text-dark: #ccabd6;
}

/* Alternate color = TEAL (light + dark palettes) */
.theme-teal {
  /* LIGHT palette (teal) */
  --bg-light: #e9fcfa;
  --text-light: #022f2f;
  --muted-text-light: color-mix(in srgb, var(--text-light) 70%, transparent);

  --accent-light: #024e4e;
  --accent-contrast-light: #ffffff;
  --accent-hover-light: #013d3d;

  --border-light: #4a8b8b;
  --box-bg-light: #f1fffd;
  --quote-bg-light: rgba(0,0,0,0.04);
  --code-bg-light: #edfbf8;
  --code-border-light: #b6e4df;
  --heading-light: #024e4e;
  --heading-underline-light: var(--border-light);
  --alt-text-light: #205a5a;

  /* DARK palette (teal) */
  --bg-dark: #031c1c;
  --text-dark: #e6fbfb;
  --muted-text-dark: color-mix(in srgb, var(--text-dark) 60%, transparent);

  --accent-dark: #5fd0c8;
  --accent-contrast-dark: #031c1c;
  --accent-hover-dark: #4cb8b1;

  --border-dark: #347f7f;
  --box-bg-dark: #0b2626;
  --quote-bg-dark: rgba(255,255,255,0.06);
  --code-bg-dark: #0b2626;
  --code-border-dark: #2c6b6b;
  --heading-dark: #5fd0c8;
  --heading-underline-dark: var(--border-dark);
  --alt-text-dark: #9dddda;
}

/* Map the ACTIVE tokens to either light or dark palette */
:root {
  /* default mode = light */
  --bg: var(--bg-light);
  --text: var(--text-light);
  --muted-text: var(--muted-text-light);

  --accent: var(--accent-light);
  --accent-contrast: var(--accent-contrast-light);
  --accent-hover: var(--accent-hover-light);

  --border: var(--border-light);
  --box-bg: var(--box-bg-light);
  --quote-bg: var(--quote-bg-light);
  --code-bg: var(--code-bg-light);
  --code-border: var(--code-border-light);
  --heading: var(--heading-light);
  --heading-underline: var(--heading-underline-light);
  --alt-text: var(--alt-text-light);
}

/* When .mode-dark is present, swap to dark palette (for whichever color theme is active) */
.mode-dark {
  --bg: var(--bg-dark);
  --text: var(--text-dark);
  --muted-text: var(--muted-text-dark);

  --accent: var(--accent-dark);
  --accent-contrast: var(--accent-contrast-dark);
  --accent-hover: var(--accent-hover-dark);

  --border: var(--border-dark);
  --box-bg: var(--box-bg-dark);
  --quote-bg: var(--quote-bg-dark);
  --code-bg: var(--code-bg-dark);
  --code-border: var(--code-border-dark);
  --heading: var(--heading-dark);
  --heading-underline: var(--heading-underline-dark);
  --alt-text: var(--alt-text-dark);
}

/* =======================================
   BASE / LAYOUT / COMPONENTS (tokenized)
   ======================================= */

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: Consolas, 'Lucida Console', Monaco, monospace;
  font-size: 18px;
  line-height: 1.6;
  padding: 2rem;
  padding-top: 0.5rem;
}

main, .site-container { max-width: 640px; margin: 0 auto; }
.main, .item { padding: 0; }

.header { position: relative; z-index: 1; overflow: visible !important; }

/* === Sticky Nav === */
nav, .nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg);
  border-bottom: 1px dashed var(--border);
  padding: 0.5rem 0;
}

.theme-btn {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 2px dashed var(--border);
  padding: .35rem .6rem;
  font: inherit;
  border-radius: 4px;
  cursor: pointer;
}
.theme-btn:hover, .theme-btn:focus-visible {
  background: var(--accent-hover);
  outline: none;
}

/* === Links === */
a {
  color: var(--accent);
  text-decoration: underline dotted;
}
a:hover {
  color: var(--accent-contrast);
  background-color: var(--accent);
  padding: 0 2px;
}

/* Icons (inline SVG helpers) */
.meta-svg { display: inline-block; line-height: 0; vertical-align: 0.5em; }
.text-muted .meta-svg svg { opacity: .7; }

/* === Nav Links & Dropdown === */
.nav-links .nav-item {
  display: inline-block;
  position: relative;
  max-width: 640px;
  margin-right: 0.5em;
}

.nav-links .nav-item summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
}

/* Dropdown menu */
.nav-links .nav-item .dropdown {
  display: none !important;
  z-index: 9999;
  position: absolute;
  max-width: 640px;
  top: 100%;
  left: 0;
  margin: 0.5em 0;
  padding: 0.5em;
  background: var(--bg);
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
  list-style: none;
}
.nav-links .nav-item[open] .dropdown { display: block !important; }
.nav-links .nav-item .dropdown li { margin: 0; }
.nav-sep { margin: 0 0.5em; }

/* === Collapsible Mobile Menu Button === */
.nav-toggle {
  display: none; /* Hidden on desktop */
  width: 100%;
  background: var(--accent);
  color: var(--accent-contrast);
  border: 2px dashed var(--border);
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-family: Consolas, 'Lucida Console', Monaco, monospace;
  text-align: left;
  cursor: pointer;
}
.nav-toggle:hover {
  background: var(--accent-hover);
  color: var(--accent-contrast);
}

/* === Menu Wrapper === */
#site-menu {
  display: flex;            /* always visible on desktop */
  box-sizing: border-box;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.5rem;
}
#site-menu a {
  color: var(--accent);
  text-decoration: underline dotted;
  flex-shrink: 1;
  min-width: 0;
}
#site-menu a:hover {
  color: var(--accent-contrast);
  background-color: var(--accent);
  padding: 0 2px;
}

/* === Mobile Styles === */
@media (max-width: 640px) {
  .nav-toggle { display: block; margin-bottom: 0.25rem; }
  #site-menu { flex-direction: row; display: none; }
  #site-menu.show { flex-direction: column; display: flex; }
  #site-menu a { padding: 0.5rem 0; border-bottom: 1px dashed var(--border); }
  #site-menu a:last-child { border-bottom: none; }
  #site-menu .nav-sep { display: none; }
}

/* === SUMMARY LAYOUT === */
.nav-links .nav-item summary {
  display: inline-flex; align-items: center;
}
.nav-links .nav-item summary::-webkit-details-marker { display: none; }
.nav-links .nav-item summary::marker { display: none; }

/* === ARROW STYLING === */
.nav-toggle-child {
  background-color: inherit;
  border: none;
  color: var(--text);
  padding: 0;
  margin-right: 0.35em;
  font-size: 1.1em;
  line-height: 1;
  cursor: pointer;
}
.nav-toggle-child::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
}
.nav-item[open] summary > .nav-toggle-child::before { transform: rotate(90deg); }

/* === Headings & Titles === */
header h1 { margin-top: 0; }
p.subtitle { margin-top: 0; margin-bottom: 0; }
div.e-content { margin-top: 0.6em; padding-top: 0; padding-bottom: 0; }
.h-feed h1.p-name { margin: 0.1em; }

article.h-entry h1.p-name { font-size: x-large; color: var(--heading); }

h1, h2, h3, h4, h5 {
  font-family: Consolas, 'Lucida Console', Monaco, monospace;
  color: var(--heading);
  border-bottom: 1px dashed var(--heading-underline);
  padding-bottom: 0;
  margin-top: 0.4em;
  margin-bottom: 0.1em;
}
.h1 { font-size: 40px; font-weight: bold; line-height: 1.2; margin: 0.3em 0; }
.h2 { font-size: 32px; font-weight: bold; line-height: 1.3; margin: 0.3em 0; }
.h3 { font-size: 28px; font-weight: bold; line-height: 1.3; margin: 0.3em 0; }
.h4 { font-size: 24px; font-weight: bold; line-height: 1.4; margin: 0.3em 0; }
.h5 { font-size: 20px; font-weight: bold; line-height: 1.4; margin: 0.3em 0; }
.h6 { font-size: 16px; font-weight: bold; line-height: 1.5; margin: 0.3em 0; }

/* === Lists === */
ul, ol { padding-left: 2em; }
.journal-list { list-style: none; padding-left: 0; }
.journal-list li { margin: 0.5em 0; }

strong {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,0.2);
  font-style: bold;
  padding: 0 0.2em;
  border-radius: 2px;
}

.datetime, small, .p-author, .dt-published { color: var(--muted-text); }
p.p-author, .published { margin-block-start: 0.2em; margin-block-end: 0.2em; }

/* === Quotes & Code === */
blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1em;
  color: var(--alt-text);
  background: var(--quote-bg);
}
code {
  background-color: var(--code-bg);
  padding: 0.2em 0.4em;
  border: 1px solid var(--code-border);
  font-size: 90%;
}
pre {
  background-color: var(--code-bg);
  padding: 1em;
  overflow-x: auto;
  border: 1px solid var(--code-border);
}

/* === Images === */
.small-photo { max-width: 200px; height: auto; border-radius: 8px; }

/* === Boxed Sections === */
aside, .box, .notice {
  background-color: var(--box-bg);
  border: 1px solid var(--border);
  padding: 1rem;
  margin-bottom: 2rem;
  color: var(--text);
}

/* === StatusCafe formats === */
#statuscafe {
  padding: .5em;
  background-color: var(--bg);
  border: 1px solid var(--text);
}
#statuscafe-username { margin-bottom: .5em; }
#statuscafe-content { margin: 0 1em 0.5em 1em; }

/* === Footer === */
footer {
  margin-top: 1rem;
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
  color: var(--alt-text);
  font-size: 14px;
}
.postend { font-size: 14px; }

/* === Horizontal Rule === */
hr {
  border: none;
  border-top: 1px solid var(--text);
  width: 100%;
  margin: 2em auto;
}