/* ==========================================================================
   xe8my Info — light theme
   Palette: xe8 logo orange (#ff7f00 / #fba14c) + the xe8.vip navy for text.
   Font:    Poppins (same as xe8.vip), CJK falls back to system sans.
   ========================================================================== */

:root {
    --bg: #f4f7fc;
    --bg-2: #e6edf8;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --panel: #eaf0f9;
    --orange: #ff7f00;
    --orange-soft: #fba14c;
    --orange-ink: #b85400; /* orange for text on white (AA contrast) */
    --orange-tint: #fff3e4; /* selected tab, hover wash */
    --bar-bg: rgba(255, 255, 255, .78); /* tab bar + language button share this */
    --bar-radius: calc(var(--radius) + 4px); /* ...and this corner radius */
    --navy: #06112a;
    --ink: #06112a;
    --muted: #566686;
    --line: rgba(6, 17, 42, .11);
    --line-strong: rgba(6, 17, 42, .22);
    --shadow: 0 8px 28px -14px rgba(6, 17, 42, .22);
    /* radii */
    --radius: 20px; /* cards, viewer, note */
    --radius-sm: 12px; /* buttons */

    /* spacing: one rhythm everywhere (phones redefine these below) */
    --gap: 20px; /* between cards / stacked blocks */
    --gap-sm: 12px; /* tight groups: button rows */
    --gap-lg: 28px; /* between sections inside a panel */
    --pad-x: 22px; /* horizontal padding of bars and panels */

    /* type scale */
    --fs-label: 12px; /* uppercase labels */
    --fs-xs: 13px; /* captions, meta, hints */
    --fs-sm: 14px; /* small buttons, phone tabs */
    --fs-base: 15px; /* body copy */
    --fs-md: 16px; /* buttons, tabs, small headings */
    --fs-card: clamp(15px, 1.2vw, 17px); /* every card title, on every tab */

    --max: 1312px;
    --gutter: clamp(16px, 3vw, 40px);
    --font: "Poppins", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* tab panels swap in and out; don't let the browser shift the page to compensate */
    overflow-anchor: none;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img,
video,
iframe,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
    margin: 0;
    padding: 0;
}

ul,
ol {
    list-style: none;
}

[hidden] {
    display: none !important;
}

.container {
    width: min(var(--max), 100% - var(--gutter) * 2);
    margin-inline: auto;
}

#main {
    padding-block: clamp(20px, 3vw, 32px) 56px;
}

.icon {
    width: 22px;
    height: 22px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:focus-visible {
    outline: 3px solid var(--orange);
    outline-offset: 3px;
    border-radius: 8px;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--orange);
    color: var(--navy);
    font-weight: 700;
    transition: top .2s;
}

.skip-link:focus {
    top: 12px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--fs-md);
    line-height: 1;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, background .2s, border-color .2s, color .2s;
}

.btn .icon {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(180deg, var(--orange-soft) 0%, var(--orange) 100%);
    color: var(--navy);
    box-shadow: 0 8px 20px -8px rgba(255, 127, 0, .7);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px -8px rgba(255, 127, 0, .85);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}

.btn-ghost:hover {
    border-color: var(--orange);
    color: var(--orange-ink);
    background: var(--orange-tint);
}

.btn-sm {
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 600;
}

/* ---------- Top bar: tabs + language picker ---------- */

.topbar {
    position: relative;
    z-index: 20; /* keeps the language dropdown above the cards below */
    display: flex;
    align-items: stretch; /* the language button is exactly as tall as the tab bar */
    gap: var(--gap-sm);
}

.topbar .tabs {
    flex: 1;
    min-width: 0;
}

/* modelled on the picker on xe8.vip: flag-only button, card dropdown */
.language-picker {
    position: relative;
    display: flex;
    flex: none;
}

.language-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 104px;
    padding: 0 20px 0 18px;
    border: 1px solid var(--line);
    border-radius: var(--bar-radius);
    background: var(--bar-bg);
    box-shadow: var(--shadow);
    color: var(--ink);
    line-height: 1;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

.language-trigger:hover,
.language-picker.open .language-trigger {
    border-color: var(--orange);
    background: var(--orange-tint);
}

