/* Portfolio prototype styles — tokens sourced from portfolio/VISUAL_SYSTEM.md,
   which itself extends case-studies/case-study-1-healthcare-ai/design/FIGMA_SPEC.md.
   Chrome is intentionally monochrome — color is reserved for product screenshots. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Color */
  --text-primary: #171717;
  --text-secondary: #525252;
  --text-tertiary: #a3a3a3;
  --surface-default: #ffffff;
  --surface-muted: #f5f5f5;
  --border-default: #e5e5e5;
  --button-primary: #171717;
  --button-primary-text: #ffffff;
  --button-secondary: #ffffff;
  --button-secondary-text: #404040;
  --button-border: #d4d4d4;
  --button-primary-hover: #000000;

  /* Spacing (8pt scale, extended per VISUAL_SYSTEM.md) */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;
  --sp-3xl: 64px;
  --sp-4xl: 96px;

  /* Layout */
  --container-max: 1280px;
  --prose-max: 800px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-tertiary: #737373;
    --surface-default: #171717;
    --surface-muted: #262626;
    --border-default: #404040;
    --button-primary: #f5f5f5;
    --button-primary-text: #171717;
    --button-secondary: #262626;
    --button-secondary-text: #e5e5e5;
    --button-border: #525252;
    --button-primary-hover: #ffffff;
  }
}

:root[data-theme="dark"] {
  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-tertiary: #737373;
  --surface-default: #171717;
  --surface-muted: #262626;
  --border-default: #404040;
  --button-primary: #f5f5f5;
  --button-primary-text: #171717;
  --button-secondary: #262626;
  --button-secondary-text: #e5e5e5;
  --button-border: #525252;
  --button-primary-hover: #ffffff;
}

@media print {
  :root, :root[data-theme="dark"], :root[data-theme="light"] {
    --text-primary: #171717;
    --text-secondary: #525252;
    --text-tertiary: #a3a3a3;
    --surface-default: #ffffff;
    --surface-muted: #f5f5f5;
    --border-default: #e5e5e5;
    --button-primary: #171717;
    --button-primary-text: #ffffff;
    --button-secondary: #ffffff;
    --button-secondary-text: #404040;
    --button-border: #d4d4d4;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, Inter, sans-serif;
  background: var(--surface-default);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: inherit; }

/* ── Type scale ── */

.type-display { font-size: 48px; font-weight: 700; line-height: 56px; }
.type-h1 { font-size: 32px; font-weight: 700; line-height: 40px; }
.type-h2 { font-size: 24px; font-weight: 700; line-height: 32px; }
.type-h3 { font-size: 18px; font-weight: 600; line-height: 26px; }
.type-body-lg { font-size: 18px; font-weight: 400; line-height: 28px; }
.type-body { font-size: 16px; font-weight: 400; line-height: 26px; }
.type-caption { font-size: 13px; font-weight: 400; line-height: 18px; color: var(--text-tertiary); }
.type-label-upper {
  font-size: 12px; font-weight: 600; line-height: 16px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary);
}

@media (max-width: 640px) {
  .type-display { font-size: 34px; line-height: 42px; }
  .type-h1 { font-size: 26px; line-height: 34px; }
  .type-h2 { font-size: 20px; line-height: 28px; }
}

/* ── Layout ── */

.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--sp-lg); }
.prose { max-width: var(--prose-max); }

section { padding: var(--sp-3xl) 0; }
@media (max-width: 640px) { section { padding: var(--sp-2xl) 0; } }

.section-muted { background: var(--surface-muted); }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ── Nav ── */

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg) 0;
  border-bottom: 1px solid var(--border-default);
}

.site-nav .logo { font-weight: 700; text-decoration: none; }

.nav-right { display: flex; align-items: center; gap: var(--sp-xl); }

.site-nav ul {
  display: flex;
  gap: var(--sp-xl);
  list-style: none;
}

.site-nav a { text-decoration: none; font-size: 14px; font-weight: 600; }
.site-nav a:hover { text-decoration: underline; }

