/* ═══════════════════════════════════════════════════════════
   skeu.css — Skeuomorphic skin (temporary, replaces style.css)
   Materials: leather sidebar, paper sheet, wood desk, metal controls
   Light source: top-left → highlights top-left, shadows bottom-right

   Palettes are switched via html[data-palette] (see .palette-swatch
   picker in nav.njk). No attribute = "forest" default.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── material tokens (non-palette) ── */
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  --sans: system-ui, sans-serif;
  --serif: Georgia, "Bitstream Charter", serif;

  --metal-hi: #ececec;
  --metal-mid: #c2c2c2;
  --metal-lo: #d9d9d9;
  --metal-border: #999;
  --metal-ink: #333;

  --track-hi: #b0b0b0;
  --track-lo: #d0d0d0;
  --fill-hi: #4a90d9;
  --fill-lo: #2d6fba;

  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");

  /* ── forest green baize + brass (default) ── */
  --desk-a: #26704f;
  --desk-b: #1d5c43;
  --desk-c: #174a35;
  --desk-dark: #0e1f18;

  --leather: #1e4a35;
  --leather-ink: #e9f1dd;
  --leather-muted: rgba(255,255,255,0.6);

  --paper: #faf7ec;
  --paper-edge: #e4dcc2;
  --ink: #20351f;
  --muted: #5f7350;
  --accent: #7a5c12;
  --accent-dark: #d6b25a;
  --border: #cfc9a8;
  --inset: #f1ecdb;
  --inset-edge: #c2ba96;
  --rule: #d8d1b2;

  --paper-dark: #161f16;
  --paper-edge-dark: #263524;
  --ink-dark: #e6ecdd;
  --muted-dark: #a3b392;
  --border-dark: #3a4a35;
  --inset-dark: #10180f;
  --inset-edge-dark: #2b3a29;
  --rule-dark: #2b3828;

  --bg: var(--desk-b);
  --blockquote-color: var(--accent);
  --text-emboss: 0 1px 0 rgba(255,255,255,0.4), 0 -1px 0 rgba(0,0,0,0.05);
  --text-emboss-dark: 0 1px 0 rgba(255,255,255,0.04), 0 -1px 0 rgba(0,0,0,0.55);
  --rule-hi: 0 1px 0 rgba(255,255,255,0.5);
  --rule-hi-dark: 0 1px 0 rgba(255,255,255,0.05);
}

/* ── warm wood + tan leather + cream paper ── */
html[data-palette="warm"] {
  --desk-a: #8B5E3C;
  --desk-b: #6B4423;
  --desk-c: #7a4e2a;
  --desk-dark: #191411;

  --leather: #3a291a;
  --leather-ink: #f3e7d3;
  --leather-muted: rgba(255,255,255,0.65);

  --paper: #f9f6f0;
  --paper-edge: #e7dcc9;
  --ink: #2b1d0e;
  --muted: #6f5d45;
  --accent: #8f3a1d;
  --accent-dark: #d99a54;
  --border: #c9b89c;
  --inset: #efe8da;
  --inset-edge: #bfb19b;
  --rule: #cfc0a6;

  --paper-dark: #211c16;
  --paper-edge-dark: #322a20;
  --ink-dark: #efe3d2;
  --muted-dark: #b3a088;
  --border-dark: #4a3b2b;
  --inset-dark: #1b1611;
  --inset-edge-dark: #3a2f25;
  --rule-dark: #352b21;

  --bg: var(--desk-b);
}

