/* The hero demo: an iPhone running "your app" on the left, the InsightsKit
   dashboard on the right, and the API between them. demo.js plays the story
   on it.

   The stage is drawn at a fixed 720×520 and scaled to fit (demo.js, fit()),
   so every size below is in stage pixels.

   The phone screen copies the web version's look (internal/hosted/static/
   web.css): system font, grouped rows, the iOS system colours. It is the one
   place on the page with iOS blue, because it shows somebody else's app. The
   dashboard side uses Graphite like the rest of the page. */

:root, [data-theme="light"] {
  --ios-bg: #f2f2f7; --ios-card: #ffffff; --ios-fg: #000000; --ios-dim: #6c6c70;
  --ios-line: #d8d8dc; --ios-tint: #007aff; --ios-tag: #e9e9ee; --ios-green: #248a3d;
  --ios-segment: #ffffff;
}
[data-theme="dark"] {
  --ios-bg: #000000; --ios-card: #1c1c1e; --ios-fg: #ffffff; --ios-dim: #98989f;
  --ios-line: #38383a; --ios-tint: #0a84ff; --ios-tag: #2c2c2e; --ios-green: #30d158;
  --ios-segment: #636366;
}

.demo { position: relative; width: 100%; height: 520px; flex: none; }
.demo-fit { position: absolute; top: 0; left: 0; width: 720px; height: 520px; transform-origin: 0 0; }
.stage { --ease: cubic-bezier(.65, 0, .35, 1);
  position: relative; width: 720px; height: 520px;
  display: grid; grid-template-columns: 232px 1fr 404px; align-items: center; }

.dev { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dev-label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--muted-foreground);
  padding: 5px 12px; border-radius: var(--radius-full); background: var(--surface); }

