/* ============================================================
   Synexian — Resources template (cream theme, home-derived)
   One template, three collections: blogs, research, case-studies.
   Each collection has a HUB page (pages/resources/<collection>/)
   and entry ARTICLE pages (pages/resources/<collection>/<slug>/),
   both driven by the LIBRARY registry in ./resource.js — the same
   registry pattern as the careers OPENINGS.
   Collection accent via <body data-collection="...">:
   blogs = amber, research = olive, case-studies = coral.
   Signature elements: rubber-stamp collection badges on index-card
   entries, and a fixed reading-progress bar on articles.
   Light motion only: CSS + IO + one rAF scroll handler.
   ============================================================ */

body[data-collection='blogs'] { --rs-accent: var(--amber-deep); --rs-soft: var(--amber); }
body[data-collection='research'] { --rs-accent: var(--olive); --rs-soft: var(--olive); }
body[data-collection='case-studies'] { --rs-accent: var(--coral); --rs-soft: var(--coral); }
body:not([data-collection]) { --rs-accent: var(--amber-deep); --rs-soft: var(--amber); }

section { padding: 6rem 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* grid-paper backdrop helper (home motif) */
.grid-paper {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, #000 30%, transparent 75%);
}
.hero .dot {
  position: absolute;
  border-radius: 50%;
  opacity: 0.85;
  animation: dot-drift 9s ease-in-out infinite alternate;
}
.dot-amber { width: 18px; height: 18px; background: var(--amber); top: 18%; left: 7%; }
.dot-coral { width: 13px; height: 13px; background: var(--coral); top: 72%; left: 84%; animation-delay: -3s; }
.dot-olive { width: 15px; height: 15px; background: var(--olive); top: 12%; left: 66%; animation-delay: -6s; }
@keyframes dot-drift {
  to { transform: translate(14px, -20px); }
}

/* rubber-stamp collection badge */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rs-accent);
  border: 1.6px solid var(--rs-accent);
  border-radius: 6px;
  padding: 0.28rem 0.55rem;
  rotate: -2deg;
  opacity: 0.9;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Ccircle cx='1' cy='1' r='1.2' fill='%23000'/%3E%3Ccircle cx='3' cy='3' r='1.2' fill='%23000'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Ccircle cx='1' cy='1' r='1.2' fill='%23000'/%3E%3Ccircle cx='3' cy='3' r='1.2' fill='%23000'/%3E%3C/svg%3E");
}
/* per-card accent override (cross-collection cards) */
[data-rs='blogs'] { --rs-accent: var(--amber-deep); }
[data-rs='research'] { --rs-accent: var(--olive); }
[data-rs='case-studies'] { --rs-accent: var(--coral); }

/* ============================================================
   HUB pages
   ============================================================ */

.hero {
  position: relative;
  padding: 5.5rem 0 5rem;
  overflow: hidden;
}
.hub-inner {
  position: relative;
  max-width: 860px;
  margin-inline: auto;
  text-align: center;
}
.tagline {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 1.4rem;
}
.hub-inner h1 {
  font-size: clamp(2.4rem, 5.4vw, 4.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.hub-inner h1 em { font-style: normal; color: var(--rs-accent); }
.hero-sub {
  margin: 1.5rem auto 0;
  max-width: 58ch;
  font-size: 1.1rem;
  color: var(--text-dim);
}
.hub-inner > * { animation: rise-in 0.9s var(--ease-out) both; }
.hub-inner > *:nth-child(2) { animation-delay: 0.08s; }
.hub-inner > *:nth-child(3) { animation-delay: 0.16s; }
.hub-inner > *:nth-child(4) { animation-delay: 0.24s; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px); }
}

/* collection switcher — the library's three drawers */
.drawers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 2.4rem;
}
.drawer {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s, transform 0.2s var(--ease-out);
}
.drawer i { width: 9px; height: 9px; border-radius: 50%; background: var(--d, var(--amber)); }
.drawer:hover { border-color: var(--rs-accent); color: var(--text); transform: translateY(-2px); }
.drawer[aria-current='page'] {
  border-color: var(--rs-accent);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--rs-accent);
}

