/* ═══════════════════════════════════════════
   Dev Diary — The Lab hero carousel, editorial index, and post pages
   Loaded by lab.html and diary/*.html (page-router injects it on soft-nav to /lab)
   ═══════════════════════════════════════════ */

:root {
  --font-editorial: 'Newsreader', Georgia, 'Times New Roman', serif;
}

/* ── Hero feature carousel (replaces the portrait on /lab) ── */

.hero-layout:has(> .hero-feature) > .hero-portrait { display: none; }

.hero-feature {
  --hf-caption-bottom: 1.5rem;
  position: relative;
  flex-shrink: 0;
  width: min(100%, 580px);
  align-self: stretch;
  min-height: clamp(260px, 34vw, 420px);
  overflow: hidden;
  isolation: isolate;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 18%);
  mask-image: linear-gradient(to right, transparent 0%, black 18%);
  animation: hfIn 0.6s ease both;
}

/* Leaving /lab via soft-nav: the portrait fades back in instead of popping */
.hero-layout.portrait-return > .hero-portrait { animation: hfIn 0.6s ease both; }

@keyframes hfIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Slide crossfade, dots and progress bar live in style.css (shared with the work reels) */

.hero-feature .hf-slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  transition: transform 7s ease-out;
}

.hero-feature .hf-slide.is-active img { transform: scale(1); }

/* Scrim so captions read over any image */
.hero-feature .hf-slide::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(var(--scrim-rgb), 0.92) 0%, rgba(var(--scrim-rgb), 0.55) 32%, transparent 62%);
  z-index: 1;
}

.hf-caption {
  position: absolute;
  z-index: 2;
  right: 1.5rem;
  bottom: var(--hf-caption-bottom);
  left: 22%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: right;
}

.hf-kicker {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.hf-title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
}

