/* ================================================================
   BRA Camisetas — Unbox (Slides 1-2)
   Mobile-first · CSS Custom Properties · Responsive Breakpoints
   ================================================================ */

/* ─── Design Tokens ─── */
:root {
    /* Colors */
    --color-primary: #0081cc;
    --color-text: #000000;
    --color-bg: #ffffff;
    --color-dot-inactive: #d0d0d0;
    --color-dot-active: #000000;
    --color-dot-disabled: #e8e8e8;
    --color-btn-back-bg: #f0f0f0;
    --color-scanner-border: #0081cc;
    --color-scanner-bg: #000000;
    --color-status-bg: rgba(0, 0, 0, 0.6);
    --color-status-success: rgba(46, 125, 50, 0.9);
    --color-status-error: rgba(211, 47, 47, 0.9);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Safe-areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Layout */
    --header-height: 3.5rem;
    --pagination-offset: 1rem;
    --footer-height: 4.5rem;
    --gutter: clamp(1rem, 5vw, 2.5rem);

    /* Slide count — 2 slides neste HTML */
    --slide-count: 2;

    /* Typography */
    --font-family: 'Arial', 'Helvetica Neue', sans-serif;
    --fs-title: clamp(1.15rem, 4.5vw, 1.75rem);
    --fs-subtitle: clamp(0.85rem, 3.2vw, 1.15rem);

    /* Transitions */
    --ease-slide: cubic-bezier(0.25, 0.8, 0.25, 1);
    --duration-slide: 0.35s;
    --duration-fast: 0.2s;

    /* Tuning */
    --illustration-gap: 2vh;
}

/* ─── Reset ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ─── Base ─── */
html {
    height: 100%;
    height: 100dvh;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
    line-height: 1.4;
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ─── Slider Architecture ─── */
#app-slider {
    display: flex;
    width: calc(100vw * var(--slide-count));
    height: 100%;
    height: 100dvh;
    transition: transform var(--duration-slide) var(--ease-slide);
    transform: translateX(0);
    position: relative;
    z-index: 10;
}

.slide {
    width: 100vw;
    height: 100%;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ─── App Container ─── */
.app-container {
    width: 100%;
    height: 100%;
    padding-top: calc(var(--header-height) + var(--pagination-offset) + var(--safe-top) + 3.5rem);
    padding-bottom: calc(var(--footer-height) + var(--safe-bottom) + 1.5rem);
    padding-inline: var(--gutter);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 0;
}

/* ─── Header ─── */
.header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: calc(0.625rem + var(--safe-top)) var(--gutter) 0;
    z-index: 50;
    height: var(--header-height);
}

.logo {
    width: clamp(7rem, 35vw, 11.25rem);
    height: auto;
    max-height: calc(var(--header-height) - 0.5rem);
    object-fit: contain;
}

/* ─── Pagination — CSS Dots ─── */
.pagination {
    position: absolute;
    top: calc(var(--header-height) + var(--safe-top) + var(--pagination-offset));
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
}

.dots {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    border: none;
    padding: 0;
    background-color: var(--color-dot-inactive);
    transition: background-color var(--duration-fast), transform var(--duration-fast);
    cursor: pointer;
    /* Área de toque mínima 44px via padding externo */
    position: relative;
}

.dot::before {
    content: '';
    position: absolute;
    inset: -0.875rem;
}

.dot--active {
    background-color: var(--color-dot-active);
    transform: scale(1.25);
}

.dot--disabled {
    background-color: var(--color-dot-disabled);
    cursor: default;
    opacity: 0.5;
}

/* ─── Typography ─── */
.main-title {
    font-size: var(--fs-title);
    text-align: center;
    line-height: 1.25;
    width: 100%;
    flex-shrink: 0;
    z-index: 10;
    font-weight: 700;
}

.sub-title {
    font-size: var(--fs-subtitle);
    text-align: center;
    font-weight: 400;
    flex-shrink: 0;
    z-index: 10;
    line-height: 1.35;
    max-width: 90%;
}

/* ─── Illustration Container ─── */
.illustration-container {
    width: 100%;
    margin-top: var(--illustration-gap);
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* ─── Parallax Scene ─── */
.parallax-scene {
    position: relative;
    overflow: hidden;
    aspect-ratio: 750.74 / 718.38;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    flex: 0 1 auto;
    align-self: center;
}

.parallax-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.parallax-scene.swiping .parallax-layer {
    transition: none;
}

.parallax-layer:first-child {
    position: relative;
}

/* ─── Footer ─── */
.footer {
    position: absolute;
    bottom: calc(0.9375rem + var(--safe-bottom));
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-inline: var(--gutter);
    z-index: 20;
    min-height: var(--footer-height);
}

.actions-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* ─── Buttons ─── */
.back-button {
    background-color: var(--color-btn-back-bg);
    border-radius: 0.75rem;
    color: var(--color-primary);
    padding: clamp(0.5rem, 2.5vmin, 0.875rem) clamp(1rem, 4vmin, 1.75rem);
    font-size: clamp(0.85rem, 3vmin, 1.1rem);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--duration-fast), transform var(--duration-fast);
    min-height: 2.75rem;
}