.language-trigger-flag {
    display: grid;
    place-items: center;
    flex: none;
    width: 26px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 50%;
    overflow: hidden;
}

.language-trigger-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.language-trigger i {
    width: 9px;
    height: 9px;
    margin: -5px 2px 0 14px;
    border-right: 1.8px solid currentColor;
    border-bottom: 1.8px solid currentColor;
    transform: rotate(45deg);
    transition: transform .22s, margin .22s;
}

.language-picker.open .language-trigger i {
    margin-top: 5px;
    transform: rotate(225deg);
}

.language-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    display: grid;
    grid-template-columns: 44px auto;
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: 0;
    align-content: center;
    width: max-content; /* sized to its content, so left and right padding match */
    max-width: calc(100vw - var(--gutter) * 2);
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 60px -16px rgba(6, 17, 42, .35);
    opacity: 0;
    visibility: hidden; /* also takes the links out of the tab order while closed */
    transform: translateY(-8px) scale(.98);
    transform-origin: top right;
    transition: opacity .2s, visibility .2s, transform .2s;
}

.language-picker.open .language-dropdown {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.country-row {
    display: contents;
}

.country-row strong {
    grid-column: 2;
    align-self: end;
    font-size: var(--fs-md);
    line-height: 1.25;
}

.malaysia-flag {
    display: grid;
    place-items: center;
    grid-row: 1 / 3;
    align-self: center; /* flag sits level with the middle of the text */
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-2);
    box-shadow: 0 8px 18px -8px rgba(6, 17, 42, .3);
    overflow: hidden;
}

.malaysia-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.language-options {
    grid-column: 2;
    align-self: start;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 -5px -6px -5px; /* cancels the links' tap padding on the left, right and bottom, so the text lines up and the gaps stay even */
    white-space: nowrap;
}

.language-options a {
    padding: 6px 5px; /* roomy enough to tap */
    line-height: 1.25;
    color: var(--muted);
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: color .2s;
}

.language-options a:hover,
.language-options a.current {
    color: var(--orange-ink);
    font-weight: 700;
}

.language-options > span {
    width: 1px;
    height: 16px;
    background: var(--line-strong);
}

/* ---------- Tabs ---------- */

.tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr; /* however many tabs there are, they share the bar equally */
    gap: 6px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: var(--bar-radius);
    background: var(--bar-bg);
    box-shadow: var(--shadow);
}

.tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 58px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 3px);
    background: transparent;
    color: var(--muted);
    font-size: var(--fs-md);
    font-weight: 600;
    cursor: pointer;
    transition: color .2s, background .2s, border-color .2s;
}

.tab:hover {
    color: var(--ink);
    background: rgba(6, 17, 42, .04);
}

.tab[aria-selected="true"] {
    color: var(--orange-ink);
    background: var(--orange-tint);
    border-color: var(--orange);
    box-shadow: 0 6px 18px -10px rgba(255, 127, 0, .7);
}

/* ---------- Panels & grids ---------- */

.panel {
    margin-top: var(--gap);
    outline-offset: 6px;
}

.panel:not([hidden]) {
    animation: panel-in .35s ease both;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.grid {
    display: grid;
    gap: var(--gap);
}

.grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid--5 {
    grid-template-columns: repeat(5, 1fr);
}

/* ---------- Cards ---------- */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .25s, border-color .25s, box-shadow .25s;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--orange);
    box-shadow: 0 18px 38px -18px rgba(255, 127, 0, .6), 0 8px 24px -12px rgba(6, 17, 42, .25);
}

.card-media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg-2);
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s ease;
}

.card:hover .card-media img {
    transform: scale(1.05);
}

.card-title {
    display: block;
    padding: 6px 14px var(--gap);
    text-align: center;
    font-size: var(--fs-card);
    font-weight: 700;
    line-height: 1.35;
}

.card-title small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 500;
    overflow-wrap: anywhere; /* a long domain wraps instead of being clipped by the card */
}

/* Results: each card shows the site's own logo on a light plate */
.card--result .card-media {
    aspect-ratio: 16 / 10;
    background: var(--surface); /* some logos ship with a white box, so the plate must stay pure white */
}

