/* ═══════════════════════════════════════════════════════════════════════════════
   Emoji Mixer Game - Styles
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --card-bg: #ffffff;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --success: #00b894;
    --slot-empty: rgba(255, 255, 255, 0.3);
    --slot-hover: rgba(255, 255, 255, 0.5);
    --slot-filled: rgba(255, 255, 255, 0.9);
}

@font-face {
    font-family: 'Fredoka';
    src: url('../../fonts/Fredoka-400.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Fredoka';
    src: url('../../fonts/Fredoka-700.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

button:focus-visible,
a:focus-visible,
.element-item:focus-visible {
    outline: 4px solid #ffe66d;
    outline-offset: 4px;
}

html,
body {
    font-family: 'Fredoka', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
    touch-action: pan-y;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Navigation Bar
   ═══════════════════════════════════════════════════════════════════════════════ */

.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(70px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
    z-index: 100;
}

.nav-btn {
    width: 60px;
    height: 60px;
    background: white;
    border: none;
    border-radius: 50%;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 0 #ccc;
    cursor: pointer;
    transition: transform 0.1s;
}

.nav-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #ccc;
}

.nav-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#sound-btn.sound-off {
    filter: grayscale(0.65);
    opacity: 0.72;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Game Container
   ═══════════════════════════════════════════════════════════════════════════════ */

.game-container {
    display: flex;
    height: calc(100vh - 140px);
    padding-top: calc(70px + env(safe-area-inset-top));
    padding-bottom: 70px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Sidebar: Element Palette
   ═══════════════════════════════════════════════════════════════════════════════ */

.sidebar {
    width: 120px;
    min-width: 100px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    margin-left: env(safe-area-inset-left);
}

.sidebar-header {
    padding: 15px;
    text-align: center;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 2px solid #eee;
}

.element-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Add momentum scrolling for iOS/Android */
    overscroll-behavior-y: contain;
    /* Prevent scrolling the whole page */
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.element-item {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    background: linear-gradient(145deg, #fff, #f0f0f0);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: grab;
    box-shadow: 0 4px 0 #ddd, 0 6px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.15s, box-shadow 0.15s;
}

.element-item:active {
    cursor: grabbing;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.element-item.dragging {
    opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Mixing Zone
   ═══════════════════════════════════════════════════════════════════════════════ */

.mixing-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 30px;
}

.mixing-area {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 100%;
    flex-wrap: wrap;
    /* Allow wrapping on very small screens */
    justify-content: center;
}

.drop-slot {
    width: 100px;
    height: 100px;
    background: var(--slot-empty);
    border: 4px dashed rgba(255, 255, 255, 0.6);
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    transition: all 0.2s;
}

.drop-slot.drag-over {
    background: var(--slot-hover);
    border-color: white;
    transform: scale(1.1);
}

.drop-slot.filled {
    background: var(--slot-filled);
    border: 4px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.slot-placeholder {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

.drop-slot.filled .slot-placeholder {
    display: none;
}

.plus-sign {
    font-size: 3rem;
    color: white;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mix-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(145deg, var(--accent), var(--accent-light));
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 0 #5543c8, 0 10px 25px rgba(0, 0, 0, 0.3);
    transition: all 0.15s;
    margin-left: 15px;
}

.mix-btn:disabled {
    background: #ccc;
    box-shadow: 0 4px 0 #999;
    cursor: not-allowed;
}

.mix-btn:not(:disabled):active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #5543c8;
}

.mix-status {
    min-height: 1.4em;
    color: white;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Result Display
   ═══════════════════════════════════════════════════════════════════════════════ */

.result-area {
    display: none;
    flex-direction: column;
    align-items: center;
}

.result-area.visible {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.result-card {
    background: white;
    padding: 20px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.result-card img {
    width: 200px;
    height: 200px;
    max-width: 100%;
    max-height: 40vh;
    /* Don't overflow the screen height vertically */
    object-fit: contain;
    border-radius: 15px;
}

.result-name {
    margin-top: 15px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.mix-again {
    margin-top: 12px;
    min-height: 48px;
    padding: 9px 18px;
    border: 0;
    border-radius: 999px;
    background: #f1edff;
    color: #4d3aaa;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.mix-again:active {
    transform: translateY(2px);
}

/* Swirl Animation */
.swirl-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    transform: translate(-50%, -50%);
    background: conic-gradient(from 0deg, #6c5ce7, #a29bfe, #fd79a8, #fdcb6e, #00b894, #6c5ce7);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.swirl-animation.active {
    animation: swirl 1s ease-out forwards;
}

@keyframes swirl {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5) rotate(360deg);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2) rotate(720deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pop Animation */
@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.pop {
    animation: pop 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Collection Gallery
   ═══════════════════════════════════════════════════════════════════════════════ */

.collection {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(70px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 15px;
    padding-left: calc(130px + env(safe-area-inset-left));
    /* Account for sidebar */
    padding-right: calc(15px + env(safe-area-inset-right));
}

.collection-header {
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.collection-count {
    background: var(--success);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.collection-items {
    flex: 1;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0;
}

.collection-item {
    width: 50px;
    height: 50px;
    min-width: 50px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.collection-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive: Portrait / Mobile
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px),
(orientation: portrait) {
    .nav-btn {
        width: 52px;
        height: 52px;
        font-size: 1.55rem;
    }

    .nav-actions {
        gap: 7px;
    }

    .sidebar {
        width: 90px;
        min-width: 80px;
    }

    .element-item {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }

    .drop-slot {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }

    .mix-btn {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }

    .result-card img {
        width: 150px;
        height: 150px;
    }

    .mix-status {
        font-size: 1rem;
    }

    .collection {
        padding-left: calc(100px + env(safe-area-inset-left));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive: Large Tablets / Landscape
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {
    .sidebar {
        width: 150px;
    }

    .element-item {
        width: 100px;
        height: 100px;
        font-size: 3rem;
    }

    .drop-slot {
        width: 120px;
        height: 120px;
        font-size: 4rem;
    }

    .mix-btn {
        width: 100px;
        height: 100px;
        font-size: 3rem;
    }

    .result-card img {
        width: 280px;
        height: 280px;
    }

    .result-name {
        font-size: 2rem;
    }
}

/* iPad landscape: preserve room for the whole mixing ritual and its result. */
@media (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
    .nav-bar { height: calc(66px + env(safe-area-inset-top)); }
    .game-container {
        height: 100dvh;
        padding-top: calc(66px + env(safe-area-inset-top));
        padding-bottom: calc(68px + env(safe-area-inset-bottom));
    }
    .sidebar { width: 132px; min-width: 132px; }
    .sidebar-header { padding: 10px 8px; font-size: .95rem; }
    .element-item { width: 82px; height: 82px; font-size: 2.6rem; }
    .mixing-zone { gap: 18px; padding: 14px 24px; }
    .drop-slot { width: 112px; height: 112px; }
    .result-card { padding: 14px; }
    .result-card img { width: min(31vw, 250px); height: min(31vw, 250px); max-height: 38dvh; }
    .mix-status { margin-top: -4px; }
    .mix-again { min-height: 46px; margin-top: 8px; }
    .collection { height: calc(68px + env(safe-area-inset-bottom)); padding-left: calc(146px + env(safe-area-inset-left)); }
}
