/* ==========================================================================
   Palette and type — carried over from the "Nothing Lasts Forever" design plan:
   sage-stone grounds, slate-blue accent, monospace headings, dense document feel.
   ========================================================================== */

:root {
  --ground:      #EDEFEA;
  --surface:     #FFFFFF;
  --sunken:      #E4E7E0;
  --line:        #D4D9CF;
  --line-2:      #B4BCB0;
  --text:        #151916;
  --muted:       #5A6359;
  --accent:      #3F5966;
  --accent-soft: #E2EAEE;
  --warn:        #8A5A1E;
  --risk:        #8C3A2E;
  --ok:          #3F6B45;
  --mark:        #F2E7BF;

  --mono: ui-monospace, "SFMono-Regular", "SF Mono", "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 3px;
  --shell:  1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #111412;
    --surface:     #181C19;
    --sunken:      #0C0F0D;
    --line:        #262B27;
    --line-2:      #39413A;
    --text:        #E3E7E1;
    --muted:       #8B958A;
    --accent:      #9DB4C0;
    --accent-soft: #1B262B;
    --warn:        #D2A362;
    --risk:        #DE8B7C;
    --ok:          #8FC49A;
    --mark:        #4A431F;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground:      #111412;
  --surface:     #181C19;
  --sunken:      #0C0F0D;
  --line:        #262B27;
  --line-2:      #39413A;
  --text:        #E3E7E1;
  --muted:       #8B958A;
  --accent:      #9DB4C0;
  --accent-soft: #1B262B;
  --warn:        #D2A362;
  --risk:        #DE8B7C;
  --ok:          #8FC49A;
  --mark:        #4A431F;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

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

:where(a, button, input, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

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

.skip {
  position: absolute; left: -9999px; top: 8px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--radius); z-index: 10;
}
.skip:focus { left: 12px; }

/* ------------------------------------------------------------------ layout */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 46px) clamp(16px, 4vw, 40px) 0;
}

.shell-listing { display: grid; grid-template-columns: 1fr; gap: 40px; }

@media (min-width: 980px) {
  .shell-listing { grid-template-columns: minmax(0, 1fr) 248px; gap: 56px; align-items: start; }
  .sidebar { position: sticky; top: 26px; }
}

.listing { min-width: 0; }

/* --------------------------------------------------------------- masthead */

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.masthead-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 40px) 16px;
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: flex-end; justify-content: space-between;
}

.brand-title {
  font-family: var(--mono);
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--text);
  text-decoration: none;
}
.brand-title:hover { color: var(--accent); }

.brand-tagline {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .87rem;
  max-width: 52ch;
}

.masthead-tools { display: flex; align-items: center; gap: 10px; }

.search { display: flex; align-items: center; gap: 0; }

.search input {
  font: inherit;
  font-size: .85rem;
  color: var(--text);
  background: var(--ground);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 6px 10px;
  width: 168px;
  min-width: 0;
}
.search input::placeholder { color: var(--muted); }

.search button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; color: var(--muted);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 6px 10px; cursor: pointer;
}
.search button:hover { color: var(--accent); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 33px; height: 33px;
  color: var(--muted);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle .icon-moon { display: none; }

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

.mainnav {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.mainnav ul {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px);
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 2px;
}
.mainnav a {
  display: block;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 11px 13px;
  border-bottom: 2px solid transparent;
}
.mainnav a:hover { color: var(--text); background: var(--sunken); }
.mainnav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ pieces */

.kicker {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
.kicker a { text-decoration: none; }

.section-label,
.side-label {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.section-label {
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line-2);
  margin: 46px 0 22px;
}

.standfirst {
  margin: 0;
  color: var(--muted);
  font-size: 1.04rem;
  max-width: 68ch;
}

.listing-head { margin-bottom: 30px; }
.listing-head h1 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: -.015em;
  margin: 0 0 10px;
  text-wrap: balance;
}

/* Lead post ---------------------------------------------------------------- */

.lead {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: clamp(20px, 3.4vw, 32px);
}
.lead-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.6rem, 4.4vw, 2.3rem);
  letter-spacing: -.02em;
  line-height: 1.22;
  margin: 0 0 12px;
  text-wrap: balance;
}
.lead-title a { color: var(--text); text-decoration: none; }
.lead-title a:hover { color: var(--accent); }
.lead-excerpt { margin: 0 0 14px; color: var(--muted); max-width: 70ch; font-size: 1.02rem; }
.lead-more a {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .06em;
  text-decoration: none;
}
.lead-more a:hover { text-decoration: underline; }