/* ── ink blue / denim ── */
html[data-palette="ocean"] {
  --desk-a: #2e4270;
  --desk-b: #26375e;
  --desk-c: #1f2e52;
  --desk-dark: #0c1224;

  --leather: #25355c;
  --leather-ink: #e6ecf9;
  --leather-muted: rgba(255,255,255,0.6);

  --paper: #f8f9fc;
  --paper-edge: #dde3ee;
  --ink: #1c2742;
  --muted: #5a6a8a;
  --accent: #2b3f8f;
  --accent-dark: #7e95d8;
  --border: #c7d0e0;
  --inset: #eef1f7;
  --inset-edge: #b9c3d6;
  --rule: #d3dae6;

  --paper-dark: #141a2e;
  --paper-edge-dark: #232c49;
  --ink-dark: #e3e9f7;
  --muted-dark: #8ea0c4;
  --border-dark: #333d5c;
  --inset-dark: #101527;
  --inset-edge-dark: #2a3452;
  --rule-dark: #2a3350;

  --bg: var(--desk-b);
}

/* ── forest green baize + brass ── */
html[data-palette="forest"] {
  --desk-a: #26704f;
  --desk-b: #1d5c43;
  --desk-c: #174a35;
  --desk-dark: #0e1f18;

  --leather: #1e4a35;
  --leather-ink: #e9f1dd;
  --leather-muted: rgba(255,255,255,0.6);

  --paper: #faf7ec;
  --paper-edge: #e4dcc2;
  --ink: #20351f;
  --muted: #5f7350;
  --accent: #7a5c12;
  --accent-dark: #d6b25a;
  --border: #cfc9a8;
  --inset: #f1ecdb;
  --inset-edge: #c2ba96;
  --rule: #d8d1b2;

  --paper-dark: #161f16;
  --paper-edge-dark: #263524;
  --ink-dark: #e6ecdd;
  --muted-dark: #a3b392;
  --border-dark: #3a4a35;
  --inset-dark: #10180f;
  --inset-edge-dark: #2b3a29;
  --rule-dark: #2b3828;

  --bg: var(--desk-b);
}

/* ── oxblood leather + gold ── */
html[data-palette="oxblood"] {
  --desk-a: #6b2130;
  --desk-b: #5c1a24;
  --desk-c: #4a1420;
  --desk-dark: #160608;

  --leather: #4a1420;
  --leather-ink: #f7e8d9;
  --leather-muted: rgba(255,255,255,0.6);

  --paper: #faf3e6;
  --paper-edge: #e6d6bb;
  --ink: #3a1d15;
  --muted: #7d6a55;
  --accent: #8f2440;
  --accent-dark: #d4687f;
  --border: #d9c8a8;
  --inset: #f2e7d3;
  --inset-edge: #c8b18a;
  --rule: #ddcfb2;

  --paper-dark: #211610;
  --paper-edge-dark: #35251a;
  --ink-dark: #f0e2d2;
  --muted-dark: #bda98c;
  --border-dark: #4a3627;
  --inset-dark: #1a100b;
  --inset-edge-dark: #3a2a1c;
  --rule-dark: #33271b;

  --bg: var(--desk-b);
}

/* ── noir charcoal + silver ── */
html[data-palette="noir"] {
  --desk-a: #46464b;
  --desk-b: #3a3a3e;
  --desk-c: #2e2e31;
  --desk-dark: #0a0a0c;

  --leather: #2b2b2f;
  --leather-ink: #ecece9;
  --leather-muted: rgba(255,255,255,0.6);

  --paper: #f5f2ec;
  --paper-edge: #ded9cf;
  --ink: #26221c;
  --muted: #6f6a60;
  --accent: #4a4a58;
  --accent-dark: #d0d0d8;
  --border: #c9c4b8;
  --inset: #ece8df;
  --inset-edge: #bdb7a9;
  --rule: #d2cdc2;

  --paper-dark: #1c1c1e;
  --paper-edge-dark: #2c2c30;
  --ink-dark: #ecece9;
  --muted-dark: #a5a5a0;
  --border-dark: #3f3f45;
  --inset-dark: #121214;
  --inset-edge-dark: #2c2c30;
  --rule-dark: #2a2a2e;

  --bg: var(--desk-b);
}

