/* ============================================================
   CUE — styles.css
   Light theme · System fonts · Right panel · Responsive
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */

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

/* ── Tokens ─────────────────────────────────────────────────── */

:root {
    --font:
        -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, "Arial",
        sans-serif;
    --font-mono:
        ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Menlo, monospace;

    --color-bg: #f5f5f5;
    --color-panel: #ffffff;
    --color-header: #ffffff;
    --color-border: #e5e5e5;
    --color-border-focus: #b0b0b0;

    --color-text: #1a1a1a;
    --color-text-muted: #777777;
    --color-text-faint: #b0b0b0;

    --color-chip-bg: #f0f0f0;
    --color-chip-hover: #e8e8e8;
    --color-chip-active-bg: #1a1a1a;
    --color-chip-active-text: #ffffff;

    --header-h: 52px;
    --panel-w: 280px;
    --radius-chip: 99px;
}

/* ── Base ───────────────────────────────────────────────────── */

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: var(--font);
    cursor: pointer;
}

svg {
    width: 14px;
    height: 14px;
}

/* ── Header ─────────────────────────────────────────────────── */

.header {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-h);
    background: var(--color-header);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 200;
}

.reset-btn {
    display: flex;
    gap: 6px;
    margin-left: auto;
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12.5px;
    font-family: var(--font);
    line-height: 1em;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
}

.reset-btn svg * {
    stroke: var(--color-text-muted);
}

.reset-btn:hover {
    background: #fff4f4;
    border-color: #ffb4b4;
    color: #e41a1a;
}

.reset-btn:hover svg * {
    stroke: #e41a1a;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    vertical-align: middle;
    cursor: default;
    user-select: none;
}

.logo-mark {
    font-size: 32px;
    color: #1a1a1a;
    line-height: 1;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--color-text);
    text-transform: lowercase;
    line-height: 1em;
}

.header-tagline {
    font-size: 13px;
    color: var(--color-text-muted);
    text-transform: lowercase;
    letter-spacing: -0.02em;
}

/* ── Layout ─────────────────────────────────────────────────── */

.layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    /* padding-top: var(--header-h); */
}

/* ── Preview area ───────────────────────────────────────────── */

.preview-area {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    overflow: auto;
    padding: 0 40px;
}

/* ── Canvas frame ───────────────────────────────────────────── */

.frame-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
}

@keyframes scaleDown {
    from {
        transform: scale(1.1);
    }
    to {
        transform: scale(1);
    }
}

@keyframes scaleDownFadeIn {
    from {
        transform-origin: 50% -50%;
        opacity: 0;
        transform: scale(1.1);
    }
    to {
        transform-origin: 50% -50%;
        opacity: 1;
        transform: scale(1);
    }
}

.paste-animate {
    animation: scaleDown 0.25s cubic-bezier(0,.69,.1,1.64);
}

.frame {
    border-radius: 6px;
    overflow: hidden;
    line-height: 0;
    max-width: 100%;
    max-height: 100%;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 4px 16px rgba(0, 0, 0, 0.08),
        0 12px 40px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.frame canvas {
    display: block;
    width: auto;
    height: auto;
}

.frame-hint {
    font-size: 11px;
    color: var(--color-text-faint);
    font-family: var(--font-mono);
    letter-spacing: 0.01em;
}

.canvas-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(26, 26, 26, 0.08);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 1;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease;
}

.frame.enter-animate {
    animation: scaleDown 0.25s cubic-bezier(0,.69,.1,1.64);
    animation-fill-mode: both;
}

.canvas-actions.enter-animate {
    opacity: 0;
    animation: scaleDownFadeIn 0.25s cubic-bezier(0,.69,.1,1.64) 0.08s forwards;
    animation-fill-mode: both;
}

.canvas-actions-label {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.2;
    white-space: nowrap;
}

.canvas-browse-btn {
    border: none;
    border-radius: 999px;
    background: #1a1a1a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 9px 14px;
    white-space: nowrap;
}

.canvas-browse-btn:hover {
    opacity: 0.86;
}

/* ── Panel ──────────────────────────────────────────────────── */

.panel {
    position: relative;
    width: var(--panel-w);
    flex-shrink: 0;
    background: var(--color-panel);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.panel::-webkit-scrollbar {
    width: 0px;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--color-border);
}

