/* ==========================================================================
   Abhishek Kuntal — portfolio styles
   Single stylesheet. Two themes via [data-theme]. Mobile-first.
   ========================================================================== */

/* --- Theme tokens -------------------------------------------------------- */
:root,
[data-theme="light"] {
  --bg:            #f6f7f7;
  --bg-elevated:   #ffffff;
  --bg-muted:      #eceeef;
  --text:          #1a2126;
  --text-muted:    #515c64;
  --text-faint:    #5d6870;
  --border:        #dde1e3;
  --border-strong: #c3c9cd;
  --accent:        #4b2a9e;
  --accent-strong: #36197a;
  --accent-soft:   rgba(75, 42, 158, 0.07);
  --shadow-sm:     0 1px 2px rgba(26, 33, 38, 0.05);
  --shadow-md:     0 8px 24px rgba(26, 33, 38, 0.08);
  --shadow-lg:     0 16px 48px rgba(26, 33, 38, 0.12);
  /* The flow field: the palette of the FTLE renders (inferno), used on dark bands only */
  --ink:           #05040a;
  --ink-text:      #f1eee8;
  --ink-muted:     #b3adbf;
  --ember:         #f2a93b;
  /* Signature stripe: the inferno colour map of the FTLE renders */
  --flow: linear-gradient(90deg, #1b0c41, #4a0c6b, #781c6d, #a52c60, #cf4446, #ed6925, #fb9b06, #f7d13d);
  --radius:        6px;
}

[data-theme="dark"] {
  --bg:            #0c0e12;
  --bg-elevated:   #14171d;
  --bg-muted:      #1b1f26;
  --text:          #e7e9ec;
  --text-muted:    #a4abb3;
  --text-faint:    #8d959e;
  --border:        #262b33;
  --border-strong: #3a414b;
  --accent:        #b9a6ff;
  --accent-strong: #d3c8ff;
  --accent-soft:   rgba(185, 166, 255, 0.1);
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:     0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg:     0 16px 48px rgba(0, 0, 0, 0.55);
}

/* Respect OS preference if user hasn't chosen */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }
}

/* --- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s ease, color 0.25s ease;
}

img, svg { max-width: 100%; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-strong); text-decoration: underline; }
/* Links inside running text are underlined so they don't rely on colour alone */
main :is(p, li, figcaption, td, dd) a:not(.btn) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in oklab, currentColor 45%, transparent);
}
main :is(p, li, figcaption, td, dd) a:not(.btn):hover { text-decoration-color: currentColor; }

h1, h2, h3, h4 {
  font-family: inherit;
  font-stretch: 112%;
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  color: var(--text);
}

p { margin: 0 0 1em; }

ul { padding-left: 1.2em; }
li { margin-bottom: 0.35em; }

code, pre {
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.9em;
}

::selection { background: var(--accent); color: var(--bg); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--bg);
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* --- Layout helpers ------------------------------------------------------ */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section-title {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.section-head .section-title { margin-bottom: 0; }
.section-link {
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-block;
  padding: 0.3rem 0;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}

/* --- Header / nav -------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
}

.nav-brand {
  font-stretch: 112%;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.nav-brand:hover { color: var(--accent); text-decoration: none; }

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
}

.theme-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-muted);
}

/* --- Hero ------------------------------------------------------------------ */
/* Full-bleed flow field. The video is the FTLE wake behind a NACA 0012 from the
   author's own lattice-Boltzmann code; text sits on the dark lower band. */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: min(82vh, 760px);
  padding: 7rem 0 2.75rem;
  background: var(--ink);
  color: var(--ink-text);
  overflow: hidden;
  isolation: isolate;
}
.hero-media { position: absolute; inset: 0; z-index: -1; }
.hero-media video,
.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 35% 40%;
}
.hero-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--ink) 0%, rgba(5, 4, 10, 0.82) 34%, rgba(5, 4, 10, 0) 68%);
}
.hero .container { position: relative; }
.hero::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--flow); }
.hero-lede a { color: var(--ember); }
.hero-lede a:hover { color: #ffc266; }
.hero-title {
  font-size: clamp(3rem, 10vw, 7.75rem);
  font-stretch: 125%;
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 0.92;
  color: var(--ink-text);
  margin: 0 0 1.25rem;
}
.hero-lede {
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  line-height: 1.5;
  color: var(--ink-text);
  max-width: 44ch;
  margin-bottom: 0.75rem;
}
.hero-availability {
  color: var(--ember);
  font-weight: 550;
  margin-bottom: 1.75rem;
}
.hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem 3rem;
}
.hero-caption {
  max-width: 34ch;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-muted);
  margin: 0;
}
.hero-pause {
  appearance: none; background: none; border: 0; padding: 0.2rem 0; margin-left: 0.35rem;
  font: inherit; color: var(--ink-text); text-decoration: underline; text-decoration-color: rgba(241, 238, 232, 0.35);
  cursor: pointer;
}
.hero-caption a { color: var(--ink-text); text-decoration: underline; text-decoration-color: rgba(241, 238, 232, 0.35); }
.hero .btn-primary { background: var(--ember); border-color: var(--ember); color: var(--ink); }
.hero .btn-primary:hover { background: #ffc266; border-color: #ffc266; color: var(--ink); }
.hero .btn-ghost { color: var(--ink-text); border-color: rgba(241, 238, 232, 0.35); }
.hero .btn-ghost:hover { background: rgba(241, 238, 232, 0.08); color: var(--ink-text); }
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
    font-size: 0.95rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--bg);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