/* ---- the phone ----------------------------------------------------------- */
.phone { width: 232px; height: 470px; border-radius: 44px; background: #1b1b1b; padding: 8px; }
[data-theme="dark"] .phone { background: #3a3a3a; }
.screen { position: relative; width: 100%; height: 100%; border-radius: 36px; overflow: hidden;
  background: var(--ios-bg); color: var(--ios-fg);
  font-family: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; font-size: 12px; line-height: 1.3; }
.sb { position: relative; height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 4px 20px 0 24px; font-size: 11.5px; }
.island { position: absolute; left: 50%; top: 9px; width: 66px; height: 19px; margin-left: -33px; border-radius: 12px; background: #000; }
.sbi { display: flex; gap: 2px; align-items: flex-end; }
.sbi i { display: block; width: 3px; border-radius: 1px; background: var(--ios-fg); }
.sbi i:nth-child(1) { height: 5px; } .sbi i:nth-child(2) { height: 7px; } .sbi i:nth-child(3) { height: 9px; }
.ph-app { margin: 2px 0 6px; text-align: center; font-size: 10px; color: var(--ios-dim); }
.ph-tabs { display: flex; margin: 0 12px; padding: 2px; border-radius: 8px; background: var(--ios-tag); }
.ph-tabs span { flex: 1; text-align: center; padding: 4px 0; border-radius: 6px; font-size: 10.5px; font-weight: 500; transition: background-color .25s; }
.ph-tabs span.on { background: var(--ios-segment); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.ph-view { position: absolute; left: 0; right: 0; top: 94px; bottom: 0; padding: 0 12px; opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
.ph-view.on { opacity: 1; visibility: visible; }
.ph-view h4 { margin: 8px 2px 8px; font-size: 19px; line-height: 1.2; font-weight: 700; }
.ph-list { list-style: none; margin: 0; padding: 0; border-radius: 11px; background: var(--ios-card); overflow: hidden; }
.ph-list li { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 11px; background: var(--ios-card); }
.ph-list li + li::before { content: ""; position: absolute; top: 0; left: 11px; right: 0; border-top: 1px solid var(--ios-line); }
.ph-list .t { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: 11.5px; font-weight: 600; }
.ph-list em { font-style: normal; font-size: 9px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--ios-tag); color: var(--ios-dim); }
.ph-list em[data-s="Shipped"] { color: var(--ios-green); }
.vote { flex: none; width: 34px; height: 36px; border-radius: 8px; background: var(--ios-tag); color: var(--ios-fg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; line-height: 1.1; font-weight: 600;
  transition: background-color .25s, color .25s; }
.vote i { font-style: normal; font-size: 8px; }
.vote.on { background: var(--ios-tint); color: #fff; }

.ph-btn { position: absolute; left: 12px; right: 12px; bottom: 16px; height: 36px; border-radius: 11px; background: var(--ios-tint); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.ph-empty { margin: 0 2px; font-size: 11px; color: var(--ios-dim); }
.ph-thread { display: flex; flex-direction: column; gap: 6px; }
.bub { max-width: 82%; padding: 7px 10px; border-radius: 14px; font-size: 11px; line-height: 1.35; }
.bub.me { align-self: flex-end; background: var(--ios-tint); color: #fff; border-bottom-right-radius: 5px; }
.bub.them { align-self: flex-start; background: var(--ios-card); border-bottom-left-radius: 5px; }
.bub small { display: block; font-size: 9px; opacity: .75; margin-bottom: 2px; }
.bubmeta { align-self: flex-end; font-size: 9px; color: var(--ios-dim); margin-top: -2px; }

.ph-dim { position: absolute; inset: 0; background: rgba(0,0,0,.28); opacity: 0; transition: opacity .35s; pointer-events: none; }
.ph-sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 232px; padding: 8px 14px 0; border-radius: 16px 16px 0 0;
  background: var(--ios-card); transform: translateY(100%); transition: transform .42s var(--ease); }
.screen.sheet-open .ph-dim { opacity: 1; }
.screen.sheet-open .ph-sheet { transform: translateY(0); }
.grab { display: block; width: 34px; height: 4px; margin: 0 auto 10px; border-radius: 2px; background: var(--ios-line); }
.sheet-title { display: block; font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.ph-field { min-height: 64px; padding: 8px 10px; border-radius: 10px; background: var(--ios-bg); font-size: 12px; }
.ph-sheet .ph-btn { bottom: 26px; }

/* A blinking text caret, shared by the phone and the dashboard. */
.caret { display: inline-block; width: 1.5px; height: 1.1em; margin-left: 1px; vertical-align: -2px; background: currentColor; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- the wire between them ------------------------------------------------ */
.wire { position: relative; height: 100%; }
.wire-line { position: absolute; top: 50%; left: 6px; right: 6px; border-top: 1.5px dashed var(--ring); }
.packet { position: absolute; top: 50%; left: 6px; width: 11px; height: 11px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--logo-accent); opacity: 0; }
.wire-label { position: absolute; left: -10px; right: -10px; top: calc(50% - 34px); text-align: center;
  font-size: 10px; line-height: 13px; font-weight: 600; color: var(--muted-foreground); opacity: 0; transition: opacity .25s; }
.wire-label.on { opacity: 1; }

/* ---- the dashboard ---------------------------------------------------------- */
.win { position: relative; width: 404px; height: 410px; padding: 12px; border-radius: 24px; background: var(--surface); overflow: hidden; }
.win-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.wm { font-size: 13px; font-weight: 700; letter-spacing: -.4px; color: var(--foreground); }
.wm span { color: var(--logo-accent); }
.win-tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-full); background: var(--background); }
.win-tabs span { padding: 3px 10px; border-radius: var(--radius-full); font-size: 10.5px; font-weight: 600; color: var(--muted-foreground); transition: background-color .25s, color .25s; }
.win-tabs span.on { background: var(--surface); color: var(--foreground); }
.win-view { position: absolute; left: 12px; right: 12px; top: 50px; bottom: 12px; opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
.win-view.on { opacity: 1; visibility: visible; }
.win-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 10px; }
.win-head b { font-size: 15px; letter-spacing: -.3px; color: var(--foreground-strong); }
.win-head small { font-size: 10px; color: var(--muted-foreground); }

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; height: calc(100% - 32px); }
.col { padding: 8px 6px; border-radius: 14px; background: var(--background); }
.col > p { display: flex; justify-content: space-between; margin: 0 3px 8px; font-size: 10.5px; font-weight: 700; color: var(--foreground); }
.col > p i { font-style: normal; color: var(--muted-foreground); font-weight: 600; }
.cards { display: flex; flex-direction: column; gap: 6px; }
.card { position: relative; padding: 8px 9px; border-radius: 10px; background: var(--surface); color: var(--foreground);
  font-size: 11px; line-height: 1.3; font-weight: 600; transition: box-shadow .2s, scale .2s; }
.card small { display: block; margin-top: 5px; font-size: 9.5px; color: var(--muted-foreground); font-weight: 600; }
.card.lift { z-index: 3; scale: 1.04; box-shadow: 0 0 0 2px var(--foreground); }

.inbox { display: grid; grid-template-columns: 132px 1fr; gap: 8px; height: calc(100% - 32px); }
.tlist { display: flex; flex-direction: column; gap: 6px; }
.ti { position: relative; padding: 8px 9px 8px 18px; border-radius: 10px; background: var(--background); }
.ti b { display: block; font-size: 10.5px; line-height: 1.3; color: var(--foreground); }
.ti small { display: block; margin-top: 3px; font-size: 9px; color: var(--muted-foreground); }
.ti::before { content: ""; position: absolute; left: 8px; top: 12px; width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.ti.is-new::before { background: var(--logo-accent); }
.ti.sel { box-shadow: inset 0 0 0 1.5px var(--foreground); }
.tpane { position: relative; padding: 10px; border-radius: 14px; background: var(--background); display: flex; flex-direction: column; gap: 8px; }
.tp-empty { margin: auto; font-size: 10.5px; color: var(--muted-foreground); }
.tp-msg { padding: 8px 10px; border-radius: 12px; background: var(--surface); font-size: 11px; line-height: 1.35; color: var(--foreground); }
.tp-msg small, .tp-out small { display: block; font-size: 9px; color: var(--muted-foreground); margin-bottom: 3px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips span { padding: 3px 7px; border-radius: var(--radius-full); background: var(--surface); font-size: 9px; font-weight: 600; color: var(--foreground); }
.tp-out { align-self: flex-end; max-width: 88%; padding: 8px 10px; border-radius: 12px; background: var(--primary); color: var(--primary-foreground); font-size: 11px; line-height: 1.35; }
.tp-out small { color: inherit; opacity: .7; }
.tp-compose { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; align-items: stretch; }
.tp-field { flex: 1; min-height: 46px; padding: 7px 9px; border-radius: 10px; background: var(--surface); font-size: 10.5px; line-height: 1.35; color: var(--foreground); }
.tp-field .ph { color: var(--muted-foreground); }
.tp-send { align-self: flex-end; padding: 6px 11px; border-radius: var(--radius-full); background: var(--primary); color: var(--primary-foreground); font-size: 10.5px; font-weight: 700; }

/* ---- pointer, touch, and the "new" pop ---------------------------------- */
.cursor { position: absolute; left: 600px; top: 470px; z-index: 6; opacity: 0; pointer-events: none;
  transition-property: left, top, opacity, scale; transition-timing-function: var(--ease); transition-duration: .65s, .65s, .25s, .12s; }
.cursor.on { opacity: 1; }
.cursor.down { scale: .85; }
.tap { position: absolute; z-index: 6; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: rgba(120,120,128,.45); opacity: 0; pointer-events: none; }
.tap.on { animation: tap .5s ease-out; }
@keyframes tap { 0% { opacity: .9; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.3); } }
/* "backwards", not "both": a finished animation must not keep its transform,
   or it would block the sliding moves demo.js sets inline. */
.pop { animation: pop .45s var(--ease) backwards; }
@keyframes pop { 0% { opacity: 0; transform: translateY(6px) scale(.96); } 100% { opacity: 1; transform: none; } }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 2px var(--logo-accent); } 100% { box-shadow: 0 0 0 2px transparent; } }

.demo.is-paused *, .demo.is-paused *::before { animation-play-state: paused !important; }

/* ---- the caption under the stage ---------------------------------------- */
.demo-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.demo-bar { flex: 1; min-width: 0; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 8px 8px 8px 8px; border-radius: 20px; background: var(--surface); }
.cap-story { padding: 4px 10px; border-radius: var(--radius-full); background: var(--primary); color: var(--primary-foreground); font-size: 12px; line-height: 16px; font-weight: 700; }
.cap-text { flex: 1; min-width: 180px; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--foreground); }
.cap-dots { display: flex; gap: 4px; padding-right: 6px; }
.cap-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border); transition: background-color .3s; }
.cap-dots i:nth-child(4) { margin-right: 6px; }
.cap-dots i.done { background: var(--ring); }
.cap-dots i.cur { background: var(--foreground); }
.demo-pause { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--surface); color: var(--foreground);
  display: grid; place-items: center; cursor: pointer; }
.demo-pause[hidden] { display: none; }
.demo-pause .i-play { display: none; }
.demo-pause[aria-pressed="true"] .i-play { display: block; }
.demo-pause[aria-pressed="true"] .i-pause { display: none; }

@media (max-width: 560px) {
  .cap-dots { display: none; }
  .cap-text { font-size: 13px; min-width: 0; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .stage *, .stage *::before { transition: none !important; animation: none !important; }
}
