/* Phones, and touch basics everywhere. Loaded after the design stylesheet (Cinematic or Classic) and uses its
   colours, so both designs get the same phone layout: a one-row top bar, the flight card as a bottom sheet,
   full-screen panels with a back button, 44 px touch targets and room for the notch and home indicator. */
#gl { touch-action: none; }
html, body { overscroll-behavior: none; }
.grab, .peek, .m-back, .q-count, .m-only { display: none; }

/* "Which plane?": several planes under one finger */
.which-ring { position: absolute; left: 0; top: 0; z-index: 3; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; pointer-events: none;
  border: 1.5px solid var(--volt); box-shadow: 0 0 18px color-mix(in srgb, var(--volt) 45%, transparent); }
.which { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 7; width: min(380px, calc(100vw - 24px)); padding: 14px 10px 10px;
  border-radius: 20px; border: 1px solid var(--hair); background: color-mix(in srgb, var(--raised) 94%, transparent); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3); }
.which h4 { margin: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.which ul { list-style: none; margin: 0; padding: 0; }
.which li + li { border-top: 1px solid var(--hair); }
.which button { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.which button:hover, .which button:focus-visible { background: var(--hair); outline: none; }
.which b { width: 90px; flex: none; font-size: 15px; font-weight: 600; letter-spacing: 0.05em; }
.which span { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.which em { font-style: normal; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  /* ---- top bar: search and Settings on one row; the count sits in the search bar */
  .top { padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left)); gap: 8px; align-items: center; }
  .left { flex: 1; min-width: 0; flex-direction: row !important; }
  .pill { display: none !important; }
  .search { flex: 1; width: auto !important; min-width: 0; height: 46px; padding: 0 14px; border-radius: 23px; }
  .search input { font-size: 16px; }   /* 16 px: iOS does not zoom the page when the field is focused */
  .search kbd { display: none; }
  .q-count { display: flex; flex: none; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .q-count i { width: 7px; height: 7px; border-radius: 50%; background: var(--volt); }
  .search:focus-within .q-count { display: none; }
  .results { top: 54px; left: -1px; width: calc(100vw - 24px); }
  .results button { min-height: 52px; }
  .tools { flex: none; flex-direction: row; }
  #zin, #zout, #home, #tilt, #theme { display: none !important; }   /* pinch, double-tap and Settings do these */
  #gear { width: 46px; height: 46px; }
  #hint { left: 16px; right: 16px; bottom: calc(40px + env(safe-area-inset-bottom)); text-align: center; }
  .attr { left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; text-align: center; font-size: 10px; }
  .m-only { display: flex; }

  /* ---- the flight card as a bottom sheet: a short peek, swipe up for everything */
  #card { left: 0 !important; right: 0 !important; bottom: 0 !important; width: auto !important; max-width: none !important; max-height: 82vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 26px calc(20px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left)) !important; gap: 12px !important; z-index: 5;
    background: color-mix(in srgb, var(--raised) 93%, transparent) !important; border: 0 !important; border-top: 1px solid var(--hair) !important;
    border-radius: 24px 24px 0 0 !important; box-shadow: 0 -16px 40px -18px rgba(0, 0, 0, 0.55) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.3) !important; backdrop-filter: blur(18px) saturate(1.3) !important; }
  #card::before { display: none !important; }
  .grab { display: block; position: absolute; top: 0; left: 50%; width: 120px; height: 44px; margin-left: -60px; z-index: 1; padding: 0; border: 0; background: none; cursor: grab; }
  .grab::after { content: ""; position: absolute; top: 9px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--muted); opacity: 0.55; }
  #card > .head { order: 1; } #c-route { order: 2; } #c-noroute { order: 3; } #c-type { order: 4; } #c-prog { order: 5; } #c-peek { order: 6; }
  #card > .stats { order: 7; } #c-phase { order: 8; } #c-prof { order: 9; } #card .actions { order: 10; } #c-zoom { order: 11; }
  #card .head { align-items: center; }
  #card .head .sub, #card .route .sub, #card .progress .row { display: none; }
  #c-close { width: 44px !important; height: 44px !important; display: grid !important; }
  #c-min, .ctab { display: none !important; }
  #card .code { font-size: 34px !important; line-height: 1 !important; }
  :root[data-design="classic"] #card .code { font-size: 28px !important; }
  #card .arrow { margin-bottom: 15px !important; }
  #card .route { margin-top: -2px; }
  #card .type, #card .stats, #card .phase, #card .profile, #card .actions, #c-zoom { display: none !important; }
  .peek { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; line-height: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .peek b { color: var(--ink); font-weight: 500; }
  #card.open .peek { display: none; }
  #card.open .head .sub, #card.open .route .sub { display: block; }
  #card.open .progress .row { display: flex; }
  #card.open .type, #card.open .phase { display: flex !important; }
  #card.open .stats { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  #card.open .stats > div { display: block !important; }
  #card.open .code { font-size: 44px !important; }
  :root[data-design="classic"] #card.open .code { font-size: 32px !important; }
  #card.open .actions { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #card.open .actions button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: auto; height: 68px; padding: 0 4px; border-radius: 16px; font-size: 12.5px; text-align: center; }
  #card.open .actions button svg { width: 20px; height: 20px; }
  #card.open .actions small, #card.open .actions .lo { display: none !important; }
  #card.open .actions .ln { display: inline !important; flex: none; }

  /* ---- History and Settings as full-screen pages with a back button */
  .settings { inset: 0 !important; width: auto !important; max-width: none !important; max-height: none !important; border: 0 !important; border-radius: 0 !important; z-index: 8 !important;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left) !important; background: var(--raised) !important; animation: fg-page-in 0.22s ease-out; }
  .set-head { padding: 6px 16px 6px 4px !important; gap: 8px; }
  .set-head .icon { display: none; }
  .m-back { display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 12px 0 6px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; }
  .m-back svg { width: 22px; height: 22px; }
  .set-body { padding-bottom: calc(28px + env(safe-area-inset-bottom)) !important; }
  .tog { min-height: 48px; }
  .seg span { padding: 10px 8px; }
  .settings select, .reset { min-height: 46px; }
  .h-links a { padding: 11px 14px; }
  body:has(#history:not([hidden])) .top, body:has(#settings:not([hidden])) .top, body:has(#replay:not([hidden])) .top { display: none; }

  /* ---- replay: bigger controls, a scrubber you can grab */
  .replay { bottom: calc(14px + env(safe-area-inset-bottom)) !important; }
  .replay .round { width: 46px; height: 46px; }
  .replay .pillbtn { height: 44px; }
  .replay .rp-head button { width: 44px; height: 44px; }
  .replay .rp-bar { height: 6px; border-radius: 3px; }
  .replay .rp-bar::before { inset: -19px 0; }
  .replay .rp-bar i { border-radius: 3px; }
  .replay .rp-now { flex-wrap: wrap; row-gap: 2px; column-gap: 16px; }
  .replay .rp-now span:first-child { flex-basis: 100%; }
  .replay .rp-now .grow { display: none; }
  .replay .rp-now b { white-space: nowrap; }
  .replay .rp-head b { white-space: nowrap; }

  /* ---- the chooser and the plane popover */
  .which { left: 0; right: 0; bottom: 0; transform: none; width: auto; padding: 16px 10px calc(12px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; border-width: 1px 0 0; }
  .pop button { min-height: 48px; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) { .settings { animation: none; } }
@keyframes fg-page-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
/* touch screens: no frosted-glass blur over the live globe (the browser would have to redo it every frame);
   the panels get a little more solid instead */
@media (pointer: coarse) {
  *, *::before, *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  html { --glass: color-mix(in srgb, var(--raised) 90%, transparent) !important; }
}
