/* Rules here are unlayered, so they beat Tailwind utilities. Only keep
what Tailwind classes can't express (gradients, pseudo-elements, JS state
classes, scrollbar, GSAP/Lenis fixes) or responsive overrides. */

/* =====================================================================
   BASE
   ===================================================================== */

/* Initial hidden state only — GSAP drives the actual reveal so the
motion can ease smoothly instead of stepping through CSS delays. */
.hero-anim, .hero-card-anim {
    opacity: 0;
    will-change: opacity, transform;
}

/* --- YTAC BRANDED SCROLLBAR STYLES --- */

/* Firefox */
html {
    scrollbar-width: thin;
    scrollbar-color: #00607A #F9FBFC; /* YTAC Blue thumb / Light Track */
}

/* WebKit Browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background-color: #F9FBFC; /* Matches main site background */
}

::-webkit-scrollbar-thumb {
    background-color: #00607A; /* YTAC Blue */
    border-radius: 9999px;
    border: 2px solid #F9FBFC; /* Gives a smooth padded pill effect */
}

::-webkit-scrollbar-thumb:hover {
    background-color: #14A39A; /* YTAC Green on hover */
}

/* --- Lenis / GSAP pinning --- */

html, body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

html.lenis, html.lenis-scrolling {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

/* !important beats the inline styles GSAP writes on pinned elements. */
.pin-spacer {
    padding-right: 0px !important;
    margin-right: 0px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#gallery {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* --- Navigation --- */

#mobileMenuButton {
    display: none;
}

#navbar.gallery-nav {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background-color: rgba(26,26,26,0.55) !important;
}

/* --- Category tracks: carousel of flip cards (main.js: "CATEGORY CAROUSEL") ---
   Every card has the same fixed size on a screen size, so the section never grows or jumps.
   The JS only sets each card's position (transform/opacity) and .is-flipped. */
.track-carousel {
    --card-w: min(300px, calc(100vw - 88px));
    --card-h: 470px;
}
@media (min-width: 640px)  { .track-carousel { --card-w: 340px; --card-h: 500px; } }
/* Phones and tablets: the stage runs to the screen edges, so the side cards peek in from the edge */
@media (max-width: 1023px) { .track-stage { margin-inline: -1rem; } }
@media (min-width: 1024px) { .track-carousel { --card-w: 370px; --card-h: 520px; } }

.track-stage {
    position: relative;
    height: var(--card-h);
    overflow: hidden;           /* Neighbours peek in from the sides; nothing widens the page */
    overflow: clip;
    padding-block: 12px 44px;   /* Room for the card shadow, so it isn't cut off */
    box-sizing: content-box;
    touch-action: pan-y;        /* Vertical scrolling stays native; sideways swipes change the card */
}
.track-card {
    position: absolute;
    top: 12px;
    left: 50%;
    width: var(--card-w);
    height: var(--card-h);
    margin-left: calc(var(--card-w) / -2);
    perspective: 1600px;
    transition: transform .55s cubic-bezier(.22, .7, .25, 1), opacity .45s ease;
    will-change: transform, opacity;
}
.track-card:not(.is-current) { cursor: pointer; }
.track-card:not(.is-current) .track-inner { pointer-events: none; }  /* A tap on a side card brings it to the centre */
.track-card.is-hidden { pointer-events: none; }

.track-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: transform .7s cubic-bezier(.3, .7, .2, 1);
}
.track-card.is-flipped .track-inner { transform: rotateY(180deg); }

.track-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 22px;
    border-radius: 2rem;
    background: #fff;
    border: 1px solid #fff;
    box-shadow: 2px 2px 0 #dcdfe6, 0 14px 30px #17364e21;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0.1px);     /* Safari: keeps each face on its own side while turning */
}
.track-back {
    transform: rotateY(180deg) translateZ(0.1px);
    padding: 16px 18px 20px;
}
@media (min-width: 640px) {
    .track-face { padding: 30px 28px; border-radius: 2.5rem; }
    .track-back { padding: 18px 22px 22px; }
}

.track-logo { width: 100%; height: 150px; }
@media (max-width: 639px) { .track-logo { height: 130px; } }

.track-back .detail-photo { aspect-ratio: 16 / 10; }
.track-back .detail-photo img { transition: opacity .7s ease, transform .3s ease; }
@media (hover: hover) { .track-back .detail-photo:hover img.is-active { transform: scale(1.04); } }

