/* Shared styles for case-study pages; tokens match index.html */
:root {
  --bg: #0F0F0F; --surface: #1A1A1A; --surface-2: #1E1E1E;
  --border: #2A2A2A; --border-soft: #1E1E1E; --border-ui: #6B6B6B;
  --text-primary: #F5F5F5; --text-secondary: #C9C9C9; --text-tertiary: #9A9A9A;
  --accent: #6A4BD1; --accent-hover: #7B5CE0; --accent-text-on: #FFFFFF; --accent-ink: #A894FF;
  --mockup-shadow: 0 30px 60px -15px rgba(0,0,0,0.6), 0 10px 24px -8px rgba(0,0,0,0.5);
}
html[data-theme="light"] {
  --bg: #FAF9F6; --surface: #FFFFFF; --surface-2: #F2F1ED;
  --border: #E2E0D8; --border-soft: #ECEAE3; --border-ui: #8F8D86;
  --text-primary: #18181A; --text-secondary: #4A4A48; --text-tertiary: #75736C;
  --accent: #5A3BC4; --accent-hover: #4B2FB0; --accent-text-on: #FFFFFF; --accent-ink: #5A3BC4;
  --mockup-shadow: 0 30px 60px -15px rgba(0,0,0,0.18), 0 10px 24px -8px rgba(0,0,0,0.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text-secondary); -webkit-font-smoothing: antialiased; font-size: 16px; line-height: 1.5; transition: background .35s ease, color .35s ease; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }

