/* Modern tall-phone layout (19.5:9 / 20:9, Dynamic Island, home indicator).
   Loaded after storefront.css / style.css. Do not break cart-only semantics. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tap: 44px;
  --header-safe: calc(var(--safe-top) + 12px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Avoid iOS bounce cutting content under the notch */
body.storefront {
  padding-left: max(0px, var(--safe-left));
  padding-right: max(0px, var(--safe-right));
  padding-bottom: calc(108px + var(--safe-bottom));
}

.storefront .app-frame {
  min-height: 100vh;
  min-height: 100dvh;
}

/* Sticky header clears Dynamic Island / status bar */
.storefront .app-header {
  padding-top: var(--header-safe);
  padding-left: max(14px, var(--safe-left));
  padding-right: max(14px, var(--safe-right));
}

/* Fluid type for 360–430px viewports (most modern phones) */
.storefront .brand {
  font-size: clamp(20px, 5.6vw, 23px);
}

.storefront .home-banner h1 {
  font-size: clamp(20px, 5.4vw, 25px);
}

.storefront .section-heading h2 {
  font-size: clamp(17px, 4.6vw, 18px);
}

.storefront .price {
  font-size: clamp(16px, 4.4vw, 18px);
}

/* Comfortable thumb targets */
.storefront button,
.storefront a,
.storefront .add-dish,
.storefront .shop-card,
.storefront .product-card {
  touch-action: manipulation;
}

.storefront .add-dish {
  min-height: 36px;
  min-width: 64px;
  padding: 8px 12px;
}

.storefront .search-wrap {
  min-height: 44px;
}

.storefront .search-wrap input {
  min-height: 36px;
  font-size: 16px; /* prevent iOS zoom-on-focus */
}

.storefront .search-wrap button {
  min-height: 36px;
}

.storefront .menu-categories button {
  min-height: 44px;
}

/* Left rail + menu on tall phones: keep categories sticky under header */
@media (max-width: 740px) {
  .storefront .menu-categories {
    top: calc(var(--header-safe) + 100px);
    max-height: calc(100dvh - (var(--header-safe) + 210px + var(--safe-bottom)));
  }

  .storefront .product-card {
    min-height: 132px;
  }

  .storefront .product-photo {
    width: 88px;
    height: 100px;
  }

  .storefront .shop-photo {
    width: 84px;
    height: 84px;
  }

  .storefront .batch-pills span {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* Floating cart respects home indicator; wider on short landscape too */
.web-cart-bar {
  bottom: calc(12px + var(--safe-bottom));
  left: 50%;
  width: min(650px, calc(100% - 24px - var(--safe-left) - var(--safe-right)));
  padding: 15px 18px;
  min-height: 56px;
}

/* Dialogs: full-height sheets on phones, keep actions above home indicator */
dialog {
  max-width: min(560px, 100vw);
  max-height: min(92dvh, 900px);
  margin: auto;
  border: 0;
  border-radius: 18px 18px 0 0;
  padding-bottom: calc(16px + var(--safe-bottom));
}

@media (max-width: 740px) {
  dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    max-height: 92dvh;
  }

  #cart-dialog .actions {
    bottom: 0;
    padding-bottom: calc(8px + var(--safe-bottom));
  }

  .dialog-close {
    top: calc(10px + var(--safe-top) * 0.3);
    right: max(12px, var(--safe-right));
    min-width: 44px;
    min-height: 44px;
  }
}

/* Very tall screens (e.g. 20:9): slightly looser vertical rhythm */
@media (min-aspect-ratio: 9/19) and (max-width: 740px) {
  .storefront .home-banner {
    margin-top: 14px;
  }

  .storefront .shop-card {
    padding: 18px 0;
  }

  .storefront .product-list {
    padding-bottom: 24px;
  }
}

/* Landscape phones: keep cart usable, tighten banner */
@media (max-height: 500px) and (orientation: landscape) {
  .storefront .home-banner {
    flex-direction: row;
    padding: 12px 14px;
  }

  .storefront .home-banner h1 {
    font-size: 18px;
  }

  .storefront .batch-pills {
    flex-direction: row;
  }

  .storefront .batch-pills span {
    transform: none;
    padding: 10px 12px;
    font-size: 12px;
  }

  .web-cart-bar {
    padding: 10px 14px;
    min-height: 48px;
  }
}

/* Privacy / shell pages on phones */
body:not(.storefront) .topbar {
  height: auto;
  min-height: 64px;
  padding: calc(var(--header-safe) - 10px) max(16px, var(--safe-left)) 12px max(16px, var(--safe-left));
  box-sizing: border-box;
}

body:not(.storefront) .shell {
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
  padding-bottom: calc(24px + var(--safe-bottom));
}

@media (max-width: 740px) {
  body:not(.storefront) h2 {
    font-size: 22px;
  }
}

/* Prefer safe-area-aware 100% */
@supports (height: 100dvh) {
  .storefront .app-frame {
    min-height: 100dvh;
  }
}