.hf-dek {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.hf-slide:hover .hf-title,
.hf-slide:focus-visible .hf-title { color: var(--accent-bright); }

@media (max-width: 900px) {
  .hero-feature {
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 9;
    max-height: 240px;
    align-self: stretch;
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
  }
  .hf-caption { left: 1.25rem; right: 1.25rem; text-align: left; bottom: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-feature .hf-slide img { transition: none; }
}

/* ── Diary index (editorial) ─────────────── */

/* #332: restored to the standard 96px/96px section rhythm (was 64px top) */
.diary { padding-top: 6rem; }

.diary-masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.25rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.diary-masthead h2 {
  font-family: var(--font-editorial);
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.01em;
}

.diary-masthead p {
  margin: 0;
  max-width: 38ch;
  font-size: 0.95rem;
  text-align: right;
}

.diary-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.diary-kicker .diary-project { color: var(--accent-bright); }

.diary-lead {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 2.5rem;
  align-items: center;
  padding-bottom: 3rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.diary-media {
  display: block;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.diary-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.diary-media:hover img { transform: scale(1.03); }

.diary-lead h3,
.diary-entry h3 {
  font-family: var(--font-editorial);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.12;
}

.diary-lead h3 { font-size: clamp(1.9rem, 3.4vw, 2.75rem); margin: 0.85rem 0 1rem; }
.diary-entry h3 { font-size: clamp(1.4rem, 2.2vw, 1.75rem); margin: 0.6rem 0 0.6rem; }

.diary-lead h3 a,
.diary-entry h3 a {
  color: var(--text-primary);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease;
}

.diary-lead h3 a:hover,
.diary-entry h3 a:hover { background-size: 100% 1px; }

.diary-dek {
  font-family: var(--font-editorial);
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.diary-entry .diary-dek { font-size: 1.02rem; margin-bottom: 0.9rem; }

.diary-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.diary-read {
  color: var(--accent-bright);
  font-weight: 600;
  text-decoration: none;
}

.diary-read:hover { text-decoration: underline; text-underline-offset: 3px; }

.diary-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.5rem;
}

.diary-entry {
  display: flex;
  flex-direction: column;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.diary-entry .diary-media { margin-bottom: 1.1rem; }

.diary-num {
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.diary-entry .diary-meta { margin-top: auto; }

@media (max-width: 900px) {
  .diary-masthead { flex-direction: column; align-items: flex-start; }
  .diary-masthead p { text-align: left; }
  .diary-lead { grid-template-columns: 1fr; gap: 1.5rem; }
  .diary-list { grid-template-columns: 1fr; gap: 2rem; }
}

/* #332: "Show N more entries" disclosure, hiding everything past the 3 most recent
   diary entries (the lead + first two of .diary-list) until opened. Native <details>,
   so no JS is required and it survives a soft-nav content swap untouched. */
.diary-more { margin-top: 2.5rem; }

.diary-more > summary {
  display: inline-flex;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.diary-more > summary::-webkit-details-marker { display: none; }
.diary-more > summary:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.diary-more[open] > summary { margin-bottom: 2.5rem; }

.diary-more .diary-list--more { margin-top: 0; }

/* Archive jump row, folded into the diary section in place of its own ~254px band */
.diary-archive-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.diary-archive-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.diary-archive-index a {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.diary-archive-index a:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ── Post pages ──────────────────────────── */

.post { padding: calc(72px + 4rem) 0 5rem; }

.post-wrap {
  width: min(100% - 2.5rem, 720px);
  margin-inline: auto;
}

.post-back {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

.post-back:hover { color: var(--text-primary); }

.post-title {
  font-family: var(--font-editorial);
  font-weight: 500;
  font-size: clamp(2.3rem, 5.5vw, 3.6rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 1rem 0 1.25rem;
}

.post-dek {
  font-family: var(--font-editorial);
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.5;
  font-style: italic;
  color: var(--text-secondary);
  max-width: none;
}

.post-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-byline a { color: var(--accent-bright); text-decoration: none; font-weight: 600; }
.post-byline a:hover { text-decoration: underline; text-underline-offset: 3px; }

.post-hero {
  width: min(100% - 2.5rem, 1100px);
  margin: 2.5rem auto 3rem;
}

.post-hero img,
.post-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.post-hero img { max-height: min(70vh, 620px); object-fit: cover; }
/* A tall capture whose top and bottom both matter (build-diary.py hero_full) */
.post-hero--full img { max-height: none; }

.post-hero figcaption,
.post-figure figcaption {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.post-hero figcaption { width: min(100%, 720px); margin-inline: auto; }

.post-body {
  font-family: var(--font-editorial);
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--text-body);
}

.post-body p { color: inherit; max-width: none; margin: 0 0 1.4rem; }

.post-body > p:first-of-type::first-letter {
  float: left;
  font-size: 3.6em;
  line-height: 0.85;
  padding: 0.08em 0.1em 0 0;
  color: var(--accent-bright);
  font-weight: 500;
}

.post-body h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 3rem 0 1rem;
  color: var(--text-primary);
}

.post-body strong { color: var(--text-primary); font-weight: 600; }
.post-body em { color: var(--text-primary); }

.post-body code {
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-size: 0.82em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(var(--ink-rgb), 0.06);
}

.post-body a { color: var(--accent-bright); text-underline-offset: 3px; }

.post-body ul,
.post-body ol { margin: 0 0 1.4rem 1.25rem; padding: 0; }
.post-body li { margin-bottom: 0.45rem; }

.pull {
  margin: 2.5rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 2px solid var(--accent);
  font-family: var(--font-editorial);
  font-size: clamp(1.5rem, 3vw, 1.95rem);
  line-height: 1.3;
  font-style: italic;
  color: var(--text-primary);
}

.pull cite {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.post-figure { margin: 2.5rem 0; }

@media (min-width: 1100px) {
  .post-figure--wide { margin-inline: -8rem; }
}

.post-facts {
  margin: 2.5rem 0;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  font-family: var(--font-body);
}

.post-facts h3 {
  margin: 0 0 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.post-facts dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.1rem 1.5rem;
  margin: 0;
}

.post-facts dt {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.post-facts dd {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.post-table {
  width: 100%;
  margin: 1.5rem 0 2rem;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.post-table th,
.post-table td {
  padding: 0.6rem 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.post-table th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.post-table td:first-child { color: var(--text-primary); font-weight: 600; white-space: nowrap; }
.post-table td { color: var(--text-secondary); }

.post-end {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-body);
}

.post-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }

.post-next {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.post-next:hover { border-color: var(--border-hover); }

.post-next img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 8px;
}

.post-next small {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.post-next strong {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-editorial);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .post-body { font-size: 1.1rem; }
  .post-next { grid-template-columns: 1fr; }
}
