/* =================================================================
   VERTICAL layout (phones, portrait tablets)
   Active when <html data-layout="vertical">.
   ================================================================= */
.vertical-shell {
    position: fixed;
    inset: 0;
}

/* Top bar (iOS navigation bar) */
.v-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    background-color: rgba(250, 248, 255, 0.9);
    /* Fill the notch / status-bar area with brand purple (white status text on iOS) */
    background-image: linear-gradient(#220041, #220041);
    background-size: 100% env(safe-area-inset-top, 0px);
    background-repeat: no-repeat;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--ios-separator);
    z-index: 1020;
}

.v-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--bms-ink);
    text-decoration: none;
}

/* ~80% density on phones: everything sized in rem scales down from here */
html[data-layout="vertical"] { font-size: 13px; }
/* ...except text fields: iOS zooms the page on focus when inputs are under 16px */
html[data-layout="vertical"] .form-control,
html[data-layout="vertical"] .form-select { font-size: 16px; min-height: 40px; }
html[data-layout="vertical"] .btn { min-height: 40px; }
html[data-layout="vertical"] .btn-sm { min-height: 30px; }

/* Content */
html[data-layout="vertical"] .content {
    padding: 1.25rem 16px 1.5rem;
    width: 100%;
}

html[data-layout="vertical"] h2 { font-size: 1.75rem; font-weight: 700; }
html[data-layout="vertical"] h3 { font-size: 1.4rem; }
html[data-layout="vertical"] .card-body { padding: 1rem; }
html[data-layout="vertical"] .row { --bs-gutter-x: 1rem; }

/* Full-width primary actions inside forms */
html[data-layout="vertical"] form .text-end > .btn,
html[data-layout="vertical"] form .text-end > button {
    width: 100%;
    margin: 0 0 0.5rem 0 !important;
}

/* Modals become bottom sheets */
html[data-layout="vertical"] .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100%;
    display: flex;
    align-items: flex-end !important;
}

html[data-layout="vertical"] .modal-content {
    border-radius: 12px 12px 0 0;
    max-height: 92vh;
}

html[data-layout="vertical"] .modal-body { overflow-y: auto; }


.v-footer {
    padding: 1rem 16px 1.25rem;
    color: var(--ios-label-2);
}

/* Bottom tab bar */
.tab-bar {
    display: flex;
    justify-content: space-around;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -2px 12px rgba(34, 0, 65, 0.06);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid var(--ios-separator);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 1030;
}

.tab-bar a, .tab-bar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    border: 0;
    background: none;
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--bms-ink-2);
    text-decoration: none;
}

.tab-bar i { font-size: 1.35rem; line-height: 1; }
.tab-bar a.active, .tab-bar button.active { color: var(--bms-tint); }

/* "More" sheet */
.v-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 1040;
}

.v-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    background: var(--ios-bg);
    border-radius: 12px 12px 0 0;
    padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow-y: auto;
    animation: v-sheet-up 0.25s ease-out;
}

@keyframes v-sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.v-sheet-grabber {
    width: 36px;
    height: 5px;
    border-radius: 3px;
    background: rgba(60, 60, 67, 0.3);
    margin: 0 auto 12px;
}

.v-list-header {
    margin: 1rem 0 0.4rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--ios-label-2);
}

.v-list {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.v-list a, .v-list button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 48px;
    padding: 0 1rem;
    border: 0;
    background: none;
    color: var(--bms-ink);
    font-size: 1rem;
    text-decoration: none;
    text-align: left;
}

.v-list a + a, .v-list button + button { border-top: 0.5px solid var(--ios-separator); }
.v-list a i:first-child, .v-list button i:first-child { color: var(--bms-tint); font-size: 1.15rem; }
.v-list a .bi-chevron-right { color: var(--bms-input-border); font-size: 0.9rem; }
.v-list a.active { color: var(--bms-tint); font-weight: 600; }

/* Auth: stacked */
html[data-layout="vertical"] .auth-shell { flex-direction: column; }
html[data-layout="vertical"] .auth-brand { padding: calc(1.5rem + env(safe-area-inset-top)) 1.5rem 2.25rem; border-radius: 0 0 28px 28px; }
html[data-layout="vertical"] .auth-seal { width: 76px; height: 76px; }
html[data-layout="vertical"] .auth-brand-name { font-size: 1.35rem; margin-top: 1rem; }
html[data-layout="vertical"] .auth-brand-tag { display: none; }
html[data-layout="vertical"] .auth-main { justify-content: flex-start; padding: 0 16px; margin-top: -1.25rem; }
html[data-layout="vertical"] .auth-form .card { border-radius: 18px; }
html[data-layout="vertical"] .auth-form .row.g-3 > [class*="col-md-6"] { flex: 0 0 100%; max-width: 100%; }

/* Academic Clinical Prestige: brand wordmark + active tab */
.v-brand { font-family: var(--bms-font-serif); font-weight: 600; font-size: 1.2rem; color: var(--bms-tint); }
.tab-bar a.active, .tab-bar button.active { font-weight: 700; }
.v-list { border: 1px solid var(--bms-border); border-radius: 8px; }
.v-list-header { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; }

/* Installed iOS app with the black-translucent status bar: the fixed-position viewport
   comes up short of the screen by the status-bar height, leaving a strip under the tab
   bar. 100vh is still the full screen height, so size to that instead of inset: 0. */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        .vertical-shell,
        .wide-shell,
        .v-sheet-backdrop,
        .bms-splash {
            bottom: auto;
            height: 100vh;
        }

        /* The blur gives the bar its own layer, which iOS appears to clip at the short viewport. */
        /* iOS still leaves that strip unpainted even though the tab bar now reaches it, and
           the grey behind it shows through. Whiten what sits behind the bar so the two read
           as one; <main> keeps the grey for the page itself. */
        html[data-layout="vertical"]:has(.tab-bar),
        html[data-layout="vertical"]:has(.tab-bar) body,
        .tab-bar { background-color: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }

        html[data-layout="vertical"] .vertical-shell:has(.tab-bar) { background-color: #fff !important; }
        .vertical-shell:has(.tab-bar) > main { background-color: var(--bms-canvas); }

        .v-sheet { bottom: calc(-1 * env(safe-area-inset-top, 0px)); }
    }
}
