/* Shared reading sections inside the persistent LCD blog shell. */
:root {
  --site-panel-bg: color-mix(in srgb, var(--ink) 2%, var(--paper));
  --site-panel-radius: 6px;
  --site-image-radius: 4px;
  --action-accent: var(--terminal-accent-secondary, #ff8b3d);
}
/* Subtle corners keep the pixel identity while softening panels and images. */
.site-header, #posts .post-card, .section-view, .site-footer {
  border-radius: var(--site-panel-radius);
}
.post-thumbnail, .post-figure, .post-figure a, .post-figure img,
.about-panorama, .about-panorama img, .lightbox-img {
  border-radius: var(--site-image-radius);
}
/* Programmatic navigation targets are containers, not interactive controls. */
#journal:focus, #postMain:focus { outline: none; }
.site-nav [aria-current] { color: var(--accent); }
.section-view { margin-top: 28px; padding: 20px; background: var(--site-panel-bg); }
.section-back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 22px; color: var(--accent); font-size: 16px; line-height: 1.5; }
.section-back:hover { color: var(--ink); }
.post-header { margin-bottom: 22px; }
.post-head { display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 12px; }
#postMain .post-title { font: 400 32px/1.25 var(--simple-font), monospace; color: var(--accent); letter-spacing: 0; margin: 0; overflow-wrap: anywhere; }
.post-description, .about-copy :is(h1, h2, p) { font: 400 16px/1.8 var(--simple-font), monospace; color: #ded5c8; white-space: pre-line; }
.post-description { max-width: 78ch; margin: 0 0 32px; }
.post-gallery { display: grid; gap: 24px; }
.post-figure { margin: 0; min-width: 0; }
.post-figure a { display: block; }
.post-figure img { display: block; width: 100%; height: auto; background: #101115; }
.post-figure a:focus-visible { outline-offset: 4px; }
/* A fine bevel and cast shadow give blog images a mounted-print finish. */
.post-thumbnail, .post-figure {
  position: relative;
  isolation: isolate;
  box-shadow: 0 2px 3px #00000038, 0 10px 24px -8px #00000080;
}
.post-thumbnail::after, .post-figure::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border: 1px solid #ffffff24;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 #ffffff1a, inset 0 -1px 0 #00000040;
}
.post-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); }
.post-nav-link { display: flex; flex-direction: column; gap: 8px; min-height: 44px; overflow-wrap: anywhere; font-size: 16px; line-height: 1.5; }
.post-nav-meta { color: var(--muted); }
.post-nav-title { color: var(--accent); }
.post-nav-row:last-child { text-align: right; }
.post-nav-link:hover .post-nav-title { color: var(--ink); }
.post-nav-link.is-empty { visibility: hidden; }
.about-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 40px; align-items: start; }
.about-panorama { position: relative; align-self: stretch; margin: 0; }
.about-panorama img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.about-copy { min-width: 0; }
.about-copy :is(h1, h2, p) { white-space: pre-line; overflow-wrap: anywhere; }
.about-title { margin: 0 0 20px; }
.about-copy p { margin: 0 0 20px; }
.about-subtitle { margin: 26px 0 12px; }
.about-copy > :last-child { margin-bottom: 0; }
.route-error { color: var(--ink); font-size: 16px; line-height: 1.7; }
.route-error a, .route-error button { color: var(--accent); }
.route-error button { display: block; border: 0; padding: 12px 0; background: transparent; }
/* Retain the existing image reader: zoom, pan, keyboard and touch navigation. */
.lightbox { position: fixed; inset: 0; z-index: 10010; background: #08090cf5; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 160ms ease, visibility 0s 160ms; }
.lightbox.open { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.image-viewer { position: relative; width: 100%; height: 100%; color: var(--ink); font: 16px/1.5 var(--simple-font), monospace; }
.image-viewer-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lightbox-img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; touch-action: none; }
.lightbox :is(button, .lightbox-full, .lightbox-counter) { position: absolute; z-index: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--site-image-radius); background: #17191ee8; color: var(--ink); font: inherit; }
.lightbox button:hover, .lightbox-full:hover { color: var(--accent); }
.lightbox-close { top: 12px; right: 12px; width: 44px; height: 44px; }
.lightbox-full { top: 12px; right: 68px; min-height: 44px; }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); width: 44px; height: 44px; }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-counter { bottom: 12px; left: 50%; transform: translateX(-50%); }
.lightbox .hidden { visibility: hidden; }
@media (max-width: 740px) {
  .about-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .about-panorama { max-width: 100%; }
  .about-panorama img { position: static; height: auto; }
  #postMain .post-title { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .lightbox { transition: none; }
}

