/* Giao diện đơn giản, nút to để bé dễ chạm — tối ưu mobile */
* { box-sizing: border-box; }

:root {
    --font-en: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-lo: "Noto Sans Lao", "Inter", system-ui, sans-serif;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

html, body {
    min-height: 100%;
    min-height: 100dvh;
}

.install-banner {
    background: rgba(34, 197, 94, 0.15);
    border-bottom: 1px solid rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    font-size: 13px;
    text-align: center;
    font-family: var(--font-en);
}

body {
    margin: 0;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    font-family: var(--font-en);
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 45%, #0b1220 100%);
    color: #e5e7eb;
    overscroll-behavior-y: contain;
}

.wrap {
    width: min(980px, calc(100% - 24px));
    margin: 0 auto;
}

@media (max-width: 480px) {
    .wrap {
        width: 100%;
        padding-left: max(10px, env(safe-area-inset-left, 0px));
        padding-right: max(10px, env(safe-area-inset-right, 0px));
    }

    /* Chỉ phần nội dung: carousel sát mép (chỉ safe-area); header vẫn có lề */
    main.wrap {
        padding-left: max(0px, env(safe-area-inset-left, 0px));
        padding-right: max(0px, env(safe-area-inset-right, 0px));
    }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    /* Tránh nội dung chui dưới notch / status bar */
    padding-top: env(safe-area-inset-top, 0);
}

.topbar .wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 0;
    flex-wrap: wrap;
    text-align: center;
}

@media (max-width: 640px) {
    .topbar .wrap {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 10px 0 12px 0;
    }

    .brand__title {
        font-size: 17px;
    }
}

/* Điện thoại: thanh trên gọn tối đa — ưu tiên không gian cho thẻ */
@media (max-width: 480px) {
    .topbar .wrap {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 4px 8px;
        padding: max(2px, env(safe-area-inset-top, 0px)) 0 4px 0;
    }

    .brand {
        gap: 6px;
    }

    .brand__logo {
        width: 28px;
        height: 28px;
        border-radius: 9px;
        font-size: 11px;
    }

    .brand__title {
        font-size: 12px;
        line-height: 1.15;
        font-weight: 700;
    }

    .brand__subtitle {
        display: none;
    }

    .nav--scroll {
        padding: 0 0 2px 0;
        margin: 0 -2px;
    }

    .nav__item {
        padding: 7px 10px;
        min-height: 40px;
        border-radius: 11px;
        font-size: 11px;
    }

    .panel {
        padding: 6px 0 max(16px, env(safe-area-inset-bottom, 0px)) 0;
    }

    .panel__head {
        gap: 6px;
        margin-bottom: 0;
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
    }

    .panel__title {
        font-size: 13px;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .panel__hint {
        font-size: 10px;
        line-height: 1.3;
        margin: 2px auto 6px;
        max-width: 100%;
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
    }

    .btn--all {
        font-size: 10px;
        gap: 3px;
        padding: 6px 8px;
        min-height: 0;
        border-radius: 10px;
    }

    .btn--all .icon-speak {
        width: 18px;
        height: 18px;
    }

    /* Carousel: gần full-width màn hình, snap ổn định */
    .carousel {
        gap: 0;
        padding: 2px max(6px, env(safe-area-inset-left, 0px)) 0 max(6px, env(safe-area-inset-right, 0px));
        margin: 0;
        scroll-padding-inline: max(6px, env(safe-area-inset-left, 0px));
    }

    .carousel-dots {
        gap: 6px;
        padding: 8px max(12px, env(safe-area-inset-left, 0px)) 4px max(12px, env(safe-area-inset-right, 0px));
    }

    .carousel-dots button {
        width: 8px;
        height: 8px;
    }
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand__text {
    text-align: center;
}

.brand__logo {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-en);
    font-weight: 800;
    letter-spacing: 0.2px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(139, 92, 246, 0.95));
    color: white;
}

.brand__title {
    margin: 0;
    font-size: 18px;
    line-height: 1.15;
    font-family: var(--font-en);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand__subtitle {
    margin: 5px 0 0 0;
    font-size: 12px;
    font-weight: 500;
    color: rgba(229, 231, 235, 0.55);
    letter-spacing: 0.02em;
}

.nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Chủ đề: cuộn ngang trên điện thoại, không xuống dòng lộn xộn */
.nav--scroll {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 4px 2px 8px 2px;
    margin: 0 -4px;
    scrollbar-width: none;
}

.nav--scroll::-webkit-scrollbar {
    display: none;
}

.nav__item {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    flex: 0 0 auto;
    scroll-snap-align: start;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.12);
    font-family: var(--font-en);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    max-width: 11rem;
    text-align: center;
}

/* Chỉ tablet hẹp — tránh ghi đè bản ≤480px */
@media (min-width: 481px) and (max-width: 640px) {
    .nav__item {
        padding: 12px 16px;
        min-height: 48px;
        border-radius: 16px;
        font-size: 13px;
    }
}

