/* ============================================
   Blog landing page and posts
   Builds on the tokens in styles.css
   ============================================ */

/* Tags & meta */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.post-tag {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.post-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.post-meta span {
  margin: 0 0.35rem;
  color: var(--text-light);
}

/* ============================================
   Landing page cards
   ============================================ */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.blog-card:hover,
.blog-card:focus-within {
  transform: translateY(-4px);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-xl);
}

/* The newest post spans the full row */
.blog-card:first-child {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
}

.blog-card-media {
  background: #0f172a;
  overflow: hidden;
  min-height: 220px;
}

.blog-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.blog-card:hover .blog-card-media img {
  transform: scale(1.04);
}

.blog-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 2.5rem;
}

.blog-card .blog-card-body h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

.blog-card h2 a {
  color: var(--text-dark);
}

/* Makes the whole card clickable through the title link */
.blog-card h2 a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.blog-card-body p {
  margin-bottom: 1rem;
}

.blog-card-more {
  font-weight: 600;
  color: var(--primary);
}

/* ============================================
   Post layout
   ============================================ */
.reading-progress {
  position: sticky;
  top: 72px;
  z-index: 999;
  height: 3px;
  margin-bottom: -3px;
}

.reading-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transform: scaleX(0);
  transform-origin: left;
}

.post-column {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.post-header {
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-light);
  padding: 3rem 0 7rem;
}

.post-back {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2rem;
}

.post-header h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-dark);
  margin-bottom: 1.25rem;
  text-wrap: balance;
}

.post-standfirst {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.post-hero {
  max-width: 960px;
  margin: -5rem auto 3.5rem;
  padding: 0 1.25rem;
}

.post-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: 50% 62%;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.post-body {
  font-size: 1.075rem;
  line-height: 1.8;
  padding-bottom: 5rem;
}

.post-body p {
  margin-bottom: 1.25rem;
}

.post-body > p a,
.post-question a,
.references a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-body strong {
  color: var(--text-dark);
}

.post-body .post-lede {
  font-size: 1.3rem;
  line-height: 1.7;
  color: var(--text-dark);
}

.post-body h2 {
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-dark);
  margin: 3.5rem 0 1rem;
  scroll-margin-top: 96px;
}

.cite {
  /* inline, so a marker never wraps away from the word it follows */
  vertical-align: super;
  line-height: 1;
  font-size: 0.65em;
  font-weight: 700;
  margin-left: 2px;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--primary-bg);
}

.post-figure {
  margin: 1.5rem 0 2rem;
}

.post-figure img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.post-figure--doors img {
  object-position: 50% 75%;
}

.post-figure figcaption {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Numbered steps */
.post-steps {
  list-style: none;
  counter-reset: step;
  margin: 1.5rem 0 2rem;
}

.post-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 3rem;
  margin-bottom: 1rem;
}

.post-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--primary-bg);
  color: var(--primary);
}

/* Callouts */
.post-callout {
  background: var(--primary-bg);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
}

.post-body .post-callout p:last-child {
  margin-bottom: 0;
}

.post-body .post-callout-title,
.post-body .post-question-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.post-quote {
  margin: 3rem 0;
  text-align: center;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--text-dark);
}

.post-question {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-md);
}

.post-body .post-question p:last-child {
  margin-bottom: 0;
}

/* Status chips */
.status {
  display: inline-block;
  padding: 0.15rem 0.7rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.7;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-done {
  background: #ecfdf5;
  color: #047857;
}

.status-partial {
  background: #fffbeb;
  color: #b45309;
}

.status-open {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px dashed var(--text-light);
}

.status-list {
  list-style: none;
  margin: 1.5rem 0;
}

.status-list li {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border-color);
}

.status-list li:last-child {
  border-bottom: 1px solid var(--border-color);
}

.status-list .status {
  justify-self: start;
  margin-top: 0.2rem;
}

.post-body .status-list p {
  margin: 0;
  font-size: 1rem;
}

/* Table */
.table-wrap {
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.post-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  line-height: 1.6;
  text-align: left;
}

.post-table th,
.post-table td {
  padding: 0.9rem 1rem;
  vertical-align: top;
  border-top: 1px solid var(--border-light);
}

.post-table thead th {
  border-top: none;
  background: var(--bg-light);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.post-table tbody th {
  color: var(--text-dark);
}

.post-table .status {
  margin-right: 0.25rem;
}

/* Card grids */
.challenge-grid,
.metric-grid {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.challenge-grid {
  grid-template-columns: repeat(2, 1fr);
}

.metric-grid {
  grid-template-columns: repeat(4, 1fr);
}

.challenge,
.metric {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.metric {
  background: var(--text-dark);
  border-color: var(--text-dark);
  color: #d1d5db;
}

.post-body .challenge h3,
.post-body .metric h3 {
  font-size: 1rem;
  line-height: 1.4;
  margin-bottom: 0.4rem;
  color: var(--text-dark);
}

.post-body .metric h3 {
  color: #fff;
}

.post-body .challenge p,
.post-body .metric p {
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

/* References */
.references {
  margin-top: 4rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.post-body .references h2 {
  margin-top: 2rem;
  font-size: 1.35rem;
}

.references h3 {
  font-size: 0.95rem;
  color: var(--text-dark);
  margin: 1.5rem 0 0.5rem;
}

.references ol {
  padding-left: 1.75rem;
}

.references li {
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
  scroll-margin-top: 96px;
}

.references li:target {
  background: var(--primary-bg);
  border-radius: 4px;
}

/* ============================================
   Slideshow
   ============================================ */
.slideshow {
  margin: 2.5rem 0 3rem;
  padding: 1rem;
  background: var(--text-dark);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  color: #fff;
}

.slideshow:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 3px;
}

.slideshow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0.25rem 1rem;
}

.post-body .slideshow-head p {
  margin: 0;
  line-height: 1.4;
}

.post-body .slideshow-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a5b4fc;
}

.slideshow-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.slideshow-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: var(--radius-md);
}

.slideshow-track::-webkit-scrollbar {
  display: none;
}

.slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.slide img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: contain;
}

.slideshow-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
}

.slideshow-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.slideshow-btn:hover {
  background: var(--primary);
}

.slideshow-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: rgba(255, 255, 255, 0.1);
}

.slideshow-progress {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.slideshow-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary-light);
  transition: width var(--transition);
}

.post-body .slideshow-count {
  margin: 0;
  font-size: 0.85rem;
  color: #d1d5db;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slideshow:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0;
  border-radius: 0;
}

.slideshow:fullscreen .slide img {
  max-height: calc(100vh - 140px);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  .blog-card:first-child {
    display: flex;
  }

  .blog-card-media {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 640px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }

  .blog-card-body {
    padding: 1.5rem;
  }

  .post-header {
    padding: 2rem 0 6rem;
  }

  .post-hero img {
    aspect-ratio: 4 / 3;
  }

  .challenge-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .status-list li {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .slideshow {
    padding: 0.5rem;
  }

  /* Table rows become stacked blocks */
  .post-table thead {
    display: none;
  }

  .post-table,
  .post-table tbody,
  .post-table tr,
  .post-table th,
  .post-table td {
    display: block;
  }

  .post-table tbody th {
    background: var(--bg-light);
  }

  .post-table td {
    border-top: none;
  }

  .post-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-card,
  .blog-card-media img,
  .slideshow-progress span {
    transition: none;
  }
}
