/* ── Design system ── */
:root {
  --bg: #F6F4EF;
  --ink: #111111;
  --ink-soft: #5a564e;
  --rule: rgba(17,17,17,0.12);
  --accent: #C64B2E;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }

/* ── Homepage ── */
.home-page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 72px 56px 120px;
}

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--rule);
}

h1.blog-title {
  font-size: clamp(34px, 4.2vw, 56px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.02;
  margin: 0;
}

.home-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  text-align: right;
  flex-shrink: 0;
}

/* Archive grid */
.archive-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 72px;
  padding-top: 24px;
}

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

.archive-row {
  border-bottom: 1px solid var(--rule);
  transition: opacity 0.3s;
}

.archive-row a {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 24px;
  padding: 26px 0;
  align-items: baseline;
  transition: transform 0.3s;
}

.archive-row:hover a {
  transform: translateX(8px);
}

.archive-num {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.archive-titles {
  display: flex;
  gap: 18px;
  align-items: baseline;
  flex-wrap: wrap;
}

.archive-title {
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.archive-sub {
  font-size: 15px;
  color: var(--ink-soft);
}

.archive-year {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

/* Sticky preview panel */
.archive-preview {
  position: sticky;
  top: 32px;
  align-self: start;
}

.archive-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #e8e4db;
}

.preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.4s, transform 0.6s;
  pointer-events: none;
}

.preview-img.active {
  opacity: 1;
  transform: scale(1);
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.18em;
  transition: opacity 0.3s;
  pointer-events: none;
}

.preview-placeholder.hidden { opacity: 0; }

.preview-caption {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  min-height: 1.5em;
  letter-spacing: 0.1em;
}

@media (max-width: 820px) {
  .home-page { padding: 32px 20px 80px; }
  .archive-grid { grid-template-columns: 1fr; }
  .archive-preview { display: none; }
}

/* ── Post page ── */
.post-header {
  padding: 22px 32px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.post-header .blog-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.post-back {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.post-wrap {
  display: grid;
  grid-template-columns: 300px minmax(0, 640px);
  gap: 72px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 96px 40px 140px;
  align-items: start;
}

.post-aside {
  position: sticky;
  top: 88px;
}

.post-date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.post-aside h1 {
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  line-height: 1.05;
}

.post-subtitle {
  font-size: 17px;
  color: var(--ink-soft);
  margin: 0;
  font-weight: 400;
}

.post-toc {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}

.post-toc nav,
.post-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-toc li { margin: 0; }

.post-toc a {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding: 5px 0;
  border-bottom: 1px solid var(--rule);
  transition: color 0.15s;
  line-height: 1.4;
}

.post-toc a:hover { color: var(--ink); }
.post-toc a.toc-active { color: var(--accent); }

/* Indent h3 and deeper */
.post-toc ul ul a { padding-left: 12px; }

/* Prose */
.prose {
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
}

.prose p { margin: 0 0 1.4em; text-wrap: pretty; }

.prose h1, .prose h2, .prose h3, .prose h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 2em 0 0.6em;
}
.prose h1 { font-size: 1.8em; }
.prose h2 { font-size: 1.4em; }
.prose h3 { font-size: 1.15em; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose strong { font-weight: 600; }

.prose img {
  width: 100%;
  margin: 2em 0;
  cursor: zoom-in;
}

.prose figure {
  margin: 2.4em 0;
}

.prose figure img {
  width: 100%;
  margin: 0;
  cursor: zoom-in;
}

.prose figcaption {
  font-size: 13px;
  color: var(--ink-soft);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  margin-top: 8px;
}

/* Media group (gallery shortcode) */
.media-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 2em 0;
}

.tile {
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
  background: #e8e4db;
  display: block;
}

/* Standalone tile (video outside a gallery) */
.prose > .tile,
.prose p > .tile {
  aspect-ratio: 16 / 9;
  width: 100%;
  margin: 2em 0;
  cursor: zoom-in;
}

/* Tile inside media-group → square */
.media-group .tile {
  aspect-ratio: 1 / 1;
  margin: 0;
}

.tile img,
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  transition: transform 600ms cubic-bezier(.2,.7,.2,1);
}

.media-group .tile:hover img,
.media-group .tile:hover video {
  transform: scale(1.03);
}

.play-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #fff;
  background: rgba(0,0,0,0.5);
  padding: 4px 6px;
  text-transform: uppercase;
  pointer-events: none;
}

/* Prev/next nav */
.post-nav {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.post-nav a { max-width: 46%; }
.post-nav-next { text-align: right; }

.post-nav-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.post-nav-title {
  font-size: 18px;
  font-weight: 500;
}

@media (max-width: 900px) {
  .post-wrap {
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 56px 24px 100px;
  }
  .post-aside { position: static; }
  .post-header { padding: 16px 20px; }
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  flex-direction: column;
  z-index: 100;
}

.lightbox.open { display: flex; }

/* Media area: takes all remaining height */
.lightbox-media-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* side padding makes room for the nav arrows */
  padding: 52px 88px 0;
}

.lightbox-media-wrap img,
.lightbox-media-wrap video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Caption + counter sit below the media, never overlapping it */
.lightbox-bottom {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 20px 22px;
  min-height: 58px;
}

.lightbox-caption {
  color: rgba(255,255,255,0.7);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-align: center;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-counter {
  color: rgba(255,255,255,0.4);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  color: rgba(255,255,255,0.7);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
}

.lightbox-close:hover { color: #fff; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 28px;
  cursor: pointer;
  padding: 20px;
  transition: color 0.2s;
}

.lightbox-nav:hover { color: #fff; }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
