/* kitch-blog — minimal, no web fonts, no frameworks. */

:root {
  color-scheme: light;
  --bg: #fcfcfa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f3f2ee;
  --fg: #202124;
  --fg-muted: #626a70;
  --fg-faint: #6d747a;
  --border: #e5e4de;
  --border-strong: #d5d4cd;
  --accent: #0e6b63;
  --accent-hover: #0a514b;
  --mark: #fdf0a1;
  --shadow: 0 18px 50px rgba(20, 22, 24, 0.16);
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-prose: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131413;
    --bg-elevated: #1c1d1c;
    --bg-subtle: #20211f;
    --fg: #e8e6e1;
    --fg-muted: #a3a7a5;
    --fg-faint: #969c99;
    --border: #2d2f2d;
    --border-strong: #3d403d;
    --accent: #86cfc6;
    --accent-hover: #a7ded7;
    --mark: #5f551c;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131413;
  --bg-elevated: #1c1d1c;
  --bg-subtle: #20211f;
  --fg: #e8e6e1;
  --fg-muted: #a3a7a5;
  --fg-faint: #969c99;
  --border: #2d2f2d;
  --border-strong: #3d403d;
  --accent: #86cfc6;
  --accent-hover: #a7ded7;
  --mark: #5f551c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--mark);
  color: var(--fg);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

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

img {
  height: auto;
  border-radius: 6px;
}

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

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 20;
  padding: 0.6rem 0.9rem;
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: 1rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.6rem 1.25rem 1.2rem;
}

.brand {
  color: var(--fg);
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand:hover {
  color: var(--fg);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav > a,
.search-trigger,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.34rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.site-nav > a:hover,
.search-trigger:hover,
.theme-toggle:hover {
  color: var(--fg);
  background: var(--bg-subtle);
}

.site-nav > a[aria-current="page"] {
  color: var(--fg);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--fg-faint);
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: 4px;
  padding: 0.02rem 0.3rem;
  background: var(--bg-elevated);
}

.icon {
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-trigger kbd {
  margin-left: 0.1rem;
}

.theme-toggle {
  padding: 0.34rem 0.45rem;
}

.icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun,
:root:not([data-theme="light"]) .icon-sun {
  display: inline-block;
}

[data-theme="light"] .icon-moon {
  display: inline-block;
}

[data-theme="light"] .icon-sun {
  display: none;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .icon-moon {
    display: inline-block;
  }
  :root:not([data-theme="dark"]) .icon-sun {
    display: none;
  }
}

/* Main -------------------------------------------------------------------- */

.site-main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.4rem 1.25rem 4.5rem;
}

.intro,
.listing-header {
  margin: 0 0 2.4rem;
}

.intro h1,
.listing-header h1,
.not-found h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 680;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tagline {
  margin: 0.6rem 0 0;
  color: var(--fg-muted);
  font-size: 1.03rem;
  max-width: 38rem;
}

.year-group {
  margin-top: 2.4rem;
}

.year-group:first-of-type {
  margin-top: 0;
}

.year-label {
  margin: 0 0 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2rem;
}

.post-item-meta {
  margin: 0 0 0.2rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.01em;
}

.post-item-title {
  margin: 0;
  font-size: 1.16rem;
  font-weight: 620;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

.post-item-title a {
  color: var(--fg);
  text-decoration: none;
}

.post-item-title a:hover {
  color: var(--accent);
}

.post-item-excerpt {
  margin: 0.35rem 0 0;
  color: var(--fg-muted);
  font-size: 0.94rem;
  line-height: 1.55;
  max-width: 40rem;
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.65rem 0 0;
  padding: 0;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.48rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
  font-size: 0.7rem;
  line-height: 1.5;
  text-decoration: none;
}

.tag:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.empty {
  color: var(--fg-muted);
}

/* Pagination -------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
}

.pagination-link {
  text-decoration: none;
}

.pagination-status {
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.pagination-spacer {
  width: 1px;
}

/* Post -------------------------------------------------------------------- */

.post-header {
  margin-bottom: 2.2rem;
}

.post-header h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4.5vw, 2.65rem);
  line-height: 1.18;
  letter-spacing: -0.028em;
  font-weight: 690;
}

