/* ==========================================================================
   Case study template styles
   Shared by every project page under /projects/<name>/.

   Layout model
   - Desktop (>= 1100px): sections reproduce the Figma frame (1440px wide).
     Elements with .abs are placed with design-pixel coordinates:
       style="--x:64; --y:219; --w:459"   (px in the 1440 frame, relative to the section)
     Sections get their Figma height with style="--h:804".
     The whole composition (type included) is zoomed to the window width (--z).
   - Below 1100px: .abs elements fall back to normal document flow (stacked).
   - .stage is a scaled "cluster" (e.g. a group of device mockups). It keeps its
     aspect ratio at every size. Children (.st) use coordinates relative to the
     stage: style="--x:..;--y:..;--w:..;--r:-6" with the stage's --sw / --sh.
   ========================================================================== */

:root {
  --ink: #110034;
  --ink-soft: #4b4466;
  --night: #200854;
  --purple: #330d81;
  --violet: #7b2ff7;
  --cream: #f3f0df;
  --paper: #f9f7ef;
  --yellow: #ffd44f;
  --white: #ffffff;
  --success: #00c9ae;
  --warning: #ffbd3b;

  --font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-condensed: "Roboto Condensed", var(--font);

  --frame: 1440;
  --u: min(1px, calc(100vw / 1440));
  --gutter: 20px;
  --radius-card: 16px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
html, body { overflow-x: clip; }

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3 { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Typography ---------- */
/* A light, airy scale: medium-weight headings, 15px body with generous leading */
/* No single word alone on a last line (Amir's rule for every page): headings balance, running text wraps "pretty" */
h1, h2, h3, h4, .h2, .h3 { text-wrap: balance; }
p, li, figcaption, blockquote, .lead, .body { text-wrap: pretty; }
.h2 { font-size: 26px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; text-wrap: balance; }
.h3 { font-size: 18px; font-weight: 600; line-height: 1.4; }
.body { font-size: 15px; line-height: 26px; color: var(--ink-soft); }
.body b, .body strong { font-weight: 600; color: var(--ink); }
.on-dark b, .on-dark strong { color: inherit; }
.on-dark { color: var(--cream); }
.lead { font-size: 18px; line-height: 30px; font-weight: 300; color: var(--ink-soft); }
.on-dark .lead, .lead.on-dark { color: rgba(243, 240, 223, .85); }
.on-dark .body, .body.on-dark { color: rgba(243, 240, 223, .78); }
.on-dark .body b, .on-dark .body strong, .body.on-dark b, .body.on-dark strong { color: var(--cream); }
.lead b, .lead strong { font-weight: 500; color: var(--ink); }
.on-dark .lead b, .lead.on-dark b { color: var(--cream); }
.center { text-align: center; }
.stack > * + * { margin-top: 16px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: 64px;
  background: var(--white);
  box-shadow: 0 2px 8px rgba(17, 0, 52, 0.08);
  transition: transform .3s cubic-bezier(.33, 1, .68, 1), box-shadow .3s;
}
/* Hides while scrolling down, comes back on any scroll up (case-study.js) */
.site-header.is-hidden { transform: translateY(-100%); box-shadow: none; }
.site-header:focus-within { transform: none; }
.site-header__inner {
  max-width: 1440px; height: 100%; margin: 0 auto;
  padding: 0 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; font-size: 15px; text-decoration: none; white-space: nowrap; }
.brand__name { font-weight: 600; }
.brand__sep { width: 1px; height: 14px; background: #b9b5c6; }
.brand__page { color: #8a859c; font-weight: 400; }
.site-nav { display: flex; align-items: center; gap: 28px; }
.site-nav__links { display: flex; gap: 28px; }
.site-nav__links a {
  font-size: 14px; text-decoration: none; color: #4b4466;
  transition: color .2s ease;
}
.site-nav__links a:hover, .site-nav__links a:focus-visible { color: var(--ink); }
.site-nav__sep { width: 1px; height: 14px; background: #b9b5c6; }
.contact-icons { display: flex; gap: 10px; }
.contact-icon { position: relative; display: block; width: 32px; height: 32px; }
.contact-icon img { position: absolute; inset: 6px; width: 20px; height: 20px; transition: opacity .2s ease; }
.contact-icon img + img { opacity: 0; }
.contact-icon:hover img:first-child, .contact-icon:focus-visible img:first-child { opacity: 0; }
.contact-icon:hover img + img, .contact-icon:focus-visible img + img { opacity: 1; }

/* ---------- Sections ---------- */
.section { position: relative; }
.section__inner { position: relative; max-width: 1440px; margin: 0 auto; }
.bg-night { background: var(--night); }
.bg-purple { background: var(--purple); }
.bg-cream { background: var(--cream); }
.bg-paper { background: var(--paper); }
.content { position: relative; z-index: 2; }
.lift { position: relative; z-index: 3; }
.deco { position: absolute; z-index: 1; pointer-events: none; max-width: none; }

/* Stage: scaled cluster with its own coordinate system */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--sw) / var(--sh);
}
.st {
  position: absolute;
  left: calc(var(--x) / var(--sw) * 100%);
  top: calc(var(--y) / var(--sh) * 100%);
  width: calc(var(--w) / var(--sw) * 100%);
  transform: rotate(calc(var(--r, 0) * 1deg));
}
.st > img { width: 100%; }

/* Desktop: absolute design layout */
@media (min-width: 1100px) {
  .section__inner { height: calc(var(--h) * var(--u)); }
  .abs {
    position: absolute;
    left: calc(var(--x) * var(--u));
    top: calc(var(--y) * var(--u));
    width: calc(var(--w) * var(--u));
  }
  .abs.stage { width: calc(var(--w) * var(--u)); }
  .mobile-only { display: none !important; }
}
/* Desktop: lay out at the 1440 frame size and scale the whole composition (type
   included) to the window, so photos, curves and overlaps keep the Figma layout
   at every width. --z is the window width / 1440, set by case-study.js. */
@media (min-width: 1100px) {
  :root { --u: 1px; }
  .section__inner, .site-header, .site-footer { zoom: var(--z, 1); }
}

/* Tablet & mobile: stacked flow */
@media (max-width: 1099.98px) {
  .lead { font-size: 17px; line-height: 28px; }
  .section__inner { padding: 56px var(--gutter); display: flex; flex-direction: column; gap: 32px; }
  .abs { position: relative; width: 100%; }
  .abs.stage { max-width: calc(var(--w) * 1px); margin-inline: auto; }
  .deco, .desktop-only { display: none !important; }
  .h2 { font-size: 23px; }
  .site-header__inner { padding: 0 var(--gutter); }
  .site-nav__links a, .brand { font-size: 14px; }
  .site-nav, .site-nav__links { gap: 20px; }
}
@media (max-width: 720px) {
  .site-header { height: 56px; }
  html { scroll-padding-top: 64px; }
  .brand__page, .brand__sep, .site-nav__links, .site-nav__sep { display: none; }
  .h2 { font-size: 22px; }
  .h3 { font-size: 17px; }
  .body { font-size: 15px; line-height: 25px; }
}

/* ---------- Bullets ---------- */
.icon-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 10px; }
.icon-list li { display: flex; gap: 14px; align-items: flex-start; font-size: 15px; line-height: 24px; color: var(--ink-soft); }
.icon-list li img { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.ic-check {
  width: 18px; height: 18px; margin-top: 3px; flex: none; border-radius: 6px;
  background: color-mix(in srgb, currentColor 10%, transparent); position: relative;
}
.ic-check::after {
  content: ""; position: absolute; inset: 0; background: var(--violet);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 10.5l3 3 6-7'/%3E%3C/svg%3E") center / 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 10.5l3 3 6-7'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.on-dark .ic-check::after, .bg-purple .ic-check::after { background: var(--yellow); }
.icon-list b { font-weight: 600; color: var(--ink); }
.dot-list { margin: 0; padding-left: 22px; }
.dot-list li { margin: 0; }
.dot-list li::marker { font-size: .8em; }

/* ---------- Cards ---------- */
.colorful-card {
  background:
    linear-gradient(var(--white), var(--white)) padding-box,
    conic-gradient(from 210deg at 50% 50%, #7b2ff7 0deg, #ff4d6d 70deg, #ff8a3d 120deg, #ffd44f 180deg, #ffd44f 230deg, #7b2ff7 300deg, #7b2ff7 360deg) border-box;
  border: 4px solid transparent;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(17, 0, 52, 0.06);
  padding: 28px;
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tag { background: #eeebf3; border-radius: 6px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; line-height: 20px; color: var(--ink-soft); }

.result-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--white); border-radius: var(--radius-card);
  padding: 18px 20px; box-shadow: 0 2px 12px rgba(17, 0, 52, 0.05);
  font-size: 14px; line-height: 22px; color: var(--ink-soft);
}
.result-card img { width: 24px; height: 24px; flex: none; margin-top: 1px; }
.result-card b { display: block; font-weight: 600; color: var(--ink); margin-bottom: 2px; }

.label-pill {
  display: inline-block; background: var(--yellow); color: var(--ink);
  font-weight: 700; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
}
.btn-outline {
  display: inline-flex; align-items: center; gap: 10px;
  border: 2px solid #8a8799; color: #6f6c80; background: transparent;
  border-radius: 10px; padding: 8px 14px;
  font: 700 13px/22px var(--font); letter-spacing: 1px; text-transform: uppercase; text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
}
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn-outline[aria-disabled="true"] { cursor: default; }

/* Next case study card: closes every case study, stacked under the closing summary.
   Pages can set --next-accent to their brand colour. */
.next-card {
  display: grid; grid-template-columns: 96px 1fr 24px; align-items: center; column-gap: 20px;
  max-width: 480px; margin-top: 40px; padding: 20px 28px 20px 16px;
  border-radius: 24px; background: #fff; box-shadow: 0 6px 24px rgba(17, 0, 52, .06); color: var(--ink); text-decoration: none;
  transition: transform .3s cubic-bezier(.22, 1, .36, 1), box-shadow .3s ease;
}
.next-card img { width: 96px; height: 96px; object-fit: contain; }
.next-card__text { display: grid; gap: 2px; }
.next-card__kicker { font-size: 12px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--next-accent, var(--violet)); }
.next-card b { font-size: 22px; font-weight: 600; line-height: 30px; }
.next-card__text > span:last-child { font-size: 14px; line-height: 22px; color: var(--ink-soft); }
.next-card__arrow { width: 24px; height: 24px; color: var(--next-accent, var(--violet)); transition: transform .3s cubic-bezier(.22, 1, .36, 1); }
.next-card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(17, 0, 52, .1); }
.next-card:hover .next-card__arrow { transform: translateX(4px); }
.next-card:focus-visible { outline: 3px solid var(--next-accent, var(--violet)); outline-offset: 3px; }
@media (max-width: 599.98px) {
  .next-card { grid-template-columns: 72px 1fr 24px; column-gap: 16px; padding: 16px 20px 16px 12px; }
  .next-card img { width: 72px; height: 72px; }
  .next-card b { font-size: 19px; line-height: 26px; }
}

/* ---------- Media: video slots, gif overlays, interactive mocks ---------- */
.screen { position: absolute; overflow: hidden; background: #000; }
.screen video, .screen > img.poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.screen--under { z-index: 0; }
.mock-layer { position: relative; z-index: 1; width: 100%; }
.overlay { position: absolute; z-index: 2; }
.sound-toggle {
  position: absolute; z-index: 4; right: 6%; bottom: 8%;
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(17, 0, 52, 0.75); color: #fff; cursor: pointer;
  display: none; place-items: center;
}
.has-video .sound-toggle { display: grid; }
.sound-toggle svg { width: 18px; height: 18px; }

.gif-box { position: absolute; overflow: hidden; z-index: 2; }
.gif-box img { position: absolute; max-width: none; }

[data-states] { cursor: pointer; }
[data-states] .state { position: absolute; inset: 0; opacity: 0; transition: opacity .3s cubic-bezier(.33, 1, .68, 1); }
[data-states] .state:first-child { position: relative; }
[data-states] .state.is-active { opacity: 1; }
.tap-hint {
  position: absolute; z-index: 4; left: 50%; top: -14px; transform: translateX(-50%);
  background: var(--ink); color: var(--cream); font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; pointer-events: none;
}

/* Flat device frames (same style as the Simply Guitar phone).
   <figure class="dev dev--tablet|dev--phone"><div class="dev__screen">screen image / layers</div></figure>
   The frame is pure CSS, so any screen sits exactly inside it. */
.dev {
  position: relative; container-type: inline-size; margin: 0;
  background: linear-gradient(145deg, #3a3150, #120d22 55%, #2a2340);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset, 0 30px 60px -20px rgba(17, 0, 52, .45), 0 12px 24px -12px rgba(17, 0, 52, .35);
}
.dev--phone { padding: 2.1% 3.6%; border-radius: 6.4% / 11.6%; }
.dev--tablet { padding: 3.2%; border-radius: 4.4% / 6.6%; }
.dev::before {
  content: ""; position: absolute; left: 1.35%; top: 50%; width: .9%; aspect-ratio: 1; transform: translateY(-50%);
  border-radius: 50%; background: #05030a; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1);
}
.dev--tablet::before { left: 1.3%; width: .7%; }
.dev__screen { position: relative; overflow: hidden; background: #000; isolation: isolate; }
.dev--phone .dev__screen { border-radius: 2.6cqw; }
.dev--tablet .dev__screen { border-radius: 1.6cqw; }
.dev__screen > img { display: block; width: 100%; height: auto; }
.on-dark .dev, .bg-purple .dev { box-shadow: 0 0 0 1px rgba(255, 255, 255, .12) inset, 0 30px 70px -20px rgba(0, 0, 0, .6); }

/* Live iPad: a real screen (HTML layers) inside a flat frame */
.device { position: relative; width: 100%; }
.device__screen { position: relative; overflow: hidden; background: #000; aspect-ratio: 1171 / 744; border-radius: 1.6cqw; isolation: isolate; }
.device > .tap-hint { z-index: 6; }

[data-cycle] { position: relative; }
[data-cycle] > img { width: 100%; }
[data-cycle] > img + img { position: absolute; inset: 0; opacity: 0; transition: opacity .2s cubic-bezier(.33, 1, .68, 1); }
[data-cycle] > img.is-active { opacity: 1; }

/* ---------- Horizontal map scroller ---------- */
.map-viewport { position: relative; width: 100%; aspect-ratio: 1440 / 744; overflow: hidden; background: #1a0547; }
.map-scroll {
  position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; cursor: grab; touch-action: pan-x pan-y;
}
.map-scroll::-webkit-scrollbar { display: none; }
.map-scroll.is-dragging { cursor: grabbing; }
.map-track { position: relative; height: 100%; aspect-ratio: 7566 / 744; }
.map-track > img { height: 100%; width: 100%; max-width: none; user-select: none; -webkit-user-drag: none; }
/* Parallax background: layers sit behind the cards and are clipped to the track, so their offset never adds scroll length */
.map-track:has(> .map-layers) { isolation: isolate; }
.map-layers { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.map-layers > img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; max-width: none; will-change: transform; }
.map-fixed { position: absolute; z-index: 3; pointer-events: none; height: var(--fh); width: auto; max-width: none; }
@media (max-width: 1099.98px) {
  .map-band { width: calc(100% + 2 * var(--gutter)); margin-inline: calc(var(--gutter) * -1); }
}
@media (max-width: 720px) {
  .map-viewport { aspect-ratio: 4 / 3; }
}
.map-hotspot { position: absolute; background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: 6%; }
.map-hotspot:focus-visible { outline: 3px solid var(--yellow); }
.map-tip {
  position: absolute; z-index: 4; transform: translate(-50%, -100%) scale(.9); opacity: 0;
  background: var(--cream); color: var(--ink); border-radius: 12px; padding: 8px 14px;
  font-size: clamp(9px, 1vw, 14px); line-height: 1.4; text-align: center; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); pointer-events: none;
  transition: opacity .3s cubic-bezier(.33, 1, .68, 1), transform .3s cubic-bezier(.33, 1, .68, 1);
}
.map-tip::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: inherit; transform: translateX(-50%) rotate(45deg); }
.map-tip.is-visible { opacity: 1; transform: translate(-50%, -100%) scale(1); }
/* Scroll cues: a fade and arrows at the edges, a progress bar and a hint until the first scroll */
.map-viewport::after {
  content: ""; position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: 12%; pointer-events: none;
  background: linear-gradient(to right, rgba(26, 5, 71, 0), rgba(26, 5, 71, .85)); transition: opacity .3s;
}
.map-viewport.at-end::after { opacity: 0; }
.map-arrow {
  position: absolute; z-index: 4; top: 50%; width: clamp(36px, 3.9vw, 56px); aspect-ratio: 1; transform: translateY(-50%);
  display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--cream); color: var(--ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  transition: opacity .3s, transform .2s cubic-bezier(.33, 1, .68, 1);
}
.map-arrow svg { width: 42%; height: 42%; }
.map-arrow--next { right: 2%; }
.map-arrow--prev { left: calc(9.44% + 2%); }               /* clear of the fixed side menu (136 of 1440) */
.map-arrow:hover { transform: translateY(-50%) scale(1.08); }
.map-arrow:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.map-arrow[disabled] { opacity: 0; pointer-events: none; }
.map-viewport:not(.is-used) .map-arrow--next { animation: map-nudge 1.4s ease-in-out infinite; }
@keyframes map-nudge { 0%, 100% { transform: translate(0, -50%); } 50% { transform: translate(8px, -50%); } }
.map-progress {
  position: absolute; z-index: 4; left: 50%; bottom: 4%; width: 18%; height: 6px; transform: translateX(-50%);
  border-radius: 3px; background: rgba(243, 240, 223, .25); overflow: hidden; pointer-events: none;
}
.map-progress i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; background: var(--cream); }
.map-hint {
  position: absolute; z-index: 4; left: 50%; bottom: calc(4% + 16px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: rgba(243, 240, 223, .95); color: var(--ink); font-size: 14px; font-weight: 600;
  border-radius: 999px; padding: 8px 16px; pointer-events: none; transition: opacity .4s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.map-hint::after { content: "→"; display: inline-block; animation: map-hint-arrow 1.2s ease-in-out infinite; }
@keyframes map-hint-arrow { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }
.map-hint.is-hidden { opacity: 0; }
@media (max-width: 720px) {
  .map-hint { font-size: 12px; padding: 6px 12px; }
  .map-progress { width: 30%; height: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .map-viewport:not(.is-used) .map-arrow--next, .map-hint::after { animation: none; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: var(--cream); }
.site-footer__inner {
  position: relative; max-width: 1440px; margin: 0 auto; height: 84px;
  display: flex; align-items: center; justify-content: center; padding: 0 64px;
}
.site-footer .thanks { font-size: 20px; font-weight: 600; letter-spacing: .2px; }
.site-footer .contact-icons { position: absolute; right: 64px; }
@media (max-width: 720px) {
  .site-footer__inner { justify-content: space-between; padding: 0 var(--gutter); }
  .site-footer .contact-icons { position: static; }
}

/* ---------- Scroll reveal ---------- */
/* Elements are fully visible at rest; they fade up once when scrolled into view. */
@keyframes fade-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.reveal.is-visible { animation: fade-up .7s cubic-bezier(.22, 1, .36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal.is-visible { animation: none; }
  .map-tip, .site-header { transition: none; } /* sequences ([data-cycle], [data-states]) keep their cross-fades: they are content */
}