.panel-section.rowing {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-section:last-child {
    border-bottom: none;
}

/* .panel-section:nth-last-child(2) {
    margin-bottom: 76px;
    border-bottom: none;
}

.panel-section.bottom {
    position: fixed;
    background: rgba(255, 255, 255, 1);
    width: stretch;
    bottom: 0;
    border-top: 1px solid var(--color-border);
} */

.section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--color-text-faint);
}

.preview-area.drag-over .frame {
    transform: translateY(-2px);
    box-shadow:
        0 0 0 1px rgba(26, 26, 26, 0.12),
        0 12px 32px rgba(0, 0, 0, 0.12),
        0 24px 56px rgba(0, 0, 0, 0.08);
}

.preview-area.drag-over .canvas-actions {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(26, 26, 26, 0.16);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.text-input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--color-text);
    background: #ffffff;
    outline: none;
}

.text-input:focus {
    border-color: var(--color-border-focus);
}

.font-select {
    min-width: 144px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 8px 32px 8px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    background: #ffffff;
    outline: none;
}

.font-select:focus {
    border-color: var(--color-border-focus);
}

.secondary-btn {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: #f7f7f7;
    color: var(--color-text);
    font-size: 12px;
    font-weight: 500;
    padding: 8px 12px;
}

.secondary-btn:hover {
    background: #efefef;
}

.helper-text {
    font-size: 11px;
    color: var(--color-text-faint);
    font-family: var(--font-mono);
    line-height: 1.4;
}

.sound-unlock {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.sound-unlock .secondary-btn[disabled] {
    opacity: 0.6;
    cursor: wait;
}



/* ── Controls ───────────────────────────────────────────────── */

/* Chip row container */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#bgGradientDirectionPicker {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

#bgGradientDirectionPicker .chip {
    width: 100%;
    padding-inline: 0;
    text-align: center;
}

/* Individual chip button — rectangular rounded, not pill-shaped */
.chip {
    padding: 7px 14px;
    border-radius: 10px;
    background: #f7f7f7;
    border: 1px solid #e2e2e2;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 400;
    font-family: var(--font);
    white-space: nowrap;
    line-height: 1;
    transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.chip:hover {
    background: #efefef;
    color: var(--color-text);
    border-color: #d0d0d0;
}

.chip.active {
    background: #ffffff;
    color: var(--color-text);
    border-color: #c0c0c0;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

.chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Row: label left, value/swatch right */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.control-label {
    font-size: 13px;
    color: var(--color-text);
    text-transform: capitalize;
}

/* Numeric value readout — styled as a borderless number input */
.val-group {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}

.control-val {
    width: 36px;
    text-align: right;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--color-text-faint);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    /* Hide native number spinner arrows */
    -moz-appearance: textfield;
    appearance: textfield;
}

.control-val::-webkit-outer-spin-button,
.control-val::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.control-val:hover {
    color: var(--color-text);
    cursor: text;
}

.control-val:focus {
    color: var(--color-text);
}

.control-val:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.control-unit {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--color-text-faint);
}

/* ── Slider ─────────────────────────────────────────────────── */

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    border-radius: 99px;
    outline: none;
    cursor: pointer;
    /* filled portion is dark, unfilled is light — updated via --pct in JS */
    background: linear-gradient(
        to right,
        var(--color-text) 0%,
        var(--color-text) var(--pct, 50%),
        var(--color-border) var(--pct, 50%),
        var(--color-border) 100%
    );
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #1a1a1a;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #1a1a1a;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.slider:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

/* ── Color swatch (background color picker) ─────────────────── */

.color-swatch {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border: 1.5px solid var(--color-border);
    border-radius: 7px;
    padding: 2px;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
    transition: border-color 0.15s;
}

.color-swatch:hover {
    border-color: var(--color-border-focus);
}

.color-swatch::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-swatch::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-swatch::-moz-color-swatch {
    border: none;
    border-radius: 4px;
}

/* ── Export ─────────────────────────────────────────────────── */

.export-row {
    display: flex;
    gap: 8px;
}

.export-btn {
    flex: 1;
    height: 38px;
    background: #1a1a1a;
    color: #ffffff;
    border: none;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: opacity 0.15s;
}

.export-btn:hover {
    opacity: 0.8;
}

.export-icon {
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
}

.copy-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 9px;
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.12s,
        color 0.12s;
}

.copy-btn svg * {
    stroke: var(--color-text-muted);
}

.copy-btn:hover {
    background: #f5f5f5;
    border-color: #c8c8c8;
    color: var(--color-text);
}

.copy-btn:hover svg * {
    stroke: var(--color-text);
}

