/**
 * Happy Death Day - Styles
 * Phase 1: Core Navigation MVP
 GLOW LINES: Inner color:25-26, Inner Size/Reach:193-265, Outer glow rainbow Speed: 75, everything else: 80-110
 Nav menu buttons SVG color: 300
 */

/* ===== CSS Variables ===== */
:root {
    /* Colors - Dark ethereal palette */
    --bg-primary: #0a0f0d;
    --bg-secondary: #0d1210;
    --accent-red: #e11d48;
    /* Deep Rose Red */
    --accent-red-dark: #be123c;
    --accent-teal: #2dd4bf;
    /* Restored */
    --accent-teal-dark: #14b8a6;
    --accent-aurora-green: #22c55e;
    --accent-aurora-purple: #8b5cf6;
    --accent-amber: #f59e0b;
    --text-primary: #faf7f2;
    --text-secondary: #a8a29e;
    --overlay-bg: rgba(10, 15, 13, 0.85);
    /* --glow-red: rgba(225, 29, 72, 0.4); */
    --glow-red: rgba(100, 0, 0, 0.8);
    --glow-teal: rgba(0, 110, 94, 0.8);
    /* Restored */
    /* Control Button Colors*/
    --control-buttons-svg: rgba(255, 236, 151, 0.8);
    --control-buttons-glow: rgba(0, 82, 69, 0.8);
    /* Restored */
    --disabled: rgba(168, 162, 158, 0.3);

    /* Typography */
    --font-title: 'Cinzel', serif;
    --font-body: 'Cormorant Garamond', serif;

    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;

    /* Transitions */
    --transition-fast: 0.3s ease;
    --transition-medium: 0.5s ease;
    --transition-slow: 1.5s;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== Main Image Container ===== */
.image-container {
    position: relative;
    width: min(100vw, 100vh);
    height: min(100vw, 100vh);
    max-width: 1920px;
    max-height: 1920px;
    display: flex;
    align-items: center;
    justify-content: center;
    /*animation: rainbowPulse 15s linear infinite;*/
    animation: breathe 6s ease-in-out infinite;
}

/*           X/Y offset, soft, size, RGB, Transparency  */
@keyframes rainbowPulse {
    0% {
        box-shadow: 0 0 100px 25px rgba(255, 0, 0, 0.5);
    }

    15% {
        box-shadow: 0 0 125px 40px rgba(255, 127, 0, 0.6);
    }

    30% {
        box-shadow: 0 0 100px 25px rgba(255, 255, 0, 0.5);
    }

    45% {
        box-shadow: 0 0 125px 40px rgba(0, 255, 0, 0.6);
    }

    60% {
        box-shadow: 0 0 100px 25px rgba(0, 0, 255, 0.5);
    }

    75% {
        box-shadow: 0 0 125px 40px rgba(75, 0, 130, 0.6);
    }

    90% {
        box-shadow: 0 0 100px 25px rgba(148, 0, 211, 0.5);
    }

    100% {
        box-shadow: 0 0 100px 25px rgba(255, 0, 0, 0.5);
    }
}


@keyframes breathe {

    0%,
    100% {
        box-shadow: 0 0 10px 2px rgba(139, 0, 20, 0.3);
    }

    35% {
        box-shadow: 0 0 35px 12px rgba(180, 30, 50, 0.6);
    }

    42% {
        box-shadow: 0 0 35px 12px rgba(180, 30, 50, 0.6);
    }
}


.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Removed transition property - it conflicts with animation */
}

