/* ---------- Post layout (extends styles.css) ---------- */

:root {
  --text: "Newsreader", "Iowan Old Style", Georgia, serif;
  --prose: #d6d1c4;
  --measure: 41rem;
}

.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: 2px;
  pointer-events: none;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 181, 71, 0.2), var(--amber));
  box-shadow: 0 0 12px var(--amber-glow);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.moon--post {
  --m: clamp(120px, 15vw, 220px);
  top: clamp(5rem, 11vh, 7.5rem);
  right: clamp(-3rem, 4vw, 6rem);
  opacity: 0.75;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.3s;
}

.back:hover { color: var(--amber); }

/* ---------- Post header ---------- */

.post-head {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 6rem) var(--pad) clamp(2.5rem, 6vh, 4rem);
}

.post-title {
  margin: 0;
  max-width: 15ch;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.7rem, 7.4vw, 6.4rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.post-title em {
  font-style: italic;
  background: linear-gradient(100deg, var(--headline-1) 0%, var(--headline-2) 45%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.06em;
}

.dek {
  max-width: 56ch;
  margin: clamp(1.5rem, 3vh, 2.25rem) 0 0;
  font-family: var(--text);
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
  line-height: 1.55;
  color: var(--soft);
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  margin: 2rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.byline strong { font-weight: 400; color: var(--paper); }
.byline a { text-decoration: none; }
.byline a:hover strong { color: var(--amber); }

/* ---------- Prose ---------- */

.post-body {
  counter-reset: section;
  padding: 0 var(--pad) clamp(4rem, 10vh, 7rem);
  font-family: var(--text);
  font-size: clamp(1.08rem, 1rem + 0.3vw, 1.22rem);
  line-height: 1.72;
  color: var(--prose);
  font-optical-sizing: auto;
}

.post-body > * {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}

.post-body p { margin-top: 0; margin-bottom: 1.35em; }

.post-body > p:first-of-type::first-letter {
  float: left;
  margin: 0.08em 0.12em 0 0;
  font-family: var(--serif);
  font-size: 4.4em;
  line-height: 0.82;
  color: var(--amber);
}

.post-body--legal > p:first-of-type::first-letter { all: unset; }

.post-body h2 {
  counter-increment: section;
  margin-top: 2.6em;
  margin-bottom: 0.7em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 1.4rem + 2vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-wrap: balance;
}

.post-body h2::before {
  content: counter(section, decimal-leading-zero);
  display: block;
  margin-bottom: 0.9rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--amber);
}

.post-body h2 em { font-style: italic; color: var(--headline-2); }

.post-body a {
  color: var(--paper);
  text-decoration: underline;
  text-decoration-color: var(--link-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.post-body a:hover { color: var(--amber); text-decoration-color: var(--amber); }

.post-body strong { font-weight: 500; color: var(--paper); }

.post-body code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--chip);
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--chip-ink);
}

.post-body ul,
.post-body ol { padding-left: 1.3em; margin-top: 0; margin-bottom: 1.35em; }

.post-body li { margin-bottom: 0.55em; padding-left: 0.3em; }
.post-body li::marker { color: var(--amber); font-family: var(--mono); font-size: 0.8em; }

.post-body blockquote {
  margin: 2em auto;
  padding: 0 0 0 1.4em;
  border-left: 2px solid var(--amber);
  font-family: var(--serif);
  font-size: 1.35em;
  font-style: italic;
  line-height: 1.4;
  color: var(--paper);
}

.post-body blockquote p { margin-bottom: 0.5em; }

.post-body blockquote cite {
  display: block;
  font-family: var(--mono);
  font-size: 0.5em;
  font-style: normal;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Pull quote */
.post-body .pull {
  max-width: 30ch;
  margin: 2.2em auto;
  padding: 0;
  border: 0;
  font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.3rem);
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}

.post-body .pull::before,
.post-body .pull::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 1px;
  margin: 0 auto 1.1rem;
  background: var(--amber);
}

.post-body .pull::after { margin: 1.1rem auto 0; }

/* ---------- Explainers ---------- */

.explainer {
  margin-top: 2em;
  margin-bottom: 2.2em;
  padding: 1.2em 1.4em 0.2em;
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  border-radius: 0 10px 10px 0;
  background: linear-gradient(100deg, rgba(255, 181, 71, 0.06), rgba(255, 181, 71, 0) 60%), var(--panel-soft);
  font-size: 0.92em;
  line-height: 1.65;
}

.explainer-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem !important;
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--amber);
}

.explainer-label span { color: var(--muted); }