/* --- Stats strip ----------------------------------------------------------- */
.stats { padding: 3.5rem 0 1rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
  gap: 2rem 1.5rem;
  margin: 0;
}
.stat { border-top: 2px solid var(--text); padding-top: 0.9rem; }
.stat-value {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  font-stretch: 118%;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}
.stat-label { font-size: 0.95rem; color: var(--text); margin-top: 0.55rem; font-weight: 500; }
.stat-note { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.3rem; line-height: 1.45; }

/* --- Focus areas ----------------------------------------------------------- */
.focus { padding: 3.5rem 0 1rem; }
.focus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 1.5rem 2.5rem;
}
.focus-card h3, .focus-card-title { font-size: 1.1rem; margin: 0 0 0.6rem; }
.focus-card p { font-size: 0.95rem; color: var(--text-muted); margin: 0; }
.focus-card ul { list-style: none; padding: 0; margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.focus-card li { padding: 0.35rem 0; border-top: 1px solid var(--border); margin: 0; }
/* Boxed variant, still used by the contact page */
.contact-page .focus-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
}

/* --- Project cards --------------------------------------------------------- */
.featured { padding: 3.5rem 0 4rem; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 2.5rem 1.75rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.project-card:hover { text-decoration: none; color: var(--text); }
.project-card:hover .project-title { color: var(--accent); }
.project-card:focus-visible { outline-offset: 6px; border-radius: var(--radius); }

.project-thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.project-card:hover .project-thumb { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.project-tag {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
}
.project-title {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
  transition: color 0.15s ease;
}
.project-summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  flex: 1;
}
.project-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.tool {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  color: var(--text-muted);
  background: var(--bg-muted);
}

/* Home page: the lead project gets a wide row, image left */
@media (min-width: 860px) {
  .project-grid--featured { grid-template-columns: repeat(3, 1fr); gap: 2.5rem 1.5rem; }
  .project-grid--featured .project-title { font-size: 1.12rem; }
  .project-grid--featured .project-card:first-child {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: 0 2.25rem;
    align-items: center;
  }
  .project-grid--featured .project-card:first-child .project-thumb { margin: 0; grid-row: span 5; }
  .project-grid--featured .project-card:first-child .project-title { font-size: 1.75rem; }
}

/* --- Filter bar (work page) --------------------------------------------- */
.work-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-faint);
}
.filter-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.filter-btn:hover { color: var(--text); border-color: var(--border-strong); }
.filter-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.project-card.is-hidden { display: none; }

/* --- Page header (interior pages) --------------------------------------- */
.page-header {
  position: relative;
  padding: 4rem 0 2.25rem;
  margin-bottom: 2.5rem;
}
.page-header::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--flow); }
.page-header h1 {
  font-size: clamp(1.85rem, 5vw, 3rem);
  margin-bottom: 0.6rem;
}
.page-header p:not(.eyebrow) {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0;
}

/* --- Project page (case study) ----------------------------------------- */
.case {
  padding-bottom: 5rem;
}

.case-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
  gap: 1.1rem 1.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.case-meta div { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.case-meta dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0;
}
.case-meta dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
}

