/* ═══════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --blue-deep:       #1255a0;
    --blue-mid:        #1d7cc4;
    --blue-wave-back:  #1565a8;
    --blue-wave-front: #3da8e8;
    --blue-light:      #5bc8f5;
    --white:           #ffffff;
    --text-dark:       #1a3a5c;
    --text-muted:      #777;
    --input-bg:        #f0f2f5;

    --water-transition: 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    --page-transition:  0.45s ease;

    /* Altura das ondas (ajustada por breakpoint) */
    --wave-height: 70px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
    background: #fff;
    color: var(--text-dark);
}

/* ═══════════════════════════════════════
   ÁGUA ANIMADA (background global)
═══════════════════════════════════════ */
.water-bg {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    transition: height var(--water-transition);
    will-change: height;
}

/* Níveis de água por página.
   dvh (dynamic viewport height) evita o salto causado pela barra de URL
   do iOS Safari. vh é fallback para navegadores antigos. */
.water-bg.level-0 { height: 0; }
.water-bg.level-1 { height: 26vh; height: 26dvh; }
.water-bg.level-2 { height: 46vh; height: 46dvh; }
.water-bg.level-3 { height: 88vh; height: 88dvh; }

/* Wrapper das ondas – topo da coluna d'água.
   Altura definida via variável CSS para adaptação por breakpoint sem bug. */
.waves-wrapper {
    position: relative;
    width: 100%;
    height: var(--wave-height, 70px);
    flex-shrink: 0;
    overflow: hidden;
}

/* Cada SVG tem 200% de largura para o loop seamless.
   preserveAspectRatio="none" + 200% de width pode gerar sub-pixel gap
   em algumas resoluções; compensado pelo border-top do water-body. */
.wave {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: var(--wave-height, 70px);
}

.wave-back {
    fill: var(--blue-wave-back);
    animation: waveLeft 9s linear infinite;
    opacity: 0.85;
}

.wave-front {
    fill: var(--blue-wave-front);
    animation: waveRight 6s linear infinite;
}

/* Ondas: -50% = desloca 1 ciclo completo → loop perfeito */
@keyframes waveLeft {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}
@keyframes waveRight {
    from { transform: translateX(-50%); }
    to   { transform: translateX(0); }
}

/* Corpo sólido da água abaixo das ondas.
   Overlap generoso cobre gap de sub-pixel do SVG esticado no iOS Safari. */
.water-body {
    flex: 1;
    background: linear-gradient(to bottom, var(--blue-wave-front) 0%, var(--blue-deep) 100%);
    border-top: 10px solid var(--blue-wave-front);
    margin-top: -10px;
    position: relative;
    z-index: 1;
}

/* ═══════════════════════════════════════
   PÁGINAS
═══════════════════════════════════════ */
.page {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--page-transition);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page.active {
    animation: paginaEntrar 0.28s ease forwards;
    pointer-events: all;
}

@keyframes paginaEntrar {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ═══════════════════════════════════════
   CONTEÚDO INTERNO (págs 1 e 2)
═══════════════════════════════════════ */
.page-inner {
    width: 100%;
    max-width: 440px;
    padding: 28px 26px 28vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Páginas 1 e 2: sem scroll — tudo deve caber na tela */
#page1, #page2 {
    overflow: hidden;
}

.page-inner--centered {
    align-items: center;
    text-align: center;
    justify-content: flex-start;
    padding-top: 8vh;
    padding-bottom: 52vh;
}

/* ═══════════════════════════════════════
   LOGO / COPO CARD (págs 1 e 2)
═══════════════════════════════════════ */
.logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.logo-img {
    width: 50px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(61,168,232,0.35));
}

.cup-card {
    background: transparent;
    border-radius: 18px;
    padding: 14px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.logo-cup {
    width: 50px;
    height: auto;
    display: block;
}

/* ═══════════════════════════════════════
   TIPOGRAFIA
═══════════════════════════════════════ */
.main-title {
    font-size: clamp(18px, 5vw, 25px);
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
    line-height: 1.3;
    margin-bottom: 16px;
}

.step-title {
    font-size: clamp(22px, 6vw, 28px);
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 24px;
    line-height: 1.3;
}

/* ═══════════════════════════════════════
   FORMULÁRIO (pág 1)
═══════════════════════════════════════ */
.form-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input {
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid transparent;
    background: var(--input-bg);
    font-family: inherit;
    font-size: 16px;
    color: #333;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--blue-light);
}

.form-group input.input-error {
    border-color: #ef4444;
    background: #fff5f5;
}

.field-error-msg {
    font-size: 11.5px;
    color: #ef4444;
    font-weight: 500;
    margin-top: 2px;
}




/* ═══════════════════════════════════════
   INPUT DE PESO (pág 2)
═══════════════════════════════════════ */
.weight-input {
    width: 175px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 2px solid transparent;
    background: var(--input-bg);
    font-family: inherit;
    font-size: 30px;
    font-weight: 600;
    color: #333;
    text-align: center;
    outline: none;
    margin-bottom: 28px;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}
.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.weight-input:focus {
    border-color: var(--blue-light);
}

/* ═══════════════════════════════════════
   BOTÕES
═══════════════════════════════════════ */
.btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 16px 32px;
    border-radius: 50px;
    border: none;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    letter-spacing: 0.3px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
    background: var(--blue-light);
    color: var(--white);
    box-shadow: 0 6px 24px rgba(91, 200, 245, 0.45);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(91, 200, 245, 0.55);
}

