/* Eidola website styles. Palette variables (--background, --foreground, …)
 * come from the generated /assets/circadian.css — see
 * crates/eidola-www/src/circadian.rs, which ports the app's theme.rs.
 *
 * Typography mirrors the app's book metaphor (crates/eidola-gui/src/
 * space_view/mod.rs): Newsreader prose at 17px/1.65 on a 600px measure,
 * a flat heading ramp where weight carries hierarchy, hairline
 * separators, no cards. UI chrome uses the system font at 14px. */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/assets/fonts/newsreader-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/assets/fonts/newsreader-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(/assets/fonts/newsreader-vietnamese.woff2) format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(/assets/fonts/newsreader-italic-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(/assets/fonts/newsreader-italic-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url(/assets/fonts/newsreader-italic-vietnamese.woff2) format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* The palette shifts a handful of times a day; crossfade it like a slow
 * change of light rather than snapping. Gated on .circadian-ready (set by
 * circadian.js after the first resolve) so initial paint doesn't animate. */
@media (prefers-reduced-motion: no-preference) {
  :root.circadian-ready body,
  :root.circadian-ready .site-header,
  :root.circadian-ready a,
  :root.circadian-ready pre,
  :root.circadian-ready code,
  :root.circadian-ready blockquote,
  :root.circadian-ready blockquote::before,
  :root.circadian-ready td,
  :root.circadian-ready th,
  :root.circadian-ready hr,
  :root.circadian-ready button {
    transition:
      background-color 0.4s ease,
      color 0.4s ease,
      border-color 0.4s ease;
  }
}

::selection {
  background: color-mix(in srgb, var(--selection) 30%, transparent);
}

/* --- Chrome: the transparent title band ------------------------------- */
/* Mirrors the app's title bar: no border, no box — a background-to-
 * transparent fade that content scrolls under (space_view's title band). */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 24px 24px;
  background: linear-gradient(180deg, var(--background) 0%, var(--background) 55%, transparent 100%);
}

.wordmark {
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 19px;
  font-weight: 600;
  color: var(--foreground);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  gap: 20px;
}

.site-header nav a {
  color: var(--muted-foreground);
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a.active {
  color: var(--foreground);
}

/* --- The page grid ------------------------------------------------------ */
/* Mirrors the app's symmetric page geometry: [gutter | reading column |
 * gutter]. The reading column stays centered on every page; docs pages
 * put the sidebar in the left gutter (and the in-page ToC in the right),
 * so the measure never shifts between sections. */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr min(648px, 100%) 1fr;
}

.layout > main {
  grid-column: 2;
}

/* --- The reading column ------------------------------------------------ */

main.prose {
  width: 100%;
  padding: 24px 24px 96px;
  font-family: "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: 1.65;
}

/* Block rhythm: the app's 1.5rem paragraph gap, split half above and
 * half below each block. Headings get extra space above — the one
 * deliberate deviation, for scannable docs. */
.prose p,
.prose ul,
.prose ol,
.prose pre,
.prose blockquote,
.prose table {
  margin: 1.5rem 0;
}

.prose li {
    margin: 0.75rem 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 2rem 0;
  line-height: 1.3;
}

/* The app's flat heading ramp: weight carries hierarchy. */
.prose h1 {
  margin-top: 0.75rem;
  font-size: 2.5em;
  font-weight: 500;
}

.prose h2 {
  font-size: 1.75em;
  font-weight: 500;
}

.prose h3 {
  font-size: 1.25em;
  font-weight: 500;
}

.prose h4,
.prose h5,
.prose h6 {
  font-size: 1.125em;
  font-weight: 500;
}

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
}

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

/* Inline code: Courier New — its x-height matches Newsreader's, where
 * Menlo reads ~28% too large (see the GUI's prose constants). */
.prose code {
  font-family: "Courier New", monospace;
  font-size: 1em;
}

/* Fenced blocks keep the data-mono face. */
.prose pre {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.prose pre code {
  font: inherit;
}

.prose blockquote {
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--border);
  color: var(--muted-foreground);
}

