/*
 * style.css — personal site
 * Palette: warm paper ink on near-black, terracotta accent.
 * Type: Space Mono for structure, Space Grotesk for prose.
 * Accent: violet (#b49bff on dark, #6c3fd4 on light).
 */

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

:root, :root[data-theme="dark"] {
  --bg:        #0e100d;
  --panel:     #151813;
  --ink:       #e6e1cf;
  --muted:     #8b907e;
  --line:      #2b302a;
  --accent:    #b49bff;
  --link-line: #b49bff;
  --dith-base: #140f2b;
  --dith-mid:  #5240a8;
  --dith-glow: #d9cdfd;
  --scanline:  rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] {
  --bg:        #f2eee1;
  --panel:     #e9e4d2;
  --ink:       #23251e;
  --muted:     #6f7260;
  --line:      #d2ccb6;
  --accent:    #6c3fd4;
  --link-line: #6c3fd4;
  --dith-base: #2b2158;
  --dith-mid:  #8a72dc;
  --dith-glow: #efeafe;
  --scanline:  rgba(35, 37, 30, 0.10);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  transition: background 160ms ease, color 160ms ease;
}

::selection { background: var(--accent); color: var(--bg); }

.mono, nav, .post-list, .site-head, footer, time, .facts, .theme-toggle {
  font-family: "Space Mono", ui-monospace, monospace;
}

/* ---------- shell ---------- */

.shell {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--bg);
  padding: 0.4rem 0.9rem;
  z-index: 10;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- site header ---------- */

.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.6rem 0 1.2rem;
  font-size: 0.95rem;
}

.site-head .who {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.site-head .who::before {
  content: "▪";
  color: var(--accent);
  margin-right: 0.5ch;
}

nav { display: flex; gap: 1.1rem; align-items: baseline; }

nav a, .site-head .who { text-decoration: none; color: var(--ink); }
nav a[aria-current="page"] { color: var(--accent); }
nav a:hover { color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  border-radius: 2px;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- dithered header frame ---------- */

.dither-frame {
  position: relative;
  aspect-ratio: 4 / 1;
  margin: 0.4rem 0 2.2rem;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--dith-base);
}

.dither-frame canvas {
  position: absolute;
  left: -6%;
  top: -6%;
  width: 112%;
  height: 112%;
  image-rendering: pixelated;
  will-change: transform;
}

/* faint scanlines + vignette over the frame only */
.dither-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 60%, var(--scanline) 130%),
    repeating-linear-gradient(
      180deg,
      var(--scanline) 0, var(--scanline) 1px,
      transparent 1px, transparent 4px
    );
}

@media (max-width: 30rem) {
  .dither-frame { aspect-ratio: 3 / 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dither-frame canvas { transform: none !important; }
}

/* ---------- type ---------- */

h1, h2, h3, h4 {
  font-family: "Space Mono", ui-monospace, monospace;
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 1.6rem; margin: 0 0 0.9rem; }
h2 { font-size: 1.15rem; margin: 2.4rem 0 0.8rem; }
h3 { font-size: 1rem; margin: 2rem 0 0.6rem; }
h4 { font-size: 0.92rem; margin: 1.7rem 0 0.5rem; color: var(--muted); }

/* prompt-style heading marker */
h1 .mark, h2 .mark {
  color: var(--accent);
  font-weight: 400;
  margin-right: 0.35ch;
}

.lede { color: var(--muted); font-size: 1.02rem; }

p { margin: 0 0 1.1rem; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--link-line);
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); }

/* ---------- lists / posts ---------- */

.post-list { list-style: none; font-size: 0.92rem; }
.post-list li {
  display: flex;
  gap: 1.2rem;
  padding: 0.55rem 0;
  border-bottom: 1px dotted var(--line);
  align-items: baseline;
}
.post-list time { color: var(--muted); flex-shrink: 0; }
.post-list a { text-decoration: none; }
.post-list a:hover { color: var(--accent); }

.plain-list { list-style: none; }
.plain-list li { padding: 0.3rem 0; }
.plain-list li::before {
  content: "→";
  color: var(--accent);
  margin-right: 0.7ch;
}

/* ---------- about bits ---------- */

.facts { margin: 1rem 0 0; font-size: 0.9rem; }
.facts div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px dotted var(--line);
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

@media (max-width: 30rem) {
  .facts div { grid-template-columns: 1fr; gap: 0.1rem; }
}

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

