﻿/* ===== Hero Banner (full-bleed) ===== */

.hero-banner {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
}

    .hero-banner img {
        display: block;
        width: 100%;
        height: auto;
        object-fit: cover;
        max-height: 520px; /* adjust if you want it taller/shorter */
    }

@media (max-width: 768px) {
    .hero-banner img {
        max-height: 360px;
    }
}

/* ===== Puzzle Practice Page Layout ===== */

.puzzle-page {
    padding: 32px 16px 64px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.puzzle-page__inner {
    max-width: 960px;
    margin: 0 auto;
}

/* Header */

.puzzle-header {
    margin-bottom: 24px;
}

.puzzle-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 6px;
}

.puzzle-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: #6b7280; /* gray-500-ish */
}

.puzzle-subtitle-dot {
    color: #16a34a;
    margin: 0 4px;
}

/* Error state */

.puzzle-error {
    margin-top: 12px;
    color: #b91c1c; /* red-700-ish */
    font-size: 0.95rem;
}

/* Root + layout */

.puzzle-root {
    margin-top: 24px;
}

.puzzle-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

/* Info column */

.puzzle-info {
    flex: 1 1 260px;
    max-width: 420px;
    font-size: 0.95rem;
    color: #111827;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

    .puzzle-info p {
        margin-bottom: 12px;
    }

/* Stats list */

.puzzle-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0 4px;
    padding: 0;
    justify-content: center;
}

    .puzzle-stats > div {
        min-width: 110px;
        padding: 8px 12px;
        border-radius: 9999px;
        border: 1px solid #e5e7eb;
        background-color: #ffffff;
        text-align: center;
    }

    .puzzle-stats dt {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #6b7280;
        margin-bottom: 2px;
    }

    .puzzle-stats dd {
        margin: 0;
        font-weight: 600;
        font-size: 0.95rem;
        color: #16a34a;
    }

/* Difficulty */

.puzzle-difficulty {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #6b7280;
}

.puzzle-difficulty__label {
    font-weight: 600;
    color: #16a34a;
}

/* Completion message */

.puzzle-message {
    margin-top: 10px;
    font-size: 0.95rem;
    color: #166534; /* green-700-ish */
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    background-color: #ecfdf3;
    border: 1px solid #16a34a;
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.12);
}

    .puzzle-message::before {
        content: "🏆";
        font-size: 1.1rem;
        flex-shrink: 0;
    }

.puzzle-message--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Actions under message */

