/* Se3me UI layer: brand eye, video loader, splash, hover polish, skeletons.
   Loaded last. Devices that ask for reduced motion only lose the big movement
   effects (tilt, parallax, Ken Burns); everything else stays. */

/* ── Brand eye (realistic-eye.js) ─────────────────────────────────────────── */
/* The glow is drawn inside the SVG: a CSS drop-shadow filter left a visible box
   (it hid the background texture around the eye). */
.r-eye,
.r-eye--corner,
.r-eye--welcome {
    filter: none;
}

/* The welcome replays the eye's own opening; no extra scale-in on top of it */
.r-eye--welcome {
    animation: none;
}

/* In the app the eye sits inside the sidebar wordmark, centred with "Se3me" */
.r-eye--brand {
    position: relative;
    top: auto;
    left: auto;
    width: 50px;
    flex: none;
    transform: none;
    transition: none;
    z-index: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 6px 10px;
}

.sidebar-brand-text {
    font-size: 1.7rem;
    line-height: 1;
    letter-spacing: -0.01em;
}

.se-eye {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.se-eye-aperture,
.se-eye-rim {
    transform-box: view-box;
    transform-origin: 120px 70px;
    transition: transform 0.17s cubic-bezier(0.5, 0, 0.3, 1);
}

.r-blink .se-eye-aperture,
.r-blink .se-eye-rim {
    transform: scaleY(0.04);
    transition-duration: 0.1s;
}

/* The iris scales (opening) and moves (glances) around its own centre */
.se-eye-look {
    transform-box: fill-box;
    transform-origin: center;
}

.se-eye-pupil {
    transform-box: fill-box;
    transform-origin: center;
    animation: sePupil 7s ease-in-out infinite;
}

.se-eye-haze {
    animation: seHaze 4.5s ease-in-out infinite;
}

@keyframes sePupil {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.18); }
    75% { transform: scale(0.9); }
}

@keyframes seHaze {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

/* Opening: the gold rim draws itself, then the eye parts and the iris lights up */
.se-eye-opening .se-eye-rim {
    stroke-dasharray: 1;
    animation: seRimDraw 0.7s cubic-bezier(0.65, 0, 0.35, 1) both, seOpen 0.6s cubic-bezier(0.34, 1.45, 0.64, 1) 0.6s both;
}

.se-eye-opening .se-eye-aperture {
    animation: seOpen 0.6s cubic-bezier(0.34, 1.45, 0.64, 1) 0.6s both;
}

.se-eye-opening .se-eye-look {
    animation: seIrisIn 0.65s var(--ease) 0.8s both;
}

@keyframes seRimDraw {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

@keyframes seOpen {
    from { transform: scaleY(0.04); }
    to { transform: scaleY(1); }
}

@keyframes seIrisIn {
    from { opacity: 0; transform: scale(0.55); }
    to { opacity: 1; transform: none; }
}

/* The old photoreal eye's glow ellipse is gone */
.r-eye-glow { display: none; }

/* ── Video loader: a small eye scanning inside a spinning gold ring ───────── */
.player-loader {
    display: flex;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s var(--ease), visibility 0.35s;
}

.player-loader.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.extract-loader {
    position: relative;
    width: 104px;
    height: 104px;
    display: grid;
    place-items: center;
}

.player-loader.show .extract-loader {
    animation: loaderIn 0.45s var(--ease-spring) both;
}

@keyframes loaderIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: none; }
}

.se-loader-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    animation: seSpin 1.5s linear infinite;
}

.se-loader-ring circle {
    fill: none;
    stroke: var(--accent-secondary);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-dasharray: 0.24 0.76;
}

.se-loader-ring circle.se-loader-glow {
    stroke-width: 7;
    stroke-opacity: 0.22;
}

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

.se-eye--loader {
    width: 66px;
}

.se-eye--loader .se-eye-look {
    animation: seScan 2.4s ease-in-out infinite;
}

.se-eye--loader .se-eye-aperture,
.se-eye--loader .se-eye-rim {
    animation: seLoaderBlink 3.4s ease-in-out infinite;
}

