/* ─────────────────────────────────────────────────────────────
   THEME — Jacob Scarpaci Portfolio
   Only things Tailwind cannot express live here:
     • CSS custom properties (referenced by animations + JS)
     • @keyframes + animation utility classes
     • Child-selector hover (.work-card:hover img)
     • clamp() typography scale
     • Nested .prose selectors
     • Reusable component classes for patterns with internal
       border logic (stats-row, spec-sheet, pullquote, buttons)
   Everything else — layout, spacing, colour — uses Tailwind.
   ───────────────────────────────────────────────────────────── */

/* ── CSS Custom Properties ── */
:root {
  --page-bg:       #f8fafc;
  --surface:       #ffffff;
  --alt-surface:   #f0f4f8;
  --primary:       #1e2d3a;
  --secondary:     #3d5060;
  --tertiary:      #7a8fa0;
  --border:        #dce4ed;
  --subtle-border: #b8c8d8;
  --accent:        #2d7dd2;
  --font-display:  'Cormorant Garamond', Georgia, serif;
  --font-body:     'IBM Plex Sans', system-ui, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; }
a { transition: opacity 0.15s ease; }

/* ── Page-load animation ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { opacity: 0; animation: fadeUp 0.65s ease forwards; }
.d1 { animation-delay: 0.05s; }
.d2 { animation-delay: 0.15s; }
.d3 { animation-delay: 0.25s; }
.d4 { animation-delay: 0.38s; }
.d5 { animation-delay: 0.50s; }

/* ── Work card image zoom (hover on child — not expressible in CDN Tailwind) ── */
.work-card {
  overflow: hidden; display: block; text-decoration: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.work-card:hover {
  border-color: #b8c8d8;
  box-shadow: 0 6px 24px rgba(30, 45, 58, 0.12);
}
.work-card .thumb-wrap { overflow: hidden; }
.work-card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.work-card:hover img { transform: scale(1.06); }

/* ── Expandable figure (in-article image: shows a chosen slice, grows in place on click) ──
   Framing is driven by three custom properties set per-instance by cases.js
   from the markup's data-crop-pos (0–100) and data-thumb-h (px):
     --thumb-h     collapsed window height
     --full-h      full rendered image height (for the open state)
     --crop-offset negative margin-top that selects which vertical slice shows */
.fig { margin-block: 1.75rem; }
.fig-expand { border: 1px solid var(--border); background: var(--alt-surface); overflow: hidden; }
.fig-expand-wrap {
  height: var(--thumb-h, 220px); overflow: hidden; position: relative;
  transition: height 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fig-expand.open .fig-expand-wrap { height: var(--full-h, 900px); }
.fig-expand-wrap img {
  display: block; width: 100%; height: auto;
  margin-top: var(--crop-offset, 0px);
  transition: margin-top 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fig-expand.open .fig-expand-wrap img { margin-top: 0; }
/* fade veil over the clipped bottom while collapsed */
.fig-expand-fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 64px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(240, 244, 248, 0), var(--alt-surface));
  transition: opacity 0.3s ease;
}
.fig-expand.open .fig-expand-fade { opacity: 0; }
.fig-expand-toggle {
  width: 100%; border: none; border-top: 1px solid var(--border); cursor: pointer;
  background: var(--surface); color: var(--accent);
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.6rem 1rem; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: background 0.15s ease;
}
.fig-expand-toggle:hover { background: var(--alt-surface); }
.fig-expand-toggle svg { transition: transform 0.3s ease; }
.fig-expand.open .fig-expand-toggle svg { transform: rotate(180deg); }

/* ── Typography scale (clamp() values, semantic, used across all pages) ── */
.t-label {
  font-family: var(--font-body);
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--tertiary);
}
.t-hero {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5.5vw, 4.25rem);
  font-weight: 400; letter-spacing: -0.02em; line-height: 1.1;
  color: var(--primary);
}
.t-section-heading {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 400; letter-spacing: -0.01em; line-height: 1.15;
  color: var(--primary);
}
.t-case-headline {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 400; letter-spacing: -0.02em; line-height: 1.1;
  color: var(--primary);
}
.t-body {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 300; color: var(--secondary); line-height: 1.75;
}
.t-body-large {
  font-family: var(--font-body);
  font-size: 1.125rem; font-weight: 300; color: var(--secondary); line-height: 1.8;
}

/* ── Prose article body (nested selectors) ── */
.prose h2 {
  font-family: var(--font-display);
  font-size: 1.625rem; font-weight: 400;
  color: var(--primary); letter-spacing: -0.01em;
  margin-top: 3rem; margin-bottom: 1rem;
}
.prose h3 {
  font-family: var(--font-body);
  font-size: 0.875rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--tertiary);
  margin-top: 2.5rem; margin-bottom: 0.75rem;
}
.prose p {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 300;
  color: var(--secondary); line-height: 1.8; margin-bottom: 1.25rem;
}
.prose ul { padding-left: 1.25rem; margin-bottom: 1.25rem; }
.prose li {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 300;
  color: var(--secondary); line-height: 1.8; margin-bottom: 0.375rem;
}
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose a:hover { opacity: 0.75; }
.prose .not-prose a {
  color: inherit;
  text-decoration: none;
  font-family: inherit;
  font-size: inherit;
}

