@import url("syntax.css");

:root {
  color-scheme: light;
  --bg: #f2f0e8;
  --panel: #e8e5da;
  --line: #d3cfc0;
  --text: #25251f;
  --dim: #6d6c62;
  --accent: #596619;
  --code: #374b3b;
  --glass: rgba(255, 255, 255, .48);
  --glass-edge: rgba(0, 0, 0, .12);
  --glass-active: rgba(89, 102, 25, .10);
}

:root[data-theme="paper"] {
  color-scheme: light;
  --bg: #f2f0e8;
  --panel: #e8e5da;
  --line: #d3cfc0;
  --text: #25251f;
  --dim: #6d6c62;
  --accent: #596619;
  --code: #374b3b;
  --glass: rgba(255, 255, 255, .48);
  --glass-edge: rgba(0, 0, 0, .12);
  --glass-active: rgba(89, 102, 25, .10);
}

:root[data-theme="terminal"] {
  color-scheme: dark;
  --bg: #101511;
  --panel: #19211a;
  --line: #303b31;
  --text: #e3ebdf;
  --dim: #a0ad9e;
  --accent: #a8d08d;
  --code: #c4d9bb;
  --glass: rgba(16, 21, 17, .82);
  --glass-edge: rgba(200, 230, 190, .16);
  --glass-active: rgba(168, 208, 141, .12);
}

:root[data-theme="phosphor"] {
  color-scheme: dark;
  --bg: #17120d;
  --panel: #211911;
  --line: #403222;
  --text: #f2e6d1;
  --dim: #bdad92;
  --accent: #e2a34f;
  --code: #ead0a5;
  --glass: rgba(23, 18, 13, .84);
  --glass-edge: rgba(240, 210, 160, .16);
  --glass-active: rgba(226, 163, 79, .13);
}

:root[data-theme="synthwave"] {
  color-scheme: dark;
  --bg: #11101a;
  --panel: #1b1928;
  --line: #39334d;
  --text: #ebe5f5;
  --dim: #b0a8c3;
  --accent: #c5a3ff;
  --code: #d2c2f5;
  --glass: rgba(17, 16, 26, .84);
  --glass-edge: rgba(210, 190, 255, .17);
  --glass-active: rgba(197, 163, 255, .13);
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #000;
  --panel: #080a08;
  --line: #202820;
  --text: #e5f5e2;
  --dim: #a9c3a5;
  --accent: #39ff14;
  --code: #c7efbf;
  --glass: rgba(0, 0, 0, .72);
  --glass-edge: rgba(57, 255, 20, .20);
  --glass-active: rgba(57, 255, 20, .12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #000;
    --panel: #080a08;
    --line: #202820;
    --text: #e5f5e2;
    --dim: #a9c3a5;
    --accent: #39ff14;
    --code: #c7efbf;
    --glass: rgba(0, 0, 0, .72);
    --glass-edge: rgba(57, 255, 20, .20);
    --glass-active: rgba(57, 255, 20, .12);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
  transition: background-color .2s ease, color .2s ease;
}
a { color: var(--accent); text-underline-offset: .2em; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.site-header, main, .site-footer {
  width: min(100% - 44px, 640px);
  margin-inline: auto;
}
.site-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  color: var(--accent);
  font: 700 .95rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-decoration: none;
}
.site-footer nav a {
  color: var(--dim);
  font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-decoration: none;
}
.site-footer nav a:hover { color: var(--accent); }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
}
.theme-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--line);
}

