/* Handle: the phone layer.
   Everything here applies only on phones: the page under 600px wide (the maths scene under 760px, where its
   desktop orbit doesn't fit), and the demos whose column is phone-sized (container under 520px).
   Desktop and tablet never see any of it. The house rules on a phone:
   - every demo fits on one screen, never changes size while it plays, and has no big empty gaps;
   - text is big enough to read (nothing under about 11px), and anything you can tap is at least 44px;
   - things that pop up arrive as overlays (sheets, notifications) instead of new boxes that push the page about. */

/* =============================== Page =============================== */

@media (max-width: 600px) {
  /* demos use nearly the full width of the screen (8px from its edge), so they can be drawn bigger */
  .feature-demo { margin-inline: calc(8px - var(--gutter)); }

  /* no "Try it" chips on a phone: you tap the demos themselves */
  .try { display: none !important; }

  /* the to-do list at a size you can read */
  .todo { font-size: 15px; }
  .todo-chip { font-size: 0.74em; }

  /* touch targets */
  .nav-burger { width: 44px; height: 44px; }
  .nav-burger span:first-child { top: 18.5px; }
  .nav-burger span:last-child { top: 25.5px; }
  .nav-burger[aria-expanded="true"] span:first-child, .nav-burger[aria-expanded="true"] span:last-child { top: 22px; }

  /* the chapter bar spans the screen, one big tab per chapter */
  .chapters { left: 10px; right: 10px; transform: translateY(160%); }
  .chapters.show { transform: none; }
  .chapters a { flex: 1; padding: 12px 0; font-size: 14px; text-align: center; }

  /* the menu starts clear of the bar above it, with roomy rows */
  .menu { padding: 136px 24px calc(28px + env(safe-area-inset-bottom)); }
  .menu nav a { padding: 5px 0; font-size: 32px; }

  /* 16px in form fields, so iPhones don't zoom in when you tap one; taps show the controls' own pressed states */
  input, textarea, select { font-size: 16px !important; }
  html { -webkit-tap-highlight-color: transparent; }

  /* footer links: comfortable to tap */
  .footer-nav { gap: 0 24px; }
  .footer-nav a { padding: 9px 0; }

  /* ----- Human taste. AI speed.: the sorter never changes size. The pile holds all eight tags (and "Sorted."),
     and both columns are already as tall as the six jobs that land in the violet one. ----- */
  .sorter { gap: 10px; margin-top: 44px; }
  .sorter-pile { min-height: 0; height: 152px; padding: 14px; gap: 8px 6px; }
  .sorter-col { height: 322px; padding: 16px 14px; }
  .sorter-slot { min-height: 0; gap: 6px; margin-top: 12px; }
  .chip-task { height: 34px; padding: 0 11px; font-size: 13.5px; }
  .week { padding: 18px 14px 14px; }
  .week-head { margin-bottom: 34px; }                 /* room for the moving time label */
  .week-axis span:nth-child(5) { display: none; }     /* the closing "12am" crowds "9pm" at this width */

  /* ----- What we do: the build story in one compact panel that never changes size. Your inputs sit under the
     Handle ring and rise into it; the modules it builds drop out into the same place. ----- */
  .assembly {
    grid-template-columns: minmax(0, 1fr); grid-template-areas: "core" "chips" "badge";
    justify-items: center; align-items: start; gap: 18px; min-height: 0; padding: 26px 14px 22px;
  }
  .asm-core { grid-area: core; width: 120px; height: 120px; }
  .asm-in, .asm-out { grid-area: chips; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 8px; width: 100%; }
  .asm-chip, .asm-mod { gap: 8px; padding: 9px 12px; font-size: 13.5px; }
  .asm-chip { justify-self: auto; }
  .assembly.absorb .asm-chip { transform: translateY(-96px) scale(0.4); opacity: 0; }
  .asm-mod { transform: translateY(-84px) scale(0.5); }
  .asm-badge { grid-area: badge; position: relative; left: auto; bottom: auto; transform: translateY(8px); }
  .assembly.live .asm-badge { transform: none; }

  /* ----- Services: one tidy list with a chevron per chapter, like a settings screen ----- */
  .svc-index { gap: 0; margin-top: 36px; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
  .svc-group {
    grid-template-columns: 24px minmax(0, 1fr) 10px; grid-template-areas: "num name go" ". items go";
    align-items: center; gap: 2px 12px; padding: 15px 18px; border-radius: 0; background: transparent; box-shadow: none;
  }
  .svc-group + .svc-group { border-top: 1px solid var(--line); }
  .svc-group:hover { transform: none; box-shadow: none; }
  .svc-group:active { background: var(--panel-3); }
  .svc-num { grid-area: num; }
  .svc-name { grid-area: name; font-size: 26px; }
  .svc-items { grid-area: items; font-size: 13.5px; line-height: 1.4; }
  .svc-group::after { content: ""; grid-area: go; width: 8px; height: 8px; border-top: 1.5px solid var(--quiet); border-right: 1.5px solid var(--quiet); transform: rotate(45deg); }
  .svc-note { margin-top: 36px; }

  /* ----- Warm-up: the comments come up as a sheet over the phone, and slide away once one is posted ----- */
  .meet-stage { position: relative; display: grid; place-items: center; height: 690px; }
  .meet-stage .phone { justify-self: center; font-size: 12.5px; }
  .meet-stage .picker {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
    box-shadow: 0 -18px 50px rgba(12, 12, 16, 0.2), 0 0 0 1px rgba(12, 12, 16, 0.06);
  }
  .meet-stage .picker.away { opacity: 0; transform: translateY(24%); filter: none; }

  /* ----- Why Handle: the same cards, tighter ----- */
  .bento-card { padding: 8px 8px 22px; }
  .vs { gap: 6px; }
  .vs-them, .vs-us { gap: 9px; min-height: 0; padding: 14px; }

  /* ----- The platform: the sticker sits on the panel's corner, the panel takes the width ----- */
  .platform-art { padding: 30px 0 0; }
  .tag-sticker { top: 2px; left: 10px; font-size: 13.5px; }
  .switch-panel { width: 100%; padding: 16px 18px 12px; }
  .sp-row { padding: 12px 0; }

  /* ----- Contact: what eats the hours as a neat two-column grid of chips, and a full-width send button ----- */
  .contact-form { gap: 14px; padding: 20px 16px; }
  .cf-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cf-chips label { display: flex; }
  .cf-chips span { width: 100%; height: auto; min-height: 48px; padding: 8px 12px; font-size: 14.5px; line-height: 1.25; }
  .cf-field textarea { min-height: 96px; }
  .contact-form .btn { justify-self: stretch; width: 100%; }
}

/* ----- AI has changed the maths: on a phone the six jobs line up under the headline and, as you scroll,
   come in one by one and then light up as handled. ----- */
@media (max-width: 760px) {
  .maths { height: 230vh; }
  .maths-plane { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 84px 22px 40px; }
  .maths-line { order: 1; }
  .maths-sub { order: 2; --s: clamp(0, calc((var(--p) - 0.4) * 7), 1); margin-top: 22px; font-size: 17px; }
  .maths-orbit { order: 3; position: relative; inset: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 350px; margin-top: 30px; }
  .maths-orbit span {
    --c: clamp(0, calc((var(--p) - 0.5 - var(--k) * 0.035) * 9), 1);
    --h: clamp(0, calc((var(--p) - 0.74 - var(--k) * 0.03) * 10), 1);
    position: relative; left: auto; top: auto;
    padding: 9px 12px 9px 11px; font-size: 14px;
    background: rgba(255, 255, 255, calc(0.06 + var(--h) * 0.04));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, calc(0.12 + var(--h) * 0.14)), 0 0 calc(var(--h) * 22px) rgba(110, 90, 255, calc(var(--h) * 0.4));
    opacity: var(--c);
    transform: translateY(calc((1 - var(--c)) * 14px)) scale(calc(0.94 + var(--c) * 0.06));
    filter: blur(calc((1 - var(--c)) * 4px));
  }
  .maths-orbit span::after {
    content: ""; width: 12px; height: 12px; margin-left: 2px; background: #c4bbff;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: var(--h); transform: scale(calc(0.5 + var(--h) * 0.5));
  }
}

