@font-face {
    font-family: 'Noto Sans Thai';
    src: url('/assets/ebook/fonts/NotoSansThai-Variable.ttf') format('truetype');
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

html:has(.home-portal),
body:has(.home-portal) {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

body:has(.home-portal) #header-main-wrapper {
    border-bottom-width: 0;
}

body:has(.home-portal) #main-content > div:first-child {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.home-portal {
    position: relative;
    isolation: isolate;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 0;
    padding: clamp(20px, 4dvh, 48px) clamp(12px, 4vw, 64px) max(20px, env(safe-area-inset-bottom));
    overflow: hidden;
    color: #fff;
    font-family: 'Noto Sans Thai', 'Inter', sans-serif;
    background: linear-gradient(180deg, #fc9942 0%, #e525d7 30%, #4361e9 60%, #45cab1 100%);
}

.home-portal::before,
.home-portal::after {
    content: '';
    position: absolute;
    z-index: -1;
    pointer-events: none;
}

.home-portal::before {
    inset: 0;
    background: radial-gradient(ellipse at 50% 45%, #fff3 0%, #fff0 60%);
}

.home-portal::after {
    width: min(74vw, 1050px);
    height: 25%;
    left: 50%;
    bottom: -12%;
    border-radius: 50%;
    transform: translateX(-50%);
    background: #ffffff29;
    filter: blur(24px);
}

.home-portal .hp-heading {
    flex: none;
    max-width: 100%;
    margin: 0;
    color: #fff;
    font-family: inherit;
    font-size: clamp(22px, 2.5vw, 36px);
    font-weight: 650;
    text-align: center;
    text-wrap: balance;
    line-height: 1.55;
    text-shadow: 0 2px 16px #5124833d;
}

.hp-scene {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(4px, 2vw, 32px);
    flex: 1 1 0;
    width: min(100%, 1160px);
    min-height: 0;
    margin: auto;
    padding: clamp(12px, 3dvh, 32px) 0;
}

.hp-mascot {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0 0 3%;
}

.hp-mascot-image {
    display: block;
    width: 100%;
    height: 100%;
    max-height: min(70dvh, 690px);
    object-fit: contain;
    filter: drop-shadow(0 18px 18px #16286338);
}

.hp-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 2dvh, 20px);
    min-width: 0;
    padding: 12px 4px;
    border-radius: 28px;
    color: #fff;
    text-align: center;
    text-decoration: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.hp-choice:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 7px;
    background: #28236829;
}

.hp-choice-visual {
    position: relative;
    display: block;
    width: min(100%, 240px);
    aspect-ratio: 1;
    animation: hp-float 6s ease-in-out infinite;
}

.hp-choice--ebooks .hp-choice-visual {
    animation-delay: -3s;
}

.hp-choice-visual::before {
    content: '';
    position: absolute;
    inset: 10%;
    z-index: -1;
    border: 1px solid #ffffff30;
    border-radius: 50%;
    background: #ffffff13;
    box-shadow: 0 0 65px #fffffe24;
    transform: scale(1.3);
}

.hp-choice-icon {
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 16px 15px #23336733);
    transition: transform .25s ease, filter .25s ease;
}

.hp-choice:hover .hp-choice-icon,
.hp-choice:focus-visible .hp-choice-icon {
    transform: translateY(-6px) scale(1.06);
    filter: drop-shadow(0 22px 20px #23336745);
}

.hp-choice-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 100%;
    padding: 10px 18px;
    border: 1px solid #ffffff75;
    border-radius: 999px;
    background: #29245570;
    box-shadow: 0 5px 20px #23336717;
    color: #fff;
    font-size: clamp(17px, 1.7vw, 25px);
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: anywhere;
    hyphens: auto;
    text-wrap: balance;
    transition: background .25s ease;
}

.hp-choice-label::after {
    content: '';
    flex: none;
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
}

.hp-choice:hover .hp-choice-label {
    background: #292455a6;
}

.hp-choice-description {
    display: block;
    max-width: 240px;
    color: #fff;
    font-size: clamp(12px, 1.15vw, 15px);
    font-weight: 500;
    line-height: 1.65;
    text-wrap: balance;
    text-shadow: 0 1px 8px #22276255;
}

@keyframes hp-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@media (max-height: 620px) {
    .home-portal {
        padding-top: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .home-portal .hp-heading {
        font-size: 20px;
    }

    .hp-scene {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .hp-choice {
        gap: 6px;
        padding: 4px;
    }

    .hp-choice-visual {
        width: min(100%, 30dvh, 180px);
    }

    .hp-choice-description {
        display: none;
    }

    .hp-choice-label {
        padding: 7px 12px;
        font-size: 15px;
    }

    .hp-mascot-image {
        max-height: 65dvh;
    }
}

/* On phones, give the character its own row and align both choices below it. */
@media (max-width: 639px) and (orientation: portrait) {
    .home-portal {
        padding: clamp(16px, 3dvh, 26px) 16px max(16px, env(safe-area-inset-bottom));
    }

    .home-portal .hp-heading {
        max-width: 100%;
        font-size: clamp(20px, 5.6vw, 26px);
    }

    .hp-scene {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: minmax(0, 1fr) auto;
        align-items: stretch;
        gap: clamp(12px, 2.5dvh, 22px) 14px;
        margin: 0;
        padding: clamp(10px, 2dvh, 18px) 0 0;
    }

    .hp-mascot {
        grid-column: 1 / -1;
        grid-row: 1;
        padding: 0;
    }

    .hp-mascot-image {
        width: auto;
        max-width: 100%;
        height: 100%;
        max-height: min(38dvh, 320px);
    }

    .hp-choice {
        grid-row: 2;
        align-self: stretch;
        justify-content: flex-start;
        gap: 8px;
        padding: 12px 8px;
        border: 1px solid #ffffff55;
        border-radius: 24px;
        background: #ffffff13;
        box-shadow: 0 8px 24px #26386d17;
    }

    .hp-choice--knowledge { grid-column: 1; }
    .hp-choice--ebooks { grid-column: 2; }

    .hp-choice-visual {
        flex: none;
        width: min(100%, clamp(96px, 15dvh, 130px));
        margin: 0 auto;
    }

    .hp-choice-visual::before {
        inset: 15%;
        transform: scale(1.08);
    }

    .hp-choice-label {
        width: 100%;
        min-height: 2.9em;
        padding: 0 4px;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        font-size: clamp(15px, 4.2vw, 18px);
        line-height: 1.45;
    }

    .hp-choice-label::after { display: none; }

    .hp-choice-description {
        display: block;
        min-height: 3.3em;
        padding: 0 2px;
        font-size: 12px;
        line-height: 1.65;
    }

    .hp-choice:hover .hp-choice-label { background: transparent; }
}

@media (max-width: 639px) and (orientation: portrait) and (max-height: 650px) {
    .home-portal {
        padding-top: 14px;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .home-portal .hp-heading { font-size: 20px; }
    .hp-scene { gap: 12px; padding-top: 8px; }
    .hp-mascot-image { max-height: 40dvh; }
    .hp-choice { gap: 6px; padding: 10px 6px; border-radius: 20px; }
    .hp-choice-visual { width: min(100%, 16dvh, 96px); }
    .hp-choice-label { font-size: 15px; }
    .hp-choice-description { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .hp-choice-visual {
        animation: none;
    }

    .hp-choice-icon,
    .hp-choice-label {
        transition: none;
    }
}