/* Primary buttons use the secondary accent only on hover and active states. */
.site-header .site-nav { gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.site-header .site-nav a,
:is(.read-post, .more-posts),
.section-back,
.post-nav-link,
#scrollTop,
#back-to-top,
.route-error button,
.lightbox :is(button, .lightbox-full) {
  --button-accent: var(--accent);
  min-height: 44px;
  padding: 9px 16px;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: color-mix(in srgb, var(--button-accent) 8%, var(--paper));
  color: var(--button-accent);
  border-radius: var(--site-image-radius);
  transition: background-color 140ms ease, border-color 140ms ease;
}
.site-header .site-nav a:hover,
:is(.read-post, .more-posts):hover,
.section-back:hover,
.post-nav-link:hover,
#scrollTop:hover,
#back-to-top:hover,
.route-error button:hover,
.lightbox :is(button, .lightbox-full):hover {
  --button-accent: var(--action-accent);
  background: color-mix(in srgb, var(--action-accent) 20%, var(--paper));
  border-color: var(--action-accent);
  color: var(--action-accent);
}
.site-header .site-nav a[aria-current] {
  --button-accent: var(--action-accent);
  background: color-mix(in srgb, var(--action-accent) 16%, var(--paper));
  border-color: var(--action-accent);
  box-shadow: none;
}
.site-header .site-nav a:active, :is(.read-post, .more-posts):active, .section-back:active, .post-nav-link:active, #scrollTop:active, #back-to-top:active, .route-error button:active, .lightbox :is(button, .lightbox-full):active { --button-accent: var(--action-accent); background: color-mix(in srgb, var(--action-accent) 28%, var(--paper)); }
.site-header .site-nav a:focus-visible, :is(.read-post, .more-posts):focus-visible, .section-back:focus-visible, .post-nav-link:focus-visible, #scrollTop:focus-visible, #back-to-top:focus-visible, .route-error button:focus-visible, .lightbox :is(button, .lightbox-full):focus-visible { outline-color: var(--button-accent); }
@media (max-width: 580px) {
  .section-view { padding: 14px; margin-top: 24px; }
  .post-nav { gap: 16px; }
  .site-header .site-nav { gap: 8px; }
  .site-header .site-nav a, a.read-post { padding-inline: 10px; }
}

/* Navigation sits at the right edge of the shared header. */
.site-header { flex-wrap: wrap; }
.site-header .site-nav { margin: 0 0 0 auto; justify-content: flex-end; }
@media (max-width: 740px) {
  .site-header .site-identity { width: auto; flex: 1 1 auto; }
  .site-header .site-nav { flex: 0 0 auto; }
}
@media (max-width: 580px) {
  .site-header .site-identity { flex-basis: 100%; }
  .site-header .site-nav { margin-left: auto; }
}
/* A 2px gap separates the navigation from the header divider. */
.site-header { padding-bottom: 0; }
.site-header .site-identity { padding-bottom: 24px; }
.site-header .site-nav { align-self: flex-end; margin-bottom: 2px; }


/* One compact identity block, using native dot sizes throughout. */
.brand-copy { min-width: 0; }
.brand-wordmark picture, .brand-wordmark img { display: block; }
.brand-wordmark img { width: 576px; height: 42px; max-width: none; image-rendering: pixelated; }
.site-header { gap: 12px 24px; padding-top: 24px; }
.site-header .site-identity {
  display: grid;
  grid-template-columns: 150px 576px;
  align-items: start;
  gap: 24px;
  flex: 0 1 auto;
  padding-bottom: 12px;
}
.site-header .brand-copy { align-self: end; padding-top: 0; }
.site-header .brand-wordmark { margin: 0; }
.site-header .brand-copy > p { margin-top: 12px; line-height: 24px; color: var(--ink); }
.site-header .site-nav { margin-top: 0; margin-bottom: 2px; }
@media (max-width: 740px) {
  .site-header .site-identity { gap: 18px; }
}
@media (max-width: 580px) {
  .brand-wordmark img { width: 192px; height: 14px; }
  .site-header { gap: 8px 16px; }
  .site-header .site-identity { grid-template-columns: 100px 192px; gap: 20px; padding-bottom: 4px; }
  .site-header .brand-copy > p { margin-top: 8px; }
}
@media (max-width: 360px) {
  .site-header .site-identity { grid-template-columns: 192px; gap: 12px; }
  .site-header .brand-copy { padding-top: 0; }
  .site-shell { padding-inline: 12px; }
}
@media (min-width: 581px) and (max-width: 800px) {
  .site-header { row-gap: 6px; }
  .site-header .site-identity { padding-bottom: 0; }
}

/* Native-sized single-line variants preserve the dot geometry at each width. */
@media (min-width: 581px) and (max-width: 960px) {
  .brand-wordmark img { width: 288px; height: 21px; }
  .site-header .site-identity { grid-template-columns: 150px 288px; }
}

/* Share the subtitle row with navigation instead of adding a separate row. */
.site-header {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  grid-template-rows: 127px 44px;
  align-items: center;
  gap: 0 24px;
  padding-bottom: 2px;
}
.site-header .site-identity, .site-header .brand-copy { display: contents; }
.site-header .brand { grid-column: 1; grid-row: 1 / 3; align-self: start; }
.site-header .brand-wordmark { grid-column: 2 / 4; grid-row: 1; align-self: end; margin: 0 0 8px; }
.site-header .brand-copy > p { grid-column: 2; grid-row: 2; align-self: start; margin: 0; white-space: nowrap; }
.site-header .site-nav { grid-column: 3; grid-row: 2; align-self: center; margin: 0; gap: 8px; flex-wrap: nowrap; }
.site-header .site-nav a { padding-inline: 8px; gap: 8px; }
@media (min-width: 581px) and (max-width: 740px) {
  .site-header { column-gap: 12px; }
}
@media (max-width: 580px) {
  .site-header { grid-template-columns: 100px minmax(0, 1fr) auto; grid-template-rows: 114px 44px; gap: 8px 12px; }
  .site-header .brand { grid-row: 1; }
  .site-header .brand-wordmark { margin-bottom: 0; }
  .site-header .brand-copy > p { grid-column: 1 / 3; }
}
@media (max-width: 360px) {
  .site-header .site-nav { gap: 4px; }
  .site-header .site-nav a { padding-inline: 4px; gap: 4px; }
}
.site-header .site-nav { gap: 4px; }
.site-header .site-nav a { padding-inline: 4px; gap: 6px; }
@media (max-width: 580px) {
  .site-header .site-nav { font-size: 12px; }
  .site-header .site-nav a { gap: 4px; }
}
@media (max-width: 360px) {
  .site-header { grid-template-columns: minmax(0, 1fr); grid-template-rows: 114px 14px 24px 44px; gap: 8px 0; }
  .site-header .brand { grid-column: 1; grid-row: 1; }
  .site-header .brand-wordmark { grid-column: 1; grid-row: 2; }
  .site-header .brand-copy > p { grid-column: 1; grid-row: 3; }
  .site-header .site-nav { grid-column: 1; grid-row: 4; justify-self: end; }
}
/* Leave breathing room under the head while tabs meet the divider. */
.site-header {
  grid-template-rows: 127px 60px;
  padding: 20px;
  background: var(--site-panel-bg);
  border-bottom: 0;
}
.site-header .site-nav { align-self: end; margin-bottom: 0; }
@media (max-width: 580px) {
  .site-header { grid-template-rows: 114px 60px; padding: 14px; column-gap: 8px; }
}
@media (max-width: 380px) {
  .site-header { grid-template-columns: minmax(0, 1fr); grid-template-rows: 114px 14px 24px 60px; gap: 8px 0; }
  .site-header .brand { grid-column: 1; grid-row: 1; }
  .site-header .brand-wordmark { grid-column: 1; grid-row: 2; }
  .site-header .brand-copy > p { grid-column: 1; grid-row: 3; }
  .site-header .site-nav { grid-column: 1; grid-row: 4; justify-self: end; }
}

/* Reading navigation and viewer chrome share the homepage button surfaces. */
.post-nav-link { width: 100%; align-items: stretch; }
.post-nav-link .post-nav-title, .post-nav-link:hover .post-nav-title { color: inherit; }
.lightbox .lightbox-counter { border: 0; background: var(--site-panel-bg); color: var(--muted); }

/* Reserve room for the persistent footer, including mobile safe areas. */
body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.site-footer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 30;
  width: calc(100% - 96px);
  max-width: 1344px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  border: 0;
  background: color-mix(in srgb, var(--ink) 2%, var(--paper));
  box-shadow: 0 -12px 0 var(--paper);
  font-size: 14px;
}
.site-footer > span { white-space: nowrap; }
#back-to-top { gap: 8px; }
@media (min-width: 581px) and (max-width: 740px) {
  .site-footer { width: calc(100% - 52px); }
}
@media (max-width: 580px) {
  .site-footer {
    width: calc(100% - 44px);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    font-size: 12px;
    line-height: 1.5;
  }
  .site-footer #back-to-top { padding-inline: 8px; white-space: nowrap; }
}
@media (max-width: 360px) {
  .site-footer { width: calc(100% - 24px); padding-inline: 8px; }
}