/* =============================== Demos =============================== */

@media (max-width: 600px) {
  /* the app overview under the hero, drawn at a size you can read */
  .hero-app { --ui-size: 13.5px; }
  .hero-app .ui-tile { padding: 0.85em 0.8em; }
  .hero-app .ui-tile-icon, .hero-app .ui-tile .chev, .hero-app .ui-tile-foot { display: none; }
  .hero-app .ui-tile .ui-num { margin-top: 0.5em; font-size: 2em; }
  .hero-app .ui-tile-label { white-space: normal; line-height: 1.25; }
}

@container (max-width: 520px) {
  .feature-demo > .ui { font-size: clamp(14.5px, 4.4cqi, 16.5px); }

  /* nothing smaller than about 11px */
  .ui-example, .rail-mono, .ag-client, .b2b-status, .delta, .ac-note, .ui-progress-label, .slack-time,
  .it-day, .it-note, .rt-label, .ui-stat-hint, .deliv, .picker-q kbd, .picker-opt kbd { font-size: 0.72em; }

  /* app windows lose the desktop's traffic lights: the bar is just the screen's name and the example-data tag */
  .ui-chrome { height: 2.4em; padding: 0 0.85em; }
  .ui-chrome > i { display: none; }
  .ui-url { margin: 0 auto 0 0; }
  .ui-title { font-size: 1.35em; }
  .ui-title.sm { font-size: 1.2em; }

  /* the demos' own small controls get a thumb-sized hit area around them, without looking any bigger */
  .ui-chip, .ui-seg button, .ui-switch, .suggest-tools button, [data-ask] { position: relative; }
  .ui-chip::after, .ui-seg button::after, .ui-switch::after, .suggest-tools button::after, [data-ask]::after {
    content: ""; position: absolute; inset: -10px -3px;
  }
  [data-ask]::after { inset: -4px -3px; }   /* these are stacked, so they mustn't reach into each other */

  /* ----- Discovery: numbers that fit their tiles, markets on one line, one clean line per creator ----- */
  .disc .ui-page { gap: 0.8em; padding: 1.1em 1em 1.1em; }
  .ui-stat { padding: 0.75em 0.8em; }
  .ui-stat .ui-num { margin: 0.4em 0 0.15em; font-size: 1.5em; }
  .ui-stat-label { font-size: 0.7em; }
  .disc-markets .ui-chip { height: 2.3em; padding: 0 0.85em; font-size: 0.72em; }
  .ui-prow-name, .ui-prow-bio { display: none; }
  .ui-prow { padding: 0.7em 0.6em; align-items: center; }
  .ui-prow-side { padding-top: 0; }
  .ui-feed { height: 16em; }

  /* ----- Vetting: one row of photos is enough (every detection is in it), and nine criteria rows always ----- */
  .vet-tile:nth-child(n + 4) { display: none; }

  /* ----- Warm-up: the phone shows the post, so the sheet goes straight to the comments ----- */
  .meet-stage .picker-post { display: none; }
  .meet-stage .picker-q { margin-top: 0.1em; }

  /* ----- Outreach: a fixed column for each step's status, so a "Done" appearing never squeezes the step ----- */
  .seq-step { grid-template-columns: 2.4em minmax(0, 1fr) 6.2em; }
  .seq-state { justify-content: flex-end; flex-wrap: wrap; gap: 0.3em; white-space: normal; text-align: right; line-height: 1.25; }

  /* ----- Collaborations: the timeline tells the story on its own; the side cards are for big screens ----- */
  .collab-top { flex-direction: column; align-items: stretch; gap: 0.6em; padding: 0.85em 1em; }
  .collab-top .ui-pipe { min-width: 0; }
  .collab-top .ui-pipe-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collab-grid { padding: 0.9em; }
  .collab-side { display: none; }
  .ui-step { padding: 0.32em 0; }

  /* ----- Content capture: five clips side by side are too small for file names ----- */
  .cap-file span { display: none; }

  /* ----- Inbox: the conversation fills the screen, without a gap above it ----- */
  .msgs-grid { height: 29.5em; }

  /* ----- Community: the hand-off to Slack arrives as a notification over the bottom of the stream ----- */
  .community { overflow: hidden; }
  .comm-stream { height: 20em; }
  .comm-slack { position: absolute; left: 0.8em; right: 0.8em; bottom: 0.8em; width: auto; margin: 0; opacity: 0; transform: translateY(115%); }
  .community.slack-on .comm-slack { opacity: 1; transform: none; }

  /* ----- Reports: tighter tiles, a shorter chart, and the weekly summary as a notification on top ----- */
  .report-page { gap: 0.7em; padding: 1em 1em 1.1em; }
  .rt { gap: 0.15em; padding: 0.65em 0.75em; }
  .rt strong { font-size: 1.25em; }
  .usual { height: 8.6em; margin-top: 1.3em; }
  .rc-title.second, .praise { display: none; }
  .report-summary {
    left: 0.8em; right: 0.8em; bottom: 0.8em; width: auto; opacity: 0; transform: translateY(115%);
    transition: transform 0.7s var(--ease-spring), opacity 0.35s ease;
  }
  .report.summary-on .report-summary { opacity: 1; transform: none; }

  /* ----- Agency: the clients become tabs across the top, and the list shows the three latest ----- */
  .agency-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 24.5em; }
  .agency-rail { flex-direction: row; gap: 0.35em; padding: 0.6em 0.8em; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  .agency-rail::-webkit-scrollbar { display: none; }
  .rail-title, .rail-name { display: none; }
  .rail-item { flex: none; width: auto; grid-template-columns: auto auto; justify-content: start; gap: 0.45em; padding: 0.3em 0.6em 0.3em 0.3em; }
  .rail-count { display: block; }
  .agency-main { padding: 0.95em 1em; }
  .ag-row { grid-template-columns: auto minmax(0, 1fr); align-items: start; row-gap: 0.4em; }
  .ag-row:nth-child(n + 4) { display: none; }
  .ag-text span { display: none; }
  .ag-state { grid-column: 2; justify-self: start; font-size: 0.72em; }
  .ag-who { display: none; }

  /* ----- B2B: the status goes under the name, so names aren't cut short ----- */
  .b2b-row { grid-template-columns: auto minmax(0, 1fr); row-gap: 0.45em; padding: 0.7em 0.75em; }
  .b2b-status { grid-column: 2; justify-self: start; }
  .b2b-icon, .b2b-row .ui-avatar { width: 2.3em; height: 2.3em; }
}