/* The full description scrolls inside the card; a soft fade shows there is more */
.track-description {
    -webkit-mask-image: linear-gradient(to bottom, #000 85%, transparent);
    mask-image: linear-gradient(to bottom, #000 85%, transparent);
    scrollbar-width: thin;
}

.track-card:focus-visible { outline: none; }
.track-card:focus-visible .track-face { outline: 3px solid #822384; outline-offset: 4px; }

.track-dot { width: 10px; }
.track-dot.is-active { width: 28px; background: #822384; }

/* --- Pathway nodes (.expanded is toggled by JS) --- */

.pathway-node {
    max-width: 42rem;
    transition: max-width .5s cubic-bezier(.4,0,.2,1),
                min-height .5s cubic-bezier(.4,0,.2,1),
                padding .4s ease, transform .3s ease,
                border-color .3s ease, box-shadow .3s ease,
                background-color .3s ease;
}

.pathway-node.expanded {
    width: 95%;
    max-width: 100%;
    min-height: 560px;
    padding: 2.5rem;
}

.pathway-node.expanded .node-expanded-content {
    max-height: 1200px;
    overflow: visible; /* Don't clip the resource buttons */
    margin-top: 1rem;
    padding-top: 1rem;
}

.pathway-node.expanded .expand-icon {
    transform: rotate(180deg);
}

@keyframes pathway-icon-pulse {
    0%, 100% { scale: 1; }
    50% { scale: 1.14; }
}

/* --- Image lightbox --- */

#imgLightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 2rem;
}

#imgLightbox.open {
    opacity: 1;
    pointer-events: auto;
}

#imgLightbox img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.25s ease;
    cursor: zoom-out;
}

#imgLightbox.open img {
    transform: scale(1);
}

#lightboxClose {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

#lightboxClose:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* =====================================================================
   TABLET + PHONE (max 1023px)
   ===================================================================== */

@media screen and (max-width: 1023px) {
    main section[id] {
        scroll-margin-top: 5rem;
    }

    /* Navigation: hamburger + dropdown menu */
    #mobileMenuButton {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        margin-left: auto;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        cursor: pointer;
    }

    #mobileMenuButton span {
        display: block;
        width: 23px;
        height: 2px;
        background: #00607a;
    }

    #navbar #mobileNavLinks {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        max-height: calc(100dvh - 68px);
        overflow-y: auto;
        overflow-x: hidden;
        padding: .5rem 1rem;
        margin: 0;
        background: white;
        box-shadow: 0 8px 16px rgb(0 0 0 / 10%);
    }

    #navbar #mobileNavLinks.is-open {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    #navbar #mobileNavLinks .nav-link {
        display: block;
        flex-shrink: 0;
        padding: .875rem .5rem;
        min-height: 44px;
        color: #00607a;
        font-size: .875rem;
        text-align: left;
        white-space: nowrap;
    }

    /* Login / Register pills: spaced apart and set off from the links above */
    #navbar #mobileNavLinks > a:not(.nav-link) {
        flex-shrink: 0;
        margin-top: .625rem;
        padding: .75rem 1rem;
    }

    #navbar #mobileNavLinks > .nav-link + a:not(.nav-link) {
        margin-top: .75rem;
        position: relative;
    }

    #navbar #mobileNavLinks > .nav-link + a:not(.nav-link)::before {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: -.5rem;
        border-top: 1px solid #e5e7eb;
    }

    #navbar #mobileNavLinks > a:last-child {
        margin-bottom: .5rem;
    }

    /* Countdown */
    .experience {
        height: auto;
        min-height: 100svh;
    }

    /* Pathway */
    .pathway-node,
    .pathway-node.expanded {
        width: 100%;
        min-height: 0;
        padding: 1.5rem;
    }

    .pathway-main,
    .expand-card {
        min-width: 0;
        max-width: 100%;
    }

    .expand-card iframe {
        width: 100%;
        max-width: 100%;
        height: 60svh;
    }

    /* Recognition */
    #recognition {
        min-height: 0;
        overflow: visible;
        padding-block: 3rem;
    }

    #recognition .documents-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
        margin-block: 2rem 0;
    }

    /* Floating contact */
    .floating-contact-container {
        right: 1rem;
        bottom: 1rem;
    }
}

/* =====================================================================
   TABLET ONLY (640px – 1023px)
   ===================================================================== */

@media screen and (min-width: 640px) and (max-width: 1023px) {
    #recognition .doc-card:last-child {
        grid-column: 1 / -1;
        justify-self: center;
        width: calc((100% - 1.25rem) / 2);
    }
}

/* =====================================================================
   PHONE (max 639px)
   ===================================================================== */

