/*
 * Hue Two: A Duotone Zoo
 * Layout inspired by duotone.shapefactory.co: dark app shell, left rail of
 * big circular color swatches, pill search in a top bar, image stage.
 * CSS custom properties --c1 / --c2 are updated live from script.js.
 */
:root {
    --c1: #0f2c5c;
    --c2: #ff6f91;

    --bg: #141416;
    --panel: #1c1c1f;
    --panel-2: #242428;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.85);
    --text: #f4f4f5;
    --muted: #9a9aa3;

    --radius: 14px;
    --sidebar-w: 220px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Soft glow in the active colors behind the app shell */
.ambient {
    position: fixed;
    inset: -20%;
    z-index: 0;
    background:
        radial-gradient(40% 50% at 15% 20%, color-mix(in srgb, var(--c2) 35%, transparent), transparent 70%),
        radial-gradient(45% 55% at 85% 85%, color-mix(in srgb, var(--c1) 55%, transparent), transparent 70%);
    filter: blur(60px);
    opacity: .55;
    transition: background .6s var(--ease);
    pointer-events: none;
}

.app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    padding: 14px;
    gap: 14px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(12px, 2vh, 20px);
    padding: clamp(14px, 2.2vh, 20px) 16px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(18px);
    overflow: hidden;
}

/* Mascot: small, with a glow tinted by the highlight color */
.mascot {
    width: auto;
    height: clamp(60px, 9vh, 80px);
    filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--c2) 45%, transparent));
    transform-origin: 50% 100%;
    transition: filter .4s var(--ease);
    user-select: none;
    -webkit-user-drag: none;
}
.mascot:hover { animation: wiggle .6s var(--ease); }

@keyframes wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-6deg); }
    50% { transform: rotate(5deg); }
    75% { transform: rotate(-3deg); }
}

.swatches {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.swatch {
    position: relative;
    width: clamp(96px, 14vh, 120px);
    height: clamp(96px, 14vh, 120px);
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .08);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .3s var(--ease);
}
#swatch1 { background: var(--c1); }
#swatch2 { background: var(--c2); }

.swatch:hover { transform: scale(1.05); }
.swatch:active { transform: scale(.97); }
.swatch:focus-within { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

.swatch input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
    padding: 0;
}

.swatch-hex {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: .02em;
    pointer-events: none;
    color: #fff;
}
.swatch-hex.is-dark { color: #111; }

.sidebar-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
    margin-bottom: 8px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 30px);
    gap: 8px;
}

.preset {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    cursor: pointer;
    transform: rotate(-45deg);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.preset:hover { transform: rotate(-45deg) scale(1.15); }
.preset.is-active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }

.sidebar-actions {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 999px;
    font: 600 14px 'Inter', sans-serif;
    cursor: pointer;
    transition: transform .15s var(--ease), background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn--primary {
    border: 0;
    color: #111;
    background: var(--text);
}
.btn--primary:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }


.icon-btn {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--line-strong);
    cursor: pointer;
    font-size: 16px;
    transition: background .2s, transform .2s var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); transform: translateY(-1px); }
.icon-btn--sm { width: 34px; height: 34px; font-size: 13px; }
#swapButton:hover { transform: rotate(180deg); }

/* ---------- Main ---------- */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    gap: 14px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 10px 6px 0 10px;
}

.logo-wrap { margin: 0; line-height: 0; }
.logo { height: 34px; width: auto; display: block; }

.topbar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 1 560px;
}

.search-bar {
    position: relative;
    flex: 1;
    display: flex;
}
.search-bar input {
    width: 100%;
    height: 46px;
    padding: 0 52px 0 22px;
    border-radius: 999px;
    border: 1.5px solid var(--line-strong);
    background: transparent;
    color: var(--text);
    font: 500 15px 'Inter', sans-serif;
    outline: none;
    transition: background .2s, border-color .2s;
}
.search-bar input::placeholder { color: rgba(255, 255, 255, .7); }
.search-bar input:focus { background: rgba(255, 255, 255, .06); border-color: #fff; }
.search-bar button {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    transition: background .2s;
}
.search-bar button:hover { background: rgba(255, 255, 255, .1); }

/* ---------- Stage ---------- */
.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 28px;
    background: color-mix(in srgb, var(--panel) 70%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

canvas {
    display: none;
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
    animation: rise .5s var(--ease);
}
.stage.has-image canvas { display: block; }
.stage.has-image .empty-state { display: none; }



.empty-state {
    max-width: 460px;
    text-align: center;
    color: var(--muted);
    animation: rise .6s var(--ease);
}
.empty-state h2 {
    font-family: 'Sour Gummy', sans-serif;
    font-weight: 600;
    font-size: 30px;
    color: var(--text);
    margin: 18px 0 10px;
}
.empty-state p { line-height: 1.6; font-size: 15px; margin: 0; }
.empty-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 34px;
    color: var(--c2);
    background: linear-gradient(135deg, var(--c1), color-mix(in srgb, var(--c2) 30%, var(--c1)));
    box-shadow: 0 0 0 1px var(--line);
}

.credit {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}
.credit a { color: var(--text); }

.loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(20, 20, 22, .55);
    backdrop-filter: blur(4px);
    z-index: 2;
}
.loader[hidden] { display: none; }
.loader span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c2);
    animation: bounce .9s infinite var(--ease);
}
.loader span:nth-child(2) { background: var(--text); animation-delay: .15s; }
.loader span:nth-child(3) { background: var(--c2); animation-delay: .3s; }

@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-10px); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    body { overflow: auto; }

    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
        min-height: 100vh;
    }

    .main { order: -1; }

    .topbar { flex-direction: column; align-items: stretch; padding: 4px 0 0; }
    .logo { height: auto; width: 100%; max-width: 420px; margin: 0 auto; }
    .topbar-controls { flex: 1 1 auto; }

    .stage { min-height: 55vh; padding: 16px; }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 20px;
    }
    .mascot { height: 72px; }
    .swatches { flex-direction: row; }
    .swatch { width: 92px; height: 92px; }
    .swatch-hex { font-size: 13px; }
    #swapButton i { transform: rotate(90deg); }
    .sidebar-actions { margin-top: 0; flex-direction: row; }
}