/* GFM alert blockquotes (`> [!NOTE]` …, pulldown-cmark's markdown-alert-*
 * classes) keep the quote's hairline form — no fills, no cards. The app's
 * status colors carry the kind: the left rule takes the color, and an
 * uppercase chrome label (the docs-nav-title voice) names it. The body
 * stays at full foreground — an alert is content, not an aside. */
.prose blockquote[class^="markdown-alert-"] {
  color: inherit;
  border-left-color: var(--alert-color);
}

.prose blockquote[class^="markdown-alert-"]::before {
  content: var(--alert-label);
  display: block;
  margin-bottom: 0.25rem;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--alert-color);
}

/* The label suppresses margin collapse, so the first block's top margin
 * would otherwise open a gap under it. */
.prose blockquote[class^="markdown-alert-"] > :first-child {
  margin-top: 0;
}

.prose .markdown-alert-note { --alert-color: var(--info); --alert-label: "Note"; }
.prose .markdown-alert-tip { --alert-color: var(--success); --alert-label: "Tip"; }
.prose .markdown-alert-important { --alert-color: var(--accent-foreground); --alert-label: "Important"; }
.prose .markdown-alert-warning { --alert-color: var(--warning); --alert-label: "Warning"; }
.prose .markdown-alert-caution { --alert-color: var(--danger); --alert-label: "Caution"; }

.prose table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.5;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 6px 16px 6px 0;
}