/* Hover effect - ethereal glow */
.image-container:hover img {
    filter: brightness(1.05) drop-shadow(0 0 20px var(--glow-red));
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {

    .image-container img,
    .poem-overlay,
    .nav-zone {
        transition: none !important;
    }
}

/* ===== Navigation Zones ===== */
.nav-zone {
    position: absolute;
    cursor: pointer;
    z-index: 10;
    transition: box-shadow var(--transition-fast);
}

/* Edge zones - 20% each side */
/* Navigation Zones - Diagonal Quadrants */
.nav-zone-left,
.nav-zone-right,
.nav-zone-top,
.nav-zone-bottom {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    transition: background var(--transition-medium);
}

/* Diagonal cuts */
.nav-zone-left {
    clip-path: polygon(0 0, 0 100%, 50% 50%);
}

.nav-zone-right {
    clip-path: polygon(100% 0, 100% 100%, 50% 50%);
}

.nav-zone-top {
    clip-path: polygon(0 0, 100% 0, 50% 50%);
}

.nav-zone-bottom {
    clip-path: polygon(0 100%, 100% 100%, 50% 50%);
}

/* Center zone - overlay on top */
.nav-zone-center {
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    cursor: pointer;
    z-index: 20;
    /* Circular toggle area or reduced square */
    border-radius: 50%;
}

/* Navigation availability indicators (Gradients) */
.nav-zone.available {
    cursor: pointer;
}

/* Edge glows using gradients instead of box-shadows */
.nav-zone-left.available {
    background: linear-gradient(to right, var(--glow-teal) 0%, transparent 2%);
}

.nav-zone-right.available {
    background: linear-gradient(to left, var(--glow-teal) 0%, transparent 2%);
}

.nav-zone-top.available {
    background: linear-gradient(to bottom, var(--glow-teal) 0%, transparent 2%);
}

.nav-zone-bottom.available {
    background: linear-gradient(to top, var(--glow-teal) 0%, transparent 2%);
}

/* Hover emphasis */
.nav-zone-left.available:hover {
    background: linear-gradient(to right, var(--accent-teal) 0%, transparent 3%);
}

.nav-zone-right.available:hover {
    background: linear-gradient(to left, var(--accent-teal) 0%, transparent 3%);
}

.nav-zone-top.available:hover {
    background: linear-gradient(to bottom, var(--accent-teal) 0%, transparent 3%);
}

.nav-zone-bottom.available:hover {
    background: linear-gradient(to top, var(--accent-teal) 0%, transparent 3%);
}

/* Disabled directions - Red indication */
.nav-zone-left.disabled {
    background: linear-gradient(to right, var(--glow-red) 0%, transparent 2%);
    cursor: not-allowed;
}

.nav-zone-right.disabled {
    background: linear-gradient(to left, var(--glow-red) 0%, transparent 2%);
    cursor: not-allowed;
}

.nav-zone-top.disabled {
    background: linear-gradient(to bottom, var(--glow-red) 0%, transparent 2%);
    cursor: not-allowed;
}

.nav-zone-bottom.disabled {
    background: linear-gradient(to top, var(--glow-red) 0%, transparent 2%);
    cursor: not-allowed;
}



/* Hover pulse for available directions */
.nav-zone.available:hover {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Pulsing effect for Z/T buttons */
.control-button.pulse-active {
    animation: pulse-size-glow 2s ease-in-out infinite;
    box-shadow: 0 0 15px var(--glow-teal);
    border: 1px solid var(--accent-teal);
}

@keyframes pulse-size-glow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--glow-teal);
    }

    50% {
        transform: scale(1.15);
        box-shadow: 0 0 25px var(--accent-teal);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--glow-teal);
    }
}

/* ===== Poem Overlay ===== */
.poem-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
    text-align: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 20;
}

.poem-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.poem-text-container {
    max-width: 80%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
}

/* Hide scrollbar but keep functionality */
.poem-text-container::-webkit-scrollbar {
    width: 0;
    display: none;
}

