/* ==========================================================================
   COFFEE OS | iOS NATIVE POLISH
   Visual-only shell tuning for iPhone/iPad/standalone/Capacitor.
   No auth, sync, or business logic changes.
   ========================================================================== */

:root {
    --font-ui: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Manrope', system-ui, sans-serif;
    --font-data: 'SF Mono', ui-monospace, 'Space Mono', 'Menlo', monospace;
}

html.is-ios,
body.is-ios {
    background: #080808;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.is-ios {
    overscroll-behavior: none;
}

body.is-ios #app-shell {
    background: transparent;
}

body.is-ios #top-bar {
    background: linear-gradient(to bottom, rgba(10,10,12,0.94), rgba(10,10,12,0.86));
    border-bottom: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

body.is-ios #top-bar.top-bar-scrolled {
    background: linear-gradient(to bottom, rgba(10,10,12,0.98), rgba(10,10,12,0.90));
    border-bottom-color: rgba(255,255,255,0.08);
    box-shadow: 0 12px 36px rgba(0,0,0,0.26);
}

body.is-ios #header-title {
    font-family: var(--font-ui);
    font-size: 0.84rem;
    letter-spacing: 0.16em;
    font-weight: 800;
}

body.is-ios #header-actions {
    min-width: 44px;
    min-height: 44px;
    justify-content: flex-end;
}

body.is-ios #viewport {
    scrollbar-width: none;
    scroll-behavior: smooth;
    padding-bottom: calc(var(--nav-base-height) + var(--safe-area-bottom) + 14px);
}
body.is-ios #viewport::-webkit-scrollbar { display: none; }

body.is-ios #bottom-dock {
    left: max(12px, calc(var(--safe-area-left) + 10px));
    right: max(12px, calc(var(--safe-area-right) + 10px));
    bottom: calc(var(--safe-area-bottom) + 6px);
    height: 58px;
    border-radius: 24px;
    border-color: rgba(255,255,255,0.07);
    background: linear-gradient(to bottom, rgba(28,28,30,0.82), rgba(16,16,18,0.90));
    box-shadow:
      0 18px 48px rgba(0,0,0,0.52),
      inset 0 0.5px 0 rgba(255,255,255,0.10);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

body.is-ios #bottom-dock.dock-scrolled {
    box-shadow:
      0 22px 52px rgba(0,0,0,0.58),
      inset 0 0.5px 0 rgba(255,255,255,0.11);
}

body.is-ios #bottom-nav {
    gap: 5px;
    padding-left: 12px;
    padding-right: 12px;
}

body.is-ios #bottom-nav .nav-item {
    width: 54px;
    min-width: 54px;
    height: 46px;
    border-radius: 15px;
}

body.is-ios #bottom-nav .nav-item i {
    font-size: 1.08rem;
}

body.is-ios #bottom-nav .nav-item.active {
    background: rgba(194,124,46,0.16);
    border-color: rgba(194,124,46,0.30);
    box-shadow:
      0 8px 18px rgba(0,0,0,0.24),
      0 0 14px rgba(194,124,46,0.12);
}

body.is-ios .btn-arch,
body.is-ios .auth-btn,
body.is-ios button,
body.is-ios select,
body.is-ios input,
body.is-ios textarea {
    font-family: var(--font-ui);
}

body.is-ios input,
body.is-ios select,
body.is-ios textarea,
body.is-ios .input,
body.is-ios .input-pro {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 14px;
    min-height: 46px;
}

body.is-ios textarea,
body.is-ios .input-pro[multiline],
body.is-ios textarea.input-pro {
    min-height: 98px;
}

body.is-ios .modal-overlay,
body.is-ios .biz-modal,
body.is-ios .ux-modal-overlay,
body.is-ios .more-sheet {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

body.is-ios .modal-overlay,
body.is-ios .biz-modal {
    align-items: flex-end;
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
}

body.is-ios .modal-card,
body.is-ios .biz-modal .biz-modal-card,
body.is-ios .ux-modal-card,
body.is-ios .more-sheet-panel,
body.is-ios .brew-steps-sheet {
    border-radius: 24px 24px 18px 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.46);
}