@keyframes seScan {
    0%, 100% { transform: translateX(-15px); }
    45%, 55% { transform: translateX(15px); }
}

@keyframes seLoaderBlink {
    0%, 86%, 100% { transform: scaleY(1); }
    90%, 92% { transform: scaleY(0.05); }
}

.player-loader .loader-text {
    background: linear-gradient(90deg, var(--text-secondary) 0%, var(--accent-secondary) 45%, var(--text-secondary) 90%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: textSheen 2.2s linear infinite;
}

@keyframes textSheen {
    from { background-position: 120% 0; }
    to { background-position: -120% 0; }
}

/* ── First-load splash ────────────────────────────────────────────────────── */
.app-splash {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse 60% 45% at 50% 45%, rgba(232, 163, 61, 0.12), transparent 70%),
        var(--bg-base);
    transition: opacity 0.45s var(--ease), visibility 0.45s;
}

.app-splash.is-done {
    opacity: 0;
    visibility: hidden;
}

.app-splash-eye {
    width: min(200px, 50vw);
}

/* Right after the sign-in welcome the eye has just played */
.skip-splash .app-splash {
    display: none;
}

.app-splash.is-done .app-splash-eye {
    transform: scale(1.12);
    transition: transform 0.45s var(--ease);
}

/* ── Hover polish ─────────────────────────────────────────────────────────── */

/* Posters: image eases in closer, frame warms up */
.result-poster,
.cw-poster-wrap,
.row-card-poster,
.history-poster {
    overflow: hidden;
}

.result-poster img,
img.result-poster,
.cw-poster,
.history-poster img,
.row-card img {
    transition: transform 0.6s var(--ease), filter 0.4s var(--ease);
}

.result-card:hover .result-poster img,
.cw-card:hover .cw-poster,
.history-item:hover .history-poster img,
.row-card:hover img {
    transform: scale(1.06);
    filter: brightness(1.08) saturate(1.05);
}

.result-card:hover .result-title,
.cw-card:hover .cw-label,
.row-card:hover .row-card-title {
    color: var(--accent-secondary);
    transition: color 0.25s var(--ease);
}

/* Frameless posters (the <img> is the poster) brighten and pick up a gold edge */
.result-card:hover img.result-poster {
    filter: brightness(1.08) saturate(1.05);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(232, 163, 61, 0.45);
}

/* Primary buttons: a light sheen sweeps across on hover */
.btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost),
.featured-play-btn {
    position: relative;
    overflow: hidden;
}

.btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost)::after,
.featured-play-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.38) 50%, transparent 70%);
    transform: translateX(-120%);
    pointer-events: none;
}

.btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost):hover::after,
.featured-play-btn:hover::after {
    transform: translateX(120%);
    transition: transform 0.7s var(--ease);
}

.btn.btn-secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(232, 163, 61, 0.25);
}

.btn i,
.featured-play-btn i {
    transition: transform 0.25s var(--ease-spring);
}

.btn:hover:not(:disabled) i,
.featured-play-btn:hover i {
    transform: scale(1.15);
}

/* Sidebar: a gold bar slides in beside the active item */
.sidebar-link.nav-link {
    position: relative;
}

.sidebar-link.nav-link::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 50%;
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 0 10px var(--accent-glow);
    transform: translateY(-50%) scaleY(0);
    transition: transform 0.3s var(--ease-spring);
}

.sidebar-link.nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.sidebar-link.nav-link:hover:not(.active)::before {
    transform: translateY(-50%) scaleY(0.45);
}

/* Chips and small controls lift a touch */
.history-chip:hover:not(.active) {
    transform: translateY(-1px);
}

.poster-action-btn,
.card-bookmark-btn,
.featured-bookmark-btn,
.modal-close-btn,
.featured-hero-arrow {
    transition: transform 0.22s var(--ease-spring), background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.poster-action-btn:hover,
.card-bookmark-btn:hover,
.featured-bookmark-btn:hover {
    transform: scale(1.1);
    border-color: rgba(232, 163, 61, 0.55);
    color: var(--accent-secondary);
}

.modal-close-btn:hover {
    transform: rotate(90deg);
}

.profile-menu-btn img {
    transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease-spring);
}