.nav__item--active {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

.panel {
    padding: 16px 0 max(30px, env(safe-area-inset-bottom, 0px)) 0;
    text-align: center;
}

.panel__head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.panel__title {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.03em;
    font-weight: 700;
    font-family: var(--font-en);
    text-align: center;
}

.panel__hint {
    margin: 8px 0 12px 0;
    line-height: 1.45;
    font-family: var(--font-en);
    font-size: 13px;
    font-weight: 500;
    color: rgba(229, 231, 235, 0.78);
    letter-spacing: -0.01em;
    text-align: center;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

.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;
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-en);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
}

.btn:focus {
    outline: 3px solid rgba(59, 130, 246, 0.35);
    outline-offset: 2px;
}

.btn--primary {
    background: rgba(255, 255, 255, 0.92);
    color: #0b1220;
}

.btn--primary:hover {
    background: #ffffff;
}

.btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.92);
}

.btn--secondary:hover {
    background: rgba(255, 255, 255, 0.10);
}

/* Cuộn ngang / vuốt: một thẻ mỗi “trang” */
.carousel {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-padding-inline: 4px;
    padding: 4px 2px 0 2px;
    margin: 0 -2px;
    outline: none;
}

.carousel:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.45);
    outline-offset: 4px;
    border-radius: 12px;
}

.carousel::-webkit-scrollbar {
    display: none;
}

.carousel__slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    min-width: 0;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 8px 6px;
}

.carousel-dots[data-hidden="1"] {
    display: none;
}

.carousel-dots button {
    width: 9px;
    height: 9px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.carousel-dots button[aria-current="true"] {
    background: rgba(255, 255, 255, 0.88);
    transform: scale(1.15);
}

.card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 12px 12px 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: min(300px, 50vh);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    /* Cho phép trình duyệt cuộn carousel khi vuốt ngang */
    touch-action: pan-x pan-y;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
    .card {
        min-height: 0;
        padding: 6px 4px 8px 4px;
        border-radius: 14px;
    }
}

.card::before {
    content: "";
    position: absolute;
    inset: -2px -2px auto -2px;
    height: 70px;
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0) 55%),
                linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 4px 4px;
    min-height: 0;
    flex: 1 1 auto;
    flex-shrink: 1;
    width: 100%;
}

.card__icon svg {
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.28));
    width: auto;
    height: auto;
    max-width: min(240px, 100%);
    max-height: min(220px, 32vh);
}

.card__icon .card__img {
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.28));
    width: auto;
    height: auto;
    max-width: min(240px, 100%);
    max-height: min(220px, 32vh);
    object-fit: contain;
}

@media (max-width: 480px) {
    .card__icon {
        padding: 2px 0 4px 0;
    }

    /* Ảnh / SVG gần full-width trong thẻ (trừ padding thẻ) */
    .card__icon .card__img {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: min(72vh, 92vw);
        object-fit: contain;
    }
}

.card__icon svg text {
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

@media (max-width: 480px) {
    .card__icon svg {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: min(72vh, 92vw);
    }
}

/* English + Lao under the picture — must not shrink (was clipped with grid 1fr + overflow) */
.card__caption {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
    flex: 0 0 auto;
    flex-shrink: 0;
    padding: 8px 8px 4px 8px;
    position: relative;
    z-index: 2;
}

.card__en {
    font-family: var(--font-en);
    font-size: 17px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: 0.03em;
    text-align: center;
    width: 100%;
    margin: 0;
    text-transform: capitalize;
}

.card__lo {
    font-family: var(--font-lo);
    font-size: 12px;
    font-weight: 500;
    color: rgba(229, 231, 235, 0.62);
    line-height: 1.45;
    font-feature-settings: "kern" 1;
    letter-spacing: 0.02em;
    text-align: center;
    width: 100%;
    margin: 0;
}

@media (max-width: 480px) {
    .card__caption {
        padding: 6px 4px 2px;
    }

    .card__en {
        font-size: 17px;
    }

    .card__lo {
        font-size: 11px;
    }
}

.card__actions {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 4px;
    flex: 0 0 auto;
    flex-shrink: 0;
}

.icon-speak {
    display: block;
    flex-shrink: 0;
}

.speak-btn {
    width: 100%;
    border-radius: 18px;
    padding: 14px 16px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.88));
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0b1220;
}

.speak-btn:active {
    transform: translateY(1px);
}

.btn--all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

@media (max-width: 480px) {
    .speak-btn {
        min-height: 54px;
        padding: 16px 18px;
        border-radius: 20px;
    }

    .speak-btn .icon-speak {
        width: 30px;
        height: 30px;
    }

    .btn--secondary {
        min-height: 48px;
        padding: 12px 14px;
        font-size: 14px;
    }
}