/* featured entry — full-width lead card */
.shelf { background: var(--surface); border-block: 1px solid var(--line); }
.shelf .section-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.6rem;
}
.featured-card {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 5px solid var(--rs-accent);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 1.6rem;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), border-color 0.3s;
  box-shadow: 0 20px 45px -30px rgba(20, 36, 48, 0.35);
}
.featured-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 32px 65px -30px rgba(20, 36, 48, 0.45);
}
.feat-main { padding: clamp(1.8rem, 3.5vw, 2.8rem); display: flex; flex-direction: column; gap: 0.9rem; align-items: flex-start; }
.feat-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rs-accent);
}
.featured-card h3 { font-size: clamp(1.5rem, 2.8vw, 2.1rem); }
.featured-card p { color: var(--text-dim); max-width: 56ch; }
.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.featured-card .go,
.entry-card .go {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--rs-accent);
  margin-top: auto;
}
.featured-card .go svg, .entry-card .go svg { width: 16px; height: 16px; transition: transform 0.2s var(--ease-out); }
.featured-card:hover .go svg, .entry-card:hover .go svg { transform: translateX(4px); }
/* the featured card's right pane — oversized issue number on grid paper */
.feat-orn {
  position: relative;
  background: var(--ink-800);
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 200px;
}
.feat-orn::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(240, 235, 218, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 235, 218, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
}
.feat-orn span {
  position: relative;
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 8vw, 6rem);
  color: color-mix(in srgb, var(--rs-soft) 75%, transparent);
  letter-spacing: -0.04em;
}
.feat-orn .win-dots {
  position: absolute;
  top: 1rem;
  left: 1.1rem;
  display: inline-flex;
  gap: 6px;
}
.feat-orn .win-dots i { width: 10px; height: 10px; border-radius: 50%; }
.feat-orn .win-dots i:nth-child(1) { background: var(--amber); }
.feat-orn .win-dots i:nth-child(2) { background: var(--coral); }
.feat-orn .win-dots i:nth-child(3) { background: var(--olive); }

/* entry index-cards */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
}
.entry-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.25s var(--ease-out), transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.entry-card:hover {
  border-color: var(--rs-accent);
  transform: translateY(-5px);
  box-shadow: 0 20px 44px -26px rgba(20, 36, 48, 0.4);
}
.entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}
.entry-card h3 { font-size: 1.15rem; }
.entry-card > p { color: var(--text-dim); font-size: 0.93rem; flex: 1; }

/* empty-drawer card for collections still filling up */
.entry-card.empty {
  border-style: dashed;
  border-color: var(--line-strong);
  background: transparent;
  justify-content: center;
  text-align: center;
  align-items: center;
}
.entry-card.empty p { flex: none; }

/* ============================================================
   ARTICLE pages
   ============================================================ */

/* fixed reading-progress bar under the navbar */
.read-progress {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 45;
  pointer-events: none;
  background: transparent;
}
.read-progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--rs-accent);
  transform-origin: left;
  transform: scaleX(0);
}

.article-hero {
  position: relative;
  padding: 5rem 0 3.5rem;
  overflow: hidden;
}
.article-head { position: relative; max-width: 780px; }
.kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1.6rem;
}
.kicker .crumb {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.2s;
}
.kicker .crumb:hover { color: var(--rs-accent); }
.article-head h1 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.article-dek {
  margin: 1.3rem 0 1.6rem;
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 58ch;
}
.byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.byline b { color: var(--text-dim); font-weight: 500; }
.byline i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rs-accent);
}
.article-head > * { animation: rise-in 0.8s var(--ease-out) both; }
.article-head > *:nth-child(2) { animation-delay: 0.07s; }
.article-head > *:nth-child(3) { animation-delay: 0.14s; }
.article-head > *:nth-child(4) { animation-delay: 0.21s; }

/* tl;dr card */
.tldr {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--rs-accent) 40%, var(--line));
  border-radius: var(--radius);
  padding: 1.5rem 1.7rem;
}
.tldr-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  color: var(--rs-accent);
  margin-bottom: 0.9rem;
}
.tldr ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.65rem; }
.tldr li {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-size: 0.96rem;
  color: var(--text-dim);
}
.tldr li::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rs-accent);
  margin-top: 0.5em;
}