.export-note {
    font-size: 11px;
    color: var(--color-text-faint);
    font-family: var(--font-mono);
}

/* ── Utility ────────────────────────────────────────────────── */

.hidden {
    display: none !important;
}

/* ── Toast ──────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    z-index: 999;
    pointer-events: none;
}

.toast {
    background: #1a1a1a;
    color: #ffffff;
    font-size: 13px;
    padding: 10px;
    border-radius: 10px;
    opacity: 0;
    white-space: normal;
    max-width: 100%;
    transition:
        opacity 0.18s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.toast.show {
    opacity: 1;
}

@media (max-width: 768px) {
    .toast {
        width: 100%;
        text-align: center;
    }
}

@media (min-width: 769px) {
    .toast {
        white-space: nowrap;
        max-width: 500px;
    }
}

/* ── Responsive — mobile ────────────────────────────────────── */

@media (max-width: 680px) {
    .header-tagline {
        display: none;
    }

    .layout {
        flex-direction: column;
        overflow: hidden;
        height: 100dvh;
    }

    /* Preview pinned at top — shows upload UI or canvas */
    .preview-area {
        flex: none;
        height: 75dvh;
        padding: 16px;
        border-bottom: 1px solid var(--color-border);
        overflow: hidden;
    }

    .frame,
    .frame-wrap {
        max-width: 100%;
        max-height: 100%;
    }

    .canvas-actions {
        width: 100%;
        max-width: min(100%, 420px);
        justify-content: space-between;
        padding: 10px 12px;
        border-radius: 18px;
    }

    .canvas-actions-label {
        display: none;
    }

    .canvas-browse-btn {
        padding: 8px 12px;
        font-size: 11px;
    }

    /* Panel becomes a horizontal control rail */
    .panel {
        flex: none;
        width: 100%;
        height: 25dvh;
        border-left: none;
        border-top: 1px solid var(--color-border);
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 12px;
        padding: 10px 16px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    .panel-section {
        flex: 0 0 auto;
        min-width: 220px;
        max-width: 82vw;
        height: 100%;
        padding: 12px 14px;
        gap: 10px;
        border-bottom: none;
        border: 1px solid var(--color-border);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.72);
        scroll-snap-align: start;
        overflow: hidden;
    }

    .panel-section.rowing {
        min-width: 150px;
        justify-content: center;
        align-items: flex-start;
        flex-direction: column;
    }

    .panel-section.bottom {
        position: static;
        width: auto;
        bottom: auto;
        border-top: 1px solid var(--color-border);
        min-width: 132px;
        justify-content: center;
    }

    #section-style {
        min-width: max-content;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(150px, 38vw);
        align-content: start;
        gap: 12px;
    }

    #section-style > .section-label {
        min-width: 54px;
        margin-top: 4px;
    }

    .control-group {
        gap: 8px;
        min-width: 0;
    }

    .control-label {
        font-size: 12px;
    }

    .control-row {
        align-items: flex-start;
        gap: 6px;
    }

    .chip-row {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    #bgGradientDirectionPicker {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        overflow: visible;
    }

    .chip {
        padding: 8px 12px;
        font-size: 12px;
    }

    .slider {
        min-width: 132px;
    }

    #section-style .control-group:has(.slider) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 28px;
        align-items: stretch;
        column-gap: 12px;
    }

    #section-style .control-group:has(.slider) .control-row {
        grid-column: 1;
        grid-row: 1;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 4px;
    }

    #section-style .control-group:has(.slider) .val-group {
        gap: 2px;
    }

    #section-style .control-group:has(.slider) .slider {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: stretch;
        justify-self: center;
        min-width: 0;
        width: 28px;
        height: 100%;
        min-height: 120px;
        writing-mode: vertical-lr;
        direction: rtl;
        background: linear-gradient(
            to top,
            var(--color-text) 0%,
            var(--color-text) var(--pct, 50%),
            var(--color-border) var(--pct, 50%),
            var(--color-border) 100%
        );
        touch-action: pan-y;
    }

    .control-val,
    .control-unit,
    .export-note {
        font-size: 11px;
    }

    .section-label {
        font-size: 9px;
    }

    .export-row {
        width: 100%;
    }

    .export-btn {
        height: 40px;
        font-size: 12px;
    }

    .copy-btn {
        width: 40px;
        height: 40px;
    }

    .reset-btn {
        width: 100%;
        justify-content: center;
    }

    .panel::-webkit-scrollbar {
        display: none;
    }
}