.nav-dropdown { position: relative; }
.nav-dropdown > a { display: inline-flex; align-items: center; gap: 4px; }
.nav-dropdown > a::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-secondary);
  border-bottom: 1.5px solid var(--text-secondary);
  transform: rotate(45deg) translateY(-1px);
  margin-top: -3px;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: -12px;
  margin-top: var(--sp-sm);
  min-width: 240px;
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  padding: var(--sp-xs);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 30;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: var(--surface-muted); text-decoration: none; }
.nav-dropdown-menu a span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
}

@media (prefers-reduced-motion: reduce) {
  .nav-dropdown-menu { transition: none; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--button-border);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--text-tertiary); }
.theme-toggle svg { display: block; }

/* ── Mobile nav toggle ── */

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
@media (prefers-reduced-motion: reduce) {
  .nav-toggle-bar { transition: none; }
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; }

  .site-nav { position: relative; }

  .site-nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: calc(-1 * var(--sp-lg));
    right: calc(-1 * var(--sp-lg));
    flex-direction: column;
    gap: 0;
    background: var(--surface-default);
    border-bottom: 1px solid var(--border-default);
    padding: var(--sp-sm) var(--sp-lg) var(--sp-lg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    z-index: 40;
  }
  .site-nav ul.is-open { display: flex; }
  .site-nav ul li { width: 100%; }
  .site-nav ul > li > a { display: block; padding: var(--sp-sm) 0; }

  .nav-dropdown > a::after { display: none; }
  .nav-dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 var(--sp-xs) var(--sp-md);
    margin-top: 0;
    min-width: 0;
    display: none;
    flex-direction: column;
  }
  .site-nav ul.is-open .nav-dropdown-menu { display: flex; }
  .nav-dropdown-menu a { padding: var(--sp-xs) 0; white-space: normal; }
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 12px var(--sp-lg);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary { background: var(--button-primary); color: var(--button-primary-text); }
.btn-primary:hover { background: var(--button-primary-hover); }

.btn-secondary {
  background: var(--button-secondary);
  color: var(--button-secondary-text);
  border-color: var(--button-border);
}
.btn-secondary:hover { background: var(--surface-muted); }

.btn-row { display: flex; gap: var(--sp-md); flex-wrap: wrap; }

/* ── Hero ── */

.hero { padding-top: var(--sp-4xl); padding-bottom: var(--sp-3xl); }
.hero .eyebrow { margin-bottom: var(--sp-md); }
.hero h1 { margin-bottom: var(--sp-lg); }
.hero .subline { color: var(--text-secondary); margin-bottom: var(--sp-xl); max-width: 640px; }
.hero cite { font-style: normal; color: var(--text-tertiary); }

/* ── Featured case study ── */

.featured-card {
  border: 1px solid var(--border-default);
  border-radius: 12px;
  overflow: hidden;
}

.image-slot {
  background: var(--surface-muted);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.figma-embed {
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: var(--sp-sm);
  background: var(--surface-muted);
}

.figma-embed iframe {
  display: block;
  width: 100%;
  height: 640px;
  border: none;
}

.shot-frame {
  position: relative;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: var(--sp-sm);
}

.shot-frame img {
  display: block;
  width: 100%;
  height: auto;
}

/* Expand-on-hover, scoped to compact screenshot grids where thumbnails
   are too small to read at a glance (Vantar's "A closer look" gallery,
   Letterboxd's current-vs-redesign comparison). */
.shot-zoom-grid .shot-frame {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: zoom-in;
}
.shot-zoom-grid .shot-frame:hover {
  transform: scale(1.6);
  z-index: 10;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
@media (prefers-reduced-motion: reduce) {
  .shot-zoom-grid .shot-frame { transition: none; }
  .shot-zoom-grid .shot-frame:hover { transform: none; box-shadow: none; }
}

/* Compact current-vs-redesign screenshot rows (Letterboxd case study) */
.compare-row-label { color: var(--text-tertiary); }
.compare-row-label.is-after { color: var(--text-primary); }
.compare-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 200px));
  gap: var(--sp-md);
  justify-content: center;
}
.compare-thumbs .shot-frame { margin-bottom: var(--sp-xs); }
.compare-thumbs .type-caption { text-align: center; }
@media (max-width: 640px) {
  .compare-thumbs { grid-template-columns: repeat(2, minmax(0, 160px)); }
}

