/* edgeblog stylesheet — HTML-first, system fonts, respects prefers-color-scheme. */

:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg:     #ffffff;
  --fg:     #111418;
  --muted:  #55606b;
  --accent: #0366d6;
  --border: #e1e4e8;
  --code-bg: #f6f8fa;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #0d1117;
    --fg:     #e6edf3;
    --muted:  #8b949e;
    --accent: #58a6ff;
    --border: #30363d;
    --code-bg: #161b22;
  }
}

/* Explicit user override via cookie — wins over OS preference. */
html[data-theme="light"] {
  color-scheme: light;
  --bg:     #ffffff;
  --fg:     #111418;
  --muted:  #55606b;
  --accent: #0366d6;
  --border: #e1e4e8;
  --code-bg: #f6f8fa;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg:     #0d1117;
  --fg:     #e6edf3;
  --muted:  #8b949e;
  --accent: #58a6ff;
  --border: #30363d;
  --code-bg: #161b22;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  max-width: 44rem;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 2rem 0 0.75rem; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}
.skip-link:focus { left: 0; z-index: 100; }

.site-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.site-header h1 { margin: 0; font-size: 1.75rem; }
.site-header .tagline { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.95rem; }

.site-footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

code, pre {
  font-family: var(--mono);
  font-size: 0.925em;
}

code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

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

/* --- Post list on home page ------------------------------------------ */

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.post-list > li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.post-list > li:last-child { border-bottom: none; }
.post-list h3 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}
.post-list h3 a { text-decoration: none; }
.post-list h3 a:hover { text-decoration: underline; }
.post-list p { margin: 0.25rem 0; color: var(--muted); }

/* --- Individual post ------------------------------------------------- */

article header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
article header h1 { margin: 0.25rem 0; }

.breadcrumb {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.breadcrumb a { color: var(--muted); }

.post-meta {
  margin: 0.25rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.post-tags { margin: 0.5rem 0 0; }
.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  margin-right: 0.3rem;
  background: var(--code-bg);
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--muted);
}

.post-body { font-size: 1.0625rem; }
.post-body h2 { margin-top: 2.5rem; }
.post-body blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.post-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}
.post-body th, .post-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}
.post-body th { background: var(--code-bg); }

.post-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- Theme toggle ---------------------------------------------------- */

.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.25rem;
  margin: 0;
}
.theme-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
}
.theme-toggle button:hover { border-color: var(--accent); color: var(--accent); }

body { position: relative; }

/* --- Draft styling --------------------------------------------------- */

.draft-badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  margin-right: 0.35rem;
  background: #ffbf47;
  color: #111;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.draft-notice {
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  background: #fff4da;
  color: #5a4200;
  border-left: 3px solid #ffbf47;
  border-radius: 3px;
  font-size: 0.95rem;
}
html[data-theme="dark"] .draft-notice,
@media (prefers-color-scheme: dark) {
  .draft-notice { background: #3a2e10; color: #ffe1a6; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
