/* ==========================================================================
   VoiceBridge Tigrinya - shared mobile layout
   - Everything is sized in rem/em so it scales evenly when the user
     enlarges the system font (Android "Font size", iOS Dynamic Type, browser zoom).
   - Fixed footer at the bottom; its real height is measured by js/layout.js
     and written to --vb-footer-h so content is never hidden behind it.
   - Respects iPhone notch / Android gesture bar via env(safe-area-inset-*).
   ========================================================================== */

:root {
    --vb-bg: #f4f5f7;
    --vb-surface: #ffffff;
    --vb-text: #1f2937;
    --vb-muted: #6b7280;
    --vb-primary: #2563eb;
    --vb-primary-dark: #1e40af;
    --vb-danger: #dc2626;
    --vb-ok: #16a34a;
    --vb-border: #e5e7eb;
    --vb-header-bg: #d3d3d3;
    --vb-footer-bg: #4b5563;
    --vb-footer-text: #ffffff;
    --vb-radius: 1rem;
    --vb-gap: 1rem;
    --vb-max-w: 40rem;
    /* fallback until layout.js measures the real footer */
    --vb-footer-h: 4.5rem;
    --vb-safe-top: env(safe-area-inset-top, 0px);
    --vb-safe-bottom: env(safe-area-inset-bottom, 0px);
    --vb-safe-left: env(safe-area-inset-left, 0px);
    --vb-safe-right: env(safe-area-inset-right, 0px);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    /* 100% = the user's chosen font size. Never set px here. */
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
}

body.vb {
    margin: 0;
    min-height: 100vh;      /* old browsers */
    min-height: 100dvh;     /* mobile: excludes the URL bar */
    display: flex;
    flex-direction: column;
    background: var(--vb-bg);
    color: var(--vb-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans Ethiopic", sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    overflow-x: hidden;
    padding-left: var(--vb-safe-left);
    padding-right: var(--vb-safe-right);
}

/* iOS: follow Dynamic Type (only when the OS supports it) */
@supports (font: -apple-system-body) {
    body.vb.vb-dynamic-type { font: -apple-system-body; font-family: system-ui, -apple-system, sans-serif; }
}

body.vb h1, body.vb h2, body.vb h3, body.vb h4, body.vb h5, body.vb h6 {
    font-family: inherit;
    line-height: 1.25;
    margin: 0.5em 0;
    overflow-wrap: anywhere;
}
body.vb h1 { font-size: clamp(1.5rem, 1.1rem + 2vw, 2.25rem); }
body.vb h2 { font-size: clamp(1.3rem, 1rem + 1.5vw, 1.9rem); }
body.vb h3 { font-size: clamp(1.15rem, 0.95rem + 1vw, 1.5rem); }
body.vb h4 { font-size: 1.1rem; }

body.vb img, body.vb video, body.vb audio { max-width: 100%; }
body.vb p, body.vb li, body.vb span, body.vb a, body.vb label { overflow-wrap: anywhere; }

/* tap targets: at least 44x44 css px, grows with the font */
.vb-btn, body.vb button, body.vb input[type=button], body.vb input[type=submit] {
    min-height: 2.75rem;
    font-size: 1rem;
}

/* ---------- page skeleton ---------- */
.vb-page {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--vb-max-w);
    margin: 0 auto;
    padding: 0 var(--vb-gap);
    /* room for the fixed footer (measured) + a little air */
    padding-bottom: calc(var(--vb-footer-h) + 1rem);
}
.vb-page--wide { max-width: 72rem; }