/* ── dark theme: remap light palette vars to their -dark variants ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: var(--paper-dark);
    --paper-edge: var(--paper-edge-dark);
    --ink: var(--ink-dark);
    --muted: var(--muted-dark);
    --accent: var(--accent-dark);
    --border: var(--border-dark);
    --inset: var(--inset-dark);
    --inset-edge: var(--inset-edge-dark);
    --rule: var(--rule-dark);
    --text-emboss: var(--text-emboss-dark);
    --rule-hi: var(--rule-hi-dark);
    --bg: var(--desk-dark);
  }
  :root:not([data-theme="light"]) body {
    background-color: var(--bg);
    background-image: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(0,0,0,0.35)), var(--noise);
    background-size: 140px 140px;
  }
  ::selection { background: var(--accent); color: #16130e; }
}

html[data-theme="dark"] {
  --paper: var(--paper-dark);
  --paper-edge: var(--paper-edge-dark);
  --ink: var(--ink-dark);
  --muted: var(--muted-dark);
  --accent: var(--accent-dark);
  --border: var(--border-dark);
  --inset: var(--inset-dark);
  --inset-edge: var(--inset-edge-dark);
  --rule: var(--rule-dark);
  --text-emboss: var(--text-emboss-dark);
  --rule-hi: var(--rule-hi-dark);
  --bg: var(--desk-dark);
}

[data-theme="dark"] body {
  background-color: var(--bg);
  background-image: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(0,0,0,0.35)), var(--noise);
  background-size: 140px 140px;
}

[data-theme="dark"] ::selection { background: var(--accent); color: #16130e; }

/* ═══════════════════════════ base ═══════════════════════════ */

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

input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

/* ── Desk / backdrop ── */

body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.08) 100%),
    repeating-linear-gradient(88deg, rgba(0,0,0,0.08) 0 2px, transparent 2px 140px),
    linear-gradient(90deg, var(--desk-a), var(--desk-b), var(--desk-c), var(--desk-b), var(--desk-a));
  max-width: none;
  margin: 0;
  padding: 2rem 1.25rem;
  font-weight: 400;
}

@media (max-width: 899px) {
  body { padding: 1rem 0.75rem; }
}

/* ── Layout ── */

.layout-grid {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 899px) {
  .layout-grid { grid-template-columns: 1fr; gap: 1.25rem; }
}

/* ── Leather sidebar ── */

.sidebar-left {
  position: sticky;
  top: 1.5rem;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.10), rgba(0,0,0,0.18)),
    var(--leather);
  border: 2px solid rgba(0,0,0,0.35);
  border-radius: 12px;
  padding: 1.5rem 1.25rem;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.18) inset,
    0 -2px 6px rgba(0,0,0,0.3) inset,
    0 6px 16px rgba(0,0,0,0.4),
    0 2px 4px rgba(0,0,0,0.4);
}

@media (max-width: 899px) {
  .sidebar-left { position: static; }
}

/* Stitched edge */
.sidebar-left::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed rgba(255,255,255,0.14);
  border-radius: 8px;
  pointer-events: none;
}

.site-header {
  margin-bottom: 0;
  padding-bottom: 1em;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  flex-direction: column;
  gap: 0.75rem;
}

.logo-title {
  font-size: 1.25em;
  font-weight: 500;
  color: var(--leather-ink) !important;
  margin: 0;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6), 0 -1px 0 rgba(255,255,255,0.12);
}

.logo-subtitle {
  font-size: 0.85em;
  color: var(--leather-muted);
  margin: 0;
  font-family: var(--sans);
}

.nav-links {
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.1rem;
}

.nav-links a {
  font-family: var(--sans);
  font-size: 0.9em;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: rgba(0,0,0,0.18);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.14) inset,
    0 2px 3px rgba(0,0,0,0.35);
  transition: all 0.12s ease;
}

.nav-links a:hover {
  color: #fff;
  background: rgba(0,0,0,0.28);
}

.nav-links a.active {
  font-weight: 600;
  color: #ffe9c7;
  background: rgba(0,0,0,0.35);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.10) inset,
    0 2px 5px rgba(0,0,0,0.45) inset;
}

/* ── Palette picker (temporary, footer) ── */