.featured-card .image-slot {
  border-bottom: 1px solid var(--border-default);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.featured-card .card-body { padding: var(--sp-xl); }
.featured-card h2 { margin-bottom: var(--sp-sm); }
.featured-card .outcome-line { color: var(--text-secondary); margin-bottom: var(--sp-lg); }

/* ── Stat callouts ── */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-lg);
  margin-bottom: var(--sp-lg);
}

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

.stat {
  border: 1px dashed var(--border-default);
  border-radius: 8px;
  padding: var(--sp-md);
  text-align: center;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-tertiary);
}

.stat .value.filled { color: var(--text-primary); }

.stat .label { margin-top: var(--sp-xs); }

/* ── Pending placeholder ── */

.pending {
  display: inline-block;
  border: 1px dashed var(--border-default);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--surface-muted);
}

.pending-block {
  border: 1px dashed var(--border-default);
  border-radius: 8px;
  padding: var(--sp-lg);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Technical literacy strip ── */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-lg);
}

@media (max-width: 900px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr; }
}

/* Narrower variant for card grids holding paragraph-length copy (case
   study findings/decisions, build tiles) — 4 tracks leaves columns too
   tight for that much text even at the full .container width. */
.tile-grid-prose { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 640px) {
  .tile-grid-prose { grid-template-columns: 1fr; }
}

/* Three even columns — for small sets of card content (e.g. 3 decisions). */
.tile-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .tile-grid-3 { grid-template-columns: 1fr; } }

.tile {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
}

.tile h3 { margin-bottom: var(--sp-sm); }
.tile p.type-body { color: var(--text-secondary); flex: 1 0 auto; margin-bottom: var(--sp-sm); }
.tile .source { margin-top: auto; padding-top: var(--sp-sm); }
.tile a { font-size: 14px; font-weight: 600; text-decoration: underline; margin-top: auto; padding-top: var(--sp-sm); }

/* One-card, arrow-navigated feature carousel (CivicPulse "Five screens") */
.feature-carousel-card {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: var(--sp-lg);
  margin-top: var(--sp-lg);
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
}
.feature-slide {
  display: none;
  flex: 1;
  grid-template-columns: 200px 1fr;
  gap: var(--sp-xl);
  align-items: center;
}
.feature-slide.is-active { display: grid; }
.feature-slide .shot-frame { max-width: 200px; margin: 0 auto; }
.feature-slide-copy .type-label-upper { margin-bottom: var(--sp-sm); }
.carousel-arrow {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-default);
  background: var(--surface-muted);
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.carousel-arrow:hover { background: var(--border-default); }
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: var(--sp-sm);
  margin-top: var(--sp-md);
}
.carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--border-default);
  cursor: pointer;
}
.carousel-dot.is-active { background: var(--text-primary); }
@media (max-width: 640px) {
  .feature-carousel-card { flex-direction: column; }
  .feature-slide { grid-template-columns: 1fr; }
}

/* Citation links inside a .source line are references, not CTAs — undo
   the bold "Read more" tile-link treatment above. */
.tile .source a,
.fact .fact-source a {
  font-size: inherit;
  font-weight: 400;
  margin-top: 0;
  padding-top: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tile .source a:hover,
.fact .fact-source a:hover { color: var(--text-primary); }

#sources li:target { color: var(--text-primary); }

/* ── About teaser / general two-col ── */

.split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-xl);
  align-items: start;
}
@media (max-width: 640px) { .split { grid-template-columns: 1fr; } }

.pill-row { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.pill {
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── About hero: headshot + intro ── */

.about-hero {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: var(--sp-2xl);
  align-items: start;
}
.about-hero .about-headshot { order: 2; }
@media (max-width: 700px) {
  .about-hero { grid-template-columns: 1fr; }
  .about-hero .about-headshot { order: -1; max-width: 160px; }
}

.about-headshot {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: top;
  border-radius: 12px;
  border: 1px solid var(--border-default);
  background: var(--surface-muted);
  display: block;
}

/* ── Case study page ── */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-xl);
  margin: var(--sp-lg) 0 var(--sp-xl);
  padding-bottom: var(--sp-lg);
  border-bottom: 1px solid var(--border-default);
}
.meta-row .meta-item .label { margin-bottom: 2px; }

