/* W22 (Elad 3/11 on a desktop: "the first screen does not fit desktop, the photo is cropped, it looks like half-mobile"):
   the tablet and desktop layout of the web funnel and of the home-screen app. Everything here is inside a min-width
   media query, so phones (< 768px) render exactly as before. Every query also needs min-height: 600px (W22 r1 F1): a
   phone held sideways (844x390, 932x430) is wide but short, and stays on the phone layout.

   Tablet + desktop (>= 768px): every screen is a centred PANEL on a calm tinted page: the screen column keeps its own
   off-white background, rounded corners and a soft shadow, and is only as tall as its content (capped at the window),
   so the action bar sits right after the content instead of at the window bottom; a long screen scrolls inside the
   panel as on a phone. Panel width: 640px on a tablet (768-899), 560px on a desktop (>= 900, a reading column).
   Home: the tab bar is the panel's own bottom edge (same width, rounded below), never a full-window bar.
   welcome (>= 900): two columns, the photo large and uncropped beside the text.
   Per screen, not a blanket look (CLAUDE.md rule 8): each rule names the screens it is for. */
@media (min-width: 768px) and (min-height: 600px) {
  :root { --panel-max: 640px; --panel-gap: 32px; --panel-radius: 28px; --page-tint: #e6edf4; }
  html, html body { background: var(--page-tint); }
  html body { background-image: radial-gradient(1200px 600px at 50% 0%, #f1f5f9 0%, rgba(241, 245, 249, 0) 70%); }
  html #app { padding: var(--panel-gap) var(--space-6); align-items: center; justify-content: center; }
  html #app::before { display: none; } /* W117: the phone's mint wave is not drawn behind the panel */
  /* the panel: the screen column itself */
  html #app > main.screen {
    flex: 0 1 auto;
    inline-size: 100%;
    max-inline-size: var(--panel-max);
    max-block-size: 100%;
    margin: 0;
    background: var(--background);
    border-radius: var(--panel-radius);
    box-shadow: 0 1px 2px rgba(11, 42, 111, 0.06), 0 12px 40px rgba(11, 42, 111, 0.10);
    --screen-pad-inline: var(--space-10);
    --screen-pad-top: var(--space-8);
    --screen-pad-bottom: var(--space-8);
    --screen-actions-pad-bottom: var(--space-8);
  }
  /* framed screens: the body grows only to its content, so the action bar follows it */
  html #app > main.screen[data-framed] > .screen__body { flex: 0 1 auto; }
  html #app > main.screen > .screen__actions { margin-block-start: 0; }
  /* photos: never a strip. The welcome / hero photo shows whole (4:3), at most 420px tall */
  html #app > main.screen .hero img { block-size: auto; aspect-ratio: 900 / 672; max-block-size: 420px; object-fit: cover; object-position: center 30%; }
  html #app > main.screen .hero.tall img { block-size: auto; }

  /* home (the app): the tab bar is the panel's bottom edge */
  html[data-screen="home"] #app { gap: 0; }
  html[data-screen="home"] #app > main.screen { border-end-start-radius: 0; border-end-end-radius: 0; flex: 0 1 auto; }
  html[data-screen="home"] #app > nav.tabbar {
    inline-size: 100%;
    max-inline-size: var(--panel-max);
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-6) var(--space-3);
    border-end-start-radius: var(--panel-radius);
    border-end-end-radius: var(--panel-radius);
    box-shadow: 0 12px 40px rgba(11, 42, 111, 0.10);
  }
  html[data-screen="home"] #app > nav.tabbar .tab { flex: 0 1 8rem; }
}

/* tablet: a smaller (whole) photo, so the first screen's text and button stay in view on an iPad */
@media (min-width: 768px) and (max-width: 899.98px) and (min-height: 600px) {
  /* the photo stays whole (4:3): a narrower photo card, centred, instead of a cropped strip */
  html #app > main.screen .hero { inline-size: min(100%, 456px); margin-inline: auto; }
  html #app > main.screen .wl-vid { inline-size: min(100%, 456px); margin-inline: auto; } /* W118: the welcome clip card */
}