.profile-menu-btn:hover img {
    transform: scale(1.06);
    box-shadow: 0 0 0 2px rgba(232, 163, 61, 0.55);
}

.profile-menu-btn .bx-chevron-down {
    transition: transform 0.25s var(--ease);
}

.profile-menu-btn[aria-expanded="true"] .bx-chevron-down {
    transform: rotate(180deg);
}

.context-bar a {
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: background-size 0.3s var(--ease);
}

.context-bar a:hover {
    background-size: 100% 1px;
}

.section-header-actions a,
.row-see-all {
    transition: color 0.2s var(--ease), transform 0.2s var(--ease);
}

/* Player controls */
.cp-btn {
    transition: transform 0.18s var(--ease-spring), color 0.2s var(--ease);
}

.cp-btn:hover {
    transform: scale(1.12);
}

.cp-big-play {
    transition: transform 0.3s var(--ease-spring), box-shadow 0.3s var(--ease);
}

.cp-big-play:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(232, 163, 61, 0.55), 0 0 44px rgba(232, 163, 61, 0.35);
}

.cp-seek {
    transition: height 0.2s var(--ease);
}

.cp-seek:hover .cp-seek-played {
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Featured hero: the backdrop drifts slowly (Ken Burns) */
.featured-slide {
    isolation: isolate;
    overflow: hidden;
}

.featured-slide::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: inherit;
    background-size: cover;
    background-position: inherit;
    transform-origin: 62% 40%;
}

.featured-slide.is-active::before {
    animation: kenBurns 18s ease-out both;
}

@keyframes kenBurns {
    from { transform: scale(1.02); }
    to { transform: scale(1.12) translateX(-1.5%); }
}

/* ── Loading skeletons ────────────────────────────────────────────────────── */
.skeleton-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-poster,
.skeleton-line {
    border-radius: 8px;
    background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 20%, rgba(232, 163, 61, 0.1) 40%, rgba(255, 255, 255, 0.04) 60%);
    background-size: 250% 100%;
    animation: skeletonShine 1.4s linear infinite;
}

.skeleton-poster {
    aspect-ratio: 2 / 3;
}

.skeleton-line {
    height: 10px;
    width: 80%;
}

.skeleton-line.short {
    width: 45%;
}

@keyframes skeletonShine {
    from { background-position: 120% 0; }
    to { background-position: -130% 0; }
}



.skeleton-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 150px;
    gap: 14px;
    overflow: hidden;
}

/* `hidden` always wins over inline or component display rules */
[hidden] {
    display: none !important;
}

/* ── Sign-in page ─────────────────────────────────────────────────────────── */
/* The eye sits in the layout directly above the card, so it can never drift
   onto the card on short or odd-sized screens. */
.login-gate {
    display: flex;
    overflow-y: auto;
}

