/* --------------------------------------------------------------------------
   Design tokens — light (default) / dark via [data-theme]
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --font-body: Georgia, "Times New Roman", Times, serif;
  --font-title: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --bg: #f7f6f2;
  --surface: #eeede8;
  --text: #24303a;
  --muted: #6b7280;
  --accent: #146c5a;
  --accent-hover: #0f5a4b;
  --quote-text: #24303a;
  --border: rgba(15, 23, 42, 0.08);

  --focus-ring: rgba(20, 108, 90, 0.45);
  --selection-bg: rgba(20, 108, 90, 0.16);
  --selection-text: var(--text);

  --content-max: 42.5rem; /* ~680px */
  --page-pad-x: 1.25rem; /* 20px mobile */
  --page-pad-x-md: 1.75rem;
  --page-pad-x-lg: 2rem;

  --transition-theme: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #121417;
  --surface: #1a1e22;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #5bc8af;
  --accent-hover: #7dd3c0;
  --quote-text: #d1d5db;
  --border: rgba(255, 255, 255, 0.08);

  --focus-ring: rgba(91, 200, 175, 0.5);
  --selection-bg: rgba(91, 200, 175, 0.22);
  --selection-text: var(--text);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem; /* 17px mobile */
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: var(--transition-theme);
}

@media (min-width: 48rem) {
  body {
    font-size: 1.125rem; /* 18px desktop */
  }
}

::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

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

/* --------------------------------------------------------------------------
   Layout shell
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: var(--page-pad-x);
  top: 0.75rem;
  width: auto;
  height: auto;
  z-index: 200;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.site-wrap {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem var(--page-pad-x) 3rem;
  position: relative;
}

@media (min-width: 48rem) {
  .site-wrap {
    padding-left: var(--page-pad-x-md);
    padding-right: var(--page-pad-x-md);
  }
}

@media (min-width: 80rem) {
  .site-wrap {
    padding-left: var(--page-pad-x-lg);
    padding-right: var(--page-pad-x-lg);
  }
}

/* Wider shell for future landing layouts */
.site-wrap--wide {
  max-width: 48rem;
}

/* --------------------------------------------------------------------------
   Header: name + nav + rule
   -------------------------------------------------------------------------- */

.site-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 0.25rem;
}

.site-name {
  display: inline-block;
  margin: 0 0 1rem;
  font-family: var(--font-title);
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-name:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
}

.site-nav li {
  display: inline-flex;
  align-items: center;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.2rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 0.2rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.site-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.15em;
}

.site-nav a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.site-nav-sep {
  color: var(--muted);
  user-select: none;
  font-weight: 400;
  padding: 0 0.15rem;
  pointer-events: none;
}

.site-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
  transition: var(--transition-theme);
}

/* --------------------------------------------------------------------------
   Main & typography (.prose)
   -------------------------------------------------------------------------- */

main {
  min-height: 40vh;
}

.prose {
  max-width: var(--content-max);
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose h1 {
  margin: 2rem 0 0.75rem;
  font-family: var(--font-body);
  font-size: clamp(1.45rem, 3.5vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.prose h2 {
  margin: 2rem 0 0.65rem;
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

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

.prose a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

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

.prose a:visited {
  color: var(--accent);
  opacity: 0.92;
}

.prose a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.15rem;
}

.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--accent);
  font-style: italic;
  font-size: inherit;
  line-height: inherit;
  color: var(--quote-text);
}

.prose blockquote p {
  margin-bottom: 0.5em;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose code,
.prose kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.12em 0.35em;
  border-radius: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.prose pre {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 0.88em;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.prose pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: inherit;
}

.prose table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  border-collapse: collapse;
  font-size: 0.95em;
  -webkit-overflow-scrolling: touch;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
}

.prose th {
  font-family: var(--font-body);
  font-weight: 600;
  text-align: left;
  background: var(--surface);
}

.prose ul,
.prose ol {
  margin: 0 0 1.1em;
  padding-left: 1.35rem;
}

.prose li {
  margin: 0.35em 0;
}

/* --------------------------------------------------------------------------
   Blog index previews
   -------------------------------------------------------------------------- */

.prose .posts-index {
  list-style: none;
  margin: 1.25rem 0 2.5rem;
  padding: 0;
}

.prose .post-preview {
  margin: 0 0 0.85rem;
  padding: 0;
  line-height: 1.55;
}

.prose .post-preview__title {
  font-family: var(--font-title);
  font-size: 1.05em;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.prose .post-preview__title:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.12em;
}

.prose .post-preview__title:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.15rem;
}

.prose .post-preview__sep {
  color: var(--muted);
  padding: 0 0.25em;
  user-select: none;
}

.prose .post-preview__date {
  font-family: var(--font-body);
  font-size: 0.9em;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Posts / notes (note.html)
   -------------------------------------------------------------------------- */

.post-back {
  margin: 0 0 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
}

.post-back a {
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.post-back a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.post-back a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.15rem;
}

article.post {
  max-width: var(--content-max);
}

.note-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.note-header h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font-body);
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.note-metadata {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--muted);
}

.note-metadata span {
  margin-right: 1rem;
}

.tags {
  margin-top: 0.75rem;
}

.tag {
  display: inline-block;
  margin: 0.25rem 0.35rem 0 0;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  color: var(--muted);
}

.note-content {
  /* body typography comes from .prose when wrapped */
}

.note-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.note-footer h2 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 600;
}

.backlinks {
  list-style: none;
  padding: 0;
  margin: 0;
}

.backlinks li {
  margin: 0.5rem 0;
}

/* --------------------------------------------------------------------------
   Notes list (existing class names)
   -------------------------------------------------------------------------- */

.notes-list {
  margin: 2rem 0;
}

.notes-list .note-item {
  margin-bottom: 2rem;
}

.notes-list .note-title {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.notes-list .note-title a {
  color: var(--accent);
  text-decoration: none;
}

.notes-list .note-title a:hover {
  text-decoration: underline;
}

.notes-list .note-meta {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--muted);
}

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

.site-footer {
  margin-top: 3.5rem;
  padding-top: 2rem;
}

.logo-band {
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-theme);
}

.social-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.social-icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  text-decoration: none;
  border-radius: 0.25rem;
}

.social-icons a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.social-icons img {
  width: 22px;
  height: 22px;
}

[data-theme="dark"] .social-icons img {
  filter: brightness(0) invert(0.88);
}

[data-theme="light"] .social-icons img {
  filter: none;
  opacity: 0.85;
}

.footer-bottom {
  text-align: center;
  padding: 1rem 0.5rem 0;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

.footer-bottom__sep {
  user-select: none;
}

/* Theme toggle (footer moon, inline with copyright) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
  transition: color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.15rem;
}

.theme-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

.footer-bottom a {
  color: var(--accent);
  text-decoration: none;
}

.footer-bottom a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.footer-bottom a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 0.15rem;
}

.internal-link {
  border-bottom: 1px solid var(--border);
}

.internal-link:hover {
  background-color: var(--surface);
  border-bottom-color: var(--accent);
}