.skip-link { position: absolute; left: -9999px; top: 0; z-index: 1000; background: var(--accent); color: var(--accent-text-on); padding: 12px 20px; border-radius: 0 0 8px 0; font-size: 14px; font-weight: 600; }
.skip-link:focus { left: 0; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.nav { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 3rem; position: sticky; top: 0; z-index: 100; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.nav-back { font-size: 15px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 8px; min-height: 44px; transition: color .15s; }
.nav-back:hover { color: var(--accent-ink); }
.nav-right { display: flex; gap: 1rem; align-items: center; }
.nav-cta { font-size: 14px; font-weight: 600; color: var(--accent-text-on); background: var(--accent); padding: 12px 24px; border-radius: 8px; transition: background .15s, transform .15s; }
.nav-cta:hover { background: var(--accent-hover); transform: translateY(-1px); }
.theme-toggle { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--border-ui); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color .2s; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.icon-sun { color: var(--accent-ink); display: none; }
.icon-moon { color: var(--text-secondary); display: block; }
html[data-theme="light"] .icon-sun { display: block; }
html[data-theme="light"] .icon-moon { display: none; }

.wrap { max-width: 1100px; margin: 0 auto; padding-left: 3rem; padding-right: 3rem; }
.case-hero { padding-top: 4rem; padding-bottom: 3rem; }
.case-index { font-size: 14px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 1.25rem; }
.case-index span { color: var(--accent-ink); font-weight: 600; }
.case-title { font-family: 'Crimson Pro', Georgia, serif; font-weight: 500; font-size: clamp(38px, 5.5vw, 68px); line-height: 1.08; letter-spacing: -0.015em; color: var(--text-primary); margin-bottom: 1.5rem; max-width: 18ch; }
.case-lede { font-size: 19px; line-height: 1.7; color: var(--text-secondary); max-width: 640px; }

.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; padding-top: 2rem; padding-bottom: 3rem; border-bottom: 0.5px solid var(--border); }
.meta-label { font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 6px; }
.meta-val { font-size: 16px; color: var(--text-primary); line-height: 1.5; }

.case-img { margin-top: 3.5rem; margin-bottom: 3.5rem; }
.case-img figure { border-radius: 14px; overflow: hidden; box-shadow: var(--mockup-shadow); border: 1px solid var(--border); }
.case-img figcaption { font-size: 14px; color: var(--text-tertiary); margin-top: 14px; }

.case-section { display: grid; grid-template-columns: 220px 1fr; gap: 3rem; padding: 3rem 0; border-bottom: 0.5px solid var(--border); }
.case-section:last-child { border-bottom: none; }
.case-section-label { font-size: 13px; font-weight: 600; color: var(--accent-ink); letter-spacing: 0.12em; text-transform: uppercase; padding-top: 8px; }
.case-section h2 { font-family: 'Crimson Pro', Georgia, serif; font-weight: 500; font-size: 32px; color: var(--text-primary); margin-bottom: 1.1rem; line-height: 1.2; }
.case-section p, .case-section li { font-size: 17px; line-height: 1.8; color: var(--text-secondary); max-width: 62ch; }
.case-section p { margin-bottom: 1.1rem; }
.case-section p:last-child { margin-bottom: 0; }
.case-section ul { padding-left: 1.2rem; }
.case-section li { margin-bottom: 0.6rem; }
.case-section li::marker { color: var(--accent-ink); }
.case-section strong { color: var(--text-primary); font-weight: 600; }

.impact-row { display: flex; gap: 3rem; flex-wrap: wrap; margin-top: 1rem; }
.impact-num { font-family: 'Crimson Pro', Georgia, serif; font-size: 44px; font-weight: 500; color: var(--text-primary); line-height: 1; }
.impact-label { font-size: 13px; color: var(--text-tertiary); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 8px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 1rem; }
.chip { font-size: 13px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 100px; padding: 6px 14px; }

.next-case { display: block; margin: 2rem 0 4rem; padding: 2.5rem; border: 1.5px solid var(--border-ui); border-radius: 16px; transition: border-color .2s, background .2s; }
.next-case:hover { border-color: var(--accent); background: var(--surface); }
.next-label { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 10px; }
.next-title { font-family: 'Crimson Pro', Georgia, serif; font-weight: 500; font-size: 32px; color: var(--text-primary); display: flex; align-items: center; gap: 14px; }
.next-title .arrow { color: var(--accent-ink); transition: transform .2s; }
.next-case:hover .arrow { transform: translateX(6px); }

.footer-bar { display: flex; justify-content: space-between; padding: 2rem 3rem; border-top: 0.5px solid var(--border); flex-wrap: wrap; gap: 1rem; }
.footer-copy { font-size: 14px; color: var(--text-tertiary); }
.footer-links { display: flex; gap: 1.75rem; }
.footer-link { font-size: 14px; color: var(--text-secondary); transition: color .15s; }
.footer-link:hover { color: var(--accent-ink); }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
@media (max-width: 900px) {
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .case-section { grid-template-columns: 1fr; gap: 0.75rem; }
}
@media (max-width: 640px) {
  .nav, .footer-bar { padding-left: 1rem; padding-right: 1rem; }
  .wrap { padding-left: 1rem; padding-right: 1rem; }
  .nav-back .back-text { display: none; }
  .next-case { padding: 1.75rem; }
  .next-title { font-size: 26px; }
}

/* ---- Before / after pair ---- */
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.ba figure { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--mockup-shadow); }
.ba-tag { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 10px; }
.ba-tag::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--text-tertiary); }
.ba-tag.after { color: var(--accent-ink); }
.ba-tag.after::before { background: var(--accent); border-color: var(--accent); }

