/* Tangent Effect — editorial, system-font typography */

:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-elev: #fbf7f0;
  --ink: #1c1916;
  --ink-soft: #5e584e;
  --rule: #ddd4c6;
  --accent: #9a3b24;
  --accent-hover: #7c2e1b;
  --mark: #ead7b6;
  --embed-bg: #1c1916;
  --shadow: 0 1px 0 rgba(28, 25, 22, 0.04);
  --font-serif: Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, "IBM Plex Serif", "Source Serif Pro", "Noto Serif", serif;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Helvetica, "IBM Plex Sans", sans-serif;
  --measure: 42.5rem;
  --side: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #131210;
    --bg-elev: #1b1916;
    --ink: #efece4;
    --ink-soft: #b5aea1;
    --rule: #3a362f;
    --accent: #e39a86;
    --accent-hover: #f3c2b4;
    --mark: #3a2e1e;
    --embed-bg: #000;
    --shadow: none;
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-elev: #fbf7f0;
  --ink: #1c1916;
  --ink-soft: #5e584e;
  --rule: #ddd4c6;
  --accent: #9a3b24;
  --accent-hover: #7c2e1b;
  --mark: #ead7b6;
  --embed-bg: #1c1916;
  --shadow: 0 1px 0 rgba(28, 25, 22, 0.04);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131210;
  --bg-elev: #1b1916;
  --ink: #efece4;
  --ink-soft: #b5aea1;
  --rule: #3a362f;
  --accent: #e39a86;
  --accent-hover: #f3c2b4;
  --mark: #3a2e1e;
  --embed-bg: #000;
  --shadow: none;
}

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.11rem;
  line-height: 1.75;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 0.4rem 0.8rem;
  z-index: 10;
}
.skip:focus { left: var(--side); }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-hover); }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.wrap {
  width: min(var(--measure), 100% - 2 * var(--side));
  margin-inline: auto;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.header-inner {
  width: min(48rem, 100% - 2 * var(--side));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding: 1.05rem 0;
}
.wordmark {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
.wordmark:hover { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 1.1rem 1.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.byline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.byline:hover { color: var(--accent); }
.avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--rule);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}
.nav-links a {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--ink);
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--bg-elev);
  color: var(--ink-soft);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-soft); }
.theme-toggle svg { width: 0.95rem; height: 0.95rem; display: block; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  html:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

/* Main */
main {
  flex: 1 0 auto;
  padding: 2.6rem 0 4rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.lede {
  margin: 0 0 2.4rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* Home / lists */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list > li {
  border-top: 1px solid var(--rule);
  padding: 1.55rem 0 1.65rem;
}
.post-list > li:last-child { border-bottom: 1px solid var(--rule); }

.post-card.has-thumb {
  display: grid;
  grid-template-columns: 1fr 180px;
  column-gap: 1.35rem;
  row-gap: 0;
  align-items: start;
}
.post-card.has-thumb .meta { grid-column: 1; grid-row: 1; }
.post-card.has-thumb h2 { grid-column: 1; grid-row: 2; }
.post-card.has-thumb .summary { grid-column: 1; grid-row: 3; }
.post-card.has-thumb .tags { grid-column: 1; grid-row: 4; }
.post-card.has-thumb .post-thumb {
  grid-column: 2;
  grid-row: 2 / 4;
  align-self: start;
  margin-top: 0.2rem;
}
.post-thumb {
  display: block;
  width: 180px;
  height: 120px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.post-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.35s ease;
}
.post-card:hover .post-thumb img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) {
  .post-thumb img { transition: none; }
  .post-card:hover .post-thumb img { transform: none; }
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}
.meta time { color: var(--ink-soft); }

.post-list h2 {
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0 0 0.4rem;
}
.post-list h2 a {
  color: inherit;
  text-decoration: none;
}
.post-list h2 a:hover { color: var(--accent); }

.summary {
  margin: 0 0 0.7rem;
  color: var(--ink);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tags a,
.tag {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink-soft);
}
.tags a:hover { color: var(--accent); }
.tags a::before,
.tag::before { content: "#"; opacity: 0.6; }

/* Archive */
.year-group { margin: 0 0 2.2rem; }
.year-group h2 {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--rule);
}
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.75rem;
  padding: 0.45rem 0;
  align-items: baseline;
}
.archive-list time {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.archive-list a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}
.archive-list a:hover { color: var(--accent); }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.tag-cloud a {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--ink);
}
.tag-cloud a:hover { color: var(--accent); }
.tag-cloud .count {
  color: var(--ink-soft);
  font-size: 0.8em;
  margin-left: 0.2rem;
}

