/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #ffffff;
  --bg2:       #fafafa;
  --surface:   rgba(0,0,0,0.025);
  --border:    rgba(0,0,0,0.10);
  --line:      rgba(0,0,0,0.08);
  --accent:    #111111;    /* B&W: emphasis = pure black */
  --accent2:   #111111;
  --text:      #1a1a1a;
  --text-muted:#6b6b6b;
  --heading:   #0a0a0a;
  --overlay-text: #ffffff;
  --radius:    12px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --expo:      cubic-bezier(0.19, 1, 0.22, 1);
  /* Keel-style center image sizes */
  --circle-card-w: 16.6vw;
  --square-card-w: 12.5vw;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise texture removed for B&W theme — clean white background */

/* ─── Layout ─── */
#app { position: relative; z-index: 2; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ─── Header ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.site-header .container {
  /* override max-width: full nav like the hero */
  max-width: none;
  padding: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 56px;
}

.site-logo {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--heading);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.site-logo .logo-bracket { color: var(--heading); }
.site-logo .logo-name { color: var(--heading); }

.site-nav {
  display: flex;
  gap: 44px;
  list-style: none;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.site-nav a {
  position: relative;
  color: var(--heading);
  text-decoration: none;
  padding: 6px 2px;
  transition: opacity 0.2s ease;
}
.site-nav a::after {
  content: '';
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.45s var(--expo);
}
.site-nav a:hover::after { transform: scaleX(1); }

@media (max-width: 767px) {
  .header-inner { padding: 22px 24px; }
  .site-logo { font-size: 14px; letter-spacing: 0.14em; }
  .site-nav { gap: 22px; font-size: 12px; letter-spacing: 0.10em; }
}

/* ─── Posts Section (Keel-style) ─── */
.posts-section {
  padding: 0;
  /* full-width to match Keel; rely on grid borders for visual rhythm */
}

.posts-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: max(48px, 4vw) max(24px, 1.67vw) max(18px, 1.25vw);
  position: relative;
}
.posts-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--line);
}

.posts-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.posts-title {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-weight: 800;
  color: var(--heading);
  letter-spacing: -0.02em;
  margin-top: 0.5rem;
}

.posts-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  align-self: flex-end;
}

/* ─── Keel-style Grid ─── */
.post-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

/* ─── Post Card (Keel-style clip-path expansion) ─── */
.post-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: block;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: color 0.2s ease;

  /* Stagger animation start state */
  opacity: 0;
  transform: translateY(24px);
}

.post-card.visible {
  animation: cardIn 0.6s var(--expo) forwards;
}

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Bottom + right dividers (subtle lines, Keel-style) */
.post-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--line);
}
.post-card::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 1px;
  background: var(--line);
}
/* Remove right border on every 3rd card (last col) */
.post-card:nth-child(3n)::before { content: none; }

.post-card-inner {
  position: relative;
  padding: max(28px, 1.94vw) max(24px, 1.67vw);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  z-index: 3;
}

.post-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.post-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  transition: color 0.3s var(--expo);
}

.post-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.3s var(--expo);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.post-tag::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.post-card-bottom {
  max-width: 75%;
}

.post-card-title {
  font-size: clamp(1.05rem, 1.6vw, 1.55rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--heading);
  letter-spacing: -0.015em;
  transition: color 0.3s var(--expo);
}

.post-card-excerpt {
  margin-top: max(8px, 0.6vw);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.3s var(--expo);
}

/* ─── The Keel Image Layer with clip-path circular expansion ─── */
.post-card-image {
  position: absolute;
  inset: 0;
  clip-path: circle(calc(var(--circle-card-w) / 2) at 50% 47%);
  overflow: hidden;
  transition: clip-path 0.7s ease;
  z-index: 2;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The dark overlay on image for text contrast when expanded */
.post-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.15), rgba(0,0,0,0.55));
  opacity: 0;
  transition: opacity 0.7s ease;
}

/* On hover: expand the image to fill */
.post-card:hover .post-card-image {
  clip-path: circle(100% at 50% 50%);
}
.post-card:hover .post-card-image::after { opacity: 1; }

/* Text turns white on hover (image filled) */
.post-card:hover .post-number,
.post-card:hover .post-tag,
.post-card:hover .post-card-title,
.post-card:hover .post-card-excerpt {
  color: var(--overlay-text);
}

/* Square variant (uses inset clip-path) */
.post-card[data-card-type="square"] .post-card-image {
  clip-path: inset(
    calc(50% - var(--square-card-w) / 2 - 3%)
    calc(50% - var(--square-card-w) / 2)
    calc(50% - var(--square-card-w) / 2 + 3%)
    calc(50% - var(--square-card-w) / 2)
  );
  transition: clip-path 0.5s ease;
}
.post-card[data-card-type="square"]:hover .post-card-image {
  clip-path: inset(0);
}

/* Placeholder (for cards without feature image) — simple geometric mark */
.post-card-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
}
.post-card-placeholder-mark {
  width: var(--circle-card-w);
  height: var(--circle-card-w);
  border-radius: 50%;
  border: 1px solid var(--line);
  position: relative;
  top: -3%;
  transition: transform 0.6s var(--expo), opacity 0.4s ease;
}
.post-card:hover .post-card-placeholder-mark {
  transform: scale(0.4) rotate(180deg);
  opacity: 0;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
}

/* ─── Footer ─── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.site-footer a { color: var(--accent); text-decoration: none; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }

/* ─── Responsive (Keel breakpoints) ─── */
@media (max-width: 1080px) {
  :root {
    --circle-card-w: 26vw;
    --square-card-w: 22vw;
  }
}

@media (max-width: 767px) {
  :root {
    --circle-card-w: 58vw;
    --square-card-w: 44vw;
  }
  .post-grid { grid-template-columns: 1fr; }
  .post-card { aspect-ratio: auto; min-height: 60vw; }
  .post-card::before { content: none; }
  .post-card-bottom { max-width: 100%; }
  .posts-header { padding: 28px 18px 18px; }
}