/* long-form body */
.article-wrap { padding: 3.5rem 0 4.5rem; }
.article-body {
  max-width: 720px;
  margin-inline: auto;
  font-size: 1.05rem;
  line-height: 1.75;
}
.article-body > * + * { margin-top: 1.3em; }
.article-body p { color: var(--text-dim); }
.article-body h2 {
  font-size: 1.65rem;
  margin-top: 2.2em;
  letter-spacing: -0.02em;
}
.article-body h3 { font-size: 1.25rem; margin-top: 1.8em; }
.article-body ul, .article-body ol { padding-left: 1.3em; color: var(--text-dim); display: grid; gap: 0.5em; }
.article-body strong { color: var(--text); }
.article-body a { color: var(--rs-accent); text-underline-offset: 3px; }
.article-body blockquote {
  margin: 2em 0;
  padding: 0.4em 0 0.4em 1.4em;
  border-left: 4px solid var(--rs-accent);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--text);
}
.article-body blockquote cite {
  display: block;
  margin-top: 0.7em;
  font-family: var(--font-mono);
  font-style: normal;
  font-weight: 400;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: color-mix(in srgb, var(--rs-accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--rs-accent) 25%, transparent);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}
.article-body pre {
  background: var(--ink-800);
  color: var(--cream);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
}
.article-body pre code { background: none; border: none; padding: 0; }
/* traffic-dot section divider */
.dots-divider {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 2.6em 0 !important;
}
.dots-divider i { width: 9px; height: 9px; border-radius: 50%; }
.dots-divider i:nth-child(1) { background: var(--amber); }
.dots-divider i:nth-child(2) { background: var(--coral); }
.dots-divider i:nth-child(3) { background: var(--olive); }
/* callout box */
.callout {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  font-size: 0.97rem;
}
.callout .co-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rs-accent);
  margin-bottom: 0.5rem;
}

/* share / end row */
.article-end {
  max-width: 720px;
  margin: 3.5rem auto 0;
  padding-top: 1.8rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.copy-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.55rem 1.15rem;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  transition: border-color 0.2s, color 0.2s;
}
.copy-link:hover { border-color: var(--rs-accent); color: var(--rs-accent); }
.copy-link svg { width: 15px; height: 15px; }
.back-hub {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--rs-accent);
  text-decoration: none;
}
.back-hub:hover { text-decoration: underline; text-underline-offset: 4px; }

/* more from the library */
.more { background: var(--surface); border-block: 1px solid var(--line); }
.more .section-head { margin-bottom: 2.6rem; }
.section-head h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }

/* ---------- final CTA — ink card (family pattern) ---------- */
.cta-final { padding-bottom: 7rem; }
.cta-card {
  position: relative;
  background: var(--ink-800);
  color: var(--cream);
  border-radius: var(--radius-lg);
  padding: clamp(2.5rem, 6vw, 4.5rem);
  text-align: center;
  overflow: hidden;
}
.cta-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(240, 235, 218, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 235, 218, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
.cta-card > * { position: relative; }
.cta-dots { display: inline-flex; gap: 8px; margin-bottom: 1.4rem; }
.cta-dots i { width: 12px; height: 12px; border-radius: 50%; }
.cta-dots i:nth-child(1) { background: var(--amber); }
.cta-dots i:nth-child(2) { background: var(--coral); }
.cta-dots i:nth-child(3) { background: var(--olive); }
.cta-card h2 { font-size: clamp(1.9rem, 4.5vw, 3rem); }
.cta-card p {
  max-width: 62ch;
  margin: 1.1rem auto 2rem;
  color: rgba(240, 235, 218, 0.7);
}
.cta-group { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }
.cta-card .btn-ghost { color: var(--cream); border-color: rgba(240, 235, 218, 0.3); }
.cta-card .btn-ghost:hover { border-color: var(--amber); color: var(--amber); }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .entry-grid { grid-template-columns: repeat(2, 1fr); }
  .featured-card { grid-template-columns: 1fr; }
  .feat-orn { min-height: 130px; }
  .shelf .section-row { flex-direction: column; align-items: flex-start; gap: 1.2rem; }
}
@media (max-width: 680px) {
  section { padding: 4rem 0; }
  .hero { padding: 3.5rem 0 4rem; }
  .entry-grid { grid-template-columns: 1fr; }
  .article-hero { padding: 3.5rem 0 2.5rem; }
  .article-end { flex-direction: column; align-items: flex-start; }
}
