/* ============================================
   GLHFDD Motion Poster - V17b Styles
   JS SCALE TRANSFORM + DUAL MODE

   TWO CANVAS SIZES:
   - Portrait: 1080 x 1500px
   - Horizontal: 1920 x 1080px

   JS PosterScaler class:
   - Detects viewport aspect ratio
   - Sets data-mode="portrait" or data-mode="horizontal"
   - Applies transform: scale() for proportional scaling

   All sizing uses fixed px values relative to canvas.
   ============================================ */

/* ============================================
   Web Fonts
   ============================================ */
@font-face {
    font-family: 'Digital-7 Mono';
    src: url('../fonts/digital-7-mono.woff2') format('woff2'),
         url('../fonts/digital-7-mono.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #bd0001;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

img {
    max-width: none;
    height: auto;
    display: block;
}

/* ============================================
   Poster Container - JS Controlled
   Default: Portrait mode (1080×1500)
   ============================================ */
.poster-container {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1080px;
    height: 1500px;
    transform-origin: top center;
    overflow: hidden;
    /* Portrait: JS sets transform: translate(-50%, 0) scale(X) */
}

/* Horizontal mode - centered vertically */
.poster-container[data-mode="horizontal"] {
    top: 50%;
    transform-origin: center center;
    /* JS sets: transform: translate(-50%, -50%) scale(X) */
}

/* ============================================
   Layer System
   ============================================ */
.poster-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.poster-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

/* Background Layer - z-index 1 */
.layer-bg {
    z-index: 1;
}

/* ============================================
   Portrait Mode Styles (default)
   Canvas: 1080×1500
   ============================================ */

/* Credits Top - z-index 2 */
/* 68% of 1080 = 734px, 4% of 1500 = 60px */
.layer-credits-top {
    z-index: 2;
    height: auto;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 734px;
}

.layer-credits-top img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Credits Top - Individual Names Container */
.credits-top-names {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* 5.2% of 1080 = 56px */
img.credit-name {
    height: 56px;
    width: auto;
    min-width: 0;
    object-fit: contain;
}

/* Credits Bottom - Stacked Lines Container */
.credits-bottom-lines {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

.credit-line {
    height: auto;
    width: auto !important;
    flex-shrink: 0;
    max-width: 100%;
}

/* Handle picture element as credit-line */
picture.credit-line img {
    width: 100%;
    height: auto;
}

/* Midground (Wires) - z-index 3 */
/* -3.33% of 1500 = -50px */
.layer-mid {
    z-index: 3;
    top: -50px;
}

.layer-mid img {
    object-fit: contain;
    object-position: center top;
}

/* Foreground (Hand/Watch) - z-index 4 */
/* 92% of 1080 = 994px, -2% of 1500 = -30px */
.layer-fg {
    z-index: 4;
    top: auto;
    bottom: -30px;
    left: 77%;
    transform: translateX(-50%);
    width: 994px;
    height: auto;
}

.layer-fg img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(270px 100px 20px rgba(0,0,0,.5));
}

/* Noise Canvas - z-index 10 (top of stack) */
.noise-canvas {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

/* Credits Bottom - z-index 5 */
/* Centered, moved down for better positioning */
.layer-credits-bottom {
    z-index: 5;
    top: auto;
    bottom: 200px;    /* Was 180px - move down */
    left: 25%;        /* Was 26% - center it */
    transform: translateX(-50%);
    width: 250px;     /* Was 248px - wider container */
    height: auto;
}

.layer-credits-bottom img {
    width: auto;      /* Was 100% - let images be natural size */
    max-width: 100%;  /* But don't exceed container */
    height: auto;
    object-fit: contain;
}

/* ============================================
   Countdown Clock - Portrait Mode
   ============================================ */
@keyframes blink {
    0%, 85%, 100% { opacity: 1; }
    92% { opacity: 0.3; }
}

.countdown {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 0;
    filter: url(#noisy-alpha);
    pointer-events: none;
    animation: blink 1s ease-in-out infinite;

    /* Position on watch face: 77% of 1500 = 1155px, 44% of 1080 = 475px */
    top: 585px;
    left: 435px;
    transform: translate(-50%, -50%) rotate(-43deg);
}

/* 6.4% of 1080 = 69px */
.countdown .countdown-digit {
    height: 69px;
    width: auto;
    display: block;
    object-fit: contain;
}

/* 4.8% of 1080 = 52px */
.countdown .countdown-separator {
    height: 52px;
    width: auto;
    display: block;
    object-fit: contain;
}

/* Countdown Completion State */
.countdown-complete {
    color: #ff605b;
    text-decoration: none;
    font-family: 'Digital-7 Mono', monospace;
    font-size: 48px;
    white-space: nowrap;
    display: block;
    text-shadow: 
        0 0 10px rgba(255, 96, 91, 0.8),
        0 0 20px rgba(255, 96, 91, 0.6),
        0 0 30px rgba(255, 96, 91, 0.4);
}

/* Hover transition - only applies after button is visible */
.countdown-complete.watch-now-btn {
    transition: color 3s ease, text-shadow 3s ease;
}

.countdown-complete:hover {
    color: #fff;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.8),
        0 0 20px rgba(255, 255, 255, 0.6),
        0 0 30px rgba(255, 255, 255, 0.4);
}

/* Enable clicking and stop blink when completed */
.countdown:has(.countdown-complete) {
    pointer-events: auto;
    animation: none;
}

/* ============================================
   Horizontal Mode Styles
   Canvas: 1920×1080
   Triggered by data-mode="horizontal"
   ============================================ */

/* Background & Wires - full coverage, aligned to top */
.poster-container[data-mode="horizontal"] .layer-bg,
.poster-container[data-mode="horizontal"] .layer-mid {
    top: 0;
}

.poster-container[data-mode="horizontal"] .layer-bg img,
.poster-container[data-mode="horizontal"] .layer-mid img {
    object-fit: cover;
    object-position: center top;
}

/* Credits Top - wider spread for horizontal layout */
/* 95% of 1920 = 1824px */
.poster-container[data-mode="horizontal"] .layer-credits-top {
    width: 1824px;
    top: 43px;  /* 4% of 1080 */
}

/* 5% of 1920 = 96px gap */
.poster-container[data-mode="horizontal"] .credits-top-names {
    gap: 96px;
}

.poster-container[data-mode="horizontal"] img.credit-name {
    height: 100px;  /* Scaled for 1920px canvas */
    flex-shrink: 0;
}

/* Credits Bottom - repositioned for horizontal layout */
/* 32% of 1920 = 614px, 8% of 1080 = 86px */
.poster-container[data-mode="horizontal"] .layer-credits-bottom {
    width: 614px;
    bottom: 86px;
    left: 18%;
}

.poster-container[data-mode="horizontal"] .credit-line {
    width: 100% !important;
}

/* Credit-bottom-3 repositioned */
/* right: -61.85% of 1920 = -1188px, width: 20% of 1920 = 384px */
.poster-container[data-mode="horizontal"] .credit-line:nth-child(3) {
    position: absolute;
    right: -1188px;
    top: 0;
    bottom: auto;
    width: 384px !important;
}

/* Hand/Watch - center-right position */
/* 50% of 1920 = 960px, -5% of 1080 = -54px */
.poster-container[data-mode="horizontal"] .layer-fg {
    left: 60%;
    bottom: 0px;
    width: 960px;
}

/* Countdown - adjust for horizontal layout */
/* 77% of 1080 = 832px, 44% of 960 = 422px (relative to hand position) */
.poster-container[data-mode="horizontal"] .countdown {
    top: 565px;
    left: 425px;
}

/* 3.5% of 1920 = 67px */
.poster-container[data-mode="horizontal"] .countdown .countdown-digit {
    height: 67px;
}

/* 2.6% of 1920 = 50px */
.poster-container[data-mode="horizontal"] .countdown .countdown-separator {
    height: 50px;
}

/* ============================================
   Entry Animations (Phase 3)
   ============================================ */

/* Initial hidden states for animated elements */
[data-animate] {
    opacity: 0;
    will-change: opacity, transform;
}

[data-animate="slide-down"] {
    transform: translateX(-50%) translateY(-40px);
}

/* Individual credit name animation initial state */
.credit-name[data-animate="slide-down"] {
    transform: translateY(-40px);
}

/* Individual credit line animation (bottom credits - slide up) */
.credit-line[data-animate="slide-up"] {
    transform: translateY(40px);
}

.credit-line[data-animate="slide-up"].animated {
    opacity: 1;
    transform: translateY(0);
}

/* Layer-specific initial transforms */
.layer-mid[data-animate="slide-up"] {
    transform: translateY(40px);
}

.layer-fg[data-animate="slide-up"] {
    transform: translateX(-50%) translateY(60px);
}

/* Countdown initial state (preserve rotation) */
.countdown[data-animate="fade"] {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-43deg);
}

/* Animated states - triggered by JS */
[data-animate].animated {
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-animate="fade"].animated {
    opacity: 1;
}

[data-animate="slide-down"].animated {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.credit-name[data-animate="slide-down"].animated {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="slide-up"].animated {
    opacity: 1;
}

.layer-mid[data-animate="slide-up"].animated {
    transform: translateY(0);
}

.layer-fg[data-animate="slide-up"].animated {
    transform: translateX(-50%) translateY(0);
}

.countdown[data-animate="fade"].animated {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-43deg);
}

/* ============================================
   Motion Prompt (iOS Permission)
   ============================================ */
.motion-prompt {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    animation: motionPromptFade 0.3s ease-out;
}

.motion-prompt-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 25px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.motion-prompt-icon {
    font-size: 18px;
}

@keyframes motionPromptFade {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
/* Watch Now Button Fade-In Animation */
@keyframes watchNowFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Watch Now Button Enhancement */
.watch-now-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    outline: none !important;
    /* Start invisible - animation will fade in */
    opacity: 0;
}

.watch-now-btn.fade-in {
    animation: watchNowFadeIn 1.5s ease forwards;
}

/* Standalone button positioned same as countdown */
.watch-now-standalone {
    position: absolute;
    top: 585px;
    left: 435px;
    transform: translate(-50%, -50%) rotate(-43deg);
    filter: url(#noisy-alpha);
    pointer-events: auto;
}

/* Horizontal mode positioning for standalone button */
.poster-container[data-mode="horizontal"] .watch-now-standalone {
    top: 565px;
    left: 425px;
}

/* Override entry animation transitions when countdown shows button */
.countdown:has(.watch-now-btn) {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
}

/* Countdown ready state - ensure proper positioning */
.countdown.countdown-ready {
    animation: none !important;
    transition: none !important;
}

.watch-now-btn:focus,
.watch-now-btn:active {
    outline: none;
    border: none;
    box-shadow: none;
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Show all animated elements immediately */
    [data-animate] {
        opacity: 1 !important;
    }

    [data-animate="slide-down"] {
        transform: translateX(-50%) !important;
    }

    .credit-name[data-animate] {
        opacity: 1 !important;
        transform: none !important;
    }

    .credit-line[data-animate] {
        opacity: 1 !important;
        transform: none !important;
    }

    .layer-mid[data-animate],
    .layer-bg[data-animate] {
        transform: none !important;
    }

    .layer-fg[data-animate] {
        transform: translateX(-50%) !important;
    }

    .countdown[data-animate] {
        opacity: 1 !important;
        transform: translate(-50%, -50%) rotate(-43deg) !important;
    }
}
