/* App layer. Loads after site.css on every page.
   Desktop: instant page changes and install support only.
   Phones (760px and under): the site works like an app. Bottom tabs, a "More" sheet,
   sticky price bars, a compact header that hides while you scroll down.
   The mobile build copies the APP block below without the media query (build_mobile.py). */

/* Smooth page changes in browsers that support it. Header and tabs stay still. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; }
.site-head { view-transition-name: site-head; }
.tabbar { view-transition-name: tabbar; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* Hidden until the phone layout turns them on */
.tabbar, .app-sum, .head-call, .head-back, .install-card, .swipe-hint { display: none; }
.more-sheet { border: 0; padding: 0; max-width: none; }
.more-sheet:not([open]) { display: none; }

/* APP START */
@media (max-width: 760px) {
  html { -webkit-tap-highlight-color: transparent; scroll-padding-top: 64px; }
  a, button, label, summary, input, select { touch-action: manipulation; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); overscroll-behavior-y: none; }
  input, select, textarea { font-size: 16px !important; }
  .btn { transition: transform 0.08s ease; }
  .btn:active, .tab:active, .more-grid a:active { transform: scale(0.97); }

  /* Compact header, sticky, hides on scroll down and comes back on scroll up */
  .site-head { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: transform 0.22s ease; }
  html.head-hidden .site-head { transform: translateY(-100%); }
  .site-head .wrap { flex-wrap: nowrap !important; height: 56px !important; padding-top: 0 !important; padding-bottom: 0 !important; gap: 8px !important; padding-left: max(16px, env(safe-area-inset-left)) !important; }
  .site-head .logo { font-size: 21px; margin-right: auto; }
  .site-head .logo-icon { height: 30px; }
  .nav, .nav-toggle, .head-track, .head-cta, .head-login, .head-phone { display: none !important; }
  .head-call, .head-back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 22px; color: var(--field); background: var(--sage); border: 0; padding: 0; text-decoration: none; flex: none; }
  .head-back { background: none; margin-left: -10px; }
  .head-call svg, .head-back svg { width: 22px; height: 22px; }
  .head-back[hidden] { display: none; }

  /* Bottom tab bar */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(255, 255, 255, 0.97); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 4px max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left)); transition: transform 0.2s ease; }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); text-decoration: none; font: 600 11px/1.1 "Archivo", system-ui, sans-serif; background: none; border: 0; padding: 4px 0; cursor: pointer; letter-spacing: 0.01em; }
  .tab svg { width: 24px; height: 24px; }
  .tab[aria-current="page"] { color: var(--field); }
  .tab[aria-current="page"] svg { stroke-width: 2.4; }
  .tab-go span.tab-dot { width: 46px; height: 46px; border-radius: 23px; background: var(--signal); color: var(--ink); display: flex; align-items: center; justify-content: center; margin-top: -18px; box-shadow: 0 6px 16px -6px rgba(20, 52, 38, 0.55); border: 3px solid #fff; }
  .tab-go { color: var(--ink); }
  html.kb .tabbar, html.kb .app-sum { transform: translateY(120%); }

  /* Sticky price bar: route planner, quote pages, order page */
  .app-sum { display: flex; align-items: center; gap: 12px; position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 35; background: var(--field); color: #fff; padding: 10px 12px 10px 16px; transition: transform 0.2s ease; box-shadow: 0 -8px 20px -12px rgba(20, 52, 38, 0.6); }
  .app-sum.no-tabs { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .app-sum .sum-txt { flex: 1; min-width: 0; line-height: 1.2; }
  .app-sum .sum-txt b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
  .app-sum .sum-txt small { display: block; font-size: 13px; color: #CFE0D6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app-sum .btn { min-height: 46px; padding: 12px 16px; font-size: 16px; white-space: nowrap; flex: none; }
  body.has-sum { padding-bottom: calc(136px + env(safe-area-inset-bottom)); }
  body.has-sum.no-tabs-page { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* "More" bottom sheet */
  .more-sheet[open] { display: block; position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-height: 86vh; overflow-y: auto; background: #fff; border-radius: 18px 18px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25); animation: sheet-up 0.22s ease; }
  .more-sheet::backdrop { background: rgba(24, 32, 27, 0.45); }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
  .sheet-grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
  .more-sheet h2 { font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; font-weight: 700; }
  .more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .more-grid a { display: flex; align-items: center; min-height: 52px; padding: 10px 14px; border-radius: 10px; background: var(--sage); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; line-height: 1.2; }
  .more-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
  .more-acts .btn { text-align: center; }
  .more-close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border-radius: 20px; border: 0; background: var(--sage); font-size: 22px; line-height: 1; color: var(--ink); cursor: pointer; }
  .install-row { margin-top: 14px; padding: 14px; border-radius: 12px; border: 1.5px dashed var(--line); font-size: 15px; }
  .install-row[hidden] { display: none; }
  .install-row b { display: block; margin-bottom: 4px; }

  /* "Add to home screen" card, shown on a later visit */
  .install-card { display: flex; align-items: center; gap: 12px; position: fixed; left: 10px; right: 10px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 36; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 12px 32px -10px rgba(20, 52, 38, 0.45); animation: sheet-up 0.25s ease; }
  .install-card[hidden] { display: none; }
  .install-card img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
  .install-card p { margin: 0; flex: 1; font-size: 14px; line-height: 1.3; }
  .install-card p b { display: block; font-size: 15px; }
  .install-card .btn { padding: 10px 14px; min-height: 42px; font-size: 15px; }
  .install-card .x { background: none; border: 0; font-size: 22px; color: var(--muted); width: 32px; height: 40px; cursor: pointer; }
  body.has-sum .install-card { bottom: calc(140px + env(safe-area-inset-bottom)); }

  /* Plans: swipe side to side like app cards, recommended plan first */
  .plans { display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; padding: 4px 16px 12px; margin: 0 -16px; border: 0 !important; scrollbar-width: none; }
  .plans::-webkit-scrollbar { display: none; }
  .plan { flex: 0 0 84%; scroll-snap-align: center; border: 1.5px solid var(--line) !important; border-radius: 14px; background: #fff; }
  .plan-hot { order: -1; border-color: var(--field) !important; background: var(--field); }
  .plan-price small { display: block; margin-top: 4px; }
  .swipe-hint { display: block; font-size: 14px; color: var(--muted); margin: 0 0 8px; }

  /* Footer: shorter on phones. The More sheet carries the links. */
  .site-foot { padding: 28px 0 20px; }
  .site-foot .wrap { grid-template-columns: 1fr 1fr !important; gap: 18px !important; }
  .site-foot .wrap > div:first-child { grid-column: 1 / -1; }
  .site-foot a { padding: 6px 0; }

  /* Wide tables scroll sideways inside the page, not the whole page */
  main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

  /* Hide the old quick-action bar if a page still has it */
  .m-bar { display: none !important; }
}
/* APP END */

/* Installed app (opened from the home screen) */
@media (display-mode: standalone) {
  .site-head { padding-top: env(safe-area-inset-top); }
}
