/* Desktop and wide tablets (>= 980px). The phone layout stays the base; here
   the tab bar becomes a side menu, content gets real width, and each screen
   gets a layout that uses it. Loaded last, so it overrides the screen files. */

@media (min-width: 980px) {
  :root { --side-w: 232px; --content-w: 1040px; }

  body { background: var(--bg); }

  /* the side menu is hidden during onboarding (renderNav sets [hidden]) */
  .nav[hidden] { display: none; }
  /* the brand is in the side menu: no second logo in the top bar */
  .topbar .logo { display: none; }

  /* cards that open something lift a little under the mouse */
  @media (hover: hover) and (pointer: fine) {
    .bcard, .tile, .choice, .offer-head { transition: transform .15s ease-out, box-shadow .15s ease-out; }
    .bcard:hover, .tile:hover, .choice:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
  }

  /* ---------- side menu (the tab bar) ---------- */
  .nav {
    inset-block: 0; inset-inline-start: 0; left: auto; bottom: 0; transform: none;
    width: var(--side-w); max-width: none; height: 100vh;
    border-top: 0; border-inline-end: 1px solid var(--line);
    padding: 28px 16px;
    display: flex; flex-direction: column; gap: 6px;
    background: var(--surface);
  }
  html[dir="rtl"] .nav { right: 0; }
  html[dir="ltr"] .nav { left: 0; }
  .nav::before {
    content: "SuperZol"; font-family: var(--font-brand); font-weight: 800; font-size: 24px;
    padding: 0 12px 18px; color: var(--ink);
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 12px; font-size: 15px; }
  .nav .ni { width: auto; height: auto; background: none !important; }
  .nav a[aria-current="page"] { background: var(--lilac-50); }
  .nav a:hover { background: var(--lilac-50); color: var(--purple); }

  /* the short "about" panel sits at the bottom of the side menu */
  .desk {
    display: block; position: fixed; z-index: 31; transform: none; top: auto; bottom: 24px;
    width: calc(var(--side-w) - 32px); inset-inline-start: 16px; inset-inline-end: auto;
    font-size: 13px;
  }
  html[dir="rtl"] .desk { right: 16px; left: auto; }
  html[dir="ltr"] .desk { left: 16px; right: auto; }
  .desk .desk-brand, .desk h2, .desk ul { display: none; }
  .desk-phone { background: var(--lilac-50); border-radius: var(--r-sm); padding: 10px 12px; box-shadow: none; font-weight: 700; margin: 0 0 8px; }
  .desk-cities { margin: 0; color: var(--ink-2); line-height: 1.6; }
  .desk a { color: var(--purple); }

  /* ---------- content column ---------- */
  .app { max-width: none; margin: 0; margin-inline-start: var(--side-w); box-shadow: none; background: var(--bg); }
  body:has(#nav[hidden]) .app { margin-inline-start: 0; }
  body:has(#nav[hidden]) .desk { display: none; }
  .screen {
    max-width: var(--content-w); margin: 0 auto;
    padding: 32px 40px 56px;
    gap: var(--s6);
  }
  .topbar h1 { font-size: 26px; text-align: start; }
  .h-hero { font-size: 34px; }

  /* ---------- home: savings card + "next step" side by side ---------- */
  .screen.home { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: stretch; }
  .screen.home > * { grid-column: 1 / -1; }
  .screen.home > .savings, .screen.home > .first-basket { grid-column: 1; }
  .screen.home > .home-side { grid-column: 2; display: flex; flex-direction: column; gap: var(--s3); justify-content: center;
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 24px; }
  .home-side h2 { margin: 0 0 4px; font-size: 18px; }
  .rail { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .bcard { min-height: 150px; }
  .savings { --art-w: 150px; --art-h: 125px; --art-bottom: 20px; min-height: 240px; padding: 32px 36px; padding-inline-end: calc(36px + var(--art-w)); }
  .rail { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); overflow: visible; scroll-snap-type: none; }

  /* ---------- my lists: two columns of cards ---------- */
  .screen:has(> .lcard) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .screen:has(> .lcard) > :not(.lcard) { grid-column: 1 / -1; }

  /* ---------- new list: template choices side by side ---------- */
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* ---------- list editor: products in a grid, the summary as a side panel ---------- */
  .cats { flex-wrap: wrap; overflow: visible; }
  .key-hint { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
    font: 700 12px var(--font-en); color: var(--ink-3); order: 3; }
  .tiles { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .plist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen.has-dock { padding-bottom: 56px; padding-inline-end: calc(40px + 360px); max-width: calc(var(--content-w) + 360px); }
  .dock {
    left: auto; transform: none; bottom: auto; top: 24px; width: 340px; max-width: none;
    max-height: calc(100vh - 48px); overflow-y: auto;
    border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
    padding: 16px;
  }
  html[dir="rtl"] .dock { left: max(24px, calc((100vw - var(--side-w) - var(--content-w) - 360px) / 2)); right: auto; }
  html[dir="ltr"] .dock { right: max(24px, calc((100vw - var(--side-w) - var(--content-w) - 360px) / 2)); left: auto; }
  .dock-list { max-height: 56vh; }

  /* ---------- compare: chains in two columns ---------- */
  .offers { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .offer.open, .offer.best { grid-column: 1 / -1; }
  .filters { flex-wrap: wrap; }
  table.detail { font-size: 14px; }

  /* ---------- narrow, centered screens ---------- */
  .legal, .shop { max-width: 640px; }

  /* ---------- onboarding: what SuperZol is, beside the steps ---------- */
  .welcome { max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 64px; align-content: start; }
  .welcome > * { grid-column: 2; }
  .welcome > .w-aside { grid-column: 1; grid-row: 1 / span 30; display: block; position: sticky; top: 48px; align-self: start;
    background: linear-gradient(160deg, var(--purple), var(--purple-300)); color: #fff; border-radius: var(--r-lg); padding: 36px; }
  .w-aside .mascot { width: 120px; height: 100px; }
  .w-aside-title { font-size: 28px; font-weight: 800; line-height: 1.25; margin: 16px 0; }
  .w-aside ul { margin: 0; padding-inline-start: 20px; display: grid; gap: 10px; font-size: 16px; }
  .group, .premium-card, .about-card { max-width: 720px; }

  /* ---------- dialogs: centered cards instead of bottom sheets ---------- */
  .sheet-backdrop { align-items: center; }
  .sheet { max-width: 560px; border-radius: var(--r-lg); max-height: calc(100vh - 64px); overflow-y: auto; }
  .sheet .grab { display: none; }

  /* ---------- toast: centered over the content ---------- */
  .toast { bottom: 32px; }
  html[dir="rtl"] .toast { left: calc(50% - var(--side-w) / 2); }
  html[dir="ltr"] .toast { left: calc(50% + var(--side-w) / 2); }
}

@media (min-width: 1400px) {
  .plist { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .screen.has-dock { --content-w: 1120px; }
}

@media (min-width: 980px) {
  .guide { max-width: 760px; }
  .g-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