main { min-height: 65vh; padding: 56px 0 200px; }
h1, h2, h3 { color: var(--text); line-height: 1.25; }
h1 {
  max-width: 15ch;
  margin: 0 0 22px;
  font-size: clamp(2.3rem, 7vw, 4rem);
  letter-spacing: -.045em;
}
h2 { margin: 52px 0 16px; font-size: 1.25rem; letter-spacing: -.02em; }
h2::before { margin-right: .6ch; color: var(--accent); content: "##"; opacity: .6; }
h3 { margin: 28px 0 10px; font-size: 1.05rem; }
p, ul, ol, blockquote, table { margin-top: 0; margin-bottom: 20px; }
p { max-width: 68ch; }
li { padding-left: 3px; }
li + li { margin-top: 7px; }
main > ul:not(.posts), main > ol { padding-left: 22px; }
blockquote {
  margin-left: 0;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--accent);
  color: var(--dim);
}
hr { height: 1px; margin: 36px 0; border: 0; background: var(--line); }
img { max-width: 100%; height: auto; }
figure { margin: 32px auto; }
figure img { display: block; margin-inline: auto; }
figcaption { margin-top: 8px; color: var(--dim); font-size: .85rem; text-align: center; }
.build-flow { margin: 36px 0 48px; padding: 0; }
.build-flow figcaption { margin: 0 0 12px; color: var(--dim); font: .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: left; }
.build-flow ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0; list-style: none; }
.build-flow li { position: relative; display: grid; gap: 5px; min-width: 0; padding: 12px 18px 12px 0; border-top: 1px solid var(--line); }
.build-flow li:not(:last-child)::after { position: absolute; top: 21px; right: 10px; width: 7px; height: 7px; border-top: 1px solid var(--accent); border-right: 1px solid var(--accent); content: ""; transform: rotate(45deg); }
.build-flow li span { color: var(--dim); font: .68rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.build-flow li strong { overflow-wrap: anywhere; color: var(--text); font-size: .9rem; font-weight: 600; }
code, pre, .meta, time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
code { color: var(--code); font-size: .9em; }
pre {
  max-width: 100%;
  overflow: auto;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--code);
  font-size: .88rem;
  line-height: 1.65;
}
pre code { color: inherit; }
.highlight {
  max-width: 100%;
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--code);
}
.highlight pre { margin: 0; border: 0; background: transparent; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; }
caption { padding: 8px; color: var(--dim); text-align: left; }
.posts { margin: 26px 0 0; padding: 0; list-style: none; }
.posts li {
  display: flex;
  gap: 20px;
  align-items: baseline;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.posts li span { flex: 0 0 104px; color: var(--dim); font: .78rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.posts li a { text-decoration: none; }
.posts li a:hover { text-decoration: underline; }
.site-footer { padding: 20px 0 calc(116px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 15px; }
.site-footer p { margin: 0; color: var(--dim); font-size: .8rem; }
.site-footer p a { color: var(--dim); }
.glass-nav { position: fixed; z-index: 10; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 2px; height: 68px; padding: 6px; border: 1px solid var(--glass-edge); border-radius: 999px; background: var(--glass); -webkit-backdrop-filter: blur(14px) saturate(1.9) brightness(1.1); backdrop-filter: blur(14px) saturate(1.9) brightness(1.1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -1px 0 rgba(0, 0, 0, .16), 0 10px 30px rgba(0, 0, 0, .14); transform: translateX(-50%); transition: left .4s cubic-bezier(.3,1.2,.4,1), padding .4s cubic-bezier(.3,1.2,.4,1), gap .4s, transform .4s, width .4s; }
.glass-nav::before { position: absolute; inset: 0; padding: 1px; border-radius: inherit; background: linear-gradient(135deg, rgba(255,255,255,.42), transparent 30%, transparent 72%, var(--glass-edge)); content: ""; pointer-events: none; -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.glass-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: clamp(66px, calc((100vw - 54px) / 4), 84px); min-width: 0; height: 56px; padding: 0; border-radius: 999px; color: var(--dim); font: .7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-decoration: none; transition: background-color .18s ease, color .18s ease, opacity .2s ease, width .3s ease; }
.glass-nav a:hover, .glass-nav a.active { background: var(--glass-active); color: var(--accent); }
.glass-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.glass-nav.mini { left: calc(18px + env(safe-area-inset-left, 0px)); right: auto; gap: 0; width: 68px; padding: 6px; transform: translateX(0); }
.glass-nav.mini a { width: 54px; min-width: 54px; }
.glass-nav.mini a:not(.active) { width: 0; min-width: 0; opacity: 0; visibility: hidden; pointer-events: none; }
.glass-nav.mini a.active span { display: none; }
.glass-nav a:focus-visible { z-index: 1; outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .glass-nav, .glass-nav a { transition: none; }
}
@media (max-width: 560px) {
  .site-header, main, .site-footer { width: min(100% - 32px, 640px); }
  .site-header { min-height: 64px; flex-wrap: wrap; gap: 12px; padding-block: 10px; }
  .wordmark { margin-right: auto; }
  .theme-toggle { min-height: 36px; padding-inline: 9px; }
  main { padding-top: 48px; }
  .build-flow ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .build-flow li:nth-child(2)::after { display: none; }
  .glass-nav { max-width: calc(100vw - 20px); }
  .posts li { gap: 12px; }
  .posts li span { flex-basis: 88px; }
}