@media screen and (max-width: 639px) {
    /* Hero + countdown */
    #home > div {
        max-width: 100%;
        padding-inline: 1.5rem;
    }

    .experience-text-wrapper {
        font-size: clamp(1.75rem, 7vw, 2.5rem);
    }

    /* Countdown: compact so it fits small phones (e.g. iPhone SE, ~550px visible in Safari):
       the four time cards on one row, buttons side by side, tighter spacing. */
    #expScene2 {
        gap: 1.25rem;
    }

    /* Centre both scenes in the space below the fixed navbar (instead of the section's
       own top/bottom padding, which leaves too little room on small phones) */
    .experience {
        height: 100svh;     /* An exact height, so the scenes' wrapper (h-full) isn't 0px tall */
        min-height: 0;
        padding-block: 0;
    }

    #expScene1,
    #expScene2 {
        padding-top: 4rem;
    }

    .countdown-timer-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .countdown-timer-grid .time-card {
        padding: 0.75rem 0.25rem;
        border-radius: 1rem;
    }

    .countdown-timer-grid .time-digit {
        font-size: 1.75rem;
        line-height: 1;
    }

    .countdown-timer-grid .time-unit-label {
        margin-top: 0.375rem;
        font-size: 0.5625rem;
        letter-spacing: 0.08em;
    }

    #experience #register {
        margin-top: 0.25rem;
        gap: 0.75rem;
    }

    #experience #s2Button,
    #experience #s2Handbook {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }

    /* Pathway */
    .pathway-node,
    .pathway-node.expanded {
        padding: 1rem;
        border-radius: 1rem;
    }

    .pathway-node.expanded .node-expanded-content {
        max-height: none;
    }

    /* Recognition */
    #recognition .documents-container {
        grid-template-columns: minmax(0, 1fr);
    }

    #recognition .doc-card {
        min-width: 0;
        padding: 1.5rem;
    }

    #recognition h2 {
        font-size: 2rem;
    }

    /* Gallery: normal section, photos stacked vertically */
    #gallery {
        height: auto;
        min-height: 0;
        padding: 10rem 1rem 2rem;
    }

    #gallery .gallery-sticky {
        display: block;
        overflow: visible;
    }

    #gallery .gallery-track {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 1.5rem;
        padding: 0;
    }

    #gallery .gallery-track > .gallery-row {
        display: contents;
    }

    #gallery .gallery-row > .gallery-item {
        width: 100%;
        height: auto;
    }

    #gallery .gallery-item > img,
    #gallery .gallery-item > div {
        flex: none;
        height: auto;
    }

    #gallery .gallery-track img {
        display: block;
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    /* Lightbox + floating contact */
    #imgLightbox {
        padding: 1rem;
    }

    #imgLightbox img {
        max-width: 100%;
        max-height: 80svh;
    }

    #lightboxClose {
        top: 1rem;
        right: 1rem;
    }

    .floating-contact-container > button {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* =====================================================================
   TABLET + DESKTOP (min 640px): two staggered gallery rows
   ===================================================================== */

@media (min-width: 640px) {
    /* The track moves on its own GPU layer while scrolling. */
    #gallery .gallery-track {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        height: 100%;
        width: max-content;
        gap: 24px;
        padding: 8px 5vw;
        box-sizing: border-box;
        will-change: transform;
        backface-visibility: hidden;
        transform: translate3d(0,0,0);
        contain: layout style;
    }

    #gallery .gallery-track > .gallery-row {
        display: flex;
        flex: 0 0 calc((100% - 24px) / 2);
        align-items: center;
        gap: 24px;
        width: max-content;
        height: calc((100% - 24px) / 2);
        min-height: 0;
    }

    #gallery .gallery-track > .gallery-row:nth-child(2) {
        padding-left: 100px;
    }

    /* The frame has the photo's own shape (--photo-ratio, read from the file): no cropping.
       Frames sit at the bottom of their row; the caption goes in the space above. */
    #gallery .gallery-row > .gallery-item {
        position: relative;
        flex: none;
        align-self: flex-end;
        width: auto;
        height: var(--photo-height);
        aspect-ratio: var(--photo-ratio);
        min-height: 0;
    }

    #gallery .gallery-item > img,
    #gallery .gallery-item > div {
        flex: 1;
        min-height: 0;
        height: 0;
        width: 100%;
        overflow: hidden;
        border-radius: 16px;
    }

    #gallery .gallery-item img {
        backface-visibility: hidden;
    }

    #gallery .gallery-item > div > img {
        height: 100%;
    }

    #gallery .gallery-item > span {
        position: absolute;
        left: 0;
        bottom: 100%;
        padding: 0 0 6px 8px;
        white-space: nowrap;
    }

    /* Avoid per-frame blur/filter work over the moving photos. */
    #gallery .gallery-title-overlay { will-change: transform; transform: translateZ(0); }
    #gallery .gallery-title-overlay span,
    #gallery .gallery-title-overlay h2 {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
    }
    #gallery .gallery-title-overlay span { background-color: rgba(59,7,100,0.85) !important; }
    #gallery .gallery-title-overlay h2 { text-shadow: 0 4px 12px rgba(0,0,0,0.8); }
}