.poem-text-container {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

/* Poem typography */
.poem-title {
    font-family: var(--font-title);
    font-weight: 500;
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.poem-author {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.poem-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
    z-index: 25;
    font-size: 1.5rem;
    color: var(--text-secondary);
    filter: drop-shadow(0 0 6px var(--glow-red));
}

.scroll-indicator.visible {
    opacity: 0.6;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* ===== Controls Container ===== */
.controls-container {
    position: fixed;
    z-index: 30;
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    background: rgba(10, 15, 13, 0.6);
    border: 1px solid var(--glow-red);
    border-radius: 2rem;
    backdrop-filter: blur(5px);
    transition: opacity var(--transition-fast);
}

.controls-container:hover {
    opacity: 1;
}

/* Landscape Mode (Default/Desktop) - Column on Right */
@media (orientation: landscape) {
    .controls-container {
        right: 2rem;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
    }
}

/* Portrait Mode (Mobile) - Row at Bottom */
@media (orientation: portrait) {
    .controls-container {
        bottom: 2rem;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
    }
}

/* ===== Sub-Controls Container ===== */
.sub-controls-container {
    position: fixed;
    z-index: 29;
    /* Below controls (30) but above overlay */
    display: none;
    /* Hidden by default */
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: rgba(10, 15, 13, 0.8);
    border: 1px solid var(--accent-teal);
    border-radius: 2rem;
    backdrop-filter: blur(5px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sub-controls-container.visible {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

/* Sub-controls positioning based on orientation *must* match controls-container */
@media (orientation: landscape) {
    .sub-controls-container {
        right: 6rem;
        /* Left of the main controls */
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
    }
}

@media (orientation: portrait) {
    .sub-controls-container {
        bottom: 6rem;
        /* Above the main controls */
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
    }
}

/* ===== Control Buttons ===== */
.control-button {
    background: transparent;
    border: none;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: transform var(--transition-fast), background-color var(--transition-fast);
}

.control-button:hover {
    transform: scale(1.1);
    background-color: rgba(45, 212, 191, 0.1);
}

.control-button svg {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--control-buttons-svg);
    /* For text icons */
    font-size: 1.5rem;
    filter: drop-shadow(0 0 6px var(--control-buttons-glow));
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(10, 15, 13, 0.95);
    border: 1px solid var(--accent-red);
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    z-index: 100;
    opacity: 0;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    box-shadow: 0 0 20px var(--glow-red);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Poem Intro Animation ===== */
.poem-intro {
    position: absolute;
    width: 80%;
    /* 3 lines approx */
    height: 4.5em;
    /* Bottom third-ish */
    bottom: 20%;
    left: 10%;
    overflow: hidden;
    pointer-events: none;
    /* Clicks pass through to nav/toggle */
    z-index: 18;
    /* Below center nav zone (20) but above image */
    mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    display: none;
    /* Hidden by default */
}

.poem-intro-content {
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: center;
    /* Will be animated via JS applying inline animation style */
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

@keyframes introScroll {
    0% {
        transform: translateY(5em);
        /* Start just below the 4.5em container */
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-150%);
        opacity: 0;
    }
}

/* ===== Transition Effects ===== */
/* Each effect has multiple easing variations for different feels */

/* 1. FADE - Simple opacity transitions */
.transition-fade-out {
    animation: fadeOut var(--transition-slow) ease-out forwards;
}

.transition-fade-in {
    animation: fadeIn var(--transition-slow) ease-in forwards;
}

.transition-fade-smooth {
    animation: fadeOut var(--transition-slow) ease-in-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 2. DISSOLVE - Blur + fade (digital artifacts effect) */
.transition-dissolve {
    animation: dissolve var(--transition-slow) ease-out forwards;
}

.transition-dissolve-fast {
    animation: dissolve 1s ease-in forwards;
    /* Faster, starts slow */
}

.transition-dissolve-glitch {
    animation: dissolveGlitch var(--transition-slow) ease-in-out forwards;
}

@keyframes dissolve {
    0% {
        opacity: 1;
        filter: blur(0px);
    }

    100% {
        opacity: 0;
        filter: blur(10px);
    }
}

@keyframes dissolveGlitch {
    0% {
        opacity: 1;
        filter: blur(0px);
    }

    25% {
        opacity: 0.8;
        filter: blur(3px) hue-rotate(10deg);
    }

    50% {
        opacity: 0.6;
        filter: blur(6px) hue-rotate(-10deg);
    }

    75% {
        opacity: 0.3;
        filter: blur(9px);
    }

    100% {
        opacity: 0;
        filter: blur(12px);
    }
}

/* 3. WIPE - Directional slide-out effects */
.transition-wipe-left {
    animation: wipeLeft var(--transition-slow) ease-out forwards;
}

.transition-wipe-left-fast {
    animation: wipeLeft 0.8s ease-in forwards;
    /* Quick exit */
}

.transition-wipe-left-smooth {
    animation: wipeLeft var(--transition-slow) ease-in-out forwards;
}

@keyframes wipeLeft {
    from {
        clip-path: inset(0 0 0 0);
    }

    to {
        clip-path: inset(0 100% 0 0);
    }
}

.transition-wipe-right {
    animation: wipeRight var(--transition-slow) ease-out forwards;
}

.transition-wipe-right-fast {
    animation: wipeRight 0.8s ease-in forwards;
}

.transition-wipe-right-smooth {
    animation: wipeRight var(--transition-slow) ease-in-out forwards;
}

@keyframes wipeRight {
    from {
        clip-path: inset(0 0 0 0);
    }

    to {
        clip-path: inset(0 0 0 100%);
    }
}

/* Ripple effect */
.transition-ripple {
    animation: ripple var(--transition-slow) ease-out forwards;
}

@keyframes ripple {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }

    100% {
        opacity: 0;
        transform: scale(1.2);
        filter: blur(5px);
    }
}

/* Ethereal shimmer */
.transition-shimmer {
    animation: shimmer var(--transition-slow) ease-out forwards;
}

@keyframes shimmer {
    0% {
        opacity: 1;
        filter: brightness(1) saturate(1);
    }

    50% {
        filter: brightness(1.3) saturate(1.5) hue-rotate(15deg);
    }

    100% {
        opacity: 0;
        filter: brightness(0.5) saturate(0);
    }
}

/* Fade to black */
.transition-fade-black {
    animation: fadeToBlack var(--transition-slow) ease-out forwards;
}

@keyframes fadeToBlack {
    0% {
        opacity: 1;
        filter: brightness(1);
    }

    50% {
        filter: brightness(0);
    }

    100% {
        opacity: 0;
        filter: brightness(0);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .poem-title {
        font-size: 1.25rem;
    }

    .poem-author {
        font-size: 0.85rem;
    }

    .poem-body {
        font-size: 1rem;
    }

    .poem-overlay {
        padding: 1.5rem;
    }

    /* Ensure touch targets are at least 44px */
    .nav-zone {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===== Accessibility ===== */
/* High contrast for text */
/* Contrast ratio checks: ~12:1 for primary text, ~6:1 for secondary text */

/* Focus indicators for keyboard navigation */
.nav-zone:focus-visible {
    outline: 2px solid var(--accent-red);
    outline-offset: -2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Close Button */
.code-close-button {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--accent-red);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30;
    transition: all var(--transition-fast);
    background: rgba(10, 15, 13, 0.5);
    backdrop-filter: blur(4px);
}

.code-close-button svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.code-close-button:hover {
    background: rgba(225, 29, 72, 0.2);
    transform: rotate(90deg);
}

.code-close-button:hover svg {
    color: var(--accent-red);
}

@media (max-width: 768px) {
    .code-close-button {
        top: 1rem;
        right: 1rem;
        width: 2rem;
        height: 2rem;
    }
}