/*
  Site-wide visual layer.
  Keeps existing content and page-specific structure, while harmonizing color,
  spacing, and mobile reading rhythm across the static site.
*/

:root {
  --site-bg: #f1f0eb;
  --site-paper: #fffefa;
  --site-paper-soft: #f8f5ee;
  --site-text: #171813;
  --site-muted: #69675f;
  --site-faint: #8b877d;
  --site-line: #ddd8ce;
  --site-soft-line: #ebe7de;
  --site-accent: #2f6b4f;
  --site-accent-soft: #edf3ec;
  --site-code: #f4f1ea;
  --site-shadow: rgba(42, 39, 31, 0.045);
}

html {
  scroll-padding-top: 22px;
}

body {
  color: var(--site-text);
  background:
    linear-gradient(90deg, rgba(23, 24, 19, 0.018) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 24, 19, 0.014) 1px, transparent 1px),
    var(--site-bg);
  background-size: 48px 48px, 48px 48px, auto;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Aptos", "Helvetica Neue", sans-serif;
  font-feature-settings: "kern" 1, "liga" 1;
  overflow-x: hidden;
}

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

a:hover {
  color: var(--site-text);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--site-accent) 38%, transparent);
  outline-offset: 4px;
}

strong {
  color: var(--site-text);
  font-weight: 680;
}

body > main.page {
  width: min(920px, calc(100vw - 36px));
  margin: 20px auto;
  padding: 0 clamp(28px, 5vw, 56px) 76px;
  background: var(--site-paper);
  border: 1px solid var(--site-soft-line);
  box-shadow: 0 18px 60px var(--site-shadow);
}

body > main.page > header#top {
  padding: 34px 0 26px;
}

body > main.page > header:not(#top) {
  padding-bottom: 8px;
}

.topbar,
.project-nav {
  border-color: var(--site-line);
}

.topbar {
  min-height: 68px;
  margin-bottom: 60px;
  color: var(--site-muted);
}

.topbar a,
.project-nav a,
.site-menu nav a {
  color: var(--site-muted);
}

.topbar a:hover,
.project-nav a:hover,
.site-menu nav a:hover {
  color: var(--site-text);
}

.topline {
  align-items: center;
}

h1 {
  color: var(--site-text);
  letter-spacing: -0.038em;
}

body > main.page h1 {
  max-width: 820px;
  font-size: clamp(2.05rem, 6vw, 3.5rem);
  line-height: 1.04;
}

body > main.page header#top h1 {
  font-size: clamp(2rem, 5vw, 2.9rem);
}

.role,
.date,
.byline,
.dek,
p,
li,
footer,
.article-figure figcaption,
.abstract,
.disclaimer {
  color: var(--site-muted);
}

.date,
.byline {
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.dek {
  max-width: 760px;
  margin-top: 22px;
  font-size: 1.16rem;
  line-height: 1.62;
}

.abstract {
  max-width: 780px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--site-line);
  color: var(--site-text);
}

.disclaimer {
  max-width: 780px;
  margin-top: 18px;
  padding: 13px 0;
  border-top: 1px solid var(--site-line);
  border-bottom: 1px solid var(--site-line);
}

article {
  max-width: 720px;
}

article p,
body > main.page #summary p,
body > main.page #projects p {
  line-height: 1.72;
}

body > main.page section {
  padding-top: 42px;
}

body > main.page h2 {
  color: var(--site-text);
  letter-spacing: -0.012em;
}

body > main.page header#top + section {
  padding-top: 38px;
}

body > main.page header#top ~ section h2 {
  margin-bottom: 16px;
  color: var(--site-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

article h2 {
  margin: 54px 0 16px;
  padding-top: 28px;
  font-size: 1.2rem;
  line-height: 1.22;
}

article h2::before {
  width: 30%;
  border-color: var(--site-line);
}

body > main.page li {
  border-color: var(--site-soft-line);
}

#blogs li {
  padding: 9px 0;
}

#blogs a,
#projects a,
.contact a {
  border-bottom-color: color-mix(in srgb, var(--site-accent) 34%, transparent);
}

#blogs a {
  display: inline;
  line-height: 1.58;
}

#projects > ul > li {
  padding: 22px 0;
}

#projects > ul > li > strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.02rem;
}

.quote {
  margin: 30px 0;
  padding: 19px 0;
  border-color: var(--site-line);
  color: var(--site-text);
  font-size: 1.06rem;
  line-height: 1.58;
}

.formula,
.tldr,
.note,
.callout,
pre {
  background: var(--site-code);
  border-color: var(--site-line);
}

.formula,
.tldr {
  margin: 22px 0;
  padding: 16px 17px;
  border-left: 2px solid var(--site-line);
  color: var(--site-text);
  line-height: 1.55;
}