/* Cards -------------------------------------------------------------------- */

.cards {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card { background: var(--surface); padding: 20px clamp(16px, 2.4vw, 24px); }
.card:hover { background: var(--accent-soft); }

.card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.card-meta .dot { opacity: .5; }

.card-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: -.01em;
  line-height: 1.32;
  margin: 0 0 7px;
}
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }

.card-excerpt { margin: 0 0 10px; color: var(--muted); font-size: .93rem; max-width: 72ch; }

/* Chips and tags ----------------------------------------------------------- */

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid currentColor;
  text-decoration: none;
  color: var(--accent);
  white-space: nowrap;
}
.chip:hover { background: var(--accent-soft); }
.chip-gamedev  { color: var(--risk); }
.chip-appdev   { color: var(--accent); }
.chip-personal { color: var(--ok); }
.chip-draft    { color: var(--warn); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tag {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--muted);
  text-decoration: none;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2px 7px;
}
.tag:hover { color: var(--accent); border-color: var(--line-2); }
.tag .count { opacity: .6; font-size: .9em; }

/* Sidebar ------------------------------------------------------------------ */

.sidebar { display: flex; flex-direction: column; gap: 28px; }
.side-block { border-top: 2px solid var(--line-2); padding-top: 12px; }

.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.side-list li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: .88rem; }
.side-list a { text-decoration: none; color: var(--text); }
.side-list a:hover { color: var(--accent); }
.side-list .count { font-family: var(--mono); font-size: .7rem; color: var(--muted); }

.side-recent li { flex-direction: column; gap: 1px; margin-bottom: 8px; }
.side-recent .side-date { font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.side-note { margin: 0; font-size: .86rem; color: var(--muted); }

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

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 34px 0 0; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: .78rem;
}
.pagination a { text-decoration: none; }
.pagination a:hover { text-decoration: underline; }
.page-count { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.pagination .page-next { margin-left: auto; }

/* ----------------------------------------------------------------- article */

.shell-article { display: grid; grid-template-columns: 1fr; gap: 34px; }

@media (min-width: 1040px) {
  .shell-article.has-toc { grid-template-columns: 214px minmax(0, 1fr); gap: 52px; align-items: start; }
  .shell-article.has-toc .toc { position: sticky; top: 26px; max-height: calc(100vh - 52px); overflow-y: auto; }
  .shell-article.has-toc .article-foot { grid-column: 1 / -1; }
}

.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.toc a {
  display: flex; gap: 9px; padding: 3px 0;
  font-size: .81rem; color: var(--muted); text-decoration: none;
}
.toc a:hover, .toc a.is-active { color: var(--text); }
.toc a.is-active .n { color: var(--accent); }
.toc .n { font-family: var(--mono); font-size: .71rem; opacity: .75; min-width: 1.7em; }

.article-head { margin-bottom: 26px; }
.article-head h1 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  letter-spacing: -.02em;
  line-height: 1.18;
  margin: 0 0 12px;
  text-wrap: balance;
}

.cover { margin: 0 0 26px; }
.cover img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
}

/* Prose -------------------------------------------------------------------- */

.prose { min-width: 0; max-width: 74ch; }
.prose.standalone { margin: 0 auto; }