.next-button {
    transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
    padding: var(--space-xs);
    min-height: 2.75rem;
    min-width: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.next-button img {
    height: clamp(2.5rem, 9vmin, 3.75rem);
    width: auto;
}

.back-button:active,
.next-button:active {
    opacity: 0.7;
    transform: scale(0.96);
}

/* ─── QR Scanner (Slide 2) ─── */
/*
 * O #reader precisa ocupar a mesma LARGURA da parallax scene do slide 2.
 * A ALTURA é determinada pela câmera (4:3 ou 16:9) — não forçamos aspect-ratio
 * do SVG aqui, senão o feed fica esmagado/esticado.
 * max-height evita overflow sem distorcer.
 */
#reader {
    width: var(--reader-w, 100%);
    max-height: var(--reader-h, 100%);
    max-width: 100%;
    flex-shrink: 0;
    margin: 0 auto;
    display: none;
    border-radius: 1.25rem;
    overflow: hidden;
    border: 2px solid var(--color-scanner-border);
    position: relative;
    background-color: var(--color-scanner-bg);
}

/* Override html5-qrcode inline styles */
#reader * {
    max-width: 100% !important;
}

/* Scan region container */
#reader [id$="__scan_region"] {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow: hidden;
}

/* Esconder a moldura verde/shaded do viewfinder da lib */
#reader [id$="__scan_region"] > img,
#qr-shaded-region {
    display: none !important;
}

#reader video {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100%;
    object-fit: cover !important;
}

/* Hide scanner UI chrome */
#reader img,
#reader [id*="html5-qrcode-anchor"],
#reader [id*="html5-qrcode-button"],
#reader [id$="__dashboard"],
#reader [id$="__dashboard_section"],
#reader [id$="__dashboard_section_csr"],
#reader [id$="__dashboard_section_swaplink"],
#reader [style*="text-align: center"],
#reader span,
#reader a {
    display: none !important;
    border: none !important;
}

#qr-status {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-status-bg);
    color: #fff;
    border-radius: 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    z-index: 10;
    display: none;
    pointer-events: none;
    width: max-content;
    max-width: 90%;
}

/* ─── Hidden ─── */
[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */

@media (max-width: 374px) {
    :root {
        --header-height: 3rem;
        --fs-title: clamp(1rem, 5vw, 1.25rem);
        --fs-subtitle: clamp(0.75rem, 3.5vw, 0.95rem);
        --illustration-gap: 1vh;
    }

    .app-container {
        padding-top: calc(var(--header-height) + var(--pagination-offset) + var(--safe-top) + 2.5rem);
        padding-bottom: calc(var(--footer-height) + var(--safe-bottom) + 1rem);
    }

    .logo {
        width: clamp(5.5rem, 30vw, 8rem);
    }
}

@media (min-width: 375px) and (max-width: 479px) {
    :root {
        --illustration-gap: 2vh;
    }
}

@media (min-width: 480px) {
    :root {
        --fs-title: clamp(1.25rem, 3.5vw, 1.75rem);
        --fs-subtitle: clamp(0.9rem, 2.5vw, 1.15rem);
        --illustration-gap: 2.5vh;
    }

    #reader {
        max-width: 85%;
    }
}

@media (min-width: 768px) {
    :root {
        --header-height: 4rem;
        --footer-height: 5rem;
        --fs-title: clamp(1.5rem, 3vw, 2rem);
        --fs-subtitle: clamp(1rem, 2vw, 1.35rem);
        --illustration-gap: 3vh;
    }

    .app-container {
        max-width: 40rem;
        margin-inline: auto;
    }

    #reader {
        max-width: 70%;
    }

    .logo {
        width: clamp(8rem, 15vw, 11rem);
    }
}

@media (min-width: 1024px) {
    :root {
        --fs-title: clamp(1.5rem, 2.5vw, 2.25rem);
        --fs-subtitle: clamp(1rem, 1.5vw, 1.25rem);
    }

    .app-container {
        max-width: 36rem;
    }

    #reader {
        max-width: 60%;
    }
}

@media (min-width: 1440px) {
    .app-container {
        max-width: 32rem;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --header-height: 2.5rem;
        --footer-height: 3.5rem;
        --pagination-offset: 0.5rem;
        --fs-title: clamp(0.9rem, 3vh, 1.25rem);
        --fs-subtitle: clamp(0.75rem, 2.5vh, 1rem);
        --illustration-gap: 1vh;
    }

    .app-container {
        padding-top: calc(var(--header-height) + var(--pagination-offset) + var(--safe-top) + 2rem);
        padding-bottom: calc(var(--footer-height) + var(--safe-bottom) + 0.5rem);
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: var(--space-sm);
    }

    .main-title {
        width: 100%;
        flex-basis: 100%;
    }

    .illustration-container {
        flex: 1;
        max-width: 50%;
        margin-top: 0;
    }

    .sub-title {
        flex: 1;
        max-width: 45%;
        text-align: left;
    }

    .logo {
        max-height: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #app-slider {
        transition-duration: 0.01ms;
    }

    .back-button,
    .next-button {
        transition: none;
    }
}

@media (forced-colors: active) {
    .back-button {
        border: 1px solid ButtonText;
    }

    .next-button img,
    .logo {
        forced-color-adjust: none;
    }
}