body.is-ios .modal-card,
body.is-ios .biz-modal .biz-modal-card,
body.is-ios .more-sheet-panel,
body.is-ios .brew-steps-sheet {
    max-height: min(88dvh, calc(100vh - 18px - env(safe-area-inset-top)));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    /* See note above on the food/drink modal — these properties are
       required together for iOS standalone PWA to render scrollable
       modals. Without min-height:0 the flex child grows unboundedly and
       overflow-y:auto is silently ignored. */
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

body.is-ios .modal-card::before,
body.is-ios .biz-modal .biz-modal-card::before,
body.is-ios .more-sheet-panel::before,
body.is-ios .brew-steps-sheet::before {
    content: '';
    display: block;
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    margin: 0 auto 14px;
}

body.is-ios .ux-modal-card {
    padding-top: 16px;
}

body.is-ios .biz-modal .biz-modal-actions,
body.is-ios .pantry-modal-actions,
body.is-ios .ux-modal-actions {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

body.is-ios #auth-screen {
    background:
      radial-gradient(circle at top, rgba(33,33,40,0.95) 0%, rgba(11,11,15,0.98) 42%, #080808 100%);
    padding: calc(28px + env(safe-area-inset-top)) 22px calc(30px + env(safe-area-inset-bottom));
}

body.is-ios .auth-logo {
    border-radius: 18px;
}

body.is-ios .auth-buttons {
    width: min(360px, 90vw);
}

body.is-ios .auth-btn {
    min-height: 54px;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
}

body.is-ios .auth-footer {
    margin-top: 32px;
    padding-bottom: env(safe-area-inset-bottom);
}

body.is-ios #cloud-sync-chip {
    top: calc(env(safe-area-inset-top, 0px) + 8px) !important;
    right: calc(env(safe-area-inset-right, 0px) + 12px) !important;
    border-radius: 999px !important;
}

body.is-ios.is-ipad {
    --app-max-width: 1180px;
    --content-max-width: 980px;
    --dock-max-width: 880px;
}

body.is-ios.is-ipad #top-bar {
    width: min(100%, 1180px);
}

body.is-ios.is-ipad #viewport {
    padding-left: clamp(22px, 3vw, 34px);
    padding-right: clamp(22px, 3vw, 34px);
}

body.is-ios.is-ipad #bottom-dock {
    left: max(18px, calc((100vw - var(--dock-max-width, 880px)) / 2));
    right: max(18px, calc((100vw - var(--dock-max-width, 880px)) / 2));
}

body.is-ios.is-compact-landscape #top-bar {
    min-height: calc(50px + var(--safe-area-top));
}

body.is-ios.is-compact-landscape #bottom-dock {
    height: 50px;
    bottom: calc(var(--safe-area-bottom) + 4px);
}

body.is-ios.is-compact-landscape #bottom-nav .nav-item {
    height: 40px;
    width: 48px;
    min-width: 48px;
}


/* Specific iPhone fixes for Pantry / Foods / Drinks create modals */
body.is-ios .modal-overlay.pantry-modal,
body.is-ios .modal-overlay:has(#myfood-close),
body.is-ios .modal-overlay:has(#mydrink-close){
    align-items:center;
    justify-content:center;
    padding-top:calc(var(--header-height) + env(safe-area-inset-top) + 12px);
    padding-right:max(10px, calc(env(safe-area-inset-right) + 10px));
    padding-bottom:calc(var(--nav-base-height) + env(safe-area-inset-bottom) + 12px);
    padding-left:max(10px, calc(env(safe-area-inset-left) + 10px));
}

body.is-ios .modal-overlay.pantry-modal .modal-card,
body.is-ios .modal-overlay:has(#myfood-close) .modal-card,
body.is-ios .modal-overlay:has(#mydrink-close) .modal-card{
    width:min(96vw, 760px) !important;
    max-height:calc(100dvh - var(--header-height) - var(--nav-base-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px) !important;
    border-radius:22px !important;
    padding-top:14px !important;
    padding-bottom:calc(18px + env(safe-area-inset-bottom)) !important;
    overscroll-behavior:contain;
    scroll-padding-top:12px;
    /* CRITICAL: ensure scroll works on iOS standalone PWA. Without these
       three properties together, the modal renders at fixed height with no
       scroll — the last fields of long forms (Foods/Drinks recipe editor)
       become unreachable. */
    overflow-y:auto !important;
    min-height:0 !important;
    -webkit-overflow-scrolling:touch !important;
    display:flex !important;
    flex-direction:column !important;
}

body.is-ios .modal-overlay.pantry-modal .modal-card > div:first-child,
body.is-ios .modal-overlay:has(#myfood-close) .modal-card > div:first-child,
body.is-ios .modal-overlay:has(#mydrink-close) .modal-card > div:first-child{
    /* `position:sticky` was causing the modal-card to lose scroll on iOS
       standalone PWA (a known WebKit bug when sticky lives inside a flex
       column with overflow-y:auto). Reverted to static positioning so the
       scroll works. The header simply scrolls with the rest of the form,
       which is acceptable since the modal already has a Close button. */
    background:linear-gradient(180deg, rgba(26,28,34,0.98), rgba(26,28,34,0.94));
    padding-top:2px;
    padding-bottom:10px;
    margin-bottom:6px;
    border-radius:18px 18px 0 0;
}

body.is-ios .modal-overlay:has(#myfood-close) .modal-card,
body.is-ios .modal-overlay:has(#mydrink-close) .modal-card{
    padding-left:14px !important;
    padding-right:14px !important;
}