.case-section {
  margin-bottom: 2.5rem;
}
.case-section h2 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.case-section ul, .case-section ol {
  color: var(--text-muted);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.result {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.result-value {
  font-stretch: 112%;
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.case-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* --- Skills tables (resume page) ---------------------------------------- */
.skills-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2.5rem;
  font-size: 0.95rem;
}
.skills-table th, .skills-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.skills-table th {
    font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-faint);
  background: var(--bg-muted);
}
.skills-table td:first-child { font-weight: 500; color: var(--text); }
.skills-table td:nth-child(2) { color: var(--text-muted); white-space: nowrap; width: 120px; }
.skills-table td:nth-child(3) { color: var(--text-muted); }

.skill-bar {
  display: block;
  width: 100%;
  height: 6px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.skill-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s ease;
}

.skill-advanced .skill-bar-fill { width: 90%; }
.skill-expert .skill-bar-fill { width: 100%; }
.skill-intermediate .skill-bar-fill { width: 65%; }
.skill-basics .skill-bar-fill { width: 40%; }

/* --- About page --------------------------------------------------------- */
/* Single prose column — the photo this grid was built for was removed. */
.about-page .page-header { margin-bottom: 1.5rem; }
.bio-grid {
  margin-bottom: 3rem;
}
.bio-prose { max-width: 100%; }
.bio-prose p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.bio-prose p:first-child { color: var(--text); font-size: 1.15rem; }

/* --- Timeline ----------------------------------------------------------- */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border);
  padding-left: 1.5rem;
}
.timeline li {
  position: relative;
  margin-bottom: 2rem;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -1.78rem;
  top: 0.5rem;
  width: 0.6rem;
  height: 0.6rem;
  background: var(--accent);
  border-radius: 999px;
}
.timeline-when {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
  margin-bottom: 0.25rem;
}
.timeline-role {
  font-stretch: 112%;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.timeline-org {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.timeline li p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

/* --- Contact ------------------------------------------------------------ */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}
.contact-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: block;
  color: var(--text);
}
.contact-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  color: var(--text);
}
.contact-card .label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}
.contact-card .value {
  font-stretch: 112%;
  font-size: 1.05rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* --- Footer ------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}
.footer-links { display: inline-flex; gap: 0.5rem; align-items: center; margin: 0; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }

/* --- Reveal animation --------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Case-study figures & media ---------------------------------------- */
.case figure {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}
.case figure img,
.case figure video {
  display: block;
  width: 100%;
  height: auto;
}
.case figure figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
}
.case-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}
/* The figure is the frame; pairs share a height and captions stay left-aligned */
.case-figures figure { margin: 0; display: flex; flex-direction: column; }
.case-figures figure figcaption { flex: 1; }
.case-figures img { background: var(--bg-muted); }
.case .video-hero {
  margin: 1rem 0 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.case .video-hero video { width: 100%; display: block; }

.video-solo {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}
.video-solo video {
  width: 100%;
  display: block;
}


.case-poster {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}
.case-poster img {
  width: 100%;
  display: block;
  height: auto;
}


.callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  color: var(--text);
}
.callout p:last-child { margin-bottom: 0; }
.ip-note {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-faint);
  border: 1px dashed var(--border-strong);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}

/* --- Scroll progress & back-to-top ------------------------------------- */
.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  z-index: 100;
  pointer-events: none;
}

.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease, visibility 0.2s;
  z-index: 90;
  box-shadow: var(--shadow-md);
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--accent-strong);
}