.post-meta {
  margin: 0.8rem 0 0;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.post-meta > span {
  margin: 0 0.2rem;
}

.post .tag-list {
  margin-top: 0.9rem;
}

.prose {
  max-width: 42rem;
  font-family: var(--font-prose);
  font-size: 1.06rem;
  line-height: 1.78;
  overflow-wrap: break-word;
}

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

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

.prose h2,
.prose h3,
.prose h4 {
  position: relative;
  font-family: var(--font-ui);
  line-height: 1.3;
  letter-spacing: -0.015em;
  scroll-margin-top: 1.5rem;
}

.prose h2 {
  margin: 2.4em 0 0.65em;
  font-size: 1.42rem;
  font-weight: 650;
}

.prose h3 {
  margin: 1.9em 0 0.5em;
  font-size: 1.13rem;
  font-weight: 650;
}

.prose h4 {
  margin: 1.6em 0 0.4em;
  font-size: 1rem;
  font-weight: 650;
}

.heading-anchor {
  margin-left: 0.35em;
  color: var(--fg-faint);
  font-size: 0.75em;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

.prose a {
  text-decoration: underline;
}

.prose ul,
.prose ol {
  margin: 0 0 1.25em;
  padding-left: 1.4em;
}

.prose li {
  margin: 0.3em 0;
}

.prose li > input[type="checkbox"] {
  margin-right: 0.45em;
}

.prose li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.25em;
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 0.1em 0 0.1em 1.1em;
  border-left: 3px solid var(--border-strong);
  color: var(--fg-muted);
  font-style: italic;
}

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

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.08em 0.32em;
}

.prose pre {
  margin: 1.5em 0;
  padding: 1em 1.15em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}

.prose pre code {
  display: block;
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.85rem;
  white-space: pre;
}

.prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  overflow-x: auto;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.prose th,
.prose td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.prose th {
  font-weight: 650;
}

.prose hr {
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.prose img {
  margin: 1.5em 0;
}

.prose sup {
  line-height: 0;
}

.post.page .post-header {
  margin-bottom: 1.8rem;
}

/* Post navigation --------------------------------------------------------- */

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0;
  text-decoration: none;
  color: var(--fg);
  min-width: 0;
}

.post-nav-older {
  text-align: right;
}

.post-nav-label {
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-nav-title {
  font-size: 0.9rem;
  font-weight: 550;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-nav-spacer {
  min-height: 1px;
}

/* Archive, tags, 404 ------------------------------------------------------ */

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  font-size: 0.94rem;
}

.archive-list time {
  flex: none;
  width: 3.9rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.archive-list a {
  color: var(--fg);
  text-decoration: none;
}

.archive-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}

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

.tag-index li {
  border-bottom: 1px solid var(--border);
}

.tag-index a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  color: var(--fg);
  text-decoration: none;
}

.tag-index a:hover {
  color: var(--accent);
}

.tag-index .count {
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.not-found {
  max-width: 34rem;
  margin: 3rem auto;
  text-align: center;
}

.not-found p {
  color: var(--fg-muted);
}

.button {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--fg);
  font: inherit;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button-secondary {
  background: none;
}

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

.site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.4rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 0.78rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--fg-muted);
}

.footer-note {
  margin-top: 0.3rem !important;
}

/* Search ------------------------------------------------------------------ */

.search-dialog {
  width: min(42rem, calc(100vw - 2rem));
  max-width: none;
  max-height: none;
  margin: 11vh auto auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
}

.search-dialog::backdrop {
  background: rgba(12, 14, 14, 0.45);
  backdrop-filter: blur(3px);
}

.search-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg-faint);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 1.05rem;
  outline: none;
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.search-close {
  flex: none;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  cursor: pointer;
}

.search-close:hover {
  color: var(--fg);
  border-color: var(--border-strong);
}

.search-status {
  margin: 0;
  padding: 0.55rem 1rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0 0 0.4rem;
  max-height: min(55vh, 26rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.search-result {
  display: block;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--fg);
  border-left: 2px solid transparent;
}

.search-result:hover,
.search-result[aria-selected="true"] {
  background: var(--bg-subtle);
  border-left-color: var(--accent);
}

.result-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.result-meta {
  display: block;
  margin-top: 0.12rem;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.result-snippet {
  margin-top: 0.25rem;
  color: var(--fg-muted);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.05em;
}

.search-help {
  margin: 0;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 0.68rem;
}

.search-help kbd {
  margin-right: 0.12rem;
}

.search-help span {
  margin: 0 0.25rem;
}

@media (max-width: 40rem) {
  .search-dialog {
    width: 100%;
    height: 100%;
    margin: 0;
  }

  .search-panel {
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .search-results {
    max-height: none;
    flex: 1;
  }

  .search-field input {
    font-size: 1rem;
  }
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 34rem) {
  .site-header {
    flex-wrap: wrap;
    padding-top: 1.1rem;
    gap: 0.5rem;
    row-gap: 0.3rem;
  }

  .site-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 0.15rem;
  }

  .site-nav > a {
    padding-inline: 0.4rem;
    font-size: 0.82rem;
  }

  .search-trigger-label,
  .search-trigger kbd {
    display: none;
  }

  .search-trigger {
    padding: 0.4rem;
  }

  .site-main {
    padding-top: 1rem;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav-older {
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 0.8rem;
  }

  .post-nav-spacer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .search-dialog,
  .post-nav,
  .pagination,
  .heading-anchor {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .site-main {
    max-width: none;
  }

  .prose {
    max-width: none;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}