/* =====================================================================
   INPUT TYPE
   ===================================================================== */

/* Pathway hover highlight: no movement or automatic expansion. */
@media (hover: hover) and (pointer: fine) {
    #pathway .pathway-node:hover {
        border-color: rgba(20,163,154,.55);
        box-shadow: 0 0 0 3px rgba(132,212,199,.18),
                    0 0 24px rgba(20,163,154,.20),
                    0 16px 28px rgba(0,96,122,.12);
    }
    #pathway .pathway-node:hover .expand-icon {
        animation: pathway-icon-pulse .9s ease-in-out;
    }
}

/* Touch devices: video controls (header and review videos) can't rely on hover, so they
   stay open, as a slim translucent pill with a thin progress line. */
@media (hover: none) and (pointer: coarse) {
    .video-controls {
        width: calc(100% - 1.5rem);
        max-width: 32rem;
        height: 2.75rem;            /* Fits the 40px buttons */
        min-height: 0;
        padding: 0 0.25rem 0 0.875rem;
        gap: 0.5rem;
        background: rgb(0 0 0 / 35%);
        -webkit-backdrop-filter: blur(6px);
        backdrop-filter: blur(6px);
    }

    /* Looks 4px thin, but the finger target is 14px tall */
    .video-controls .vc-progress-track {
        height: 14px;
        border-radius: 0;
        background: linear-gradient(rgb(255 255 255 / 30%), rgb(255 255 255 / 30%)) center / 100% 4px no-repeat;
    }
    .video-controls .vc-progress-track > div {
        height: 4px;
        margin-top: 5px;
    }

    .video-controls .vc-btn,
    .video-controls .vc-time {
        opacity: 1;
    }

    .video-controls .vc-btn {
        width: 2.5rem;              /* 40px: easier to tap */
        height: 2.5rem;
    }

    .video-controls .vc-btn svg {
        width: 1.35rem;
        height: 1.35rem;
    }

    .video-controls .vc-time {
        font-size: 0.6875rem;
    }
}

/* Phones: the floating "Contact Us" button sits bottom-right, so the header's scroll hint moves up. */
@media screen and (max-width: 639px) {
    #scrollHint { bottom: 5rem; }  /* Clear of the floating Contact Us button */
}

/* --- Video header scroll hint (shown by main.js with .is-visible) --- */
#scrollHint.is-visible { opacity: 1; }

/* A small mouse outline whose wheel moves down */
.scroll-hint-mouse {
    position: relative;
    width: 22px;
    height: 34px;
    border: 2px solid rgb(255 255 255 / 85%);
    border-radius: 12px;
}
.scroll-hint-mouse::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    width: 4px;
    height: 7px;
    margin-left: -2px;
    border-radius: 2px;
    background: #fff;
    animation: scroll-hint-wheel 1.4s ease-in-out infinite;
}
@keyframes scroll-hint-wheel {
    0%   { transform: translateY(0);    opacity: 1; }
    70%  { transform: translateY(10px); opacity: 0; }
    100% { transform: translateY(0);    opacity: 0; }
}

/* --- Floating "Contact Us" ---
   The closed menu is invisible but still takes up room, which stretched the container's
   (transparent) box over whatever is behind it, e.g. the header video's mute button, and
   swallowed those taps. While closed only the button catches pointer events; once hovered
   (desktop) or opened (tap) the whole container does, so the pointer can cross the gap to the menu. */
#floatingContact { pointer-events: none; }
#floatingContact:hover,
#floatingContact.is-open,
#floatingContactButton { pointer-events: auto; }

/* --- Floating "Contact Us": gentle bob, paused while hovered, focused or open --- */
#floatingContactButton {
    animation: contact-float 3.2s ease-in-out infinite;
}
.floating-contact-container:hover #floatingContactButton,
.floating-contact-container.is-open #floatingContactButton,
#floatingContactButton:focus-visible {
    animation-play-state: paused;
}
@keyframes contact-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
    .track-card, .track-inner { transition: none; }
    #pathway .pathway-node:hover .expand-icon { animation: none; }
    #floatingContactButton, .scroll-hint-mouse::before { animation: none; }
}
