/* ========================================================================
   Ertius Blog CSS - Blog-specific styles for ertius.org
   Extracted from /Users/rob/src/web/themes/mine/sass/style.scss
   ======================================================================== */

/* ========================================================================
   Blog Header & Navigation
   ======================================================================== */
header {
  margin-bottom: 0;
}

header nav {
  display: flex;
  gap: 0.2em;
}

header nav a {
  padding: 0.1em 0.3em;
  color: inherit;
  text-decoration: none;
}

header nav a.active {
  background-color: #000;
  color: #fff;
}

header nav a:hover:not(.active) {
  text-decoration: underline;
}

header a {
  color: inherit;
  text-decoration: none;
}

header a:hover {
  text-decoration: underline;
}

/* ========================================================================
   Main Content & Article Layout
   ======================================================================== */
main {
  width: 100%;
  max-width: 100%;
}

article {
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  padding-top: var(--space-md);
  padding-bottom: var(--space-lg);
}

article pre {
  overflow-x: auto;
  max-width: 100%;
}

article img {
  max-width: 100%;
  height: auto;
}

article a {
  text-decoration: underline;
}

article ol > li {
  list-style: square;
}

/* ========================================================================
   Typography Refinements
   ======================================================================== */
h1.title {
  border-bottom: 1px solid #000;
  margin-bottom: 0;
  margin-top: 0.5em;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  font-size: 150%;
  width: 100%;
  text-align: left;
}

h2 {
  font-size: 1.5em;
  line-height: 1.4;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  font-weight: bold;
}

h3 {
  font-size: 1.25em;
  line-height: 1.4;
  margin-top: 1.3em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

h4 {
  font-size: 1.1em;
  line-height: 1.5;
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  font-weight: 600;
}

h5,
h6 {
  font-size: 1em;
  line-height: 1.5;
  margin-top: 1em;
  margin-bottom: 0.3em;
  font-weight: 600;
  font-style: italic;
}

main > article p {
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  text-rendering: optimizeLegibility;
  line-height: 1.65;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  text-justify: inter-word;
  text-wrap: pretty;
  margin-bottom: 1.2em;
  text-align: justify;
}

/* ========================================================================
   Anchor Links
   ======================================================================== */
article h2,
article h3,
article h4,
article h5,
article h6 {
  position: relative;
}

article h2 .zola-anchor,
article h3 .zola-anchor,
article h4 .zola-anchor,
article h5 .zola-anchor,
article h6 .zola-anchor {
  position: absolute;
  left: -1.5em;
  text-decoration: none;
  color: #666;
  font-weight: normal;
  opacity: 0;
  transition: opacity 0.2s;
}

article h2:hover .zola-anchor,
article h3:hover .zola-anchor,
article h4:hover .zola-anchor,
article h5:hover .zola-anchor,
article h6:hover .zola-anchor {
  opacity: 1;
}

/* ========================================================================
   Table of Contents
   ======================================================================== */
div.toc-container ul.toc-list {
  padding-left: 0;
  margin: 0;
  list-style: none;
}

div.toc-container ul {
  margin: 0;
  padding-top: 0;
  list-style: none;
}

div.toc-container ul li::before {
  content: none;
}

div.toc-container ul a {
  color: #666;
  text-decoration: none;
  font-size: 0.75em;
  line-height: 1.4;
  transition: all 0.2s ease;
}

div.toc-container ul a:hover {
  color: #000;
  text-decoration: underline;
}

div.toc-container ul a.active {
  color: #000;
  font-weight: bold;
}

div.toc-container ul li.toc-top {
  margin-bottom: 0.5em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid #eee;
}

div.toc-container ul li.toc-top a {
  color: #000;
  font-weight: 600;
}

div.toc-container ul ul {
  padding-left: 0.8em;
  margin-top: 0;
}

/* Mobile: Collapsible TOC */
@media only screen and (max-width: 1199px) {
  div.toc-container {
    border: 3px solid #000;
    margin: var(--space-md) 0;
    background: #fff;
  }

  div.toc-container li.toc-top {
    display: none;
  }

  div.toc-container .toc-toggle {
    display: none;
    background: #000;
    color: #fff;
    border: none;
    padding: 0.5em var(--space-md);
    /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
    font-family: monospace, monospace;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    width: 100%;
    text-align: left;
    position: relative;
  }

  div.toc-container .toc-toggle:hover {
    background: #555;
  }

  div.toc-container .toc-toggle:focus {
    outline: 3px solid #fff;
    outline-offset: -3px;
  }

  div.toc-container .toc-toggle::after {
    content: "▼";
    position: absolute;
    right: var(--space-md);
    transition: transform 0.3s ease;
  }

  div.toc-container .toc-toggle.collapsed::after {
    transform: rotate(-90deg);
  }

  div.toc-container .toc-content {
    padding: 0 var(--space-md) var(--space-md) var(--space-md);
    max-height: 50vh;
    overflow-y: auto;
  }

  div.toc-container.toc-collapsible .toc-toggle {
    display: block;
  }

  div.toc-container.toc-collapsible.toc-collapsed .toc-content {
    display: none;
  }
}

/* Desktop: Fixed sidebar TOC */
@media only screen and (min-width: 1200px) {
  div.toc-container {
    position: fixed;
    left: calc(50% + 60ch + 0.5rem);
    top: 7.5rem;
    max-width: calc(50vw - 40ch - 1rem);
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    padding: 0;
    border: none;
  }

  div.toc-container .toc-toggle {
    /* biome-ignore lint/complexity/noImportantStyles: Required to override mobile styles in desktop view */
    display: none !important;
  }

  div.toc-container .toc-content {
    padding: 0;
    max-height: none;
    overflow-y: visible;
  }

  div.toc-container a {
    white-space: nowrap;
  }
}

/* ========================================================================
   Post Lists
   ======================================================================== */
ul.posts {
  list-style: none;
  margin: var(--space-md) 0 0 0;
  padding: 0;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  line-height: 1.4;
  /* Disable auto two-column layout for post listings */
  /* biome-ignore lint/complexity/noImportantStyles: Required to override base multi-column list styles */
  columns: auto !important;
  /* biome-ignore lint/complexity/noImportantStyles: Required to override base multi-column list styles */
  -webkit-columns: auto !important;
  /* biome-ignore lint/complexity/noImportantStyles: Required to override base multi-column list styles */
  -moz-columns: auto !important;
}

ul.posts li {
  padding: 0;
  display: flex;
  gap: 0.5em;
}

ul.posts li::before {
  content: none;
}

ul.posts a {
  text-decoration: underline;
}

ul.posts li.draft {
  border-left: 3px solid #cc0000;
  padding-left: 0.5em;
}

/* ========================================================================
   Code Blocks
   ======================================================================== */
code {
  background-color: #f0f0f0;
  border: 1px solid #e5e5e5;
  padding: 0.1em 0.3em;
  font-size: 0.9em;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  display: inline-block;
  line-height: 1.2;
  vertical-align: baseline;
}

pre {
  background-color: #fff;
  border: 3px solid #000;
  padding: 0;
  overflow-x: auto;
  line-height: 1.4;
  position: relative;
  margin: 1.5em 0;
}

pre code {
  background-color: transparent;
  border: none;
  padding: 0.8em 0.5em;
  font-size: 0.85em;
  display: block;
}

/* Code header bar */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #000;
  color: #fff;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  font-size: 0.7em;
  font-weight: bold;
  text-transform: uppercase;
  border-bottom: 3px solid #000;
}