.btn-white {
    background: var(--white);
    color: var(--blue-deep);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    font-weight: 700;
}
.btn-white:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}

/* ═══════════════════════════════════════
   PÁGINA 3 – RESULTADO
═══════════════════════════════════════ */
.page--result {
    background: transparent;
    justify-content: flex-start;
}

.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* Empurra conteúdo para abaixo da linha d'água.
       Fórmula: (espaço branco no topo) + (altura da onda) + (buffer).
       Espaço branco = 100vh - altura do level-3 (padrão 88vh → 12vh). */
    padding-top: calc(12vh + var(--wave-height) + 24px);
    padding-top: calc(12dvh + var(--wave-height) + 24px);
    padding-bottom: 48px;
    padding-left: 28px;
    padding-right: 28px;
    color: var(--white);
    max-width: 420px;
    width: 100%;
}

.result-title {
    font-size: clamp(16px, 4vw, 20px);
    font-weight: 600;
    opacity: 0.95;
    margin-bottom: 6px;
}

.result-number {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 36px;
    line-height: 1;
}

.result-number #resultNum {
    font-size: clamp(60px, 18vw, 88px);
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1;
}

.result-unit {
    font-size: clamp(20px, 5vw, 26px);
    font-weight: 500;
    padding-bottom: 10px;
}

.result-box {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    margin-bottom: 32px;
    max-width: 320px;
}

.result-icon {
    width: 42px;
    height: auto;
    flex-shrink: 0;
    filter: brightness(0) invert(1) opacity(0.88);
}

.result-box p {
    font-size: 13.5px;
    line-height: 1.55;
    font-weight: 400;
    opacity: 0.95;
}

/* ═══════════════════════════════════════
   BOTÃO VOLTAR (pág 2)
═══════════════════════════════════════ */
.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background 0.18s, color 0.18s, transform 0.15s;
    z-index: 5;
}

.btn-back svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-back:hover {
    background: rgba(61, 168, 232, 0.12);
    color: var(--blue-mid);
    transform: translateX(-2px);
}

.btn-back:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════
   ANIMAÇÃO DE SHAKE (input inválido)
═══════════════════════════════════════ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-9px); }
    40%       { transform: translateX(9px); }
    60%       { transform: translateX(-6px); }
    80%       { transform: translateX(6px); }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVIDADE – Breakpoints por categoria de dispositivo
   ═══════════════════════════════════════════════════════════════════
   Cobertura:
     • Phone XS    ≤ 360px (iPhone SE 1, Galaxy Fold fechado)
     • Phone S     361–390px (iPhone SE 2/3, 12 mini, 13 mini)
     • Phone M     391–430px (iPhone 12/13/14/15, Pro, Pro Max)
     • Phone L     431–599px (phones grandes em landscape estreito)
     • Tablet S    600–767px (small tablets, landscape de phones)
     • Tablet M    768–1023px (iPad portrait)
     • Desktop S   1024–1439px (iPad landscape, laptops)
     • Desktop L   ≥ 1440px (monitores)

   Combinações com altura para evitar bug em telas curtas.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── PHONE XS (≤ 360px) iPhone SE 1ª gen, Galaxy Fold fechado ─── */
@media (max-width: 360px) {
    :root { --wave-height: 50px; }
    .water-bg.level-1 { height: 55px; }
    .water-bg.level-2 { height: 17vh; height: 17dvh; }
    .water-bg.level-3 { height: 72vh; height: 72dvh; }

    /* 100 - 72 = 28vh de espaço branco no topo */
    .result-content {
        padding-top: calc(28vh + var(--wave-height) + 20px);
        padding-top: calc(28dvh + var(--wave-height) + 20px);
    }

    .page-inner {
        padding: 16px 18px 18vh;
    }
    .page-inner--centered {
        padding-top: 4vh;
        padding-bottom: 22vh;
    }
    .logo-cup    { width: 42px; }
    .logo-wrap   { margin-bottom: 6px; }
    .cup-card    { padding: 6px 10px; }
    .main-title  { margin-bottom: 10px; font-size: 17px; }
    .step-title  { font-size: 20px; margin-bottom: 18px; }
    .form-fields { gap: 6px; margin-bottom: 12px; }
    .form-group input { padding: 11px 14px; font-size: 15px; }
    .weight-input { width: 150px; font-size: 26px; padding: 12px 16px; margin-bottom: 20px; }
    .btn { padding: 13px 24px; font-size: 15px; }
}

