/* Web Lab — Blog & Editorial Reading Styles */
/* Reuses design tokens from _assets/weblab.css */

/* ==========================================================================
   1. Editorial List & Rows (Homepage #blog, /blog/, and Read Next)
   ========================================================================== */

#blog {
  scroll-margin-top: 88px;
}

.wl-blog-list {
  display: flex;
  flex-direction: column;
}

.wl-blog-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.28fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(16px, 3vw, 48px);
  padding-block: clamp(22px, 2.8vw, 36px);
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.wl-blog-row:last-child {
  border-bottom: 1px solid var(--border);
}

.wl-blog-row[hidden] {
  display: none;
}

.wl-blog-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: 1.4;
}

.wl-blog-meta-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.wl-blog-topic {
  color: var(--ink);
  font-weight: 500;
}

.wl-blog-sep {
  opacity: 0.45;
}

.wl-blog-date {
  color: var(--ink-muted);
}

.wl-blog-content {
  min-width: 0;
}

.wl-blog-content h3 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--ink);
  transition: color 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.wl-blog-content p {
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--ink-muted);
  max-width: 62ch;
}

.wl-blog-arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  background: transparent;
  transition:
    background-color 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.wl-blog-arrow span {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.wl-blog-row:hover .wl-blog-content h3,
.wl-blog-row:focus-visible .wl-blog-content h3 {
  color: var(--accent);
}

.wl-blog-row:hover .wl-blog-arrow,
.wl-blog-row:focus-visible .wl-blog-arrow {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.wl-blog-row:hover .wl-blog-arrow span,
.wl-blog-row:focus-visible .wl-blog-arrow span {
  transform: translateX(2px);
}

/* Optional compact editorial thumbnail on /blog/ index when author graphics exist */
.wl-blog-row--media {
  grid-template-columns: minmax(140px, 0.24fr) minmax(0, 1fr) minmax(140px, 200px) auto;
}

.wl-blog-thumb {
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-subtle);
}

.wl-blog-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   2. Minimal Topic Navigation (/blog/ index — used when > 6 articles)
   ========================================================================== */

.wl-blog-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  margin-bottom: clamp(24px, 3vw, 40px);
  border-bottom: 1px solid var(--border);
}

.wl-blog-filter-btn {
  position: relative;
  appearance: none;
  background: none;
  border: 0;
  padding: 0 0 12px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.wl-blog-filter-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.wl-blog-filter-btn:hover,
.wl-blog-filter-btn.is-active,
.wl-blog-filter-btn[aria-pressed="true"] {
  color: var(--ink);
}

.wl-blog-filter-btn.is-active::after,
.wl-blog-filter-btn[aria-pressed="true"]::after {
  transform: scaleX(1);
}

/* Blog index header & section spacing */
.wl-blog-index-header {
  padding-bottom: clamp(24px, 3vw, 44px);
}

.wl-blog-index-header .wl-lead {
  max-width: 56ch;
}

.wl-blog-index-section {
  padding-top: 0;
}

/* ==========================================================================
   3. Article Header (.wl-article-header)
   ========================================================================== */

.wl-article-header {
  width: 100%;
  padding-top: clamp(112px, 10vw, 152px);
  padding-bottom: clamp(28px, 3.5vw, 48px);
}

.wl-article-header-inner {
  max-width: 820px;
  margin-inline: auto;
}

.wl-article-header .wl-back-link {
  margin-bottom: clamp(20px, 2.5vw, 32px);
  font-size: var(--text-sm);
  font-weight: 500;
}

.wl-article-header .wl-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: clamp(14px, 1.8vw, 22px);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.wl-article-category {
  color: var(--accent);
  font-weight: 500;
}

.wl-article-meta-sep {
  opacity: 0.45;
  user-select: none;
}

.wl-article-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.95rem, 4vw, 3.5rem);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.04em;
  color: var(--ink);
  max-width: 22ch;
}

.wl-article-header .wl-lead {
  margin-top: clamp(16px, 2vw, 24px);
  font-family: var(--font-body);
  font-size: clamp(1.08rem, 1.35vw, 1.28rem);
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 58ch;
}

/* Optional Cover Media (only when authentic visual/diagram exists) */
.wl-article-cover {
  max-width: 1080px;
  margin: clamp(32px, 4vw, 56px) auto 0;
}

.wl-article-cover img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: block;
}

.wl-article-cover figcaption {
  margin-top: 12px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-align: center;
}

/* ==========================================================================
   4. Article Reading Layout (Single Column & Long-Guide Sticky TOC)
   ========================================================================== */

.wl-article-main {
  padding-top: clamp(16px, 2.5vw, 32px);
  padding-bottom: var(--space-section);
}

.wl-article-layout {
  width: 100%;
}

.wl-article-layout:not(.wl-article-layout--toc) .wl-article-body {
  max-width: 64ch;
  margin-inline: auto;
}

/* Long guide layout with centered 64ch text + left sticky TOC */
.wl-article-layout--toc {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 64ch) minmax(0, 220px);
  justify-content: center;
  gap: clamp(24px, 3vw, 56px);
  align-items: start;
}

.wl-article-layout--toc .wl-article-body {
  grid-column: 2;
  max-width: 64ch;
  width: 100%;
}

/* Desktop Sticky TOC */
.wl-toc {
  grid-column: 1;
  position: sticky;
  top: 104px;
  padding-right: 12px;
}

