/* TOKEN FLOW STYLES — layered on base KV style.css */

@font-face {
    font-family: 'Faro';
    src: url('/assets/fonts/Faro.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

.center-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
    width: 80%;
    max-width: 400px;
}

/* ---- INPUT FLEX LAYOUT ---- */
.input-flow {
    position: absolute;
    top: 2%;
    bottom: 5%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 0 5%;
    overflow: visible;
    gap: clamp(4px, 1vh, 10px);
}

.input-tagline {
    width: clamp(280px, 65vw, 700px);
    flex-shrink: 0;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}

.name-input-area {
    width: 80%;
    max-width: 400px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Vị trí rương */
.input-chest-flow {
    width: clamp(350px, 70vw, 750px);
    margin-top: -5%;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
    animation: floatChestFlex 4s ease-in-out infinite;
}

/* Error page — class riêng, tách khỏi input */
.error-area {
    text-align: center;
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: 2rem;
}

.error-tagline {
    width: clamp(258px, 60vw, 644px);
    flex-shrink: 0;
    margin-bottom: -3%;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}

.error-chest {
    width: clamp(322px, 64vw, 690px);
    margin-top: -3%;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
    animation: floatChestFlex 4s ease-in-out infinite;
}

@keyframes floatChestFlex {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.01);
    }
}