.card--result .card-media img {
    position: absolute;
    inset: 16px 0;
    margin: auto; /* centres the capped logo box in the plate */
    width: min(calc(100% - 64px), 168px);
    height: min(calc(100% - 32px), 100px);
    object-fit: contain;
}

/* 90VS only publishes a wide banner, so it sits as a rounded chip */
.card--result[data-result="90vs"] .card-media img {
    inset: 50% 0 auto;
    width: min(calc(100% - 56px), 190px);
    height: auto;
    transform: translateY(-50%);
    border-radius: 10px;
    box-shadow: 0 6px 16px -8px rgba(6, 17, 42, .45);
}

.card--result[data-result="90vs"]:hover .card-media img {
    transform: translateY(-50%) scale(1.05);
}

/* Events: poster cards that open the video in a popup */
.card--video .card-media {
    aspect-ratio: 16 / 9;
}

.card--video .card-title {
    padding-top: 16px;
}

.play {
    position: absolute;
    inset: 0; /* covers the poster so the button sits dead centre */
    z-index: 1;
    display: grid;
    place-items: center;
}

.play::before {
    content: "";
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(6, 17, 42, .62);
    border: 2px solid rgba(255, 255, 255, .9);
    backdrop-filter: blur(6px);
    transition: transform .25s, background .25s, border-color .25s;
}

.play .icon {
    position: relative;
    width: 26px;
    height: 26px;
    left: 1px; /* the triangle is centred in its box; 1px right balances its visual weight, which sits left of its box centre */
    color: var(--orange-soft);
    transition: color .25s;
}

.card:hover .play::before {
    transform: scale(1.1);
    background: var(--orange);
    border-color: var(--orange);
}

.card:hover .play .icon {
    color: var(--navy);
}

/* selected result card */
.card[aria-current="true"] {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 127, 0, .28), 0 16px 34px -18px rgba(255, 127, 0, .65);
}

.card[aria-current="true"] .card-title {
    color: var(--orange-ink);
}

/* ---------- Result viewer ---------- */

.viewer {
    margin-top: var(--gap);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    scroll-margin-top: 16px;
}

.viewer-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 12px var(--pad-x);
    border-bottom: 1px solid var(--line);
}

.viewer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.viewer-icon {
    flex: none;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.viewer-title strong {
    font-size: var(--fs-base);
    font-weight: 700;
}

.viewer-title span {
    color: var(--muted);
    font-size: var(--fs-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.viewer-frame {
    position: relative;
    height: clamp(540px, 80vh, 940px);
    background: #fff;
    overflow: hidden; /* clips the embedded page's scrollbar, see --sbw */
    --sbw: 0px; /* system scrollbar width, measured by script.js */
}

.viewer-frame iframe {
    position: absolute;
    inset: 0;
    width: calc(100% + var(--sbw)); /* the scrollbar sits in the clipped part, so no empty strip */
    max-width: none; /* the global iframe rule would cap it at 100% */
    height: 100%;
    border: 0;
    background: #fff;
}

.viewer-frame:fullscreen {
    height: 100vh;
}

.viewer-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 14px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-base);
    transition: opacity .3s;
}

.viewer:not(.is-loading) .viewer-loading {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid var(--line-strong);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.viewer-hint {
    padding: 12px var(--pad-x);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-xs);
}

.viewer-hint a,
.note a {
    color: var(--orange-ink);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--orange);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.viewer-hint a:hover,
.note a:hover {
    color: var(--navy);
}

/* ---------- Note ---------- */

.note {
    margin-top: var(--gap-lg);
    padding: calc(var(--pad-x) - 2px) var(--pad-x);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--muted);
    font-size: var(--fs-base);
    line-height: 1.7;
}

/* ---------- Video popup ---------- */

body:has(dialog[open]) {
    overflow: hidden;
}

.modal {
    width: min(1400px, 96vw); /* as large as the screen allows */
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    overflow: visible;
}

.modal::backdrop {
    background: rgba(6, 17, 42, .86);
    backdrop-filter: blur(8px);
}