.code-lang {
  padding: 0.3em 0.8em;
  pointer-events: none;
}

.copy-btn {
  background: #000;
  border: none;
  border-left: 3px solid #fff;
  color: #fff;
  padding: 0.3em 0.8em;
  font-size: 1em;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.copy-btn:hover {
  background-color: #fff;
  color: #000;
}

.copy-btn:focus {
  outline: 3px solid #fff;
  outline-offset: -3px;
  background-color: #fff;
  color: #000;
}

.copy-btn:focus:not(:focus-visible) {
  outline: none;
}

.copy-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -3px;
  background-color: #fff;
  color: #000;
}

.copy-btn:active {
  transform: scale(0.95);
}

/* ========================================================================
   Tags & Metadata
   ======================================================================== */
.post-tag,
.tag {
  display: inline-block;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  font-size: 0.85em;
  border-radius: 3px;
  text-decoration: none;
  color: #545454;
}

.post-tag:hover,
.tag:hover {
  background-color: #000;
  color: #fff;
  text-decoration: none;
}

.metadata {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  width: 100%;
  padding-top: 0.3em;
  margin-bottom: 1em;
}

.metadata time {
  display: inline-block;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  font-size: 85%;
  white-space: nowrap;
  flex-shrink: 0;
}

.metadata .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  flex-grow: 1;
  justify-content: flex-end;
  min-width: 0;
}

.post-type {
  font-size: 0.75em;
  color: #666;
  /* biome-ignore lint/suspicious/noDuplicateFontNames: Deliberate workaround for browser bug - https://github.com/necolas/normalize.css/issues/519 */
  font-family: monospace, monospace;
  margin-left: 0.5em;
}

.list-tags {
  margin-top: 0.1em;
}

.list-tags .tag {
  font-size: 0.75em;
  margin-right: 0.3em;
}

/* ========================================================================
   Draft Posts
   ======================================================================== */
.draft-label {
  background-color: #cc0000;
  color: #fff;
  padding: 0.2em 0.5em;
  font-size: 0.7em;
  font-weight: bold;
  text-transform: uppercase;
  border-radius: 3px;
  float: right;
  margin-left: 0.5em;
  vertical-align: middle;
}

article.draft {
  border: 2px dashed #cc0000;
  padding: var(--space-md);
}

div.meta {
  font-size: 75%;
}

div.page-header {
  margin-bottom: 0;
}

/* ========================================================================
   Footnotes
   ======================================================================== */
.footnote-definition {
  display: flex;
  margin: 0.5em 0;
  font-size: 0.9em;
  list-style: none;
}