.wl-toc-title {
  display: block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.wl-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wl-toc-list a {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.wl-toc-list a:hover,
.wl-toc-list a.is-active {
  color: var(--accent);
}

.wl-toc-list a.is-active {
  font-weight: 500;
}

/* Mobile / Tablet Collapsible TOC (< 1120px) */
.wl-toc-mobile {
  display: none;
  max-width: 64ch;
  margin: 0 auto clamp(28px, 3.5vw, 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  overflow: hidden;
}

.wl-toc-mobile summary {
  padding: 16px 20px;
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wl-toc-mobile summary::-webkit-details-marker {
  display: none;
}

.wl-toc-mobile summary::after {
  content: "+";
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--accent);
  line-height: 1;
}

.wl-toc-mobile[open] summary::after {
  content: "−";
}

.wl-toc-mobile .wl-toc-list {
  padding: 0 20px 18px;
  gap: 10px;
}

.wl-toc-mobile .wl-toc-list a {
  font-size: 0.92rem;
}

/* ==========================================================================
   5. Article Body Typography (.wl-article-body)
   ========================================================================== */

.wl-article-body {
  font-family: var(--font-body);
  font-size: clamp(1.03rem, 1.1vw, 1.125rem);
  line-height: 1.72;
  color: #1d1f36;
}

.wl-article-body > :first-child {
  margin-top: 0;
}

.wl-article-body p + p {
  margin-top: 1.3em;
}

.wl-article-body h2 {
  font-family: var(--font-display);
  font-size: clamp(1.42rem, 2.2vw, 2.05rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.035em;
  color: var(--ink);
  margin: 2.6em 0 0.7em;
  scroll-margin-top: 104px;
}

.wl-article-body h3 {
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 1.45vw, 1.38rem);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 2em 0 0.55em;
  scroll-margin-top: 104px;
}

.wl-article-body ul,
.wl-article-body ol {
  margin: 1.3em 0;
  padding-left: 1.35em;
}

.wl-article-body li + li {
  margin-top: 0.55em;
}

.wl-article-body li::marker {
  color: var(--accent);
}

.wl-article-body strong {
  font-weight: 600;
  color: var(--ink);
}

.wl-article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-thickness 0.18s ease, color 0.18s ease;
}

.wl-article-body a:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

/* Editorial Pull-Quote (no gray box) */
.wl-article-body blockquote {
  margin: 2.2em 0;
  padding-left: clamp(18px, 2.5vw, 28px);
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-size: clamp(1.18rem, 1.6vw, 1.45rem);
  font-weight: 500;
  line-height: 1.38;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.wl-article-body blockquote p + p {
  margin-top: 0.8em;
}

/* Figures & Wide Comparisons */
.wl-article-body figure {
  margin: 2.2em 0;
}

.wl-article-body figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: block;
}

.wl-article-body figcaption {
  margin-top: 10px;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--ink-muted);
}

.wl-figure--wide {
  width: min(960px, calc(100vw - var(--gutter) * 2));
  margin-left: 50%;
  transform: translateX(-50%);
}

.wl-figure-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-gap);
}

/* Section Divider */
.wl-article-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin-block: 2.8em;
}

/* Tables */
.wl-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-block: 2em;
  -webkit-overflow-scrolling: touch;
}

.wl-article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  line-height: 1.5;
  text-align: left;
}

.wl-article-body th,
.wl-article-body td {
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.wl-article-body th {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.wl-article-body td:last-child,
.wl-article-body th:last-child {
  padding-right: 0;
}

/* Code Blocks & Inline Code */
.wl-article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-subtle);
  color: var(--ink);
  padding: 2px 6px;
  border-radius: 6px;
}

.wl-article-body pre {
  margin-block: 2em;
  padding: clamp(16px, 2vw, 24px);
  background: var(--bg-dark);
  color: var(--ink-on-dark);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.9rem;
}

.wl-article-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ==========================================================================
   6. Read Next Section
   ========================================================================== */

.wl-read-next .wl-section-head {
  margin-bottom: clamp(20px, 2.5vw, 36px);
}

/* ==========================================================================
   7. Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1119px) {
  .wl-article-layout--toc {
    display: block;
  }

  .wl-article-layout--toc .wl-toc {
    display: none;
  }

  .wl-article-layout--toc .wl-toc-mobile {
    display: block;
  }

  .wl-article-layout--toc .wl-article-body {
    margin-inline: auto;
  }
}

@media (max-width: 820px) {
  .wl-blog-row,
  .wl-blog-row--media {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 20px;
    align-items: center;
  }

  .wl-blog-meta {
    grid-column: 1;
    grid-row: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
  }

  .wl-blog-content {
    grid-column: 1;
    grid-row: 2;
  }

  .wl-blog-thumb {
    grid-column: 1 / -1;
    grid-row: 3;
    max-width: 280px;
    margin-top: 8px;
  }

  .wl-blog-arrow {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .wl-figure-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .wl-blog-row,
  .wl-blog-row--media {
    padding-block: 20px;
  }

  .wl-blog-arrow {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }
}

/* ==========================================================================
   8. Accessibility & Reduced Motion
   ========================================================================== */

.wl-blog-row:focus-visible,
.wl-blog-filter-btn:focus-visible,
.wl-toc-list a:focus-visible,
.wl-toc-mobile summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .wl-blog-row,
  .wl-blog-content h3,
  .wl-blog-arrow,
  .wl-blog-arrow span,
  .wl-blog-filter-btn,
  .wl-blog-filter-btn::after,
  .wl-toc-list a,
  .wl-article-body a {
    transition: none !important;
  }

  .wl-blog-row:hover .wl-blog-arrow span,
  .wl-blog-row:focus-visible .wl-blog-arrow span {
    transform: none;
  }
}
