/* Shared interactive prototype player (stories/proto/player.js). Theme tokens are set by mountPrototype({ theme });
   the defaults below are Gilu's (ink ground, ivory chrome, russet accent). */
:root {
  --ink: #14213D;
  --ink-2: #0C152A;
  --glow: #1B2B4E;
  --ivory: #FBF7F1;
  --quiet: color-mix(in srgb, var(--ivory) 72%, transparent);
  --faint: color-mix(in srgb, var(--ivory) 46%, transparent);
  --line: color-mix(in srgb, var(--ivory) 14%, transparent);
  --btn: color-mix(in srgb, var(--ivory) 8%, transparent);
  --btn-hover: color-mix(in srgb, var(--ivory) 14%, transparent);
  --kbd: color-mix(in srgb, var(--ivory) 12%, transparent);
  --flow-hover: color-mix(in srgb, var(--ivory) 7%, transparent);
  --flow-on: color-mix(in srgb, var(--russet) 16%, transparent);
  --russet: #E8692E;
  --accent-ink: #14213D;
  --sheet: #1A2A4C;
  --frame: #070C18;
  --frame-line: color-mix(in srgb, var(--ivory) 12%, transparent);
  --screen-bg: #FBF7F1;
  --ff: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --ff-mono: 'Martian Mono', ui-monospace, monospace;
  --title-w: 760;
  /* state flips (toggle / chip / tile ring) */
  --fx-accent: var(--russet);
  --fx-accent-tint: #FFF4EC;
  --fx-accent-ink: #A9441A;
  --fx-off: #DCE0E9;
  --fx-toggle-on: #2DBE8C;
  --fx-text: #14213D;
  --fx-font: 600 15px/22px Inter, var(--ff);
  --s: 1;           /* screen scale, set by JS */
  --w: 390px; --h: 844px; /* viewport of the current device, set by JS */
  color-scheme: dark;
}
:root.proto-light { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 70% 20%, var(--glow) 0%, var(--ink) 55%, var(--ink-2) 100%) fixed, var(--ink);
  color: var(--ivory); font-family: var(--ff); -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--russet); outline-offset: 3px; }