.footnote-definition sup {
  min-width: 1.5em;
  margin-right: 0.5em;
}

.footnote-definition sup::after {
  content: ":";
}

.footnote-definition p {
  margin: 0;
  display: inline;
}

sup.footnote-reference {
  font-size: 0.8em;
  vertical-align: super;
}

/* ========================================================================
   Aside Notes
   ======================================================================== */
aside.note {
  margin-top: 0.5em;
  border-width: 3px;
  border-radius: 0;
  border-style: solid;
  vertical-align: middle;
  position: relative;
  padding-left: 1.5em;
  overflow: hidden;
  display: flex;
  align-items: center;

  --border: purple;
  --background: silver;
  --info: green;
  --info_back: #d4f4d4;
  --warning: orange;
  --warning_back: #ffd580;
  --alert: red;
  --alert_back: #ffd5d5;

  border-color: var(--border);
  background-color: var(--background);
}

aside.note::before {
  content: attr(data-title);
  position: absolute;
  left: 0;
  top: -3px;
  bottom: -3px;
  width: 1.8em;
  background-color: var(--border);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: var(--space-md) 0;
  box-sizing: border-box;
}

aside.note p {
  margin: 0;
  /* biome-ignore lint/complexity/noImportantStyles: Required to override article p margin styles */
  margin-top: 0 !important;
  padding: var(--space-md) 0.5em var(--space-md) 0.3em;
  font-size: smaller;
}

aside.note p.title,
aside.note h2 {
  color: #fff;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  margin: 0;
  background-color: var(--border);
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.8em;
  padding: var(--space-md) 0;
  font-weight: 100;
  font-family: monospace;
  font-size: 0.9em;
  line-height: 1.5;
  border-right: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

aside.note h2::before {
  content: "";
}

/* ========================================================================
   Lists (override base)
   ======================================================================== */
main .home-content > ul,
main article > ul:not(.toc-list):not(.posts) {
  list-style: none;
  padding-left: 0;
  margin: 1.5em 0;
}

main .home-content > ul > li,
main article > ul:not(.toc-list):not(.posts) > li {
  position: relative;
  padding-left: 1.8em;
  margin-bottom: 0.6em;
  line-height: 1.5;
}

main .home-content > ul > li::before,
main article > ul:not(.toc-list):not(.posts) > li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: #000;
  font-weight: bold;
  font-size: 1.1em;
}

/* ========================================================================
   Responsive
   ======================================================================== */
@media only screen and (max-width: 120ch) {
  body {
    max-width: 100%;
    padding: 0 0.5rem;
  }

  .code-header {
    position: sticky;
    left: 0;
    right: 0;
    z-index: 1;
    font-size: 0.6em;
  }

  .code-lang,
  .copy-btn {
    padding: 0.2em 0.6em;
  }

  h1.title {
    font-size: large;
  }
}

/* ========================================================================
   Error Pages
   ======================================================================== */
.error-content {
  text-align: center;
  margin: var(--space-lg) 0;
}

.error-content p {
  font-size: 1.1em;
  margin-bottom: var(--space-md);
}

/* ========================================================================
   Dark Mode
   ======================================================================== */
:root.dark {
  /* Base colors - warm dark theme */
  --color-bg: oklch(18% 0.005 30); /* #1c1917 warm dark */
  --color-text: oklch(91% 0.005 30); /* #e7e5e4 warm light */
  --color-text-muted: oklch(64% 0.008 30); /* #a8a29e warm medium */
  --color-text-subtle: oklch(50% 0.01 30); /* #78716c warm darker */
  --color-text-faint: oklch(37% 0.01 30); /* #57534e warm very dark */
  --color-primary: oklch(91% 0.005 30); /* light for dark mode */
  --color-primary-inverse: oklch(18% 0.005 30);
  --color-border: oklch(30% 0.008 30); /* #44403c warm medium-dark */
  --color-bg-hover: oklch(22% 0.005 30); /* #292524 slightly lighter */
  --color-bg-subtle: oklch(22% 0.005 30); /* for boxes */

  /* Links - light blue for visibility */
  --color-link: oklch(75% 0.12 240); /* #93c5fd light blue */
  --color-link-hover: oklch(70% 0.15 240); /* #60a5fa brighter blue */
}

/* Dark mode link colors */
:root.dark a {
  color: var(--color-link);
}

:root.dark a:hover {
  color: var(--color-link-hover);
}

/* Dark mode code blocks */
:root.dark .code-block {
  background: oklch(15% 0.005 30);
  border-color: var(--color-border);
}

:root.dark .code-header {
  background: oklch(20% 0.005 30);
  border-bottom-color: var(--color-border);
}

/* Dark mode navigation */
:root.dark nav a:hover {
  background: var(--color-bg-hover);
}

/* Dark Mode Toggle Button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.theme-toggle:hover {
  opacity: 1;
}

.theme-toggle svg {
  display: block;
}

/* Show sun in dark mode, moon in light mode */
:root .theme-icon-dark {
  display: none;
}

:root.dark .theme-icon-light {
  display: none;
}

:root.dark .theme-icon-dark {
  display: inline;
}