/* ─── PHONE S (361–390px) iPhone SE 2/3, 12 mini, 13 mini ─── */
@media (min-width: 361px) and (max-width: 390px) {
    :root { --wave-height: 60px; }
    .water-bg.level-1 { height: 65px; }
    .water-bg.level-2 { height: 19vh; height: 19dvh; }
    .water-bg.level-3 { height: 78vh; height: 78dvh; }

    /* 100 - 78 = 22vh */
    .result-content {
        padding-top: calc(22vh + var(--wave-height) + 20px);
        padding-top: calc(22dvh + var(--wave-height) + 20px);
    }

    .page-inner--centered {
        padding-top: 5vh;
        padding-bottom: 26vh;
    }
}

/* ─── PHONE M (391–430px) iPhone 12/13/14/15, Pro, Pro Max ─── */
@media (min-width: 391px) and (max-width: 430px) {
    :root { --wave-height: 70px; }
    .water-bg.level-1 { height: 70px; }
    .water-bg.level-2 { height: 20vh; height: 20dvh; }
    .water-bg.level-3 { height: 82vh; height: 82dvh; }

    /* 100 - 82 = 18vh */
    .result-content {
        padding-top: calc(18vh + var(--wave-height) + 22px);
        padding-top: calc(18dvh + var(--wave-height) + 22px);
    }

    .page-inner--centered {
        padding-top: 6vh;
        padding-bottom: 28vh;
    }
}

/* ─── PHONE L (431–599px) phones grandes / landscape estreito ─── */
@media (min-width: 431px) and (max-width: 599px) {
    :root { --wave-height: 75px; }
    .water-bg.level-1 { height: 22vh; height: 22dvh; }
    .water-bg.level-2 { height: 42vh; height: 42dvh; }
    .water-bg.level-3 { height: 85vh; height: 85dvh; }

    /* 100 - 85 = 15vh */
    .result-content {
        padding-top: calc(15vh + var(--wave-height) + 24px);
        padding-top: calc(15dvh + var(--wave-height) + 24px);
    }
}

/* ─── TABLET S (600–767px) tablets pequenos ─── */
@media (min-width: 600px) and (max-width: 767px) {
    :root { --wave-height: 85px; }
    .water-bg.level-1 { height: 24vh; height: 24dvh; }
    .water-bg.level-2 { height: 46vh; height: 46dvh; }
    .water-bg.level-3 { height: 86vh; height: 86dvh; }

    /* 100 - 86 = 14vh */
    .result-content {
        padding-top: calc(14vh + var(--wave-height) + 24px);
        padding-top: calc(14dvh + var(--wave-height) + 24px);
    }

    .page-inner { padding: 36px 32px 30vh; }
}

/* ─── TABLET M (768–1023px) iPad portrait ─── */
@media (min-width: 768px) and (max-width: 1023px) {
    :root { --wave-height: 100px; }
    .water-bg.level-1 { height: 24vh; height: 24dvh; }
    .water-bg.level-2 { height: 48vh; height: 48dvh; }
    .water-bg.level-3 { height: 86vh; height: 86dvh; }

    /* 100 - 86 = 14vh */
    .result-content {
        padding-top: calc(14vh + var(--wave-height) + 24px);
        padding-top: calc(14dvh + var(--wave-height) + 24px);
    }

    .page-inner { padding: 40px 36px 32vh; }
    .page-inner--centered { padding-bottom: 50vh; }
    .main-title { font-size: 24px; }
}

/* ─── DESKTOP S (1024–1439px) iPad landscape, laptops ─── */
@media (min-width: 1024px) and (max-width: 1439px) {
    :root { --wave-height: 120px; }
    .water-bg.level-1 { height: 25vh; height: 25dvh; }
    .water-bg.level-2 { height: 52vh; height: 52dvh; }
    .water-bg.level-3 { height: 88vh; height: 88dvh; }

    .page-inner { padding: 44px 40px 36vh; }
    .page-inner--centered { padding-bottom: 56vh; }
    .main-title { font-size: 26px; }
    /* 100 - 88 = 12vh */
    .result-content {
        padding-top: calc(12vh + var(--wave-height) + 28px);
        padding-top: calc(12dvh + var(--wave-height) + 28px);
        padding-left: 40px;
        padding-right: 40px;
    }
}

