/* Stable stylesheet for Pages Functions (KV writing posts) — synced at build */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0c;
  --bg-elevated: #161616;
  --text: #f2f2f2;
  --text-muted: #8a8a8a;
  --hairline: #2a2a2a;
  --accent-a: #c4b5fd;
  --accent-b: #93c5fd;
  --accent-c: #fdba74;
  --danger: #ff453a;
  --badge: #ff453a;
  --focus: #93c5fd;
  --dock-bg: rgba(22, 22, 22, 0.72);
  --dock-border: rgba(255, 255, 255, 0.08);
  --dock-height: 64px;
  --dock-pad: 140px;
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Inter", "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --measure: 66ch;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 200ms;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f4f1;
  --bg-elevated: #ffffff;
  --text: #171717;
  --text-muted: #6a6a6a;
  --hairline: #e3e0d8;
  --accent-a: #7c3aed;
  --accent-b: #2563eb;
  --accent-c: #c2410c;
  --danger: #dc2626;
  --badge: #dc2626;
  --focus: #2563eb;
  --dock-bg: rgba(255, 255, 255, 0.86);
  --dock-border: rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"][data-period="dawn"] {
  --bg: #100e0c;
  --bg-elevated: #1a1612;
  --accent-a: #d6bcf5;
  --accent-c: #f0b27a;
}

html[data-theme="dark"][data-period="day"] {
  --bg: #0c0c0c;
  --bg-elevated: #161616;
}

html[data-theme="dark"][data-period="dusk"] {
  --bg: #0a0c10;
  --bg-elevated: #12161c;
  --accent-b: #7dd3fc;
  --text-muted: #7f8a98;
}

html[data-theme="dark"][data-period="night"] {
  --bg: #050505;
  --bg-elevated: #111111;
  --accent-a: #a78bfa;
  --accent-b: #60a5fa;
  --accent-c: #fb923c;
  --text-muted: #6e6e6e;
}


@media (max-width: 640px) {
  :root,
  html[data-theme="dark"],
  html[data-theme="light"] {
    --dock-pad: 110px;
  }
}



*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  background: var(--bg);
  scroll-behavior: smooth;
  overflow-x: clip;
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: max(var(--dock-pad), calc(var(--dock-pad) + env(safe-area-inset-bottom, 0px)));
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.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;
}

.page {
  width: min(720px, calc(100% - 2.5rem));
  max-width: 100%;
  margin: 0 auto;
  padding: 4.5rem 0 3.5rem;
  box-sizing: border-box;
}

.page-wide {
  width: min(920px, calc(100% - 2.5rem));
  max-width: 100%;
}

main {
  max-width: 100%;
  overflow-x: clip;
}

img,
video,
iframe,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }
  .page,
  .page-wide {
    width: min(720px, calc(100% - 1.5rem));
    padding: 3rem 0 2.5rem;
  }
  .page-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }
}

.page-title {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.page-dek {
  color: var(--text-muted);
  margin: 0 0 2.5rem;
  font-size: 1rem;
}

.meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.prose {
  max-width: min(var(--measure), 100%);
}

.prose h2,
.prose h3 {
  letter-spacing: -0.015em;
  margin-top: 2rem;
  line-height: 1.3;
}

.prose p {
  margin: 0 0 1.15em;
}

.prose a {
  color: var(--accent-b);
}

.prose code {
  font-size: 0.92em;
  background: var(--bg-elevated);
  padding: 0.12em 0.35em;
  border-radius: 4px;
}


.prose img,
.prose video,
.prose iframe,
.prose svg {
  max-width: 100%;
  height: auto;
}

.prose figure {
  margin: 1.25em 0;
  max-width: 100%;
}

.prose figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.prose p > img,
.prose li > img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1em auto;
}

.prose pre,
.prose table {
  max-width: 100%;
  overflow-x: auto;
}

article[data-essay],
.prose {
  overflow-x: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.badge-example {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-c);
  border: 1px solid color-mix(in srgb, var(--accent-c) 40%, transparent);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.5rem;
}

.empty-state {
  color: var(--text-muted);
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* writing-list (global — survives client API overlay) */
.writing-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.writing-list li + li {
  border-top: 1px solid var(--hairline);
}
.writing-link {
  display: grid;
  gap: 0.35rem;
  padding: 1.15rem 0;
  text-decoration: none;
}
.writing-link:hover .writing-title {
  color: var(--accent-b);
}
.writing-title {
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 1.15rem;
  font-weight: 550;
  letter-spacing: -0.015em;
}
.writing-dek {
  color: var(--text-muted);
  font-size: 0.95rem;
}