/* ── Article-body: direct-child alternative to .prose (no cascade into layout blocks) ── */
.article-body > h2 {
  font-family: var(--font-display);
  font-size: 1.625rem; font-weight: 400;
  color: var(--primary); letter-spacing: -0.01em;
  margin-top: 3rem; margin-bottom: 1rem;
}
.article-body > h3 {
  font-family: var(--font-body);
  font-size: 0.875rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--tertiary);
  margin-top: 2.5rem; margin-bottom: 0.75rem;
}
.article-body > p {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 300;
  color: var(--secondary); line-height: 1.8; margin-bottom: 1.25rem;
}
.article-body > ul { padding-left: 1.25rem; margin-bottom: 1.25rem; }
.article-body > ul li {
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 300;
  color: var(--secondary); line-height: 1.8; margin-bottom: 0.375rem;
}
.article-body > p a, .article-body > ul li a {
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.article-body > p a:hover, .article-body > ul li a:hover { opacity: 0.75; }

/* ── Pullquote ── */
.img-caption {
  border-top: 1px solid var(--border);
  padding: 0.4rem 1rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--tertiary);
  letter-spacing: 0.01em;
}

.pullquote {
  border-left: 3px solid var(--accent);
  padding: 0 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-style: italic;
  font-weight: 300;
  color: var(--secondary);
  line-height: 1.65;
  margin-block: 1.75rem;
}

/* ── Stats row (internal borders) ── */
.stats-row { display: flex; border: 1px solid var(--border); }
.stat-item {
  flex: 1; padding: 1.5rem;
  border-right: 1px solid var(--border); text-align: center;
}
.stat-item:last-child { border-right: none; }
.stat-number {
  font-family: var(--font-display);
  font-size: 2.25rem; font-weight: 400;
  color: var(--primary); line-height: 1; display: block;
}
.stat-label {
  font-family: var(--font-body);
  font-size: 0.75rem; font-weight: 400;
  color: var(--tertiary); letter-spacing: 0.06em;
  text-transform: uppercase; margin-top: 0.375rem; display: block;
}

/* ── Spec sheet (grid with internal borders) ── */
.spec-sheet { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); }
.spec-item { padding: 1.25rem 1.5rem; border-right: 1px solid var(--border); }
.spec-item:last-child { border-right: none; }

/* ── Case page hero frame: image + caption stacked, no overlap ── */
.hero-frame { display: flex; flex-direction: column; overflow: hidden; }
.hero-frame img { flex: 1 1 0; min-height: 0; width: 100%; object-fit: cover; }
.hero-frame .hero-caption { flex-shrink: 0; background: rgba(30, 45, 58, 0.75); padding: 0.75rem 1.25rem; font-size: 0.75rem; color: rgba(255,255,255,0.75); letter-spacing: 0.06em; text-transform: uppercase; }

/* ── Case page sidebar: hidden below lg breakpoint ── */
.case-aside { display: none; }
@media (min-width: 1024px) { .case-aside { display: block; } }

/* ── Mobile: stats-row stacks vertically; spec-sheet collapses to 2×2 ── */
@media (max-width: 639px) {
  .stats-row { flex-direction: column; }
  .stat-item {
    border-right: none;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }
  .stat-item:last-child { border-bottom: none; }

  .spec-sheet { grid-template-columns: repeat(2, 1fr); }
  .spec-item:nth-child(2n) { border-right: none; }
  .spec-item:nth-child(1),
  .spec-item:nth-child(2) { border-bottom: 1px solid var(--border); }
}
.spec-key {
  font-family: var(--font-body);
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--tertiary); margin-bottom: 0.375rem;
}
.spec-val {
  font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 400;
  color: var(--primary); line-height: 1.4;
}

/* ── Chip / Tag ── */
.chip {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.75rem; font-weight: 400;
  color: var(--secondary); background: var(--alt-surface);
  border: 1px solid var(--subtle-border);
  padding: 0.25rem 0.625rem; white-space: nowrap;
}

/* ── Nav pill (work-page example switcher) ── */
.nav-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.22rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 0.8125rem; font-weight: 400;
  color: var(--secondary);
  cursor: pointer; background: var(--surface);
  transition: border-color 0.15s ease, color 0.15s ease;
  user-select: none; white-space: nowrap;
  position: relative;
}
.nav-pill:hover { border-color: var(--subtle-border); color: var(--primary); }
.nav-pill.open  { border-color: var(--accent); color: var(--accent); }
.nav-pill-arrow { transition: transform 0.15s ease; opacity: 0.5; flex-shrink: 0; }
.nav-pill.open .nav-pill-arrow { transform: rotate(180deg); opacity: 1; }
.nav-pill-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(30,45,58,0.10);
  min-width: 230px;
  z-index: 100;
  overflow: hidden;
}
.nav-pill.open .nav-pill-dropdown { display: block; }
.nav-pill-header {
  font-family: var(--font-body);
  font-size: 0.625rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--subtle-border);
  padding: 0.6rem 0.875rem 0.35rem;
}
.nav-pill-divider { height: 1px; background: var(--alt-surface); margin: 0.25rem 0; }
.nav-pill-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.8125rem; font-weight: 400;
  color: var(--secondary);
  text-decoration: none;
  transition: background 0.1s ease;
}
.nav-pill-item:hover { background: var(--alt-surface); color: var(--primary); opacity: 1; }
.nav-pill-item.active { color: var(--accent); }
.nav-pill-item.active:hover { background: var(--alt-surface); }
.nav-pill-num {
  font-size: 0.625rem; font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--subtle-border);
  width: 1.2rem; flex-shrink: 0;
}
.nav-pill-item.active .nav-pill-num { color: var(--accent); }
@media (max-width: 639px) {
  .nav-pill-dropdown { left: auto; right: 0; min-width: 210px; }
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8125rem; font-weight: 500;
  color: var(--surface); background: var(--accent);
  padding: 0.625rem 1.25rem;
  text-decoration: none; letter-spacing: 0.04em;
  border: none; cursor: pointer;
  transition: opacity 0.2s ease;
}
.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8125rem; font-weight: 500;
  color: var(--secondary); background: transparent;
  padding: 0.625rem 0;
  text-decoration: none; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); opacity: 1; }