.prose h2 {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 42px 0 14px;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--line-2);
  scroll-margin-top: 22px;
}
.prose h3 {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 0 9px;
  font-weight: 600;
  scroll-margin-top: 22px;
}
.prose h4 { font-family: var(--mono); font-size: .92rem; margin: 24px 0 8px; }

.prose h2 .anchor, .prose h3 .anchor, .prose h4 .anchor {
  margin-left: 8px; opacity: 0; text-decoration: none;
  font-weight: 400; color: var(--line-2);
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 1; }

.prose p { margin: 0 0 15px; }
.prose ul, .prose ol { margin: 0 0 15px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose li > ul, .prose li > ol { margin-top: 6px; }
.prose strong { font-weight: 650; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 34px 0; }

.prose blockquote {
  margin: 0 0 16px;
  padding: 13px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--mono);
  font-size: .87em;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 4px;
}

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

/* Tables ------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { border-collapse: collapse; width: 100%; font-size: .89rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  background: var(--sunken);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }

/* Code blocks -------------------------------------------------------------- */

.code-block {
  position: relative;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sunken);
  overflow: hidden;
}
.code-lang {
  position: absolute; top: 0; right: 0;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0 var(--radius) 0 var(--radius);
  padding: 3px 8px;
}
.code-block pre { margin: 0; padding: 15px 16px; overflow-x: auto; }
.code-block code {
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.6;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  white-space: pre;
}
.copy-code {
  position: absolute; top: 6px; right: 62px;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 2px;
  padding: 3px 7px; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.code-block:hover .copy-code, .copy-code:focus-visible { opacity: 1; }

/* Syntax tokens */
.tok-comment { color: var(--muted); font-style: italic; }
.tok-string  { color: var(--ok); }
.tok-number  { color: var(--warn); }
.tok-keyword { color: var(--accent); font-weight: 600; }
.tok-func    { color: var(--risk); }
.tok-tag     { color: var(--accent); }
.tok-attr    { color: var(--warn); }
.tok-punct   { color: var(--muted); }

/* Article footer ----------------------------------------------------------- */

.article-tags { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }

.article-foot { margin-top: 46px; }

.post-nav { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (min-width: 700px) { .post-nav { grid-template-columns: 1fr 1fr; } }

.post-nav-item { background: var(--surface); padding: 15px 18px; text-decoration: none; display: block; }
.post-nav-item:hover { background: var(--accent-soft); }
.post-nav-next { text-align: right; }
.post-nav-title { display: block; font-family: var(--mono); font-size: .95rem; color: var(--text); margin-top: 4px; }

.related { margin-top: 40px; }

/* Archive ------------------------------------------------------------------ */

.archive-year { margin-bottom: 38px; }
.archive-year h2 {
  font-family: var(--mono); font-size: 1.05rem; font-weight: 600;
  margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--line-2);
}
.archive-month {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 8px;
}
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.archive-list a { color: var(--text); text-decoration: none; }
.archive-list a:hover { color: var(--accent); }
.archive-date { font-family: var(--mono); font-size: .72rem; color: var(--muted); min-width: 4.6em; }

/* Search / empty states ---------------------------------------------------- */

.search-big { margin-bottom: 28px; }
.search-big input { width: min(420px, 100%); font-size: .95rem; padding: 9px 12px; }
.search-big button {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  padding: 9px 16px; color: var(--accent);
}

.empty { padding: 40px 0 20px; }
.empty h1 { font-family: var(--mono); font-size: 1.6rem; margin: 0 0 10px; }
.empty-note { color: var(--muted); }

.flash {
  margin: 18px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  background: var(--surface);
  border-radius: 2px;
  font-size: .9rem;
}
.flash-error { border-left-color: var(--risk); }

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

.site-footer { margin-top: 70px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  padding-top: 20px; padding-bottom: 24px;
  font-size: .82rem; color: var(--muted);
}
.footer-inner p { margin: 0; }
.footer-links { display: flex; gap: 16px; }
.footer-links a { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; }

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