@media (min-width: 900px) and (min-height: 600px) {
  :root { --panel-max: 560px; }

  /* welcome: two columns, the text on the reading side, the photo large and whole on the other (W118: the clip card, 4:5) */
  html #app > main.screen[data-screen="welcome"] {
    --welcome-photo: min(44vw, 480px);
    max-inline-size: calc(560px + var(--welcome-photo) + var(--space-10));
    position: relative;
    padding-inline-end: calc(var(--welcome-photo) + 2 * var(--space-10));
  }
  /* the panel itself scrolls on a short window (a scrolling body would clip the photo, which sits outside its flow) */
  html #app > main.screen[data-screen="welcome"][data-framed] { overflow-y: auto; }
  html #app > main.screen[data-screen="welcome"][data-framed] > .screen__body { overflow: visible; flex: none; }
  html #app > main.screen[data-screen="welcome"] .hero {
    position: absolute;
    inset-inline-end: var(--space-10);
    inset-block-start: 50%;
    transform: translateY(-50%);
    inline-size: var(--welcome-photo);
    z-index: 1;
  }
  html #app > main.screen[data-screen="welcome"] .hero img { max-block-size: none; }
  html #app > main.screen[data-screen="welcome"] .wl-vid {
    position: absolute;
    inset-inline-end: var(--space-10);
    inset-block-start: 50%;
    transform: translateY(-50%);
    inline-size: min(var(--welcome-photo), 340px);
    block-size: auto;
    flex-direction: column; /* W121: the whole 4:5 frame on top, the chip and the sound button in a row under it */
    gap: 0;
    margin: 0;
    z-index: 1;
  }
  html #app > main.screen[data-screen="welcome"] .wl-frame { inline-size: 100%; block-size: auto; }
  html #app > main.screen[data-screen="welcome"] .wl-side { flex-direction: row; flex-wrap: wrap; padding: 12px; }
  html #app > main.screen[data-screen="welcome"] .wl-vtag { flex-direction: row; }
}

/* join on a wide desktop: two columns inside one panel, so the paywall reads without scrolling - the timeline and the
   plans on the reading side, then "today 0 ₪", the phone + card form and the legal lines on the other; the button
   spans both, under them. A multi-column body keeps the DOM (and the phone order) as it is. */
@media (min-width: 1100px) and (min-height: 600px) {
  html #app > main.screen[data-screen="pay"] { max-inline-size: 1040px; --screen-pad-top: var(--space-6); --screen-actions-pad-bottom: var(--space-6); }
  html #app > main.screen[data-screen="pay"] .w5-tlcard { padding-block: var(--space-3); }
  html #app > main.screen[data-screen="pay"][data-framed] > .screen__body {
    display: block;
    column-count: 2;
    column-gap: var(--space-10);
    column-fill: balance;
    padding-block: var(--space-2);
  }
  html #app > main.screen[data-screen="pay"] > .screen__body > * { break-inside: avoid; margin-block: 0 var(--screen-gap); }
  html #app > main.screen[data-screen="pay"] > .screen__body > .today { break-before: column; }
  /* the last block of each column ends the column: no gap below it */
  html #app > main.screen[data-screen="pay"] > .screen__body > :is(.plans, :last-child) { margin-block-end: 0; }
  /* the two plans side by side (each stays a whole card), so the plans column fits beside the form */
  html #app > main.screen[data-screen="pay"] .plans { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-items: stretch; }
  html #app > main.screen[data-screen="pay"] .plans > .plan { margin: 0; }
  html #app > main.screen[data-screen="pay"] > .screen__actions { inline-size: min(100%, 480px); justify-self: center; margin-inline: auto; }
}

/* W22 r2 (Elad 3/11, the installed app on Windows): every wide layout's scroller gets a thin, quiet scrollbar instead of
   the heavy native one (the panel's edge showed a thick grey bar). */
@media (min-width: 768px) and (min-height: 600px) {
  html #app > main.screen, html #app > main.screen > .screen__body {
    scrollbar-width: thin;
    scrollbar-color: rgba(11, 42, 111, 0.22) transparent;
  }
  html #app > main.screen::-webkit-scrollbar, html #app > main.screen > .screen__body::-webkit-scrollbar { inline-size: 8px; block-size: 8px; }
  html #app > main.screen::-webkit-scrollbar-thumb, html #app > main.screen > .screen__body::-webkit-scrollbar-thumb { background: rgba(11, 42, 111, 0.22); border-radius: 8px; }
  html #app > main.screen::-webkit-scrollbar-track, html #app > main.screen > .screen__body::-webkit-scrollbar-track { background: transparent; }
}

/* W22 r2: the installed app in a wide window (html[data-context="pwa"], stamped by context.js from display-mode
   standalone / window-controls-overlay launches through the manifest's start_url ?src=pwa / iOS standalone) fills its
   window like an app: no floating panel, no outer margin, radius or shadow. The column stays centred (640 for the app's
   screens), full height, the page tint around it; home's tab bar sits at the window bottom, the column's width. */
@media (min-width: 768px) and (min-height: 600px) {
  html[data-context="pwa"] { --panel-max: 640px; }
  html[data-context="pwa"] #app { padding: 0; justify-content: flex-start; }
  html[data-context="pwa"] #app > main.screen { flex: 1 1 auto; max-block-size: none; border-radius: 0; box-shadow: none; }
  html[data-context="pwa"][data-screen="home"] #app > nav.tabbar { border-radius: 0; box-shadow: none; padding-block-end: calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); }
}
