:root {
    --bg-color: #fdfcfa; /* Off-white */
    --text-main: #2b2b2b;
    --text-muted: #8a8a8a;
    --grid-gap: 20px;
    --harmony-overlay: transparent;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative;
    overflow-x: hidden;
}

.harmony-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--harmony-overlay);
    transition: background-color 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
    z-index: 0;
    opacity: 0.08; /* Very subtle tint */
    mix-blend-mode: multiply; /* Better blending with off-white */
}

.content-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px;
}

.app-header {
    margin-bottom: 60px;
    text-align: left;
}

.app-header .title {
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.app-header .subtitle {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 10px;
    color: var(--text-main);
}

.app-header .description {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.filter-bar-right {
    margin-left: auto;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 14px;
    border: 1.5px solid rgba(43, 43, 43, 0.12);
    border-radius: 100px;
    background: transparent;
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition:
        background 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        color 0.25s,
        border-color 0.25s,
        transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.25s;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.filter-btn:hover {
    border-color: rgba(43, 43, 43, 0.3);
    color: var(--text-main);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.filter-btn.active {
    background: var(--text-main);
    color: #fdfcfa;
    border-color: var(--text-main);
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

.filter-btn.active:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

/* Color count dots */
.filter-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.filter-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.filter-btn.active .filter-dots .dot {
    opacity: 1;
}

/* All-icon SVG */
#filter-all svg {
    display: block;
    opacity: 0.65;
    transition: opacity 0.2s;
}
#filter-all.active svg,
#filter-all:hover svg {
    opacity: 1;
}

/* Shuffle / Randomize button */
.randomize-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: 1.5px solid rgba(43, 43, 43, 0.12);
    border-radius: 100px;
    background: transparent;
    font-family: 'Outfit', sans-serif;
    color: var(--text-muted);
    cursor: pointer;
    transition:
        background 0.25s,
        color 0.25s,
        border-color 0.25s,
        transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.25s;
}

.randomize-btn:hover {
    border-color: rgba(43, 43, 43, 0.3);
    color: var(--text-main);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.randomize-btn svg {
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.randomize-btn:hover svg {
    transform: rotate(180deg);
}

/* Spinning animation when shuffle is triggered */
.randomize-btn.spinning svg {
    transform: rotate(360deg);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================
   BENTO GRID
   ============================================ */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 240px;
    gap: var(--grid-gap);
    grid-auto-flow: dense;
}

/* Base Tile Styling */
.palette-tile {
    display: flex;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.5s cubic-bezier(0.25, 1, 0.5, 1),
                box-shadow 0.5s;
    cursor: default;
}

.palette-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* Tile hidden/visible states — come after base to override */
.palette-tile.hidden {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-tile.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sub-spans for Bento */
.colspan-2 { grid-column: span 2; }
.rowspan-2 { grid-row: span 2; }

/* ============================================
   LIQUID BLEED SWATCH SYSTEM
   ============================================ */
.color-swatch {
    flex: 1;
    height: 100%;
    /* Spring-like flex transition */
    transition:
        flex 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 2rem;
    position: relative;
    overflow: hidden; /* clip the bleed pseudo-elements */
}

/* --- Liquid Bleed: bleeds INTO left neighbor --- */
.color-swatch::before {
    content: '';
    position: absolute;
    top: 0; left: -60%; bottom: 0;
    width: 60%;
    background: linear-gradient(
        to left,
        var(--swatch-color, transparent) 0%,
        transparent 100%
    );
    opacity: 0;
    filter: blur(18px);
    /* Step 1: bleed in quickly */
    transition:
        opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        left 0.65s cubic-bezier(0.34, 1.56, 0.64, 1); /* overshoot = liquid slosh */
    pointer-events: none;
    z-index: 2;
}

/* --- Liquid Bleed: bleeds INTO right neighbor --- */
.color-swatch::after {
    content: '';
    position: absolute;
    top: 0; right: -60%; bottom: 0;
    width: 60%;
    background: linear-gradient(
        to right,
        var(--swatch-color, transparent) 0%,
        transparent 100%
    );
    opacity: 0;
    filter: blur(18px);
    transition:
        opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        right 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 2;
}

/* --- Activate bleed on the HOVERED swatch --- */
.palette-tile .color-swatch:hover::before {
    opacity: 0.55;
    left: -20%; /* push INTO left neighbor */
}
.palette-tile .color-swatch:hover::after {
    opacity: 0.55;
    right: -20%; /* push INTO right neighbor */
}

/* --- Flex expansion: hovered swatch expands, others compress --- */
.palette-tile:hover .color-swatch {
    flex: 0.55;
}

/* --- Slight darkening of non-hovered siblings --- */
.palette-tile:hover .color-swatch:not(:hover) {
    filter: brightness(0.93);
    transition:
        flex 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.4s;
}

/* Hovered swatch: expand + brighten */
.palette-tile .color-swatch:hover {
    flex: 2.4;
    filter: brightness(1.04);
}

/* HEX Code label */
.hex-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    background: rgba(0,0,0,0.2);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

/* Detect brightness via JS to swap label color? Actually just use dark translucent bg */
.color-swatch:hover .hex-label {
    opacity: 1;
    transform: translateY(0);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111;
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .bento-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 200px;
    }
    .colspan-2, .rowspan-2 {
        grid-column: span 1;
        grid-row: span 1;
    }
    .content-wrapper {
        padding: 20px;
    }
    .app-header .subtitle {
        font-size: 2rem;
    }
}
@media (max-width: 480px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
}