blockquote.opening-stat {
  border-left: 3px solid var(--text-primary);
  padding-left: var(--sp-lg);
  margin: var(--sp-lg) 0;
}

.case-section { margin-bottom: var(--sp-3xl); }
.case-section h2 { margin-bottom: var(--sp-lg); }
.case-section p { margin-bottom: var(--sp-md); color: var(--text-primary); }

.rq-list { padding-left: var(--sp-lg); margin-bottom: var(--sp-md); }
.rq-list li { margin-bottom: var(--sp-sm); }

.source-list a { text-decoration: underline; text-underline-offset: 2px; }
.source-list a:hover { color: var(--text-primary); }

/* ── Summary block: the "30-second summary" callout box ── */

.summary-block {
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: var(--sp-xl);
  margin: var(--sp-xl) 0 var(--sp-3xl);
}
.summary-block > .type-label-upper { margin-bottom: var(--sp-md) !important; }

/* ── Fact grid: hard numbers pulled out of prose, cited ── */

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-xl) var(--sp-2xl);
  margin: var(--sp-2xl) 0 var(--sp-xl);
}
@media (max-width: 640px) {
  .fact-grid { grid-template-columns: 1fr; }
}

.fact { border-top: 2px solid var(--text-primary); padding-top: var(--sp-sm); }
.fact .fact-value { font-size: 32px; font-weight: 700; line-height: 1.15; }
.fact .fact-body { color: var(--text-secondary); margin: var(--sp-xs) 0 var(--sp-sm); }
.fact .fact-source { color: var(--text-tertiary); }

/* ── Flow: a short ordered sequence (problem → status, etc.) ── */

.flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
}
@media (max-width: 900px) { .flow { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .flow { grid-template-columns: 1fr; } }

.flow-step {
  position: relative;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: var(--sp-md);
  background: var(--surface-default);
}
.flow-step .flow-label { margin-bottom: var(--sp-xs); }
.flow-step p { color: var(--text-secondary); margin: 0; }

@media (min-width: 901px) {
  .flow-step:not(:last-child)::after {
    content: "→";
    position: absolute;
    top: 50%;
    right: calc(-1 * var(--sp-md) - 5px);
    transform: translateY(-50%);
    color: var(--text-tertiary);
  }
}

/* ── Bar chart: before/after metrics on a 0–100 scale, readable at a glance ── */

.bar-chart {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-lg) var(--sp-xl);
}
@media (max-width: 800px) { .bar-chart { grid-template-columns: 1fr; } }

.bar-metric {
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: var(--sp-md) var(--sp-lg);
}

.bar-metric-label { font-weight: 600; margin-bottom: var(--sp-md); }

.bar-rows { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 30px 1fr 44px;
  align-items: center;
  gap: var(--sp-sm);
}
.bar-row .bar-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.bar-row.is-after .bar-tag { color: var(--text-primary); }

.bar-track {
  height: 10px;
  border-radius: 5px;
  background: var(--surface-muted);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--text-tertiary);
}
.bar-row.is-after .bar-fill { background: var(--text-primary); }

.bar-row .bar-value {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-secondary);
}
.bar-row.is-after .bar-value { color: var(--text-primary); font-weight: 700; }

/* Compact variant for embedding a two-bar comparison inside a .tile */
.bar-chart--compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: var(--sp-sm) 0;
}
.bar-chart--compact .bar-row { grid-template-columns: 78px 1fr 40px; }

/* ── Footer ── */

.site-footer {
  border-top: 1px solid var(--border-default);
  padding: var(--sp-xl) 0;
  color: var(--text-secondary);
}
.site-footer .links { display: flex; gap: var(--sp-lg); flex-wrap: wrap; margin-bottom: var(--sp-sm); }
.site-footer a { text-decoration: underline; }