/* Article */
.article-header { margin: 0 0 2rem; }
.article-header h1 {
  font-size: clamp(1.85rem, 4.4vw, 2.55rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.025em;
  margin: 0.15rem 0 0.85rem;
  text-wrap: balance;
}

.article-body > *:first-child { margin-top: 0; }
.article-body p { margin: 0 0 1.2rem; }
.article-body h2,
.article-body h3,
.article-body h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 2.1rem 0 0.7rem;
}
.article-body h2 { font-size: 1.5rem; }
.article-body h3 { font-size: 1.28rem; }
.article-body h4 { font-size: 1.12rem; }

.article-body ul,
.article-body ol {
  margin: 0 0 1.25rem;
  padding-left: 1.35rem;
}
.article-body li { margin: 0.25rem 0; }
.article-body li > ul,
.article-body li > ol { margin: 0.2rem 0 0.4rem; }

.article-body blockquote {
  margin: 1.7rem 0;
  padding: 0.1rem 0 0.1rem 1.2rem;
  border-left: 2px solid var(--accent);
  color: var(--ink);
  font-style: italic;
}
.article-body blockquote p { margin-bottom: 0.6rem; }
.article-body blockquote p:last-child { margin-bottom: 0; }

.article-body figure {
  margin: 2rem 0;
}
.article-body figure img,
.article-body p > img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  background: var(--bg-elev);
}
.article-body figcaption {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.65rem;
}

.article-body code {
  font-family: ui-monospace, "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.05em 0.35em;
}
.article-body pre {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.5;
  font-size: 0.9rem;
}
.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.article-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4rem 0;
}

.embed-yt {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 2rem 0 0.4rem;
  background: var(--embed-bg);
  border-radius: 3px;
  overflow: hidden;
}
.embed-yt iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.embed-caption {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 0 0 2rem;
}

.original {
  margin: 2.6rem 0 0;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}
.post-nav a {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.post-nav a:hover .nav-title { color: var(--accent); }
.post-nav .next { text-align: right; grid-column: 2; }
.post-nav .label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.post-nav .nav-title {
  font-weight: 600;
  line-height: 1.35;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.3rem 0 2rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* 404 */
.not-found {
  text-align: center;
  padding: 3rem 0 2rem;
}
.not-found h1 { font-size: 2.2rem; margin-bottom: 0.6rem; }

@media (max-width: 640px) {
  html { font-size: 17px; }
  .header-inner { padding: 0.9rem 0; }
  .byline span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  main { padding-top: 1.8rem; }
  .archive-list li { grid-template-columns: 1fr; gap: 0.1rem; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { text-align: left; grid-column: 1; }
  .post-card.has-thumb {
    grid-template-columns: 1fr;
  }
  .post-card.has-thumb .post-thumb {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 11.5rem;
    margin: 0 0 0.85rem;
  }
  .post-card.has-thumb .meta { grid-row: 2; }
  .post-card.has-thumb h2 { grid-row: 3; }
  .post-card.has-thumb .summary { grid-row: 4; }
  .post-card.has-thumb .tags { grid-row: 5; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .site-header, .site-footer, .theme-toggle, .post-nav, .skip { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: inherit; text-decoration: underline; }
  .article-body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #444; }
}