.prose th {
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.prose td {
  border-top: 1px solid var(--border);
}

.prose tr:first-child td {
  border-top: none;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose img {
  max-width: 100%;
}

/* --- Docs sidebar -------------------------------------------------------- */
/* Quiet text in the left gutter — no ground, no box, hairline-free (the
 * Library idiom). One markup source renders twice: the sticky rail here
 * and a native <details> disclosure above the content on narrow screens. */

.docs-sidebar {
  grid-column: 1;
  justify-self: end;
  width: 200px;
  margin-right: 24px;
  padding: 32px 0;
  position: sticky;
  top: 60px;
  align-self: start;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
}

/* Scoped to both renderings so .prose's block margins can't leak into
 * the disclosure copy. */
.docs-sidebar .docs-nav-title,
.docs-nav-inline .docs-nav-title {
  margin: 0 0 0.25rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-foreground);
}

.docs-sidebar ul,
.docs-nav-inline ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-sidebar li,
.docs-nav-inline li {
  margin: 0;
  padding: 3px 0;
}

.docs-sidebar .docs-nav-group,
.docs-nav-inline .docs-nav-group {
  margin: 0 0 1.25rem 1rem;
}

.docs-sidebar a,
.docs-nav-inline a {
  color: var(--muted-foreground);
  text-decoration: none;
}

.docs-sidebar a:hover,
.docs-nav-inline a:hover {
  color: var(--foreground);
}

.docs-sidebar a[aria-current="page"],
.docs-nav-inline a[aria-current="page"] {
  color: var(--foreground);
  font-weight: 600;
}

/* The narrow-screen disclosure: system-ui like all chrome, folded shut
 * by default so the document leads. */
.docs-nav-inline {
  display: none;
  margin: 0 0 1.5rem;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.docs-nav-inline summary {
  cursor: pointer;
  color: var(--muted-foreground);
  font-size: 14px;
  padding: 6px 0;
}

.docs-nav-inline summary:hover {
  color: var(--foreground);
}

.docs-nav-inline nav {
  padding: 8px 0 4px 12px;
  border-left: 1px solid var(--border);
}

@media (max-width: 1103px) {
  .docs-sidebar {
    display: none;
  }

  .docs-nav-inline {
    display: block;
  }
}

/* --- In-page table of contents ------------------------------------------ */
/* The right-hand rail — a cousin of the app's minimap: a hairline with
 * the current section marked, entries in quiet 12px chrome text. toc.js
 * sets aria-current on the section being read and .passed on the ones
 * above it, so the filled edge doubles as reading progress. */

.toc {
  display: block;
  grid-column: 3;
  justify-self: start;
  width: 200px;
  margin-left: 24px;
  padding: 32px 0;
  position: sticky;
  top: 60px;
  align-self: start;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1103px) {
  .toc {
    display: none;
  }
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc li {
  margin: 0;
  padding: 0;
}

.toc a {
  display: block;
  padding: 3px 1rem 3px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--muted-foreground);
  text-decoration: none;
}

/* The page's h1 leads the rail as a scroll-to-top entry: same indent as
 * the sections, distinguished by weight alone (the heading-ramp rule). */
.toc .toc-h1 a {
  font-weight: 600;
}

.toc .toc-h3 a {
  padding-left: 28px;
}

.toc a:hover {
  color: var(--foreground);
}

.toc a.passed {
  border-left-color: color-mix(in srgb, var(--muted-foreground) 50%, transparent);
}

.toc a[aria-current="true"] {
  color: var(--foreground);
  border-left-color: var(--foreground);
}

/* Anchored headings land clear of the sticky chrome; in-page jumps
 * glide unless the reader prefers otherwise. */
.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: 64px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* --- Page furniture ----------------------------------------------------- */

.byline {
  color: var(--muted-foreground);
  font-family: system-ui, sans-serif;
  font-size: 14px;
}

/* The quiet door back into the repo, at the foot of every docs page. */
.page-edit {
  margin-top: 3rem;
  font-family: system-ui, sans-serif;
  font-size: 13px;
}

.prose .page-edit a {
  color: var(--muted-foreground);
  text-decoration: none;
}

.prose .page-edit a:hover {
  color: var(--foreground);
}

.draft-notice {
  color: var(--accent-foreground);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
}

/* Blog index: a table of contents — hairline rules between rows, never
 * boxes (the Library idiom). */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  padding: 1.25rem 0;
}

.post-list li + li {
  border-top: 1px solid var(--border);
}

.post-list time {
  display: block;
  color: var(--muted-foreground);
  font-family: system-ui, sans-serif;
  font-size: 14px;
  margin-bottom: 0.25rem;
}

.post-list a {
  font-size: 1.125em;
  font-weight: 600;
  color: var(--foreground);
  text-decoration: none;
}

.post-list a:hover {
  color: var(--link-hover);
}

.post-list p {
  margin: 0.25rem 0 0;
  color: var(--muted-foreground);
}

/* Home hero: the one page allowed a little more air. */
.home h1 {
  margin-top: 3rem;
  font-size: 2em;
  font-weight: 600;
}

/* --- Footer ------------------------------------------------------------- */

.site-footer {
  width: 100%;
  max-width: 1102px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  color: var(--muted-foreground);
  font-size: 13px;
}

.site-footer nav {
  display: flex;
  gap: 16px;
}

.site-footer a {
  color: var(--muted-foreground);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--foreground);
}

.appearance {
  margin-left: auto;
  display: flex;
  /* The icon stays anchored at the right; options expand inline to its
     left when the disclosure is open. */
  flex-direction: row-reverse;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 2px;
}

.appearance:active, .appearance:hover, .appearance[open] {
    border-color: var(--border);
}

.appearance[open] {
    gap: 8px;
}

/* The collapsed trigger: the icon of the mode actually in use (set by JS). */
.appearance > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1;
  user-select: none;
  padding: 3px 8px;
}

.appearance > summary::-webkit-details-marker {
  display: none;
}

.appearance > summary:hover,
.appearance[open] > summary {
  color: var(--foreground);
}

.appearance-options {
  display: flex;
  gap: 2px;
}

.appearance-options button {
  background: none;
  border: none;
  padding: 2px 6px;
  font: inherit;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: var(--radius);
}

.appearance-options button:hover {
  color: var(--foreground);
}

.appearance-options button[aria-pressed="true"] {
  color: var(--foreground);
  background: var(--secondary);
}
