/* ─────────────────────────────────────────────────────────────────────
   Phones on project pages: an app shown at its own shape, upright and
   large, in a phone body drawn here, instead of a wide frame with a
   small phone in the middle. With phones.js:
   .ph          a phone; --w sets its width and the screen fills it
   .ph-live     the app itself in the phone, started by a tap
   .ph-hero     a short text beside two phones, at the top of a page
   .ph-tour     the features as a list beside one phone that plays the
                chosen one; on a phone the recordings swipe sideways
   .ph-strip    more screens in a row that scrolls sideways
   ───────────────────────────────────────────────────────────────────── */
.ph {
  --w: 300px;
  position: relative; flex: none; width: var(--w); margin: 0 auto;
  padding: calc(var(--w) * 0.032); border-radius: calc(var(--w) * 0.165);
  background: #121212;
  box-shadow: 0 0 0 calc(var(--w) * 0.008) #a8a6a1, 0 0 0 calc(var(--w) * 0.013) #75736f, 0 36px 60px -36px rgba(48, 34, 14, 0.6);
}
.ph-screen { position: relative; aspect-ratio: 390 / 844; overflow: hidden; border-radius: calc(var(--w) * 0.135); background: #f4f4f1; isolation: isolate; }
.ph-screen > img, .ph-screen > video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
/* the Dynamic Island */
.ph::after {
  content: ""; position: absolute; z-index: 4; left: 50%; top: calc(var(--w) * 0.058);
  width: calc(var(--w) * 0.298); height: calc(var(--w) * 0.086); transform: translateX(-50%);
  border-radius: 999px; background: #080808; pointer-events: none;
}
.ph-fig { margin: 0; }
.ph-fig figcaption { max-width: 32ch; margin: 18px auto 0; text-align: center; font-size: 13px; line-height: 1.45; color: var(--muted); }
.ph [data-zoom] { cursor: zoom-in; }

/* ── the app itself: a still until the tap, then the app between a status bar and the home indicator ── */
.ph-live .ph-bar, .ph-live .ph-app, .ph-live .ph-home { position: absolute; left: 0; right: 0; visibility: hidden; }
.ph-live .ph-bar { top: 0; height: 5.21%; display: flex; align-items: center; justify-content: space-between; padding: 0 7% 0 10%; color: #1b1a18; font: 600 calc(var(--w) * 0.043)/1 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; letter-spacing: -0.01em; }
.ph-live .ph-bar svg { width: 21%; height: auto; }
.ph-live .ph-app { top: 5.21%; height: 90.76%; overflow: hidden; background: #f4f4f1; }
.ph-live .ph-app iframe { position: absolute; top: 0; left: 0; width: 390px; height: 766px; border: 0; transform-origin: 0 0; background: #f4f4f1; }
.ph-live .ph-home { bottom: 0; height: 4.03%; }
.ph-live .ph-home::after { content: ""; position: absolute; left: 50%; top: 38%; width: 34%; height: 15%; transform: translateX(-50%); border-radius: 9px; background: #1b1a18; }
.ph-live.on .ph-bar, .ph-live.on .ph-app, .ph-live.on .ph-home { visibility: visible; }
.ph-live.on .ph-poster, .ph-live.on .ph-start { visibility: hidden; }
.ph-start {
  position: absolute; z-index: 3; left: 50%; bottom: 17%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 13px 22px 13px 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: #1b1a18; color: #fff; font: 600 15px/1 var(--sans, sans-serif);
  box-shadow: 0 10px 28px -8px rgba(27, 26, 24, 0.55); transition: transform 0.2s, background 0.2s;
}
.ph-start::before { content: ""; width: 11px; height: 11px; border-radius: 50%; background: #f04a3a; box-shadow: 0 0 0 4px rgba(240, 74, 58, 0.25); }
.ph-start:hover { background: #000; transform: translateX(-50%) translateY(-1px); }
.ph-poster { filter: saturate(0.92); }
.ph-live:not(.on) .ph-screen::after { content: ""; position: absolute; inset: 0; z-index: 2; background: linear-gradient(to top, rgba(246, 243, 238, 0.85), rgba(246, 243, 238, 0) 45%); pointer-events: none; }
.ph-restart { margin-left: 6px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ph-live-fig:not(.on) .ph-restart { display: none; }

/* ── a short text beside two phones ── */
.ph-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: clamp(24px, 3.4vw, 56px); align-items: center; margin: 56px 0 0; }
.ph-hero .ph { --w: clamp(250px, 21vw, 318px); }
.ph-hero h2 { font-size: clamp(19px, 1.55vw, 23px); line-height: 1.28; letter-spacing: -0.015em; font-weight: 650; margin: 8px 0 18px; }
.ph-steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 14px; }
.ph-steps li { counter-increment: s; position: relative; padding-left: 34px; color: var(--ink2); font-size: 15px; line-height: 1.5; }
.ph-steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 600 12px/1 var(--sans, sans-serif); }
.ph-steps b { color: var(--ink); font-weight: 600; }
.ph-note { margin: 18px 0 0; font-size: 13px; color: var(--muted); }

/* ── the tour: the list, and one phone that plays the chosen recording ── */
.ph-tour { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(28px, 5vw, 80px); align-items: start; margin-top: 30px; max-width: 1120px; }
.ph-tour-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ph-tour-list > li { border-bottom: 1px solid var(--line); }
.ph-tour-tab {
  position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 2px 10px; width: 100%;
  padding: 16px 0 15px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ph-tour-tab .n { grid-row: span 2; padding-top: 3px; font: 500 12px/1.4 var(--mono, monospace); color: var(--muted); }
.ph-tour-tab .t { font-size: 15.5px; font-weight: 600; letter-spacing: -0.005em; color: var(--ink); transition: color 0.2s; }
.ph-tour-tab .s { font-size: 14.5px; line-height: 1.45; color: var(--ink2); }
.ph-tour-tab:hover .t, .ph-tour-list > li.on .ph-tour-tab .t { color: var(--accent); }
.ph-tour-list > li:not(.on) .ph-tour-tab .s { color: var(--muted); }
/* how far the playing recording has got */
.ph-tour-prog { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
.ph-tour-list > li:not(.on) .ph-tour-prog { display: none; }
.ph-tour-body { display: none; padding: 0 0 18px 40px; }
.ph-tour-list > li.on .ph-tour-body { display: block; }
.ph-tour-body p { margin: 0 0 12px; color: var(--ink2); font-size: 15px; line-height: 1.6; max-width: 60ch; }
.ph-tour-stage { position: sticky; top: 36px; }
.ph-tour-stage .ph { --w: clamp(260px, 22vw, 330px); }
.ph-tour-stage video { opacity: 0; transition: opacity 0.35s; }
.ph-tour-stage video.on { opacity: 1; }
.ph-tour-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; font: 500 12px/1 var(--mono, monospace); color: var(--muted); }
.ph-arrow {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; cursor: pointer; transition: background 0.2s, border-color 0.2s;
}
.ph-arrow:hover { border-color: var(--ink); }
.ph-arrow:disabled { opacity: 0.35; cursor: default; border-color: var(--line); }

/* ── more screens, sideways ── */
.ph-strip { margin-top: 64px; }
.ph-strip-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.ph-strip-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.ph-strip-head p { margin: 4px 0 0; font-size: 14px; color: var(--ink2); }
.ph-strip-head div:last-child { display: flex; gap: 8px; flex: none; }
.ph-strip-track {
  display: flex; gap: clamp(18px, 2.4vw, 34px); overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  padding: 16px 6px 30px; margin: 0 -6px; scrollbar-width: none; cursor: grab;
}
.ph-strip-track::-webkit-scrollbar { display: none; }
.ph-strip-track.drag { cursor: grabbing; scroll-snap-type: none; }
.ph-strip-track > figure { flex: none; margin: 0; width: var(--sw, 220px); scroll-snap-align: start; }
.ph-strip-track .ph { --w: var(--sw, 220px); }
.ph-strip-track figcaption { margin-top: 14px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.ph-strip-track img { -webkit-user-drag: none; user-select: none; }

@media (max-width: 1100px) {
  .ph-hero { grid-template-columns: auto auto; justify-content: center; }
  .ph-hero-text { grid-column: 1 / -1; max-width: 640px; }
}
@media (max-width: 860px) {
  .ph-tour { grid-template-columns: minmax(0, 1fr); }
  .ph-tour-stage { position: static; order: -1; }
  .ph-tour-stage .ph { --w: min(72vw, 300px); touch-action: pan-y; }
  .ph-tour-body { padding-left: 0; }
}
@media (max-width: 640px) {
  .ph-hero { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .ph-hero .ph { --w: min(76vw, 310px); }
  .ph-hero > .ph-fig:last-child { display: none; }
  .ph-strip-track > figure { --sw: 58vw; }
  .ph-strip-head div:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ph-tour-stage video { transition: none; }
}

/* ── a phone picture that already has its own body (cut out of a mockup), at the same sizes as .ph ── */
.ph-img { display: block; width: var(--w, 300px); max-width: none; height: auto; margin: 0 auto; border-radius: 0; filter: drop-shadow(0 30px 34px rgba(30, 40, 60, 0.22)); }
.ph-strip-track .ph-img { --w: var(--sw, 220px); }
/* two phones side by side, large, in place of a wide picture at the top of a page */
.ph-duo { display: flex; justify-content: center; align-items: flex-start; gap: clamp(28px, 6vw, 110px); margin: 48px 0 0; padding: clamp(28px, 4vw, 56px) 0 8px; }
.ph-duo .ph-img, .ph-duo .ph { --w: clamp(220px, 22vw, 320px); }
.ph-duo .ph-fig:nth-child(2) { margin-top: clamp(30px, 5vw, 80px); }
@media (max-width: 640px) {
  .ph-duo { gap: 14px; }
  .ph-duo .ph-img, .ph-duo .ph { --w: 43vw; }
  .ph-duo .ph-fig figcaption { font-size: 12px; }
}

/* ── the app itself, for a prototype that draws its own phone: it fills the screen, with no bar of ours ── */
.ph-live.full .ph-app { top: 0; height: 100%; }

/* ── a tour feature shown as several phones side by side (a recording among them, or stills) ── */
.ph-tour-slide { display: none; gap: clamp(12px, 1.4vw, 20px); align-items: flex-start; }
.ph-tour-slide.on { display: flex; }
.ph-tour-stage .ph-tour-slide video { opacity: 1; }
.ph-tour-stage .ph-tour-slide .ph, .ph-tour-stage .ph-tour-slide .ph-img { --w: clamp(150px, 12.6vw, 205px); margin: 0; }
.ph-tour-slide .ph-fig { flex: none; }
.ph-tour-slide .ph-fig figcaption { max-width: 22ch; margin-top: 12px; font-size: 12.5px; }
@media (max-width: 860px) {
  .ph-tour-slide.on { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 4px 4px 8px; margin: 0 -4px; }
  .ph-tour-slide::-webkit-scrollbar { display: none; }
  .ph-tour-slide > * { scroll-snap-align: center; }
  .ph-tour-stage .ph-tour-slide .ph, .ph-tour-stage .ph-tour-slide .ph-img { --w: 60vw; }
}
/* three phones in a row, for a page with a few phone screens among desktop ones */
.ph-trio { gap: clamp(20px, 4vw, 64px); }
.ph-duo.ph-trio .ph-img { --w: clamp(190px, 17vw, 260px); }
.ph-duo.ph-trio .ph-fig:nth-child(2) { margin-top: clamp(24px, 4vw, 60px); }
@media (max-width: 640px) {
  .ph-duo.ph-trio { justify-content: flex-start; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin-right: calc(-1 * var(--pad)); padding-right: var(--pad); }
  .ph-duo.ph-trio .ph-fig { scroll-snap-align: start; flex: none; }
  .ph-duo.ph-trio .ph-img { --w: 56vw; }
}
.ph-hero .ph-img { --w: clamp(250px, 21vw, 318px); }

/* ── a demo: one recording through the app beside a line for each step; the step playing lights up ── */
.ph-demo { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(28px, 5vw, 80px); align-items: center; max-width: 1120px; margin: 56px 0 0; }
.ph-demo .ph { --w: clamp(260px, 22vw, 330px); }
.ph-demo h2 { margin: 8px 0 18px; font-size: clamp(19px, 1.55vw, 23px); line-height: 1.28; letter-spacing: -0.015em; font-weight: 650; }
.ph-chapters { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); max-width: 560px; }
.ph-chapters > li { border-bottom: 1px solid var(--line); }
.ph-chapters button { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 1px 10px; width: 100%; padding: 11px 0 10px;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ph-chapters .n { grid-row: span 2; padding-top: 2px; font: 500 12px/1.4 var(--mono, monospace); color: var(--muted); }
.ph-chapters .t { font-size: 14.5px; font-weight: 600; color: var(--ink2); transition: color 0.2s; }
.ph-chapters .s { font-size: 14px; line-height: 1.45; color: var(--muted); transition: color 0.2s; }
.ph-chapters > li.on .t, .ph-chapters button:hover .t { color: var(--accent); }
.ph-chapters > li.on .s { color: var(--ink2); }
.ph-chapters i { position: absolute; left: 0; bottom: -1px; width: 100%; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
.ph-chapters > li:not(.on) i { display: none; }

/* ── how each part works: short blocks of text, numbered as the demo's steps ── */
.ph-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px clamp(28px, 4vw, 64px); max-width: 1040px; margin-top: 30px; }
.ph-details article { border-top: 1px solid var(--line); padding-top: 14px; }
.ph-details h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 15.5px; font-weight: 600; letter-spacing: -0.005em; }
.ph-details h3 span { font: 500 12px/1 var(--mono, monospace); color: var(--muted); }
.ph-details p { margin: 0 0 10px; color: var(--ink2); font-size: 15px; line-height: 1.6; max-width: none; }
.ph-details p.lead { color: var(--ink); font-weight: 500; }

@media (max-width: 860px) {
  .ph-demo { grid-template-columns: minmax(0, 1fr); }
  .ph-demo-phone { order: -1; }
  .ph-demo .ph { --w: min(72vw, 300px); }
  .ph-details { grid-template-columns: minmax(0, 1fr); }
}