.puzzle-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.puzzle-btn {
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 9999px;
    padding: 6px 14px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.puzzle-btn--primary {
    background-color: #16a34a;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(22, 163, 74, 0.3);
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

    .puzzle-btn--primary:hover {
        background-color: #15803d;
        transform: translateY(-1px);
        box-shadow: 0 10px 18px rgba(22, 163, 74, 0.4);
    }

    .puzzle-btn--primary:active {
        transform: translateY(0);
        box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);
    }

    .puzzle-btn--primary:focus-visible {
        outline: 2px solid #22c55e;
        outline-offset: 2px;
    }

.puzzle-link {
    font-size: 0.9rem;
    text-decoration: none;
}

.puzzle-link--harder {
    color: #16a34a;
    text-decoration: underline;
    text-underline-offset: 2px;
}

    .puzzle-link--harder:hover {
        color: #15803d;
    }

/* Board wrapper */

.puzzle-board-wrap {
    flex: 1 1 320px;
    display: flex;
    justify-content: center;
    position: relative;
    flex-direction: column;
    align-items: center;
}

/* Toggle above the board */

.puzzle-mode-toggle {
    width: 100%;
    margin-bottom: 8px;
    text-align: center;
    font-size: 0.85rem;
    color: #4b5563;
}

.puzzle-mode-toggle__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.puzzle-mode-toggle__checkbox {
    width: 14px;
    height: 14px;
    accent-color: #16a34a;
}

/* ===== Puzzle Board Grid ===== */

.puzzle-board {
    /* JS sets --rows and --cols */
    --rows: 3;
    --cols: 3;
    display: grid;
    grid-template-rows: repeat(var(--rows), 1fr);
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 2px;
    width: min(420px, 100%);
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    position: relative;
}

.puzzle-board--solved {
    box-shadow: 0 0 0 2px #16a34a, 0 16px 40px rgba(15, 23, 42, 0.5);
}

    .puzzle-board--solved .puzzle-tile {
        cursor: default;
    }

/* ===== Tiles ===== */

.puzzle-tile {
    border: none;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    cursor: pointer;
    display: block;
    outline: none;
    transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

/* Number-mode tiles */

.puzzle-tile--numbered {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%, #facc15 0, #b45309 70%);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
    color: #111827;
    font-weight: 700;
    font-size: 1.4rem;
}

/* The empty tile (gap) */

.puzzle-tile--empty {
    background: radial-gradient(circle at 30% 30%, #1f2933 0, #020617 70%);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.4);
    cursor: default;
}

/* Hover / focus feedback on non-empty tiles */

.puzzle-tile:not(.puzzle-tile--empty):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.puzzle-tile:not(.puzzle-tile--empty):focus-visible {
    outline: 2px solid #22c55e; /* green-500-ish */
    outline-offset: -2px;
}

/* ===== Confetti ===== */

.puzzle-confetti {
    position: absolute;
    inset: -14% -6% auto -6%;
    pointer-events: none;
    overflow: visible;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 14px;
    border-radius: 2px;
    opacity: 0;
    transform: translateY(0) rotate(0deg);
}

.confetti-piece--1 {
    left: 8%;
    top: -10%;
    background-color: #22c55e;
}

.confetti-piece--2 {
    left: 30%;
    top: -14%;
    background-color: #f97316;
}

.confetti-piece--3 {
    left: 55%;
    top: -12%;
    background-color: #3b82f6;
}

.confetti-piece--4 {
    right: 20%;
    top: -16%;
    background-color: #eab308;
}

.confetti-piece--5 {
    right: 8%;
    top: -10%;
    background-color: #ec4899;
}

.confetti-piece--6 {
    left: 50%;
    top: -18%;
    background-color: #a855f7;
}

@keyframes puzzle-confetti-pop {
    0% {
        opacity: 0;
        transform: translateY(-20px) rotate(0deg);
    }

    10% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(40px) rotate(360deg);
    }
}

.puzzle-root.puzzle-solved .confetti-piece {
    animation: puzzle-confetti-pop 0.9s ease-out forwards;
}

.puzzle-root.puzzle-solved .confetti-piece--1 {
    animation-delay: 0s;
}

.puzzle-root.puzzle-solved .confetti-piece--2 {
    animation-delay: 0.05s;
}

.puzzle-root.puzzle-solved .confetti-piece--3 {
    animation-delay: 0.1s;
}

.puzzle-root.puzzle-solved .confetti-piece--4 {
    animation-delay: 0.15s;
}

.puzzle-root.puzzle-solved .confetti-piece--5 {
    animation-delay: 0.2s;
}

.puzzle-root.puzzle-solved .confetti-piece--6 {
    animation-delay: 0.25s;
}

/* ===== Responsive tweaks ===== */

@media (max-width: 768px) {
    .puzzle-page {
        padding-top: 24px;
    }

    .puzzle-title {
        font-size: 1.5rem;
    }

    .puzzle-layout {
        flex-direction: column;
    }

    .puzzle-board {
        width: 100%;
        max-width: 360px;
    }
}

/* ===== Completed puzzle preview ===== */

.puzzle-preview {
    margin-top: 12px;
    text-align: center;
}

    .puzzle-preview figure {
        margin: 0;
    }

.puzzle-preview__frame {
    position: relative;
    width: 100%;
    max-width: 260px;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    background-color: #000000;
    margin-left: auto;
    margin-right: auto;
}

    .puzzle-preview__frame img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

.puzzle-preview figcaption {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #6b7280;
    text-align: center;
}

/* ===== Puzzle leaderboard ===== */

.puzzle-leaderboard {
    flex: 1 1 260px;
    max-width: 320px;
}

.puzzle-leaderboard__card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    font-size: 0.9rem;
    color: #111827;
}

.puzzle-leaderboard__title {
    margin: 0 0 4px;
    font-size: 1.1rem;
    font-weight: 600;
}

.puzzle-leaderboard__subtitle {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: #6b7280;
}

.puzzle-leaderboard__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.puzzle-leaderboard__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid #e5e7eb;
}

    .puzzle-leaderboard__item:last-child {
        border-bottom: none;
    }

.puzzle-leaderboard__left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.puzzle-leaderboard__rank {
    width: 24px;
    height: 24px;
    border-radius: 9999px;
    background-color: #16a34a;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.puzzle-leaderboard__main {
    flex: 1 1 auto;
}

.puzzle-leaderboard__name {
    font-weight: 600;
    font-size: 0.9rem;
}

.puzzle-leaderboard__meta {
    margin-left: auto;
    font-size: 0.85rem;
    color: #111827;
    white-space: nowrap;
}

.puzzle-leaderboard__moves {
    color: #16a34a;
    font-weight: 600;
}

.puzzle-leaderboard__completions {
    margin-left: 4px;
}

.puzzle-leaderboard__empty {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: #6b7280;
}

/* Coach profile chip inside leaderboard */

.puzzle-coach-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

    .puzzle-coach-link:hover .puzzle-coach-name {
        text-decoration: underline;
    }

.puzzle-avatar-fallback,
.puzzle-avatar-wrap {
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: #e5e7eb;
    color: #374151;
    flex-shrink: 0;
}

.puzzle-avatar-wrap {
    overflow: hidden;
}

.puzzle-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.puzzle-coach-name {
    font-weight: 600;
    font-size: 0.9rem;
}