/* Collapse in viewport space while the anchor keeps the page flow stable. */
.site-header-anchor { position: sticky; top: 0; z-index: 30; pointer-events: none; }
.site-header-anchor .site-header {
  --header-content-gap: 12px;
  --header-collapse: 0;
  --header-open: calc(1 - var(--header-collapse));
  pointer-events: auto;
  position: relative;
  overflow: clip;
  grid-template-columns: calc(150px * var(--header-open)) minmax(0, 1fr) auto;
  grid-template-rows: calc(44px + 83px * var(--header-open)) calc(44px * var(--header-open));
  column-gap: calc(24px * var(--header-open));
  padding-block: calc(20px - 4px * var(--header-open));
  padding-inline: calc(28px - 8px * var(--header-open));
  background: color-mix(in srgb, var(--ink) 2%, var(--paper));
  /* Keep the page-colored breathing room as content passes under the header. */
  box-shadow: 0 var(--header-content-gap) 0 var(--paper);
}
.site-header-anchor .brand,
.site-header-anchor .brand-copy > p {
  opacity: var(--header-open);
}
.site-header-anchor [inert] { visibility: hidden; }
.site-header-anchor .brand { max-height: 100%; overflow: clip; }
.site-header-anchor .brand-copy > p {
  width: max-content;
  max-width: 100%;
  max-height: 100%;
  overflow: clip;
}
.site-header-anchor .brand-wordmark { margin-bottom: calc(8px * var(--header-open)); }
.site-header-anchor .site-nav {
  position: absolute;
  grid-column: auto;
  grid-row: auto;
  right: calc(28px - 8px * var(--header-open));
  bottom: calc(20px - 4px * var(--header-open));
  justify-self: end;
  justify-content: flex-end;
  align-self: end;
  margin: 0;
  gap: 24px;
  padding-top: 0;
  border: 0;
}
.site-header-anchor .site-nav a {
  padding: 9px 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: 0;
  background: transparent;
}
.site-header-anchor .site-nav a:hover,
.site-header-anchor .site-nav a[aria-current] {
  color: var(--action-accent);
  background: transparent;
}
.site-header-anchor .site-nav a[aria-current] { border-bottom-color: var(--action-accent); }
.site-header-anchor .site-nav a:active {
  background: transparent;
}
.site-header-anchor .site-nav a:focus-visible { outline-color: var(--button-accent); }
.skip-link { z-index: 31; }
/* A visible home link remains available when the monkey has faded out. */
.brand-wordmark a { display: block; }
@media (min-width: 581px) and (max-width: 800px) {
  .site-header-anchor .site-header {
    column-gap: calc(12px * var(--header-open));
    grid-template-rows: calc(21px + 106px * var(--header-open)) calc(24px * var(--header-open)) 44px;
  }
  .site-header-anchor .brand-wordmark { margin-bottom: 8px; }
  .site-header-anchor .site-nav {
    position: static;
    grid-column: 1 / -1;
    grid-row: 3;
  }
}
@media (max-width: 580px) {
  .site-header-anchor .site-header {
    --header-content-gap: 10px;
    grid-template-columns: calc(64px * var(--header-open)) minmax(0, 1fr);
    grid-template-rows: calc(14px + 59px * var(--header-open)) calc(24px * var(--header-open)) 44px;
    gap: 6px calc(12px * var(--header-open));
    padding: calc(20px - 6px * var(--header-open));
    padding-bottom: 0;
  }
  .site-header-anchor .brand {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    max-height: 100%;
    overflow: clip;
  }
  .site-header-anchor .brand-logo { width: 64px; height: 73px; }
  .site-header-anchor .brand-wordmark {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    margin: 0;
  }
  .site-header-anchor .brand-copy > p {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    max-width: none;
    overflow: hidden;
    max-height: 100%;
  }
  .site-header-anchor .site-nav {
    position: static;
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: stretch;
    justify-content: flex-start;
    align-self: end;
    margin: 0;
    gap: 24px;
  }
}
@media (max-width: 380px) {
  .site-header-anchor .site-header {
    grid-template-columns: calc(48px * var(--header-open)) minmax(0, 1fr);
    grid-template-rows: calc(14px + 40.75px * var(--header-open)) calc(24px * var(--header-open)) 44px;
    column-gap: calc(8px * var(--header-open));
  }
  .site-header-anchor .brand-logo { width: 48px; height: 54.75px; }
}