/* --- Lightbox (native <dialog>, built by main.js) ------------------------ */
.zoom { all: unset; display: block; width: 100%; cursor: zoom-in; }
.zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lightbox {
  border: 0; padding: 0; margin: 0;
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  background: rgba(5, 4, 10, 0.94);
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox img { max-width: 94vw; max-height: 90dvh; width: auto; height: auto; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 2.75rem; height: 2.75rem; border-radius: 999px; border: 0;
  background: var(--bg-elevated); color: var(--text);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: var(--accent); color: var(--bg); }

/* --- Availability note ------------------------------------------------ */
.current-work {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1.1rem;
  margin: 1.5rem 0;
}
.current-work h2 { font-size: 1rem; margin-bottom: 0.35rem; }
.current-work p { color: var(--text-muted); }

/* --- Print styles ------------------------------------------------------ */
@media print {
  .site-header,
  .scroll-progress-bar,
  .back-to-top,
  .theme-toggle,
  .filter-bar,
  .case-nav,
  .hero-ctas,
  .btn,
  .lightbox-overlay {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.4;
  }

  .container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .page-header {
    padding: 1rem 0 !important;
    border-bottom: 1px solid #ccc !important;
    margin-bottom: 1rem !important;
  }

  .case-section {
    break-inside: avoid;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  a[href^="mailto:"]::after,
  a[href^="tel:"]::after {
    content: "";
  }

  .project-card,
  .focus-card,
  .contact-card {
    break-inside: avoid;
    border: 1px solid #ddd !important;
  }

  .project-thumb {
    display: none !important;
  }

  .results-grid,
  .case-figures {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .callout {
    border-left: 3px solid #000 !important;
    background: #f5f5f5 !important;
  }

  .ip-note {
    border: 1px solid #999 !important;
  }

  h1, h2, h3 {
    color: #000 !important;
  }

  .hero {
    padding: 1rem 0 !important;
  }

  .hero-title {
    font-size: 2rem !important;
  }

  .stats {
    padding: 0.5rem 0 1rem !important;
  }

  .stat {
    padding: 0.5rem !important;
  }

  .stat-value {
    font-size: 1rem !important;
  }

  .section-title {
    font-size: 1.2rem !important;
    margin-bottom: 0.5rem !important;
  }

  .site-footer {
    margin-top: 1rem !important;
    padding: 0.5rem 0 !important;
    font-size: 0.8rem !important;
  }
}

/* --- Social share ------------------------------------------------------- */
.share-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.share-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* --- Focus visible ------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Reduced motion -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* --- Related projects --------------------------------------------------- */
.related-projects {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-projects h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* --- Small screens ------------------------------------------------------ */
@media (max-width: 540px) {
  .nav-links { gap: 1rem; }
  .nav-links a { font-size: 0.85rem; }
  .hero { min-height: 88vh; padding: 5rem 0 2rem; }
  .hero-media { bottom: auto; height: 50%; }
  .hero-media video, .hero-media img { object-position: 12% 50%; }
  .case-meta { gap: 1rem; }
  .filter-bar { gap: 0.4rem; }
  .filter-btn { font-size: 0.75rem; padding: 0.3rem 0.7rem; }
  .project-grid { grid-template-columns: 1fr; }
}

/* --- Tablet ------------------------------------------------------------- */
@media (min-width: 541px) and (max-width: 768px) {
  .project-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Large desktop ------------------------------------------------------ */
@media (min-width: 1200px) {
  .container { max-width: 1140px; }
}

/* --- Stats as a definition list: value reads first ----------------------- */
.stat { display: flex; flex-direction: column; }
.stat dd { margin: 0; }
.stat .stat-value { order: -1; }
.filter-empty { color: var(--text-muted); margin: 0 0 1.5rem; }

/* --- Charts (inline SVG; colours from tokens so both themes work) ------- */
.chart-figure { margin: 1.5rem 0; }
.case .chart-figure { border: 0; background: transparent; border-radius: 0; }
.case .chart-figure figcaption { background: transparent; border: 0; padding: 0.5rem 0 0; }
.chart { width: 100%; height: auto; display: block; overflow: visible; font-family: inherit; }
.chart-label { fill: var(--text); font-size: 13px; }
.chart-value { fill: var(--text-muted); font-size: 13px; font-weight: 600; }
.chart-tick, .chart-note { fill: var(--text-faint); font-size: 11px; }
.chart-bar { fill: var(--border-strong); }
.chart-bar--hi { fill: var(--accent); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-shade { fill: var(--accent-soft); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.chart-ref { fill: none; stroke: var(--text); stroke-width: 1.5; }
.chart-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 0 2rem; }
.video-hero figcaption { font-size: 0.85rem; color: var(--text-muted); padding: 0.75rem 1rem; background: var(--bg-muted); }
/* --- Reading pages: one column shared by header, text, figures and tables --- */
.container.reading { max-width: calc(800px + 3rem); }
.case figure.figure-narrow { max-width: 440px; margin-inline: auto; }

/* --- Narrow screens: keep wide content inside the viewport --------------- */
@media (max-width: 540px) {
  .skills-table th, .skills-table td { padding: 0.55rem 0.5rem; }
  .skills-table td:nth-child(2) { white-space: normal; width: auto; }
  .case figure img, .case-figures img { max-width: 100%; height: auto; }
  .back-to-top { right: 0.75rem; bottom: 0.75rem; width: 2.5rem; height: 2.5rem; }
  .skills-table thead { display: none; }
  .skills-table tr { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; border-bottom: 1px solid var(--border); }
  .skills-table td { border: 0; padding: 0.4rem 0.25rem; min-width: 0; }
  .skills-table td:nth-child(3) { grid-column: 1 / -1; padding-top: 0; }
}
@media (max-width: 360px) {
  .nav { padding: 0.75rem 1rem; gap: 0.5rem; }
  .nav-links { gap: 0.7rem; }
}

/* --- "In short" summary box at the top of long case studies -------------- */
.tldr {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 1.1rem 1.4rem;
  margin: 0 0 2.5rem;
}
.tldr::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--flow); }
.tldr h2 { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0.2rem 0 0.6rem; border: 0; padding: 0; }
.tldr ul { margin: 0; padding-left: 1.1rem; }
.tldr li { margin: 0.35rem 0; }
.tldr li strong { color: var(--text); }

/* --- Plain data tables inside case studies ------------------------------- */
.data-table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  /* Edge shadows appear only while there is more table to scroll to */
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left / 2rem 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, transparent) right / 2rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.2), transparent) left / 0.75rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.2), transparent) right / 0.75rem 100% no-repeat scroll;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { font-size: 0.8rem; color: var(--text-faint); background: var(--bg-muted); font-weight: 600; }
.data-table tr.is-best td { color: var(--text); font-weight: 600; }
.data-table--text th, .data-table--text td { text-align: left; }
.data-table--text td:last-child { white-space: normal; min-width: 16rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