.login-stack {
    margin: auto;
    width: min(100%, 440px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.login-eye-slot {
    width: 188px;
    aspect-ratio: 240 / 140;
}

.login-eye-slot .r-eye {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    transform: none;
    transition: none;
    z-index: auto;
}

/* Colours taken from the eye: rim gold, iris amber, catchlight cream */
.login-card {
    width: 100%;
    margin-top: 0;
    background: linear-gradient(180deg, rgba(30, 22, 13, 0.9), rgba(13, 10, 7, 0.94));
    border-color: rgba(232, 163, 61, 0.3);
}

.login-tagline {
    color: #eeb14a;
    letter-spacing: 0.34em;
    text-shadow: 0 0 14px rgba(232, 163, 61, 0.4);
}

.login-brand h1 {
    font-size: 2.1rem;
    background: linear-gradient(100deg, #b8761e 0%, #e8a33d 22%, #ffe0a0 45%, #fff4dc 50%, #ffe0a0 55%, #e8a33d 78%, #b8761e 100%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: goldSheen 7s linear infinite;
}

@keyframes goldSheen {
    from { background-position: 110% 0; }
    to { background-position: -110% 0; }
}

.login-sub,
.login-hint {
    color: #cdb38a;
}

.login-form span {
    color: #d9b577;
    letter-spacing: 0.02em;
}

.login-form input {
    color: #fff4dc;
    background: rgba(36, 26, 15, 0.55);
    border-color: rgba(232, 163, 61, 0.2);
    caret-color: #ffd98a;
    transition: border-color 0.2s var(--ease), box-shadow 0.25s var(--ease), background 0.2s var(--ease);
}

.login-form input:hover {
    border-color: rgba(232, 163, 61, 0.38);
}

.login-form input:focus {
    outline: none;
    background: rgba(40, 29, 16, 0.75);
    border-color: rgba(255, 217, 138, 0.62);
    box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.16), 0 0 24px rgba(232, 163, 61, 0.14);
}

.form-error {
    color: #f0a86b;
}

.login-card .btn-primary {
    background: linear-gradient(135deg, #b8761e 0%, #eeb14a 45%, #ffd98a 100%);
    color: #1a1206;
    box-shadow: 0 10px 28px rgba(232, 163, 61, 0.3);
}

.link-btn {
    color: #eeb14a;
}

/* Splash: a quicker opening, shown once per browser session */
.app-splash-eye.se-eye-opening .se-eye-rim {
    animation-duration: 0.5s, 0.45s;
    animation-delay: 0s, 0.4s;
}

.app-splash-eye.se-eye-opening .se-eye-aperture {
    animation-duration: 0.45s;
    animation-delay: 0.4s;
}

.app-splash-eye.se-eye-opening .se-eye-look {
    animation-duration: 0.45s;
    animation-delay: 0.55s;
}


/* ── Scroll effects (motion.js); card entrances and hover live in se3me-fx.css ── */
/* Posters: a soft shimmer holds the spot until the image arrives, then it develops
   in once (motion.js marks it ready; images seen before skip the fade). */
.js-motion img.result-poster:not(.is-ready),
.js-motion .result-poster img:not(.is-ready),
.js-motion img.cw-poster:not(.is-ready),
.js-motion .history-poster img:not(.is-ready) {
    color: transparent;
    background-image: linear-gradient(160deg, rgba(232, 163, 61, 0.08), rgba(255, 255, 255, 0.02) 55%);
}

.js-motion img.is-ready.is-fresh {
    animation: posterDevelop 0.5s var(--ease);
}

@keyframes posterDevelop {
    from { opacity: 0.2; }
}

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 2500;
    pointer-events: none;
    transform-origin: 0 50%;
    transform: scaleX(var(--sp, 0));
    background: linear-gradient(90deg, #b8761e, #eeb14a, #ffe0a0);
    box-shadow: 0 0 10px rgba(232, 163, 61, 0.6);
}

.app-topbar {
    transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.is-scrolled .app-topbar {
    background: rgba(12, 10, 8, 0.93);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(232, 163, 61, 0.16);
}

/* Hero text drifts up and fades as the page scrolls past it */
#pageHero .featured-slide-body {
    transform: translateY(calc(var(--hs, 0) * -0.14px));
    opacity: calc(1 - var(--hs, 0) / 520);
}

.to-top {
    position: fixed;
    right: 22px;
    bottom: 26px;
    z-index: 1500;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(232, 163, 61, 0.42);
    background: rgba(16, 12, 8, 0.9);
    color: var(--accent-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    opacity: 0;
    transform: translateY(18px) scale(0.9);
    pointer-events: none;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: opacity 0.3s var(--ease), transform 0.35s var(--ease-spring), box-shadow 0.3s var(--ease);
}

.to-top.show {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 0 1px rgba(232, 163, 61, 0.6), 0 0 26px rgba(232, 163, 61, 0.35);
}

@media (max-width: 768px) {
    .to-top {
        right: 14px;
        bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 14px);
    }
}

/* Devices asking for reduced motion keep the animations, minus big movement */
@media (prefers-reduced-motion: reduce) {
    .featured-slide.is-active::before {
        animation: none;
    }

    #pageHero .featured-slide-body {
        transform: none;
    }
}