/* ---- Page gallery ---- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.gallery a { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); transition: border-color .2s, transform .3s; }
.gallery a:hover { border-color: var(--accent); transform: translateY(-4px); }
.gallery img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: top; }
.gallery span { display: flex; justify-content: space-between; font-size: 15px; color: var(--text-primary); padding: 12px 16px; border-top: 1px solid var(--border); }
.gallery span em { font-style: normal; font-size: 14px; color: var(--accent-ink); }
@media (prefers-reduced-motion: reduce) { .gallery a:hover { transform: none; } }
@media (max-width: 760px) { .ba { grid-template-columns: 1fr; } .gallery { grid-template-columns: 1fr 1fr; } }

/* ---- Live site link ---- */
.site-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 1.75rem; min-height: 44px; font-size: 16px; font-weight: 500; color: var(--text-primary); border-bottom: 1.5px solid var(--border-ui); transition: color .15s, border-color .15s; }
.site-link:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
.site-note { display: block; font-size: 14px; color: var(--text-tertiary); margin-top: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Gallery: 10 desktop pages ---- */
.gallery { grid-template-columns: repeat(5, 1fr); gap: 1rem; }
.gallery span { font-size: 14px; flex-direction: column; gap: 2px; padding: 10px 12px; }
.gallery span em { font-size: 13px; }
@media (max-width: 1000px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .gallery { grid-template-columns: repeat(2, 1fr); } }

/* ---- Mobile phones strip ---- */
.phones { list-style: none; display: flex; gap: 1.25rem; overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px 4px 18px; }
.phones li { flex: 0 0 200px; scroll-snap-align: start; }
.phones a { display: block; }
.phone { display: block; border-radius: 28px; padding: 8px; background: #111; border: 1px solid var(--border); box-shadow: var(--mockup-shadow); transition: transform .3s cubic-bezier(.2,.8,.2,1), border-color .2s; }
.phone img { border-radius: 20px; width: 100%; aspect-ratio: 375 / 812; object-fit: cover; object-position: top; }
.phones a:hover .phone { transform: translateY(-6px); border-color: var(--accent); }
.phone-name { display: block; text-align: center; font-size: 14px; color: var(--text-secondary); margin-top: 12px; }
.phones a:hover .phone-name { color: var(--accent-ink); }
.phones::-webkit-scrollbar { height: 8px; }
.phones::-webkit-scrollbar-thumb { background: var(--border-ui); border-radius: 8px; }
@media (max-width: 640px) { .phones li { flex-basis: 160px; } }
@media (prefers-reduced-motion: reduce) { .phones a:hover .phone { transform: none; } }

/* ---- Live note ---- */
.live-note { display: flex; gap: 16px; align-items: flex-start; margin: 1rem 0 2.5rem; padding: 1.5rem 1.75rem; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.live-dot { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 8px; border-radius: 50%; background: #3FB950; box-shadow: 0 0 0 5px rgba(63,185,80,.18); }
.live-note .live-title { font-family: 'Crimson Pro', Georgia, serif; font-size: 24px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.live-note p { font-size: 16px; line-height: 1.7; color: var(--text-secondary); max-width: 62ch; }

.phones, .phones li, .gallery a, .link-row, .site-link { position: relative; }

/* ===== Scrollable previews (desktop browser + phones) ===== */
.scroll-view { position: relative; overflow: hidden; overscroll-behavior: contain; cursor: pointer; background: #fff; }
.scroll-view img { width: 100%; height: auto; display: block; }
.scroll-view.is-active { overflow-y: auto; cursor: auto; }
.scroll-view:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.scroll-hint {
  position: sticky; display: block; width: max-content; margin: 0 auto; bottom: 14px; margin-top: -48px;
  font-size: 13px; font-weight: 600; color: #fff; background: rgba(15,15,15,.78); padding: 8px 14px; border-radius: 100px;
  transition: opacity .2s; pointer-events: none;
}
.scroll-view.is-active .scroll-hint { opacity: 0; }
.scroll-view::-webkit-scrollbar { width: 8px; }
.scroll-view::-webkit-scrollbar-thumb { background: rgba(0,0,0,.25); border-radius: 8px; }

/* desktop browser viewer */
.browser { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.bv-tabs { display: flex; flex-direction: column; gap: 4px; }
.bv-tab { font: inherit; font-size: 15px; text-align: left; color: var(--text-secondary); background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.bv-tab:hover { color: var(--text-primary); background: var(--surface); }
.bv-tab[aria-selected="true"] { color: var(--text-primary); background: var(--surface); border-color: var(--accent); font-weight: 600; }
.bv-window { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--mockup-shadow); background: var(--surface); }
.bv-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.bv-bar span { width: 11px; height: 11px; border-radius: 50%; background: var(--border-ui); opacity: .6; }
.bv-bar em { font-style: normal; font-size: 13px; color: var(--text-tertiary); margin-left: 10px; }
.bv-view { height: min(70vh, 620px); }
@media (max-width: 860px) {
  .browser { grid-template-columns: 1fr; }
  .bv-tabs { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .bv-tab { white-space: nowrap; }
  .bv-view { height: 60vh; }
}

/* phones */
.phones li { flex: 0 0 230px; }
.phone { padding: 8px; border-radius: 30px; }
.phone .phone-view { border-radius: 22px; aspect-ratio: 375 / 812; }
.phones .phone:hover { transform: none; }
.phone:has(.is-active) { border-color: var(--accent); }
@media (max-width: 640px) { .phones li { flex-basis: 200px; } }

/* full-length image inside phone (override thumbnail crop) */
.phone .phone-view img { aspect-ratio: auto; height: auto; object-fit: fill; border-radius: 0; }

/* ===== v21: robust scrolling =====
   Mouse/trackpad: always scrollable, scroll chains to the page at the ends.
   Touch: tap to activate, so swiping the page never gets trapped. */
.scroll-hint .h-touch { display: none; }
@media (hover: hover) and (pointer: fine) {
  .scroll-view { overflow-y: auto; overscroll-behavior: auto; cursor: auto; }
}
@media (hover: none), (pointer: coarse) {
  .scroll-hint .h-fine { display: none; }
  .scroll-hint .h-touch { display: inline; }
  .scroll-view.is-active { overflow-y: auto; overscroll-behavior: contain; }
}
.scroll-view.scrolled .scroll-hint { opacity: 0; }

/* phones: grid instead of a sideways scroller, so nothing competes for the scroll */
.phones { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2rem 1.5rem; overflow: visible; scroll-snap-type: none; padding: 6px 0 0; }
.phones li { flex: none; }
@media (max-width: 900px) { .phones { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .phones { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 1rem; } .phone { padding: 5px; border-radius: 22px; } .phone .phone-view { border-radius: 17px; } }

/* ===== Mobile refinements (case studies) ===== */
@media (max-width: 640px) {
  .nav { padding-top: .875rem; padding-bottom: .875rem; }
  .nav-back .back-text { display: inline; }
  .nav-right { gap: .6rem; }
  .nav-cta { padding: 11px 18px; white-space: nowrap; }
  .case-hero { padding-top: 2.5rem; padding-bottom: 2rem; }
  .case-title { font-size: 36px; }
  .case-lede { font-size: 17px; }
  .meta-grid { gap: 1.25rem 1rem; padding-bottom: 2rem; }
  .case-img { margin-top: 2.25rem; margin-bottom: 2.25rem; }
  .case-section { padding: 2.25rem 0; }
  .case-section h2 { font-size: 27px; }
  .case-section p, .case-section li { font-size: 16px; }
  .impact-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .impact-num { font-size: 36px; }
  .ba { gap: 1.5rem; }
  .bv-view { height: 64vh; }
  .live-note { padding: 1.25rem; }
  /* mobile pages: one phone at a time, swipe sideways; tap a phone to scroll inside it */
  .phones { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 1rem; padding: 4px 1rem 12px; margin: 0 -1rem; }
  .phones li { flex: 0 0 74%; scroll-snap-align: center; }
  .phone { padding: 7px; border-radius: 28px; }
  .phone .phone-view { border-radius: 21px; }
}
.h-touch-cap { display: none; }
@media (hover: none), (pointer: coarse) { .h-fine-cap { display: none; } .h-touch-cap { display: inline; } }