.formula {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tldr li,
.tldr p {
  color: var(--site-muted);
}

.article-figure,
.hero-figure {
  margin: 32px 0;
}

.article-figure img,
.hero-figure img,
.screenshot {
  border: 1px solid var(--site-soft-line);
  background: #ffffff;
}

.article-figure figcaption,
.hero-figure figcaption {
  margin-top: 11px;
  font-size: 0.88rem;
  line-height: 1.5;
}

table {
  border-color: var(--site-line);
}

th,
td {
  border-color: var(--site-soft-line);
}

.theme-button,
.menu-button,
.button {
  border-color: var(--site-line);
  background: var(--site-paper);
  color: var(--site-muted);
  border-radius: 6px;
  transition: transform 180ms ease, color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.theme-button:hover,
.menu-button:hover,
.button:hover {
  color: var(--site-text);
  background: var(--site-paper-soft);
  border-color: var(--site-line);
  text-decoration: none;
}

.theme-button:active,
.menu-button:active,
.button:active {
  transform: translateY(1px);
}

.site-menu nav {
  border-color: var(--site-line);
  background: var(--site-paper);
  box-shadow: 0 18px 50px var(--site-shadow);
}

body > nav.project-nav {
  width: min(1180px, calc(100vw - 44px));
  min-height: 64px;
  color: var(--site-muted);
  font-size: 0.9rem;
}

body > main .page {
  width: min(1180px, calc(100vw - 44px));
}

.hero {
  min-height: min(78vh, 820px);
  padding: 42px 0 34px;
}

.hero-grid {
  gap: clamp(28px, 5vw, 56px);
}

.eyebrow {
  color: var(--site-accent);
  letter-spacing: 0.09em;
}

.hero h1 {
  max-width: 780px;
  font-size: clamp(3rem, 8vw, 5.9rem);
  line-height: 0.98;
}

.lead,
.section-head p,
.quickstart-copy p,
.snapshot-copy p,
.problem p,
.principle p,
.surface p,
.usage-step p,
.flow-step p,
.command-step p {
  color: var(--site-muted);
}

.lead {
  line-height: 1.62;
}

.button.primary {
  color: #ffffff;
  background: var(--site-accent);
  border-color: var(--site-accent);
}

.runtime-strip strong,
.tag,
code {
  color: var(--site-accent);
}

.runtime-strip span::before {
  background: var(--site-accent);
}

.flow-step {
  border-left-color: var(--site-accent);
}

.flow-step span {
  color: var(--site-accent);
}

.problem::before,
.principle::before,
.surface::before,
.usage-step::before,
.callout::before,
.callout::after,
.snapshot + .snapshot::before,
.hero::after,
section::after {
  background: var(--site-line);
}

.problem-grid,
.philosophy-grid,
.principle-grid,
.surface-grid,
.usage-grid {
  gap: 28px;
}

.problem,
.principle,
.surface,
.usage-step {
  padding-top: 20px;
}

.snapshot {
  gap: 30px;
  padding: 34px 0;
}

pre {
  border: 1px solid var(--site-line);
  border-radius: 6px;
}

footer {
  border-color: var(--site-line);
}

@media (max-width: 900px) {
  .hero {
    padding: 32px 0;
  }

  .hero h1 {
    font-size: clamp(2.45rem, 12vw, 4.2rem);
  }

  body > main .page,
  body > nav.project-nav {
    width: auto;
    margin-left: 16px;
    margin-right: 16px;
  }
}

@media (max-width: 720px) {
  body {
    background-size: 40px 40px, 40px 40px, auto;
    font-size: 16px;
    line-height: 1.66;
  }

  body > main.page {
    width: auto;
    margin: 12px;
    padding: 0 16px 52px;
  }

  body > main.page > header#top {
    padding: 26px 0 22px;
  }

  .topbar {
    flex-wrap: wrap;
    min-height: 56px;
    margin-bottom: 38px;
    padding: 10px 0;
    line-height: 1.7;
  }

  body > main.page h1 {
    font-size: clamp(1.78rem, 8vw, 2.18rem);
    line-height: 1.1;
  }

  body > main.page header#top h1 {
    font-size: clamp(1.9rem, 9vw, 2.35rem);
  }

  .dek,
  .lead {
    font-size: 1.02rem;
    line-height: 1.6;
  }

  .abstract {
    font-size: 0.94rem;
    line-height: 1.58;
  }

  .disclaimer {
    font-size: 0.78rem;
    line-height: 1.5;
  }

  body > main.page section {
    padding-top: 34px;
  }

  article h2 {
    margin-top: 38px;
    padding-top: 20px;
    font-size: 1.13rem;
  }

  article p,
  body > main.page #summary p,
  body > main.page #projects p {
    line-height: 1.68;
  }

  p {
    margin-bottom: 14px;
  }

  p,
  li,
  h1,
  h2,
  h3,
  .dek,
  .abstract,
  .disclaimer,
  .lead,
  .quote,
  .runtime-strip,
  .section-head,
  .snapshot-copy {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .quote {
    margin: 24px 0;
    padding: 16px 0;
  }

  .formula,
  .tldr {
    margin: 18px 0;
    padding: 14px 15px;
    font-size: 0.86rem;
  }

  .article-figure,
  .hero-figure {
    margin: 25px 0 30px;
  }

  #blogs li,
  .compact li {
    padding: 10px 0;
  }

  #projects > ul > li {
    padding: 20px 0;
  }

  body > nav.project-nav {
    min-height: 58px;
    margin-left: 14px;
    margin-right: 14px;
  }

  body > main .page {
    margin-left: 14px;
    margin-right: 14px;
  }

  .project-nav div {
    gap: 12px;
  }

  .hero {
    padding: 28px 0 30px;
  }

  .hero h1 {
    font-size: clamp(2.35rem, 13vw, 3.4rem);
    line-height: 1;
  }

  .hero-actions {
    gap: 9px;
  }

  .button {
    min-height: 39px;
    padding: 0 13px;
    font-size: 0.9rem;
  }

  .runtime-strip {
    gap: 9px;
  }

  .snapshot {
    padding: 28px 0;
  }
}

@media (max-width: 420px) {
  body > main.page {
    margin: 10px;
    padding-left: 14px;
    padding-right: 14px;
  }

  body > main.page h1 {
    font-size: clamp(1.66rem, 8vw, 2.02rem);
  }

  .project-nav {
    font-size: 0.84rem;
  }
}
