/* ==========================================================================
   vladgeek.com — single stylesheet
   --------------------------------------------------------------------------
   1. Theme variables  (all colors, fonts and spacing)
   2. Base & typography
   3. Layout (header, nav, main)
   4. Components (link lists, post list)
   5. Blog prose (rendered Markdown)
   6. Terminal (homepage easter egg)
   7. Accessibility & motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. THEME VARIABLES
   Light is the default. The dark palette is declared twice below and the two
   copies must match — see the note there.
   -------------------------------------------------------------------------- */
:root {
  /* Color */
  --bg: #faf7f0;            /* warm paper */
  --bg-raised: #f2ede0;     /* cards / terminal — slightly deeper paper */
  --ink: #211d16;           /* body text */
  --ink-muted: #6f675a;     /* dates, captions, secondary text */
  --accent: #9e3b1f;        /* links, prompt, highlights — 6.33:1 on --bg */
  --accent-soft: rgba(158, 59, 31, 0.22);  /* ::selection wash */
  --warn: #7d5f14;          /* terminal error lines only — 5.11:1 on --bg-raised */
  --border: #ddd5c4;
  --code-bg: #efe9da;

  /* Type */
  --font-body: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas,
               "Liberation Mono", monospace;

  /* Layout */
  --measure: 42rem;         /* max text column width */
  --space: 1.5rem;          /* base spacing unit */

  /* Motion (kept under 200ms by design) */
  --speed: 150ms;

  color-scheme: light;
}

/* Dark palette, manual override. */
:root[data-theme="dark"] {
  --bg: #161410;
  --bg-raised: #1e1b15;
  --ink: #ece5d8;
  --ink-muted: #a79e8d;
  --accent: #e89a6f;
  --accent-soft: rgba(232, 154, 111, 0.24);
  --warn: #dcbb6a;
  --border: #363126;
  --code-bg: #211e17;
  color-scheme: dark;
}

/* Fallback for when scripting is off. theme.js always writes data-theme, so
   with JS on this block cannot match and the rule above is the only one in
   play — the two can never disagree. Values duplicated because a media query
   and a plain selector cannot share a declaration block without a
   preprocessor. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #161410;
    --bg-raised: #1e1b15;
    --ink: #ece5d8;
    --ink-muted: #a79e8d;
    --accent: #e89a6f;
    --accent-soft: rgba(232, 154, 111, 0.24);
    --warn: #dcbb6a;
    --border: #363126;
    --code-bg: #211e17;
    color-scheme: dark;
  }
}

/* --------------------------------------------------------------------------
   2. BASE & TYPOGRAPHY
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-top: 2.5rem; }
h3 { font-size: 1.125rem; margin-top: 1.75rem; }

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  /* Tinted from the link's own color so the underline carries some weight.
     First declaration is the fallback where color-mix() is unsupported. */
  text-decoration-color: var(--border);
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--speed) ease;
}

a:hover {
  text-decoration-color: currentColor;
}

code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

::selection {
  background: var(--accent-soft);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin: 0 0 0.35rem;
}

.lede {
  font-size: 1.2rem;
  color: var(--ink);
}

.muted {
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   3. LAYOUT
   -------------------------------------------------------------------------- */
.site-header,
main {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--space));
  margin-inline: auto;
  padding-inline: var(--space);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  padding-block: 1.75rem 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.site-name {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

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

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: baseline;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--ink-muted);
  text-decoration: none;
}

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

.site-nav a[aria-current="page"] {
  color: var(--accent);
}

.site-nav a[aria-current="page"]::before {
  content: "*";
  margin-right: 0.15em;
}

.theme-toggle {
  display: none; /* revealed below once theme.js sets `.js` */
  font: inherit;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
  transition: color var(--speed) ease, border-color var(--speed) ease;
}

:root.js .theme-toggle {
  display: inline-block;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

main {
  flex: 1;
  padding-block: 3.5rem 4rem;
}

/* --------------------------------------------------------------------------
   4. COMPONENTS
   -------------------------------------------------------------------------- */

.link-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1.25rem 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* A class rather than an inline style, which the CSP forbids. */
.trailing-note {
  margin-top: 2.5rem;
}

/* Consecutive statements meant to read as one block: no gap after this
   paragraph, so it sits directly above the next line. */
.tight {
  margin-bottom: 0;
}

/* Blog index */
.post-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
}

.post-item {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child {
  border-top: 1px solid var(--border);
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  padding-top: 0.25rem;
}

.post-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.post-summary {
  margin: 0.25rem 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

@media (max-width: 480px) {
  .post-item {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

/* Single post header */
.post-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   5. BLOG PROSE — styles for Markdown rendered into .prose
   -------------------------------------------------------------------------- */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.1rem 1.1rem;
  border-left: 3px solid var(--accent);
  color: var(--ink-muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem auto;
  width: 40%;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
  text-align: left;
}

.prose th {
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   6. TERMINAL — homepage easter egg
   -------------------------------------------------------------------------- */
.terminal {
  margin-top: 3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 0.9rem 1.1rem;
  cursor: text;
}

.terminal-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 16rem;
  overflow-y: auto;
}

.terminal-line {
  min-height: 1.2em;
}

.terminal-line.is-prompt {
  color: var(--ink-muted);
}

/* Not --accent: errors sharing the link colour read as ordinary output. */
.terminal-line.is-error {
  color: var(--warn);
}

.terminal-form {
  display: flex;
  gap: 0.5ch;
  align-items: baseline;
  margin: 0;
}

.terminal-prompt {
  color: var(--accent);
  white-space: nowrap;
  user-select: none;
}

.terminal-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  outline: none;
  caret-color: var(--accent);
}

/* Focus shows on the container, since clicking anywhere focuses the input. */
.terminal:focus-within {
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   7. ACCESSIBILITY & MOTION
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--bg-raised);
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  z-index: 10;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