/* ---------- Spec card ---------- */

.spec {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 2em;
  margin-bottom: 2.4em;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.5;
}

.spec div {
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.spec div:nth-child(odd) { border-right: 1px solid var(--line); }
.spec div:nth-last-child(-n + 2) { border-bottom: 0; }

.spec dt {
  margin-bottom: 0.25rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--dim);
}

.spec dd { margin: 0; color: var(--paper); }
.spec dd small { display: block; color: var(--muted); font-size: 0.92em; }

@media (max-width: 560px) {
  .spec { grid-template-columns: minmax(0, 1fr); }
  .spec div:nth-child(odd) { border-right: 0; }
  .spec div:nth-last-child(2) { border-bottom: 1px solid var(--line); }
}

/* ---------- Code + terminal figures ---------- */

.post-body pre {
  margin-top: 1.6em;
  margin-bottom: 2em;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  /* Code keeps its night window in both themes, so it carries its own palette. */
  --pre-dim: #5a5e70;
  --pre-accent: #ffb547;
  background: linear-gradient(180deg, rgba(18, 22, 40, 0.75), rgba(8, 10, 20, 0.85));
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.8;
  color: #dcd8cd;
}

.post-body pre code { padding: 0; background: none; font-size: inherit; }
.post-body pre .c { color: var(--pre-dim); }
.post-body pre .p { color: var(--pre-accent); user-select: none; }

.post-body .terminal {
  max-width: 820px;
  margin-top: 2.4em;
  margin-bottom: 2.6em;
}

.post-body .terminal .log {
  height: auto;
  font-family: var(--mono);
}

.post-body .terminal .log li { animation: none; }

.post-body .terminal + figcaption,
.post-body figcaption.note {
  margin-top: -1.6em;
  margin-bottom: 2.4em;
  text-align: center;
}

/* ---------- Figures ---------- */

.post-body figure { margin-top: 2.4em; margin-bottom: 2.6em; }

.post-body figcaption {
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.pelicans {
  max-width: 980px !important;
}

.pelican-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.25rem, 4vw, 3.5rem);
  align-items: start;
  padding: 1rem clamp(0rem, 2vw, 1.5rem) 0;
}

.print {
  margin: 0 !important;
  padding: 0.85rem 0.85rem 1.1rem;
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 30px 60px -28px rgba(0, 0, 0, 0.9),
    0 0 90px -40px rgba(255, 181, 71, 0.35);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.6s;
}

.print:nth-child(1) { --tilt: -1.6deg; }
.print:nth-child(2) { --tilt: 1.3deg; }

.print:hover {
  transform: rotate(0deg) translateY(-6px) scale(1.015);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 40px 70px -28px rgba(0, 0, 0, 0.95),
    0 0 110px -30px rgba(255, 181, 71, 0.45);
}

.print-frame {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #e2dccb;
  overflow: hidden;
}

.print img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.print figcaption {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.8rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: #3b3a36 !important;
}

.print figcaption b { font-weight: 500; color: var(--ink); }

.pelicans > figcaption {
  max-width: var(--measure);
  margin: 2.2rem auto 0;
  text-align: center;
}

@media (max-width: 640px) {
  .pelican-row { grid-template-columns: minmax(0, 1fr); padding: 0 0.6rem; }
}

/* ---------- Embedded post ---------- */

.tweet {
  display: flex;
  justify-content: center;
  margin-top: 2em;
  margin-bottom: 2.4em;
}

.tweet .twitter-tweet {
  width: 100%;
  max-width: 550px;
  margin: 0;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-family: var(--text);
  font-size: 1rem;
  font-style: normal;
  line-height: 1.6;
  color: var(--prose);
}

.tweet .twitter-tweet p { margin-bottom: 0.8em; }

.tweet .twitter-tweet a { font-family: var(--mono); font-size: 0.78rem; }

/* ---------- End of post ---------- */

.signoff {
  margin-top: 3em !important;
  padding-top: 1.6em;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.8;
  color: var(--muted);
}

.signoff a { font-family: inherit; }

/* ---------- Light theme (dawn) ---------- */

html[data-theme="light"] {
  --prose: #3c3e49;
}

/* Code keeps its night window, so the page gives it a solid backdrop. */
html[data-theme="light"] .post-body pre {
  background: linear-gradient(180deg, #171b2e, #090b16);
}

/* The printed photos stay paper - that is the point of the motif. */
html[data-theme="light"] .print {
  background: #efe9da;
  color: #05060b;
}

html[data-theme="light"] .print figcaption b { color: #05060b; }