.palette-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.palette-label {
  font-family: var(--sans);
  font-size: 0.68em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.palette-swatches {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}

.palette-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.4);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset, 0 1px 2px rgba(0,0,0,0.25);
  transition: transform 0.1s ease;
  opacity: 0.85;
}

.palette-swatch:hover { transform: scale(1.25); opacity: 1; }

.palette-swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  opacity: 1;
}

/* ── Paper sheet ── */

.content-area {
  background-color: var(--paper);
  background-image: var(--noise);
  background-size: 140px 140px;
  border-radius: 4px;
  padding: 2.25rem 2.5rem 1.75rem;
  position: relative;
  min-width: 0;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 -1px 0 rgba(0,0,0,0.08) inset,
    0 12px 28px rgba(0,0,0,0.4),
    0 3px 8px rgba(0,0,0,0.35),
    0 0 0 1px var(--paper-edge);
}

/* Page-curl corner */
.content-area::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 34px;
  height: 34px;
  background: linear-gradient(225deg,
    rgba(0,0,0,0.28) 0 48%,
    rgba(0,0,0,0.10) 52%,
    transparent 55%);
  border-bottom-right-radius: 4px;
  filter: drop-shadow(-3px -3px 3px rgba(0,0,0,0.12));
  pointer-events: none;
}

@media (max-width: 899px) {
  .content-area { padding: 1.5rem 1.25rem 1.25rem; }
}

/* ── Typography ── */

::selection {
  background: var(--accent);
  color: #fff;
  text-shadow: none;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  line-height: 1.25;
  font-weight: 500;
  font-family: var(--serif);
  margin-top: 2rem;
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
  text-shadow: var(--text-emboss);
}

h1 { font-size: clamp(1.5rem, 2.5vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 2vw, 2rem); }
h3 { font-size: clamp(1.15rem, 1.5vw, 1.5rem); }
h4, h5, h6 { font-size: 1em; }

p { margin: 0 0 1rem; }
strong, b { font-weight: 600; }
h1 + p, h2 + p, h3 + p { margin-top: 0; }

/* ── Links (ink on paper) ── */

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

/* ── Meta / time ── */

time {
  font-family: var(--mono);
  color: var(--muted);
}

/* ── Media ── */

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.article-content img,
.article-content picture {
  margin: 1.5rem 0;
}

/* ── Rules & lists ── */

hr {
  border: 0;
  border-top: 2px solid var(--paper-edge);
  box-shadow: var(--rule-hi);
  margin: 2rem 0;
}

ul, ol { margin: 0 0 1rem 1.25em; }
li { margin-bottom: 0.2em; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9em;
}
th, td {
  border: 1px solid var(--paper-edge);
  padding: 0.5rem;
  text-align: left;
}
th { background: var(--inset); }

/* ── Code — inset on paper ── */

code:not(pre code) {
  font-family: var(--mono);
  font-size: 0.72em;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: var(--inset);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2) inset, 0 1px 0 rgba(255,255,255,0.6);
}

pre {
  overflow-x: auto;
  background: var(--inset);
  padding: 1rem;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25) inset, 0 1px 0 rgba(255,255,255,0.5);
  border: 1px solid var(--paper-edge);
}
pre code { background: none; padding: 0; box-shadow: none; }

/* ── Blockquote ── */

blockquote {
  margin-left: 1rem;
  font-style: italic;
  font-size: 1.4rem;
  font-family: var(--serif);
  border-left: 3px solid var(--blockquote-color);
  padding-left: 20px;
}

blockquote cite {
  font-size: 70%;
  opacity: .8;
}

/* ── Forms (embossed) ── */

input, textarea {
  font-family: var(--sans);
  font-size: 1em;
  color: var(--ink);
  background: var(--inset);
  border: 1px solid var(--inset-edge);
  border-radius: 4px;
  padding: 0.45rem 0.65rem;
  width: 100%;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6),
    0 2px 4px rgba(0,0,0,0.25) inset;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255,255,255,0.5), 0 2px 6px rgba(0,0,0,0.3) inset, 0 0 0 2px rgba(127,127,127,0.2);
}
input::placeholder { color: var(--muted); }
textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  margin-top: 1rem;
}
.form-row input { flex: 1; }