.prose { margin-top: 1.6rem; }
.prose ul, .prose ol { margin: 0 0 1.1rem 1.4rem; }
.prose li { margin-bottom: 0.3rem; }

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 1.4rem 0;
  color: var(--muted);
}

.prose hr {
  border: none;
  border-top: 1px dotted var(--line);
  margin: 2.2rem 0;
}

.prose .table-wrap { overflow-x: auto; margin: 1.5rem 0; }
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  line-height: 1.45;
}
.prose th, .prose td {
  border-bottom: 1px dotted var(--line);
  padding: 0.5rem 0.8rem;
  text-align: left;
  vertical-align: top;
}
.prose th {
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.prose td code, .prose th code { white-space: nowrap; }

code {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--panel);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.prose pre {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1.4rem 0;
  border-radius: 3px;
}
.prose pre code { background: none; padding: 0; font-size: 0.85rem; line-height: 1.6; }

.post-meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.4rem; }

.back-link {
  display: inline-block;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  margin-bottom: 1.6rem;
  text-decoration: none;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

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

footer {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
  padding: 1.2rem 0 3rem;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }
footer nav { gap: 0.9rem; }

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

/* ---------- publications ---------- */

.pub-list { list-style: none; font-size: 0.95rem; }
.pub-list li {
  padding: 0.55rem 0;
  border-bottom: 1px dotted var(--line);
}
.pub-meta {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: "Space Mono", ui-monospace, monospace;
}

/* ---------- guestbook ---------- */

.gb-form {
  display: grid;
  gap: 0.9rem;
  margin: 1.4rem 0 2.2rem;
  max-width: 26rem;
}
.gb-form label {
  display: grid;
  gap: 0.3rem;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--muted);
}
.gb-form input, .gb-form textarea {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.45rem 0.6rem;
}
.gb-form input:focus, .gb-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.gb-entry {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.9rem;
  background: var(--panel);
}
.gb-msg p { margin-bottom: 0.4rem; }
.gb-msg p:last-child { margin-bottom: 0; }
.gb-meta {
  margin-top: 0.5rem;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.notice {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--accent);
  border: 1px dashed var(--accent);
  padding: 0.5rem 0.8rem;
  border-radius: 3px;
  margin-bottom: 1.2rem;
}

.muted-note { color: var(--muted); font-size: 0.85rem; }

/* ---------- shared buttons ---------- */

.btn {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { filter: brightness(1.1); color: var(--bg); }
.btn.ghost {
  background: none;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- recent commits block ---------- */

.hm {
  margin: 0 0 1.2rem;
  font-family: "Space Mono", ui-monospace, monospace;
  --hm-cell: 14px;
  --hm-gap: 4px;
}

.hm-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--hm-cell);
  gap: var(--hm-gap);
  margin-left: calc(2rem + 0.55rem);
  font-size: 0.65rem;
  line-height: 1;
  color: var(--muted);
  padding-bottom: 4px;
  white-space: nowrap;
}

.hm-body { display: flex; gap: 0.55rem; }

.hm-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--hm-cell));
  gap: var(--hm-gap);
  width: 2rem;
  font-size: 0.62rem;
  color: var(--muted);
  align-items: center;
  text-align: right;
}

.hm-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--hm-cell));
  grid-auto-columns: var(--hm-cell);
  gap: var(--hm-gap);
}

.hm-cell {
  width: var(--hm-cell);
  height: var(--hm-cell);
  border-radius: 3px;
  background: var(--line);
}
.hm-cell[data-l="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--panel)); }
.hm-cell[data-l="2"] { background: color-mix(in srgb, var(--accent) 48%, var(--panel)); }
.hm-cell[data-l="3"] { background: color-mix(in srgb, var(--accent) 72%, var(--panel)); }
.hm-cell[data-l="4"] { background: var(--accent); }
.hm-cell:hover { outline: 1px solid var(--accent); outline-offset: 1px; }

.commit-list {
  list-style: none;
  font-size: 0.82rem;
}
.commit-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px dotted var(--line);
}
.commit-list li:last-child { border-bottom: none; }

.repo-tag {
  color: var(--accent);
  font-size: 0.74rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 0.35rem;
  text-decoration: none;
  white-space: nowrap;
}
.repo-tag:hover { border-color: var(--accent); color: var(--accent); }

.commit-msg { text-decoration: none; }
.commit-msg:hover { color: var(--accent); }

.commit-list time {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

@media (max-width: 30rem) {
  .commit-list li { grid-template-columns: auto 1fr; }
  .commit-list time { display: none; }
}
