/* ─── grainworks.css ─────────────────────────────
   Minimal terminal-meets-web1.0 theme
   Zero JavaScript. Zero tracking. Pure CSS.
   ──────────────────────────────────────────── */

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

/* ── Variables ─────────────────────────────── */
:root {
  --bg:         #0c0c0c;
  --bg-alt:     #141414;
  --fg:         #d4d4d4;
  --fg-dim:     #808080;
  --fg-alt:     #999;
  --accent:     #00cc66;
  --accent-dim: #008844;
  --link:       #6699ff;
  --link-visited: #cc66ff;
  --link-hover: #88bbff;
  --border:     #2a2a2a;
  --border-light: #333;
  --code-bg:    #181818;
  --font-mono:  'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  --font-body:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --max-w:      720px;
  --line-h:     1.7;
}

/* ── Light mode via system preference ──────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg:         #fafafa;
    --bg-alt:     #f0f0f0;
    --fg:         #1a1a1a;
    --fg-dim:     #666;
    --fg-alt:     #888;
    --accent:     #008844;
    --accent-dim: #006633;
    --link:       #0044cc;
    --link-visited: #6633aa;
    --link-hover: #2266dd;
    --border:     #ddd;
    --border-light: #e5e5e5;
    --code-bg:    #f5f5f5;
  }
}

/* ── Base ──────────────────────────────────── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--line-h);
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:visited { color: var(--link-visited); }
a:hover,
a:focus { color: var(--link-hover); text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Terminal box-drawing header ─────────────── */

.site-header {
  padding: 2.5rem 1.25rem 1.5rem;
  text-align: center;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
  text-decoration: none;
  display: inline-block;
  white-space: pre;
  letter-spacing: -0.01em;
}

.site-title::before {
  content: "┌──────────────────────────────────────────────────┐\A│";
  white-space: pre;
  display: block;
  color: var(--accent-dim);
  font-weight: 400;
  font-size: 0.6rem;
  line-height: 1.1;
  letter-spacing: normal;
}

.site-title::after {
  content: "│\A└──────────────────────────────────────────────────┘";
  white-space: pre;
  display: block;
  color: var(--accent-dim);
  font-weight: 400;
  font-size: 0.6rem;
  line-height: 1.1;
  letter-spacing: normal;
}

.site-title a,
.site-title a:visited {
  color: var(--fg);
  text-decoration: none;
}

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

/* ── Top ─────────────────────────────────── */
.site-top {
  position: relative;
}

/* ── Navigation ──────────────────────────── */

.site-nav {
  margin-top: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.site-nav a {
  color: var(--fg-dim);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
}

.site-nav a:hover,
.site-nav a:focus {
  color: var(--accent);
}

.site-nav .sep {
  color: var(--border-light);
  font-size: 0.75rem;
}

/* ── Main ────────────────────────────────── */

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* ── Homepage ────────────────────────────── */

.home-description {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--fg-dim);
  margin: 2rem 0 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  line-height: 1.6;
}

/* ── Section heading ─────────────────────── */

.section-heading {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Post list ───────────────────────────── */

.post-entry {
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.post-entry:last-of-type {
  border-bottom: none;
}

.post-entry:hover .post-title {
  color: var(--accent);
}

.post-title {
  font-family: var(--font-mono);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--fg);
  transition: color 0.15s ease;
}

.post-entry .post-title::before {
  content: "→ ";
  color: var(--accent-dim);
  font-weight: 400;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-top: 0.25rem;
}

.post-meta .tag {
  color: var(--fg-alt);
}

.post-excerpt {
  font-size: 0.9rem;
  color: var(--fg-alt);
  margin-top: 0.3rem;
  line-height: 1.5;
}

/* ── Single post / page ──────────────────── */

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
}

.page-meta {
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-top: 0.5rem;
}

.page-meta a {
  color: var(--fg-dim);
}

.page-content {
  font-size: 1rem;
  line-height: var(--line-h);
}

.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4 {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg);
  margin: 2rem 0 0.75rem;
}

.page-content h1 { font-size: 1.375rem; }
.page-content h2 { font-size: 1.2rem; }
.page-content h3 { font-size: 1.05rem; }

.page-content p {
  margin-bottom: 1rem;
}

.page-content ul,
.page-content ol {
  margin: 0 0 1rem 1.5rem;
}

.page-content li {
  margin-bottom: 0.35rem;
}

.page-content blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent-dim);
  background: var(--bg-alt);
  font-style: italic;
  color: var(--fg-alt);
}

.page-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.page-content pre {
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}

.page-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.page-content img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

.page-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.page-content th,
.page-content td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

.page-content th {
  background: var(--bg-alt);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Tag list on tag pages ───────────────── */

.tag-list {
  list-style: none;
  margin: 1rem 0;
}

.tag-list li {
  display: inline-block;
  margin: 0.25rem;
}

.tag-list a {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--fg-dim);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.15s ease;
}

.tag-list a:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ── 404 ─────────────────────────────────── */

.error-404 {
  text-align: center;
  padding: 4rem 1rem;
}

.error-404 h1 {
  font-family: var(--font-mono);
  font-size: 3rem;
  color: var(--accent-dim);
  margin-bottom: 1rem;
}

.error-404 p {
  color: var(--fg-dim);
  margin-bottom: 1.5rem;
}

/* ── Footer ──────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 2rem 1.25rem 3rem;
  font-size: 0.75rem;
  color: var(--fg-dim);
  border-top: 1px solid var(--border);
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.site-footer a {
  color: var(--fg-dim);
  text-decoration: underline;
}

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

/* ── Mailing list form ───────────────────── */

.mailing-list {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.mailing-list h3 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.mailing-list p {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-bottom: 0.75rem;
}

.mailing-list form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mailing-list input[type="email"] {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-light);
  outline: none;
}

.mailing-list input[type="email"]:focus {
  border-color: var(--accent-dim);
}

.mailing-list button {
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.mailing-list button:hover {
  opacity: 0.85;
}

/* ── Pagination ──────────────────────────── */

.pagination {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination a {
  color: var(--fg-dim);
  text-decoration: none;
}

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

/* ── Responsive ──────────────────────────── */

@media (max-width: 600px) {
  html { font-size: 15px; }

  .site-header { padding: 1.5rem 1rem 1rem; }

  .site-title { font-size: 1.2rem; }

  .site-title::before,
  .site-title::after {
    font-size: 0.5rem;
  }

  .site-nav { font-size: 0.75rem; }
  .site-nav a { padding: 0.2rem 0.35rem; }

  main { padding: 0 1rem 2rem; }

  .page-title { font-size: 1.25rem; }

  .post-title { font-size: 1rem; }

  .mailing-list form { flex-direction: column; }
  .mailing-list input[type="email"] { min-width: unset; width: 100%; }
}

@media (max-width: 380px) {
  html { font-size: 14px; }
  .site-title { font-size: 1rem; }
}