/* ── Metal buttons ── */

button, .metal-btn {
  font-family: var(--sans);
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
  color: var(--metal-ink);
  background: linear-gradient(145deg, var(--metal-hi) 0%, var(--metal-mid) 50%, var(--metal-lo) 100%);
  border: 1px solid var(--metal-border);
  border-radius: 8px;
  padding: 0.45rem 1.1rem;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 3px 6px rgba(0,0,0,0.25);
  transition: all 0.1s ease;
}

button:hover { filter: brightness(1.05); }

button:active, .metal-btn:active {
  box-shadow: 0 1px 2px rgba(0,0,0,0.4) inset;
  transform: translateY(1px);
}

/* ── Header logo / post title ── */

.post-title {
  font-family: var(--serif);
  font-size: xx-large;
  letter-spacing: -0.02em;
  text-shadow: var(--text-emboss);
}

.post-year {
  margin-top: 2rem;
  margin-bottom: 0.4rem;
}

/* ── Article content ── */

.article-content {
  line-height: 1.75;
  margin-inline: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.article-content > * + * {
  margin-top: 1rem;
}

.article-content img {
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25), 0 1px 3px rgba(0,0,0,0.2);
}

.article-content hr {
  border: 0;
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5rem;
  margin: 2.5rem auto;
}

.article-content hr::before {
  content: '⁎⁎⁎';
  text-align: center;
}

/* ── Search input ── */

.search-input {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--inset-edge);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--inset);
  box-shadow: 0 2px 4px rgba(0,0,0,0.25) inset, 0 1px 0 rgba(255,255,255,0.6);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Post list ── */

.posts-list { list-style: none; padding: 0; margin: 0; }

.home-post {
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--rule);
}
.home-post:last-child { border-bottom: none; }

body[data-page="/blog/"] .home-post {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 1rem;
}

.home-post .post-header {
  display: flex;
  align-items: center;
}
.home-post .post-header .meta { flex-shrink: 0; }

/* Embossed ink-date block */
.home-post .post-header .meta .date {
  width: 60px;
  text-align: center;
  margin-right: 1rem;
  line-height: 1;
  background: linear-gradient(145deg, var(--inset), var(--inset-edge));
  border-radius: 6px;
  padding: 0.5rem 0.25rem;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7),
    0 -1px 0 rgba(0,0,0,0.08) inset,
    0 2px 4px rgba(0,0,0,0.18);
}

.home-post .post-header .meta .date .day {
  display: block;
  font-size: 3em;
  font-family: var(--serif);
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1;
  color: var(--ink);
  text-shadow: var(--text-emboss);
}

.home-post .post-header .meta .date .rest {
  display: block;
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.home-post .post-header .matter {
  flex: 1;
  min-width: 0;
}
.home-post .post-header .matter .description {
  display: block;
  font-size: 0.85em;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--muted);
  white-space: nowrap;
}
.post-date time { font-size: inherit; }

.reading-time {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--muted);
}
.reading-time::before { content: "· "; }

.homepost-title {
  font-size: 1em;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
}
.homepost-title:hover { text-decoration: underline; }

.read-all {
  text-align: right;
  margin: 0.5rem 0 0;
  font-size: 0.85em;
}
.read-all a { color: var(--muted); text-decoration: none; }
.read-all a:hover { color: var(--accent); text-decoration: underline; }

/* ── Post navigation ── */

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0 1.5rem;
  padding-top: 1.5rem;
}
.post-nav-prev, .post-nav-next {
  text-decoration: none;
  font-size: 0.9em;
  line-height: 1.4;
  max-width: 45%;
}
.post-nav-prev { color: var(--accent); }
.post-nav-next { color: var(--accent); margin-left: auto; text-align: right; }
.post-nav-prev:hover, .post-nav-next:hover { text-decoration: underline; }