/* ---------- top status bar (name | credits | rec time) ---------- */
.vb-topbar {
    /* scrolls away with the page: with a large system font a sticky bar
       plus the fixed footer would leave almost no room for the content */
    position: relative;
    z-index: 20;
    background: var(--vb-header-bg);
    padding: calc(0.5rem + var(--vb-safe-top)) var(--vb-gap) 0.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0,0,0,.08);
}
.vb-topbar__inner {
    max-width: var(--vb-max-w);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;            /* wraps instead of overflowing on big fonts */
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.75rem;
}
.vb-topbar__icons { display: flex; gap: 0.75rem; margin-inline-end: auto; }
.vb-topbar__icons a { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; }
.vb-topbar__icons img { width: 1.25rem; height: 1.25rem; object-fit: contain; }
.vb-stat { max-width: 100%; min-width: 0; overflow-wrap: anywhere; text-align: center; }
.vb-stat b { font-weight: 700; }
.vb-credit-flash { animation: vbFlash 1.2s ease 2; }
@keyframes vbFlash { 50% { background: #fde68a; border-radius: .4rem; } }
.vb-buy {
    display: inline-flex; align-items: center;
    min-height: 2.25rem; padding: 0 0.9rem;
    border-radius: 999px;
    background: var(--vb-primary); color: #fff !important;
    text-decoration: none; font-weight: 600; font-size: 0.85rem;
}

/* ---------- hero ---------- */
.vb-hero {
    text-align: center;
    padding: 1rem 0 0.5rem;
}
.vb-hero__logo { width: clamp(4rem, 22vw, 9rem); height: auto; display: block; margin: 0 auto 0.25rem; }
.vb-hero__title { margin: 0.25rem 0; }
.vb-hero__sub { color: var(--vb-muted); margin: 0; font-size: 0.95rem; }

/* ---------- cards / forms ---------- */
.vb-card {
    background: var(--vb-surface);
    border: 1px solid var(--vb-border);
    border-radius: var(--vb-radius);
    padding: var(--vb-gap);
    margin: var(--vb-gap) 0;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.vb-field { margin: 0 0 var(--vb-gap); }
.vb-field > label, .vb-label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.vb-input, .vb-select {
    width: 100%;
    min-height: 3rem;
    padding: 0.6rem 0.9rem;
    font-size: 1rem;           /* >=16px stops iOS from zooming on focus */
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    background: #fff;
    color: inherit;
}
.vb-select { padding-inline-end: 2rem; text-overflow: ellipsis; }

.vb-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--vb-primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.vb-btn:disabled, .vb-btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }
.vb-btn--ghost { background: transparent; color: var(--vb-text); border-color: #9ca3af; }
.vb-btn--block { width: 100%; }

.vb-msg { padding: 0.75rem 1rem; border-radius: 0.75rem; margin: var(--vb-gap) 0; }
.vb-msg--ok { background: #dcfce7; color: #14532d; }
.vb-msg--err { background: #fee2e2; color: #7f1d1d; }
.vb-msg--info { background: #e0f2fe; color: #0c4a6e; }

.vb-center { text-align: center; }
.vb-hidden { display: none !important; }

/* ---------- translator (main.html) ---------- */
.vb-flag {
    display: block;
    margin: 1rem auto;
    width: clamp(6rem, 38vw, 11rem);
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    -webkit-tap-highlight-color: transparent;
}
.vb-flag[src=""], .vb-flag:not([src]) { visibility: hidden; }
.vb-status { text-align: center; min-height: 4rem; }
.vb-status img { width: 3rem; height: auto; }
.vb-textarea-wrap { width: 100%; margin: 0 auto; border: 1px solid var(--vb-border); border-radius: .75rem; padding: .5rem; background: #fff; }
.vb-textarea-wrap textarea { width: 100%; min-height: 4rem; border: 0; font-size: 1rem; resize: vertical; }
.vb-audio { display: block; width: 100%; max-width: 22rem; margin: 1rem auto 0; }

.countdown-circle {
    width: 3.25rem; height: 3.25rem;
    background-color: #e74c3c;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.5rem; font-weight: bold; color: #fff;
    box-shadow: 0 8px 16px rgba(0,0,0,.2);
    transition: transform .1s ease;
    margin: auto;
    cursor: pointer;
}
.countdown-circle.pulse { transform: scale(1.1); }
.voice-bars { display: flex; justify-content: center; align-items: flex-end; gap: 2px; height: 3rem; width: min(12.5rem, 80%); margin: .6rem auto; }
.voice-bar { flex: 1 1 0; max-width: 1rem; background-color: #4CAF50; transition: height .5s ease-in-out; height: 4%; }

/* ---------- modal / welcome overlay ---------- */
.vb-overlay {
    position: fixed; inset: 0;
    z-index: 100;
    background: rgba(55,65,81,.96);
    color: #fff;
    overflow-y: auto;                    /* scrolls when the font is very large */
    -webkit-overflow-scrolling: touch;
    padding: calc(1rem + var(--vb-safe-top)) 1.25rem calc(1rem + var(--vb-safe-bottom));
}
.vb-overlay__box { max-width: var(--vb-max-w); margin: 0 auto; }
.vb-overlay__close {
    float: right;
    width: 2.75rem; height: 2.75rem; border-radius: 50%;
    border: 0; background: #fff; color: #374151;
    font-size: 1.6rem; line-height: 1; cursor: pointer;
}

/* ---------- pricing (packages.aspx) ---------- */
.vb-plans { display: grid; gap: var(--vb-gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.vb-plan { display: flex; flex-direction: column; text-align: center; }
.vb-plan--featured { border: 2px solid var(--vb-primary); }
.vb-plan__price { font-size: 2rem; font-weight: 800; margin: .25rem 0 .75rem; }
.vb-plan ul { text-align: start; padding-inline-start: 1.25rem; margin: 0 0 1rem; flex: 1; }
.vb-plan li { margin-bottom: .35rem; }

/* ---------- PayMe hosted fields (order.aspx) ---------- */
.vb-pay-grid { display: grid; gap: 0 var(--vb-gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.vb-hosted { min-height: 3rem; padding: .35rem .5rem; border: 1px solid #cbd5e1; border-radius: .75rem; background: #fff; }
.vb-hosted iframe { width: 100% !important; min-height: 2.25rem; }
.has-error .vb-hosted { border-color: var(--vb-danger); }
.help-block { color: var(--vb-danger); font-size: .85rem; margin: .25rem 0 0; }
.vb-secure { display: flex; align-items: center; justify-content: center; gap: .4rem; color: var(--vb-muted); font-size: .85rem; }

/* ---------- fixed footer ---------- */
.vb-footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    background: var(--vb-footer-bg);
    color: var(--vb-footer-text);
    text-align: center;
    /* grows with the user's font, but only up to ~15px so the bar stays slim */
    font-size: clamp(11px, 0.8rem, 15px);
    line-height: 1.35;
    padding: 0.35rem calc(0.75rem + var(--vb-safe-right)) calc(0.45rem + var(--vb-safe-bottom)) calc(0.75rem + var(--vb-safe-left));
    box-shadow: 0 -2px 8px rgba(0,0,0,.12);
}
.vb-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 .9rem; }
.vb-footer nav > * { display: inline-block; padding: .2rem 0; }
.vb-footer a { color: inherit; text-decoration: none; }
.vb-footer a:hover, .vb-footer a:focus { text-decoration: underline; }

/* When the on-screen keyboard is open the visible viewport shrinks a lot;
   layout.js adds this class so the footer does not cover the input. */
.vb-keyboard-open .vb-footer { display: none; }

/* very small or zoomed screens */
@media (max-width: 22rem) {
    :root { --vb-gap: .75rem; }
    .vb-topbar { font-size: .85rem; }
}
/* landscape phones: keep the footer slim */
@media (max-height: 30rem) and (orientation: landscape) {
    .vb-footer { font-size: .75rem; padding-top: .25rem; }
    .vb-hero__logo { width: 3.5rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