/* ─── DESKTOP L (≥ 1440px) monitores grandes ─── */
@media (min-width: 1440px) {
    :root { --wave-height: 140px; }
    .water-bg.level-1 { height: 26vh; height: 26dvh; }
    .water-bg.level-2 { height: 54vh; height: 54dvh; }
    .water-bg.level-3 { height: 90vh; height: 90dvh; }

    .page-inner { padding: 48px 44px 38vh; }
    .page-inner--centered { padding-bottom: 58vh; }
    .main-title { font-size: 28px; }
    /* 100 - 90 = 10vh */
    .result-content {
        padding-top: calc(10vh + var(--wave-height) + 32px);
        padding-top: calc(10dvh + var(--wave-height) + 32px);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   AJUSTES POR ALTURA (combina com largura para evitar bugs)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Phone altura média (601–700px) iPhone 8, SE 2 ─── */
@media (max-height: 700px) and (max-width: 430px) {
    .water-bg.level-1 { height: 58px; }
    .water-bg.level-2 { height: 17vh; height: 17dvh; }
    .water-bg.level-3 { height: 76vh; height: 76dvh; }

    /* 100 - 76 = 24vh */
    .result-content {
        padding-top: calc(24vh + var(--wave-height) + 18px);
        padding-top: calc(24dvh + var(--wave-height) + 18px);
    }

    .page-inner {
        padding-top: 14px;
        padding-bottom: 14vh;
    }
    .page-inner--centered {
        padding-top: 3vh;
        padding-bottom: 22vh;
    }
    .logo-wrap   { margin-bottom: 6px; }
    .cup-card    { padding: 6px 10px; }
    .main-title  { margin-bottom: 10px; }
    .form-fields { gap: 6px; margin-bottom: 12px; }
}

/* ─── Phone altura baixa (≤ 600px) iPhone SE 1 ─── */
@media (max-height: 600px) and (max-width: 430px) {
    :root { --wave-height: 44px; }
    .water-bg.level-1 { height: 48px; }
    .water-bg.level-2 { height: 14vh; height: 14dvh; }
    .water-bg.level-3 { height: 70vh; height: 70dvh; }

    /* 100 - 70 = 30vh (iPhone SE: texto precisa ficar bem abaixo da onda) */
    .result-content {
        padding-top: calc(30vh + var(--wave-height) + 16px);
        padding-top: calc(30dvh + var(--wave-height) + 16px);
        padding-bottom: 24px;
    }

    .page-inner {
        padding-top: 10px;
        padding-bottom: 10vh;
    }
    .page-inner--centered {
        padding-top: 2vh;
        padding-bottom: 18vh;
    }
    .main-title  { font-size: 16px; margin-bottom: 8px; }
    .step-title  { font-size: 19px; margin-bottom: 14px; }
    .weight-input { margin-bottom: 16px; }
    .result-number { margin-bottom: 18px; }
    .result-box    { padding: 12px 14px; margin-bottom: 18px; }
}

/* ─── Landscape em phone (altura ≤ 500px, qualquer largura mobile) ─── */
@media (max-height: 500px) and (orientation: landscape) {
    :root { --wave-height: 40px; }
    .water-bg.level-1 { height: 40px; }
    .water-bg.level-2 { height: 30vh; height: 30dvh; }
    .water-bg.level-3 { height: 75vh; height: 75dvh; }

    /* 100 - 75 = 25vh */
    .result-content {
        padding-top: calc(25vh + var(--wave-height) + 10px);
        padding-top: calc(25dvh + var(--wave-height) + 10px);
        padding-bottom: 16px;
    }

    .page-inner {
        padding: 10px 20px 6vh;
    }
    .page-inner--centered {
        padding-top: 2vh;
        padding-bottom: 14vh;
    }
    .logo-cup    { width: 40px; }
    .logo-wrap   { margin-bottom: 4px; }
    .cup-card    { padding: 4px 8px; }
    .main-title  { font-size: 16px; margin-bottom: 8px; }
    .step-title  { font-size: 18px; margin-bottom: 12px; }
    .form-fields { gap: 5px; margin-bottom: 10px; }
    .form-group input { padding: 9px 12px; font-size: 14px; }
    .weight-input { width: 130px; font-size: 22px; padding: 8px 12px; margin-bottom: 12px; }
    .btn { padding: 11px 22px; font-size: 14px; }
}

/* Respeita preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    .wave-back, .wave-front { animation: none; }
    .water-bg { transition: none; }
    .page { transition: none; }
}