/* ── Back links ── */

.back, .back-link {
  display: inline-block;
  margin: 2rem 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85em;
}
.back:hover { color: var(--fg); }

/* ── Reading progress (skeuo progress bar) ── */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  z-index: 999;
  background: linear-gradient(to bottom, var(--track-hi), var(--track-lo));
  box-shadow: 0 1px 3px rgba(0,0,0,0.4) inset, 0 1px 0 rgba(255,255,255,0.3);
}

.reading-progress::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: inherit;
  background: linear-gradient(to bottom, var(--fill-hi), var(--fill-lo));
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 1px 0 0 rgba(255,255,255,0.3);
}

/* ── Tags ── */

.post-tags {
  margin: 0 0 1.5rem;
  font-size: 0.85em;
}

.tag {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--sans);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: linear-gradient(145deg, var(--metal-hi), var(--metal-lo));
  border: 1px solid var(--metal-border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 3px rgba(0,0,0,0.15);
}
.tag:hover { color: var(--fg); }

/* ── Related posts ── */

.related-posts { list-style: none; padding: 0; margin: 0; }
.related-posts li { margin-bottom: 0.5rem; }
.related-posts a { font-size: 0.95em; }

/* ── Tag page ── */

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--rule);
}
.post-list .post-date {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--muted);
}

.tag-header { margin: 1rem 0 1.5rem; }
.tag-header-label {
  font-size: 1.5em;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.tag-header-count {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ── Series badge / banner ── */

.series-badge {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 400;
}
.series-banner {
  font-size: 0.9em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.series-banner a {
  color: var(--accent);
  text-decoration: underline;
}

.series-nav h3 { margin-bottom: 1rem; margin-top: 0; }
.series-posts { margin: 0 0 1rem 1.5rem; padding: 0; }
.series-posts li { margin-bottom: 0.4rem; font-size: 0.9em; }
.series-posts li.current { color: var(--muted); font-style: italic; }
.series-posts li.current span { font-weight: 500; }

/* ── Series page ── */

.series-item { margin-bottom: 2rem; }
.series-item h2 { margin-bottom: 0.25rem; }
.series-count { font-size: 0.85em; color: var(--muted); margin-bottom: 0.75rem; }
.series-item .series-posts { list-style: decimal; }
.series-item .series-posts li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.series-item .series-posts .post-date {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--muted);
}

/* ── Projects ── */

.project-list { list-style: none; padding: 0; margin: 0; }
.project-list li { padding: 0.2rem 0; font-size: 0.95em; }
.project-list li a { color: var(--accent); text-decoration: none; }
.project-list li a:hover { text-decoration: underline; }

/* ── Library / book grid ── */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.book-grid-item { display: block; line-height: 0; }
.book-grid-cover {
  width: 100%;
  height: auto;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5),
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 5px 12px rgba(0,0,0,0.3),
    0 2px 4px rgba(0,0,0,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}
.book-grid-cover:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5),
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 10px 22px rgba(0,0,0,0.35);
}
.book-grid-placeholder {
  aspect-ratio: 2/3;
  background: linear-gradient(145deg, var(--inset), var(--inset-edge));
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  text-align: center;
  line-height: 1.3;
  font-size: 0.85rem;
  color: var(--muted);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2) inset, 0 1px 0 rgba(255,255,255,0.6);
}
.book-grid-placeholder small { font-size: 0.75rem; margin-top: 0.25rem; }
.book-cover-full {
  float: right;
  margin-left: 1rem;
  width: 33%;
  max-width: 200px;
  border-radius: 2px;
  box-shadow: 0 5px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
}

/* ── Gallery ── */

.gallery-count {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.gallery-empty { color: var(--muted); font-style: italic; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
}
.gallery-link {
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 2px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}
.gallery-link picture,
.gallery-link img { display: block; width: 100%; height: 100%; }
.gallery-link picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s ease;
}
.gallery-link picture img:hover { opacity: 0.85; }

/* ── Spotlight ── */

