/* ─── Motion & Depth System ────────────────────────────────── */

/* Particle Canvas */
#particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* Cursor Glow */
#cursor-glow {
    position: fixed;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent, #38bdf8) 0%, transparent 70%);
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
    will-change: left, top;
}

/* ─── Theme Transition Overlay ─────────────────────────────── */
#theme-transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#theme-transition-overlay.active {
    opacity: 1;
    animation: themeWipe 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes themeWipe {
    0%   { clip-path: circle(0% at 50% 50%); opacity: 1; }
    50%  { clip-path: circle(100% at 50% 50%); opacity: 1; }
    100% { clip-path: circle(100% at 50% 50%); opacity: 0; }
}

/* ─── Captured Pieces Tray ─────────────────────────────────── */
.captured-tray {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.06);
    width: min(80vw, 560px);
    overflow-x: auto;
    scrollbar-width: none;
}

.captured-tray::-webkit-scrollbar { display: none; }

.captured-pieces {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
}

.captured-pieces img {
    width: 24px;
    height: 24px;
    margin-left: -4px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
    animation: capturedPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    opacity: 0.85;
}

.captured-pieces img:first-child { margin-left: 0; }

.captured-advantage {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-left: auto;
    padding-left: 8px;
    white-space: nowrap;
}

@keyframes capturedPop {
    from { transform: scale(0) translateY(-8px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 0.85; }
}

/* ─── ROOOOK Blue Piece Tinting ────────────────────────────── */
.rooook-piece[data-color="w"] {
    filter: brightness(1.1) sepia(1) saturate(5) hue-rotate(180deg)
            drop-shadow(0 0 10px rgba(56, 189, 248, 0.8))
            drop-shadow(0 0 4px rgba(56, 189, 248, 0.5)) !important;
    z-index: 14;
}

.rooook-piece[data-color="b"] {
    filter: brightness(0.7) sepia(1) saturate(4) hue-rotate(200deg)
            drop-shadow(0 0 10px rgba(30, 64, 175, 0.9))
            drop-shadow(0 0 4px rgba(30, 64, 175, 0.6)) !important;
    z-index: 14;
}

/* ─── Enhanced Entrance Animations ─────────────────────────── */
@keyframes staggerFadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

#match-setup-layer > div,
#match-setup-layer > button {
    animation: staggerFadeUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#match-setup-layer > div:nth-child(1) { animation-delay: 0.05s; }
#match-setup-layer > div:nth-child(2) { animation-delay: 0.1s; }
#match-setup-layer > div:nth-child(3) { animation-delay: 0.15s; }
#match-setup-layer > div:nth-child(4) { animation-delay: 0.2s; }
#match-setup-layer > button { animation-delay: 0.25s; }

/* Board squares stagger on load */
@keyframes squareFadeIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.board .square {
    animation: squareFadeIn 0.25s ease both;
}

/* ─── Micro-Interactions ───────────────────────────────────── */

/* Button press haptic feel */
.btn {
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.1s ease,
                background 0.25s ease,
                border-color 0.25s ease;
}

.theme-btn {
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.1s ease,
                background 0.25s ease,
                border-color 0.25s ease,
                color 0.25s ease;
}

/* Status text pulse on check */
.status.check {
    animation: checkPulse 0.8s ease infinite alternate;
}

@keyframes checkPulse {
    from { text-shadow: 0 0 0 transparent; }
    to   { text-shadow: 0 0 20px var(--danger), 0 0 40px var(--danger); }
}

/* Move hint dot subtle pulse */
.square.hint::after {
    animation: hintPulse 1.2s ease-in-out infinite alternate;
}

@keyframes hintPulse {
    from { transform: scale(0.85); opacity: 0.5; }
    to   { transform: scale(1); opacity: 1; }
}

/* History list item entrance */
.history li {
    animation: staggerFadeUp 0.2s ease both;
}

/* Timer active glow */
.timer-box.active {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    animation: timerGlow 1.5s ease-in-out infinite alternate;
}

@keyframes timerGlow {
    from { box-shadow: 0 0 8px rgba(56, 189, 248, 0.15); }
    to   { box-shadow: 0 0 20px rgba(56, 189, 248, 0.35); }
}

/* Timer warning shake */
.timer-box.warning .time {
    animation: timerShake 0.4s ease;
}

@keyframes timerShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Game title floating */
.game-title {
    animation: titleFloat 4s ease-in-out infinite;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Menu title subtle breathing */
.menu-title {
    animation: titleBreathe 3s ease-in-out infinite;
}

@keyframes titleBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

/* Piece placement bounce */
@keyframes pieceDrop {
    0% { transform: scale(0.6) translateY(-12px); opacity: 0.3; }
    60% { transform: scale(1.08) translateY(0); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Victory modal special entrance */
#victory-modal:not(.hidden) {
    animation: victorySlam 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes victorySlam {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Frozen square ice animation */
.square.frozen::after {
    animation: iceShimmer 2s ease-in-out infinite alternate;
}

@keyframes iceShimmer {
    from { background: rgba(100, 200, 255, 0.2); box-shadow: inset 0 0 10px rgba(100, 200, 255, 0.4); }
    to   { background: rgba(100, 200, 255, 0.35); box-shadow: inset 0 0 20px rgba(100, 200, 255, 0.7); }
}

/* ─── Game Container Parallax Depth ────────────────────────── */
#game-container {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.board {
    transition: transform 0.15s ease-out;
    will-change: transform;
}

/* ─── Smooth scroll for history panel ──────────────────────── */
.history {
    scroll-behavior: smooth;
}

/* Pink theme captured tray */
body[data-theme="pink"] .captured-tray {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(219, 39, 119, 0.15);
}