.name-field {
    width: 100%;
    padding: 14px 18px;
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    border: 3px solid #ffd700;
    border-radius: 50px;
    outline: none;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.name-field:focus {
    border-color: #ff6b00;
}

.name-field::placeholder {
    color: #aaa;
}

/* ---- BUTTONS ---- */
.btn-primary {
    display: inline-block;
    width: auto;
    padding: 14px 48px;
    font-family: 'Faro', sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 700;
    color: #d1122a;
    -webkit-text-stroke: 1.5px #fff;
    paint-order: stroke fill;
    background: linear-gradient(180deg, #ffe066 0%, #ffd700 40%, #d4a800 100%);
    border: 3px solid #fff3a0;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    text-shadow: none;
    letter-spacing: 3px;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-glow {
    animation: glowPulse 1.5s ease-in-out infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(255, 107, 0, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(255, 107, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.3);
    }
}

/* ---- MESSAGE ---- */
.message-area {
    top: 45%;
}

.message-chest {
    width: 60%;
    max-width: 250px;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
    animation: floatChest 4s ease-in-out infinite;
    transform: translateX(0);
}

.message-text {
    color: #fff;
    font-size: clamp(1.1rem, 4vw, 1.6rem);
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    margin: 16px 0;
    line-height: 1.4;
}

/* ---- VIDEO FLOW ---- */
/* Mặc định: landscape (ngang) — text trái, video phải */
.video-flow {
    position: absolute;
    top: 12%;
    bottom: 8%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 0 16%;
    gap: 4%;
}

.video-header-block {
    flex: 1 1 50%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: stretch;
    justify-content: flex-start;
    padding-top: 3%;
    overflow: visible;
}

.video-text-group {
    padding-top: 5%;
}

.video-subtitle {
    font-family: 'Faro', sans-serif;
    color: #fff;
    font-size: clamp(1.6rem, 4vw, 3rem);
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    line-height: 1.3;
    margin: 0 0 0 0;
}

.video-name {
    font-family: 'Faro', sans-serif;
    color: #ffd700;
    font-size: clamp(1.8rem, 5vw, 3.8rem);
    font-weight: 700;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    margin: 8px 0 0;
    line-height: 1.2;
}

.video-tagline {
    width: clamp(200px, 40vw, 500px);
    margin-top: auto;
    margin-bottom: -15%;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.video-chest {
    width: clamp(250px, 50vw, 700px);
    margin-top: auto;
    margin-left: 4%;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
    animation: floatChestSimple 4s ease-in-out infinite;
}

@keyframes floatChestSimple {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.01);
    }
}

.video-scene {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    height: 100%;
    gap: 2%;
    min-height: 0;
}

.video-sparkles {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    flex-shrink: 0;
    color: #fff;
    gap: 8px;
}

.video-sparkles span {
    line-height: 1;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.video-sparkles span:nth-child(1) {
    font-size: clamp(1rem, 1.5vw, 1.6rem);
}

.video-sparkles span:nth-child(2) {
    font-size: clamp(0.6rem, 1vw, 1rem);
}

.video-sparkles span:nth-child(3) {
    font-size: clamp(0.8rem, 1.2vw, 1.3rem);
}

.video-wrapper {
    position: relative;
    aspect-ratio: 9 / 16;
    height: 90%;
    width: auto;
    max-width: 20vw;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border: 4px solid #ffd700;
    flex-shrink: 0;
    background: #000;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-placeholder p {
    color: #fff;
    text-align: center;
    padding: 20px;
}

.btn-mute-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffd700;
    border: 2px solid #ffd700;
    border-radius: 50%;
    cursor: pointer;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.video-replay-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 25;
}

.btn-replay {
    width: 64px;
    height: 64px;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid #ffd700;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.8rem;
    line-height: 1;
    margin-left: 3px;
    transition: transform 0.2s;
}

.btn-replay:hover {
    transform: scale(1.1);
}

.logo-small {
    width: 12% !important;
}

@media (max-aspect-ratio: 1/1) {
    .logo-small {
        width: 29% !important;
    }

    .logo-left.logo-small {
        top: 5%;
    }

    .logo-right.logo-small {
        top: 4%;
    }

    .input-flow {
        top: 18%;
        bottom: 15%;
        gap: 0;
        justify-content: flex-start;
    }

    .input-tagline {
        width: 80%;
        margin-top: 0;
    }

    .input-chest-flow {
        width: 105%;
        margin-top: -7%;
        position: relative;
        z-index: 2;
    }

    .error-area {
        margin-top: 15%;
    }

    .error-area .error-text {
        font-size: clamp(1.6rem, 7vw, 2.2rem);
        white-space: normal;
        line-height: 1.3;
    }

    .error-tagline {
        width: 75%;
        margin-top: auto;
    }

    .error-chest {
        width: 100%;
        margin-top: -7%;
        position: relative;
        z-index: 2;
    }

    .btn-primary {
        padding: 10px 32px;
        font-size: clamp(0.9rem, 3.5vw, 1.2rem);
        letter-spacing: 2px;
        white-space: nowrap;
    }

    .footer-no-crop {
        height: auto !important;
        width: 100% !important;
        object-fit: contain !important;
    }

    /* === Video View: mobile portrait === */
    .video-flow {
        flex-direction: column;
        top: 10%;
        bottom: 0;
        gap: 4px;
        padding: 0 3%;
        align-items: center;
    }

    .video-header-block {
        flex: 0 0 auto;
        align-items: center;
        text-align: center;
        width: 100%;
    }

    .video-text-group {
        padding-top: 0;
        width: 100%;
        text-align: center;
    }

    .video-subtitle {
        font-size: clamp(1.3rem, 5.5vw, 2.2rem);
        white-space: normal;
        max-width: 80%;
        text-align: center;
        margin: 0 auto;
    }

    .video-name {
        font-size: clamp(1.5rem, 6.5vw, 2.5rem);
    }

    .video-scene {
        flex-direction: column;
        align-items: center;
        height: auto;
        flex: 1;
        gap: 0;
    }

    .video-sparkles {
        display: none;
    }

    .video-tagline {
        display: none;
    }

    .video-chest {
        display: none;
    }

    .video-scene {
        flex: 1;
        min-height: 0;
    }

    .video-wrapper {
        width: 90vw;
        height: auto;
        max-height: 95%;
        max-width: 90%;
        flex: 0 0 auto;
    }
}

/* === Tablet/foldable portrait: tỉ lệ gần vuông, video cần cân đối === */
@media (max-aspect-ratio: 1/1) and (min-width: 500px) {
    .video-flow {
        top: 10%;
        bottom: 5%;
    }

    .video-header-block {
        flex: 0 0 auto;
        padding-top: 2%;
    }

    .video-subtitle {
        font-size: clamp(1.6rem, 3.5vw, 2.5rem);
    }

    .video-name {
        font-size: clamp(1.8rem, 4vw, 3rem);
    }

    .video-scene {
        flex: 1;
        min-height: 0;
        margin-top: 5%;
    }

    .video-wrapper {
        width: auto;
        height: 100%;
        max-width: 90%;
        max-height: 100%;
    }
}

/* === Màn hình ngang nhỏ hơn PC (chiều cao ≤ 850px) === */
@media (min-aspect-ratio: 1/1) and (max-height: 850px) {
    .input-flow {
        transform: scale(0.55);
        transform-origin: center center;
    }

    .video-subtitle {
        white-space: nowrap;
    }

    .video-flow {
        transform: scale(0.8);
        transform-origin: center top;
        top: 2%;
    }

    .video-header-block {
        transform: scale(0.8);
        transform-origin: center top;
        justify-content: flex-start;
        padding-top: 0;
    }

    .video-text-group {
        margin-top: 10%;
        margin-bottom: 17%;
    }

    .video-tagline {
        margin-top: 0;
        transform: translateY(-25%);
    }

    .video-chest {
        margin-top: 0;
    }

    .video-scene {
        margin-top: 35%;
    }

    .video-wrapper {
        transform: scale(1.3);
    }

    .logo-small {
        width: 10% !important;
    }
}

/* === Phone landscape (chiều cao ≤ 450px) === */
@media (min-aspect-ratio: 1/1) and (max-height: 450px) {
    .video-flow {
        transform: scale(0.7);
        transform-origin: center center;
    }

    .video-chest {
        display: none;
    }

    .logo-small {
        width: 14% !important;
    }
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffd700;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-text {
    color: #fff;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    margin-bottom: 16px;
    white-space: nowrap;
}

.kv-frame.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}