/* back to the case study: the site's light round arrow button (as on the UI/UX explainers) */
.pback {
  position: fixed; z-index: 50; top: max(18px, calc(env(safe-area-inset-top) + 10px)); right: max(18px, calc(env(safe-area-inset-right) + 14px));
  width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: #F4F1EC; color: #15130F; box-shadow: 0 8px 28px -10px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .08); transition: background-color .25s;
}
.pback svg { fill: none; stroke: currentColor; stroke-width: 1.6; }
.pback:hover, .pback:focus-visible { background: #fff; }
.pback:focus-visible { outline-color: #F4F1EC; }
.proto-light .pback { background: #fff; box-shadow: 0 8px 24px -12px rgba(20, 27, 45, .35), 0 0 0 1px rgba(20, 27, 45, .1); }
.proto-light .pback:focus-visible { outline-color: var(--russet); }

.proto { height: 100dvh; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: clamp(16px, 3vw, 56px); padding: 24px clamp(20px, 4vw, 64px); }
[data-device='desktop'] .proto, [data-device='tablet'] .proto { grid-template-columns: minmax(280px, 340px) 1fr; gap: clamp(16px, 2.4vw, 40px); padding: 24px clamp(16px, 2.5vw, 40px) 24px clamp(20px, 3vw, 48px); }

/* side panel */
.panel { align-self: center; max-height: calc(100dvh - 48px); overflow: auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent); padding-bottom: 20px; }
.panel__grab { display: none; }
.panel__kicker { margin: 0 0 10px; font: 400 11px/1.4 var(--ff-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.panel__title { margin: 0; font-weight: var(--title-w); font-stretch: 92%; font-size: clamp(24px, 2vw, 30px); line-height: 1.05; letter-spacing: -.01em; }
.panel__title span { color: var(--russet); }
.panel__how { margin: 10px 0 14px; color: var(--quiet); font-size: 15px; line-height: 1.45; }
.panel__now { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.panel__label { font: 400 10px/1 var(--ff-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); flex: none; }
#now { font-weight: 640; font-size: 15px; }
.panel__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 16px; }
.pbtn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--btn); border: 1px solid var(--line); font-size: 14px; font-weight: 600; transition: background-color .2s, border-color .2s;
}
.pbtn:hover { background: var(--btn-hover); border-color: var(--faint); }
.pbtn kbd { font: 400 10px/1 var(--ff-mono); padding: 3px 5px; border-radius: 4px; background: var(--kbd); color: var(--quiet); }
.pswitch { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--quiet); cursor: pointer; margin-left: 4px; }
.pswitch input { accent-color: var(--russet); width: 16px; height: 16px; margin: 0; }
.panel__h { margin: 0 0 8px; font: 400 11px/1 var(--ff-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.flows { list-style: none; margin: 0; padding: 0; counter-reset: f; }
.flows li { counter-increment: f; }
.flow {
  width: 100%; text-align: left; display: grid; grid-template-columns: 28px 1fr; gap: 2px 8px; padding: 7px 10px 7px 8px; margin: 0 -10px 0 -8px;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer; transition: background-color .2s;
}
.flow::before { content: counter(f, decimal-leading-zero); grid-row: span 2; font: 400 11px/20px var(--ff-mono); color: var(--faint); }
.flow b { font-weight: 640; font-size: 15px; line-height: 20px; }
.flow span { font-size: 13px; line-height: 1.4; color: var(--quiet); }
.flow:hover { background: var(--flow-hover); }
.flow[aria-current='true'] { background: var(--flow-on); }
.flow[aria-current='true']::before { color: var(--russet); }
.panel__foot { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: var(--faint); }

/* stage + device */
.stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.device { position: relative; flex: none; }
.device__bar { display: none; }
.device__view { position: relative; width: calc(var(--w) * var(--s)); height: calc(var(--h) * var(--s)); overflow: hidden; }
.screen {
  position: absolute; left: 0; top: 0; width: var(--w); height: var(--h);
  /* zoom (not transform: scale) so the browser rasterises the screen at its final size: scaled compositor layers blur text */
  zoom: var(--s);
  overflow: hidden; background: var(--screen-bg); isolation: isolate; contain: layout paint; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}

/* phone */
.device[data-device='phone'] {
  --bez: 12px;
  padding: var(--bez); border-radius: calc(55px * var(--s) + var(--bez)); background: var(--frame);
  box-shadow: 0 0 0 1px var(--frame-line), inset 0 0 0 1px rgba(255, 255, 255, .06), 0 40px 90px -30px rgba(0, 0, 0, .7), 0 12px 30px -12px rgba(0, 0, 0, .5);
}
.device[data-device='phone'] .device__view { border-radius: calc(55px * var(--s)); }
.device[data-device='phone'] .screen { border-radius: 55px; }

/* tablet (a shop till in landscape, Ponte): the phone's frame with an iPad's slimmer corners */
.device[data-device='tablet'] {
  --bez: 12px;
  padding: var(--bez); border-radius: calc(18px * var(--s) + var(--bez)); background: var(--frame);
  box-shadow: 0 0 0 1px var(--frame-line), inset 0 0 0 1px rgba(255, 255, 255, .06), 0 40px 90px -30px rgba(0, 0, 0, .7), 0 12px 30px -12px rgba(0, 0, 0, .5);
}
.device[data-device='tablet'] .device__view { border-radius: calc(18px * var(--s)); }
.device[data-device='tablet'] .screen { border-radius: 18px; }

/* desktop: a browser window */
.device[data-device='desktop'] {
  border-radius: 12px; overflow: hidden; background: #fff;
  box-shadow: 0 0 0 1px var(--frame-line), 0 40px 90px -36px rgba(0, 0, 0, .55), 0 12px 30px -14px rgba(0, 0, 0, .35);
}
.device[data-device='desktop'] .device__bar {
  display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; background: #EEF1F5; border-bottom: 1px solid #DDE2EA;
}
.device__bar i { width: 11px; height: 11px; border-radius: 50%; background: #D3D9E3; flex: none; }
.device__url {
  flex: 0 1 420px; margin: 0 auto; transform: translateX(-24px); height: 24px; padding: 0 12px; border-radius: 7px; background: #fff;
  font: 400 12px/24px var(--ff); color: #5D667A; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 0 0 1px #E4E8EF;
}
.device__url:empty { visibility: hidden; }

.layer { position: absolute; inset: 0; overflow: hidden; } /* no permanent will-change: a promoted layer keeps a stale (blurry) raster scale; the Web Animations promote it only while moving */
.layer.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.page { position: relative; }
.page > img.shot { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.layer[inert] .hs { visibility: hidden; }
/* live HTML screens (data "html"): an iframe at the screen's own CSS size. Its zoom undoes the screen's (--si = 1 / --s,
   so the page inside lays out at exactly w x h whether or not a browser carries zoom into frames) and a transform
   scales it back to the screen's size. Taps go to the hotspots over it, never to the page. A layer built ahead
   waits hidden (.pre) inside the screen until its transition reveals it. */
.page > iframe.shot { position: absolute; left: 0; top: 0; display: block; border: 0; margin: 0; padding: 0; pointer-events: none; background: var(--screen-bg);
  zoom: var(--si, 1); transform: scale(var(--s)); transform-origin: 0 0; }
.layer.pre { visibility: hidden; }

/* hotspots */
.hs {
  position: absolute; padding: 0; margin: 0; border: 0; background: transparent; cursor: pointer; border-radius: var(--r, 16px);
  transition: background-color .12s, box-shadow .12s;
}
.hs:focus-visible { outline: 3px solid var(--russet); outline-offset: 2px; }
.hs:active { background: rgba(20, 33, 61, .08); }
.hs.press:active { background: rgba(20, 20, 40, .2); }
.flash .hs, .showhs .hs { background: color-mix(in srgb, var(--russet) 28%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--russet) 90%, transparent); }
.flash .hs { animation: hsflash .6s ease-out; }
/* start hint (opts.hint): a softer double glow on the first screen of a flow */
.hint .hs { animation: hshint 1.3s ease-in-out 2; }
@keyframes hshint { 0%, 100% { background: transparent; box-shadow: none; } 45% { background: color-mix(in srgb, var(--russet) 16%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--russet) 75%, transparent); } }
@keyframes hsflash { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

/* state flips (CHANGE_TO micro-interactions) */
.fx { position: absolute; pointer-events: none; }
.fx-toggle { border-radius: 999px; background: var(--fx-off); transition: background-color var(--d, 200ms) ease-out; }
.fx-toggle i { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .15); transition: transform var(--d, 200ms) ease-out; }
.fx-toggle.on { background: var(--fx-toggle-on); }
.fx-toggle.on i { transform: translateX(20px); }
.fx-chip {
  display: flex; align-items: center; justify-content: center; border-radius: 16px; border: 2px solid var(--fx-off); background: #fff; box-shadow: 0 3px 0 var(--fx-off);
  font: var(--fx-font); color: var(--fx-text); white-space: nowrap; transition: background-color var(--d) ease-out, border-color var(--d) ease-out, box-shadow var(--d) ease-out, color var(--d) ease-out;
}
.fx-chip.on { border-color: var(--fx-accent); background: var(--fx-accent-tint); box-shadow: 0 3px 0 var(--fx-accent); color: var(--fx-accent-ink); font-weight: 700; }
.fx-ring { border-radius: var(--rr, 16px); transition: box-shadow var(--d) ease-out, background-color var(--d) ease-out; }
.fx-ring.on { box-shadow: inset 0 0 0 2px var(--fx-accent), 0 var(--dep, 3px) 0 var(--fx-accent); background: color-mix(in srgb, var(--fx-accent-tint) 55%, transparent); mix-blend-mode: multiply; }
.fx-ring.off { box-shadow: inset 0 0 0 2px var(--fx-off), 0 var(--dep, 3px) 0 var(--fx-off); }
.fx-baked { display: block; -webkit-user-drag: none; user-select: none; } /* a chip or switch state cut from the real screen */
.fx-badge { position: absolute; width: 28px; height: 28px; border-radius: 50%; background: var(--fx-accent); box-shadow: 0 0 0 2.5px #fff; transition: opacity var(--d) ease-out, transform var(--d) ease-out; }
.fx-badge::after { content: ''; position: absolute; left: 9px; top: 7px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.fx-badge.cover { background: var(--fx-accent-tint); box-shadow: none; }
.fx-badge.cover::after { display: none; }

/* bottom sheets */
.ov { position: absolute; inset: 0; z-index: 5; }
.ov__scrim { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; margin: 0; background: rgba(20, 33, 61, .4); cursor: pointer; border-radius: 0; }
.ov__sheet { position: absolute; left: 0; overflow: visible; box-shadow: 0 -8px 40px rgba(20, 33, 61, .18); border-radius: 30px 30px 0 0; }
.ov__sheet > img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.flash .ov__scrim, .showhs .ov__scrim { background: rgba(20, 33, 61, .4); box-shadow: none; animation: none; }

/* sibling prototypes (opts.switcher): a segmented switch above the title */
.pswitcher { display: flex; gap: 4px; padding: 4px; margin: 0 0 18px; border-radius: 999px; background: var(--btn); box-shadow: inset 0 0 0 1px var(--line); }
.pswitcher a { flex: 1 1 0; min-width: 0; text-align: center; padding: 9px 12px; border-radius: 999px; color: var(--quiet); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background-color .2s, color .2s; }
.pswitcher a:hover { color: var(--ivory); background: var(--flow-hover); }
.pswitcher a[aria-current='page'] { background: var(--russet); color: var(--accent-ink); }
.pnote { display: none; }

.nojs { padding: 5vw; }
.drawer-btn, .scrim-page { display: none; }

/* phones and narrow windows: the phone is the page; the flows live in a bottom drawer */
@media (max-width: 759px), (max-height: 500px) and (orientation: landscape) {
  body { background: var(--ink); }
  .proto, [data-device='desktop'] .proto, [data-device='tablet'] .proto { display: block; padding: 0; height: 100dvh; }
  .stage { position: fixed; inset: 0; }
  .device[data-device='phone'] { --bez: 0px; border-radius: 0; background: transparent; box-shadow: none; padding: 0; }
  .device[data-device='phone'] .device__view, .device[data-device='phone'] .screen { border-radius: 0; }
  .device[data-device='tablet'] { --bez: 0px; padding: 0; border-radius: 8px; overflow: hidden; }
  .device[data-device='tablet'] .device__view, .device[data-device='tablet'] .screen { border-radius: 0; }
  .device[data-device='desktop'] { border-radius: 8px; }
  .device[data-device='desktop'] .device__bar { height: 40px; padding: 0 10px; gap: 5px; }
  .device__bar i { width: 8px; height: 8px; }
  .device__url { transform: none; font-size: 11px; }
  .drawer-btn {
    display: inline-flex; align-items: center; position: fixed; z-index: 40; left: max(12px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top));
    height: 34px; padding: 0 14px; border-radius: 999px; border: 0; background: #F4F1EC; color: #15130F; font-weight: 680; font-size: 14px;
    box-shadow: 0 8px 28px -10px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .08); cursor: pointer;
  }
  .proto-light .drawer-btn { background: #fff; color: var(--ivory); box-shadow: 0 8px 24px -12px rgba(20, 27, 45, .35), 0 0 0 1px rgba(20, 27, 45, .1); }
  .scrim-page { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(5, 9, 18, .55); }
  .scrim-page[hidden] { display: none; }
  .panel {
    -webkit-mask-image: none; mask-image: none;
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; max-height: 82dvh; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
    background: var(--sheet); border-radius: 22px 22px 0 0; box-shadow: 0 -20px 60px rgba(0, 0, 0, .45);
    transform: translateY(105%); transition: transform .38s cubic-bezier(.32, .72, 0, 1); visibility: hidden;
  }
  .panel.open { transform: none; visibility: visible; }
  .panel__grab { display: block; width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--faint); }
  .panel__title { font-size: 24px; }
  .pback { top: max(8px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 34px; height: 34px; }
  .pback svg { width: 15px; height: 10px; }
}
/* a desktop screen on a phone held upright: suggest turning it */
@media (max-width: 759px) and (orientation: portrait) {
  :is([data-device='desktop'], [data-device='tablet']) .pnote { display: block; position: fixed; z-index: 30; left: 0; right: 0; bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px)); margin: 0; padding: 0 24px; text-align: center; font-size: 13px; line-height: 1.4; color: var(--quiet); pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .hs, .fx-toggle, .fx-toggle i, .fx-chip, .fx-ring, .fx-badge { transition: none !important; }
}