.modal[open] {
    animation: panel-in .25s ease both;
}

/* the video is the whole popup: no title strip, just rounded corners and a soft shadow */
.modal-box {
    position: relative;
    border-radius: var(--radius);
    background: #000;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

.modal-box video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 48px); /* never taller than the screen; letterboxed if it has to be */
    background: #000;
}

/* title + close float over the top of the video on a soft fade, and step aside while it plays */
.modal-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 16px 48px 24px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .6), rgba(0, 0, 0, 0));
    pointer-events: none; /* clicks fall through to the video, except on the close button */
    transition: opacity .35s ease;
}

.modal-bar h2 {
    margin-top: 8px;
    font-size: var(--fs-md);
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}

.icon-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 50%;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(6px);
    color: #fff;
    cursor: pointer;
    pointer-events: auto;
    transition: background .2s, border-color .2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, .22);
    border-color: rgba(255, 255, 255, .7);
}

.modal.is-idle .modal-bar {
    opacity: 0;
}

.modal.is-idle .icon-btn {
    pointer-events: none;
}

.modal.is-idle video {
    cursor: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .grid--5 {
        grid-template-columns: repeat(3, 1fr);
    }

    .card--result .card-media {
        aspect-ratio: 2 / 1;
    }

    

    

}

@media (max-width: 760px) {
    /* phones: the same tokens, just tighter. Every component follows automatically. */
    :root {
        --radius: 16px;
        --gap: 14px;
        --gap-sm: 10px;
        --gap-lg: 22px;
        --pad-x: 16px;
        --fs-card: 14px; /* narrow strip cards */
    }

    .btn {
        min-height: 44px;
        padding: 0 18px;
        font-size: var(--fs-base);
    }

    /* keep the 44px touch height from .btn, but the small-button type size */
    .btn-sm {
        padding: 0 14px;
        font-size: var(--fs-sm);
    }

    .topbar {
        gap: 8px;
    }

    /* phones: the video popup is the whole screen */
    .modal {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
    }

    .modal-box {
        height: 100%;
        border-radius: 0;
    }

    .modal-box video {
        height: 100%;
        max-height: none;
        aspect-ratio: auto;
    }

    .modal-bar {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 40px 18px;
    }

    .language-trigger {
        min-width: 64px;
        padding: 0 12px;
    }

    .language-trigger i {
        margin-left: 10px;
    }

    .tabs {
        padding: 5px;
        gap: 4px;
    }

    .tab {
        flex-direction: column;
        gap: 4px;
        min-height: 62px;
        padding: 6px 4px;
        font-size: var(--fs-sm);
    }

    .grid--2 {
        grid-template-columns: 1fr;
    }

    /* result cards become a swipeable strip */
    .grid--scroll {
        grid-auto-flow: column;
        grid-template-columns: none;
        grid-auto-columns: 128px;
        margin-inline: calc(var(--gutter) * -1);
        padding: 4px var(--gutter) 14px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scroll-padding-inline: var(--gutter);
        scrollbar-width: none;
    }

    .grid--scroll::-webkit-scrollbar {
        display: none;
    }

    .grid--scroll .card {
        scroll-snap-align: start;
    }

    /* smaller cards, smaller logos */
    .grid--scroll .card-media {
        aspect-ratio: 4 / 3;
    }

    .card--result .card-media img {
        inset: 14px 16px;
        width: calc(100% - 32px);
        height: calc(100% - 28px);
    }

    .card--result[data-result="90vs"] .card-media img {
        inset: 50% 10px auto;
        width: calc(100% - 20px);
        border-radius: 8px;
    }

    .grid--scroll .card-title {
        padding: 2px 5px var(--gap);
    }

    .grid--scroll .card-title small {
        font-size: var(--fs-label);
    }

    .viewer-frame {
        height: 72vh;
        min-height: 460px;
    }

    .viewer-bar {
        padding: 12px var(--pad-x);
    }

    .viewer-actions {
        width: 100%;
    }

    .viewer-actions .btn {
        flex: 1;
    }

}

@media (max-width: 420px) {

    .viewer-actions .btn span {
        font-size: var(--fs-xs);
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