.spotlight {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.spotlight.open { display: flex; }
.spotlight-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.spotlight-close {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
}
.spotlight-close:hover { opacity: 1; }

.comment-email > a {
  color: var(--muted);
  padding: 8px;
  border: 1px solid var(--accent);
  border-radius: 4px;
}

/* ── Stories ── */

.stories { margin-bottom: 1rem; }

.stories-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.5rem 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stories-scroll::-webkit-scrollbar { display: none; }

.story-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  padding: 0;
  background-size: cover;
  background-position: center;
  background-color: var(--border);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 -2px 4px rgba(0,0,0,0.3) inset,
    0 3px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.story-bubble:hover {
  transform: scale(1.08);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 -2px 4px rgba(0,0,0,0.3) inset,
    0 5px 10px rgba(0,0,0,0.35);
}

.story-play-icon {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 0.55em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--paper);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Story viewer — dark chrome, metal close/mute */
.story-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.88);
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
}
.story-viewer.open { display: flex; }
.story-viewer-inner {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
}
@media (min-width: 640px) {
  .story-viewer { background: rgba(0,0,0,0.75); }
  .story-viewer-inner {
    width: 420px;
    max-height: 80vh;
    border-radius: 12px;
  }
}
.story-bars {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 3px;
  padding: 8px 8px 0;
  z-index: 2;
}
.story-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4) inset;
}
.story-bar.seen { background: rgba(255,255,255,0.9); }
.story-bar-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(to bottom, #fff, #ccc);
  border-radius: 2px;
}
.story-viewer-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.story-viewer-close:hover { opacity: 1; }
.story-time {
  position: absolute;
  top: 20px;
  left: 12px;
  z-index: 3;
  color: rgba(255,255,255,0.65);
  font-size: 0.75rem;
  line-height: 1;
  background: rgba(0,0,0,0.4);
  padding: 2px 8px;
  border-radius: 4px;
}
.story-caption {
  position: absolute;
  bottom: 20px;
  left: 12px;
  right: 60px;
  z-index: 3;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.4;
  background: rgba(0,0,0,0.4);
  padding: 4px 10px;
  border-radius: 6px;
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-media {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: manipulation;
}
.story-media img,
.story-media video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.story-mute {
  position: absolute;
  top: 56px;
  right: 8px;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #fff;
  line-height: 0;
}
.story-mute svg { width: 20px; height: 20px; filter: drop-shadow(0 0 3px rgba(0,0,0,0.5)); }
.story-mute.is-muted .story-mute-icon { display: block; }
.story-mute.is-muted .story-unmute-icon { display: none; }
.story-mute:not(.is-muted) .story-mute-icon { display: none; }
.story-mute:not(.is-muted) .story-unmute-icon { display: block; }
.story-mute:hover { opacity: 0.8; }
.story-mute svg {
  display: block;
  width: 24px;
  height: 24px;
  stroke: #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.story-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  z-index: 1;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.story-nav-prev { left: 0; }
.story-nav-next { right: 0; }

/* ── Feed / microblog ── */

.feed { display: flex; flex-direction: column; }

.feed-entry {
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--rule);
}
.feed-entry:first-child { padding-top: 0; }
.feed-entry:last-child { border-bottom: none; }

.feed-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.25rem;
}

.feed-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  border: 2px solid var(--border);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85em;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1;
  font-family: var(--sans);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 -1px 2px rgba(0,0,0,0.3) inset,
    0 2px 4px rgba(0,0,0,0.2);
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  min-width: 0;
}
.feed-name { font-weight: 600; font-size: 0.9em; color: var(--ink); font-family: var(--sans); }
.feed-handle { font-size: 0.85em; color: var(--muted); font-family: var(--sans); }
.feed-dot { color: var(--muted); font-size: 0.85em; }
.feed-time {
  font-size: 0.85em;
  color: var(--muted);
  cursor: default;
  white-space: nowrap;
}

.feed-body {
  font-size: 0.95em;
  line-height: 1.6;
  word-wrap: break-word;
  margin-left: calc(36px + 0.65rem);
}
.feed-body p { margin: 0; }
.feed-body p + p { margin-top: 0.6rem; }
.feed-body img,
.feed-body video {
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  margin-top: 0.6rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}
.feed-body iframe {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 0.6rem;
  aspect-ratio: 16 / 9;
}
.feed-body a { color: var(--accent); text-decoration: none; }
.feed-body a:hover { text-decoration: underline; }

.feed-separator {
  margin: 1.5rem 0 1rem;
  border: none;
  border-top: 1px solid var(--paper-edge);
}

.home-feed-link { text-align: right; margin-top: 0.5rem; font-size: 0.85em; }
.home-feed-link a { color: var(--muted); text-decoration: none; }
.home-feed-link a:hover { color: var(--accent); text-decoration: underline; }

/* ── Theme toggle ── */

.theme-toggle {
  background: linear-gradient(145deg, var(--metal-hi) 0%, var(--metal-mid) 50%, var(--metal-lo) 100%);
  border: 1px solid var(--metal-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  color: var(--metal-ink);
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 2px 4px rgba(0,0,0,0.2);
  transition: all 0.12s ease;
}
.theme-toggle:hover { color: var(--metal-ink); filter: brightness(1.05); }
.theme-toggle:active {
  box-shadow: 0 1px 2px rgba(0,0,0,0.4) inset;
  transform: translateY(1px);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: inline; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ── Tag cloud filters (metal pills) ── */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.tag-filter {
  font-family: var(--sans);
  font-size: 0.8em;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--metal-border);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--metal-hi) 0%, var(--metal-mid) 50%, var(--metal-lo) 100%);
  color: var(--metal-ink);
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 2px 4px rgba(0,0,0,0.2);
  transition: all 0.12s ease;
}
.tag-filter:hover {
  filter: brightness(1.05);
  border-color: #777;
}
.tag-filter.active {
  background: linear-gradient(145deg, #6a6a6a, #4a4a4a, #5a5a5a);
  color: #fff;
  border-color: #333;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.4);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 2px 5px rgba(0,0,0,0.4) inset;
}

.filter-info { font-size: 0.85em; color: var(--muted); margin-bottom: 1rem; }
.filter-tag { color: var(--accent); font-weight: 500; }
.filter-info button {
  font-size: 0.85em;
  padding: 0.15rem 0.5rem;
  margin-left: 0.5rem;
  background: linear-gradient(145deg, var(--metal-hi), var(--metal-lo));
  border: 1px solid var(--metal-border);
  border-radius: 6px;
  color: var(--metal-ink);
  cursor: pointer;
}
.filter-info button:hover { filter: brightness(1.05); }

/* ── 88x31 retro button marquee ── */

.y2k-strip {
  margin: 1.25rem 0 0.75rem;
  width: 100%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}

.y2k-track {
  display: flex;
  width: max-content;
  animation: y2k-scroll 30s linear infinite;
}

.y2k-strip:hover .y2k-track { animation-play-state: paused; }

.y2k-track img {
  width: auto;
  height: 31px;
  margin-right: 8px;
  flex-shrink: 0;
  image-rendering: pixelated;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 2px 3px rgba(0,0,0,0.25),
    0 1px 0 rgba(255,255,255,0.4);
}

.y2k-track img:hover {
  transform: translateY(-2px) scale(1.08);
}

@keyframes y2k-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .y2k-strip { overflow: visible; }
  .y2k-track {
    animation: none;
    flex-wrap: wrap;
    width: auto;
    justify-content: center;
  }
  .y2k-track img { margin: 2px 4px; }
}

/* ── Footer ── */

footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--paper-edge);
  box-shadow: var(--rule-hi);
  font-size: 0.85em;
  color: var(--muted);
  line-height: 1.6;
}

.footer-bottom {
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ── Site wrapper ── */
.sitewrapper > * { margin-top: 0; }
.sitewrapper > * + * { margin-top: 1.5rem; }
