/* ==========================================================================
   Overlay Studio — design language mirrored from enesaydogan.com
   Tokens, typography, and component geometry are kept in sync with the site.
   ========================================================================== */

:root {
    --bg: #fbfbfa;
    --surface: #ffffff;
    --ink: #16181c;
    --muted: #6b7079;
    --faint: #9aa0a8;
    --line: #e6e5e1;
    --line-soft: #efeeeb;
    --accent: #1f5fd8;
    --live: #12a150;
    --danger: #c0392b;
    --shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 8px 24px -14px rgba(20, 22, 26, .18);
    --radius: 14px;
    --max: 960px;

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg: #0e0f11;
    --surface: #151719;
    --ink: #eceef1;
    --muted: #9098a2;
    --faint: #6a7078;
    --line: #26292e;
    --line-soft: #1e2125;
    --accent: #7aa2f7;
    --live: #3ecf7f;
    --danger: #f07178;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px -16px rgba(0, 0, 0, .7);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e0f11;
        --surface: #151719;
        --ink: #eceef1;
        --muted: #9098a2;
        --faint: #6a7078;
        --line: #26292e;
        --line-soft: #1e2125;
        --accent: #7aa2f7;
        --live: #3ecf7f;
        --danger: #f07178;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px -16px rgba(0, 0, 0, .7);
    }
}

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

html {
    text-size-adjust: 100%;
}

body {
    min-width: 320px;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv05", "ss01";
    transition: background .25s, color .25s;
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background: var(--accent);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.mono {
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--faint);
}

/* ===== Nav ================================================================ */

.nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}

.nav-inner {
    height: 60px;
    padding-inline: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    letter-spacing: -.02em;
    font-size: 15px;
}

.brand svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.brand span {
    color: var(--faint);
    font-weight: 400;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-link {
    font-size: 14px;
    color: var(--muted);
    transition: color .15s;
}

.nav-link:hover {
    color: var(--ink);
}

/* Icon button — same geometry as the site's theme toggle */
.icon-btn {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}

.icon-btn:hover {
    color: var(--ink);
    border-color: var(--muted);
}

.icon-btn svg {
    width: 15px;
    height: 15px;
}

.theme .moon {
    display: none;
}

:root[data-theme="dark"] .theme .sun {
    display: none;
}

:root[data-theme="dark"] .theme .moon {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme .sun {
        display: none;
    }

    :root:not([data-theme="light"]) .theme .moon {
        display: block;
    }
}

/* ===== Shell ============================================================== */

.app-container {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 312px;
    flex-shrink: 0;
    background: var(--bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 26px 22px 22px;
    overflow-y: auto;
}

/* ===== Section heads (site: .sec-head + .rule) ============================ */

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

.control-group h3 {
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--faint);
    padding-bottom: 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

/* ===== Buttons (site: .chip) ============================================== */

.btn-primary,
.btn-secondary,
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s, transform .15s;
}

.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled),
.btn-action:hover:not(:disabled) {
    color: var(--ink);
    border-color: var(--muted);
    transform: translateY(-1px);
}

/* Lucide swaps each <i data-lucide> for an <svg>, so match both */
.btn-primary i,
.btn-secondary i,
.btn-action i,
.btn-primary svg,
.btn-secondary svg,
.btn-action svg {
    width: 14px;
    height: 14px;
    opacity: .75;
    flex-shrink: 0;
}

/* Accent-led actions — the site marks primary intent with accent ink */
.btn-primary,
.btn-action.primary {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}

.btn-primary:hover:not(:disabled),
.btn-action.primary:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.btn-primary i,
.btn-action.primary i,
.btn-primary svg,
.btn-action.primary svg {
    opacity: 1;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-action:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.spacer {
    flex-grow: 1;
    min-height: 8px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== Status (site: .fact tile) ========================================== */

.status-bar {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 13px;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.status-bar::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--live);
    flex-shrink: 0;
}

/* Errors surface here rather than in a modal alert() */
.status-bar[data-tone="error"] {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
    color: var(--danger);
}

.status-bar[data-tone="error"]::before {
    background: var(--danger);
}

.status-bar[data-tone="busy"]::before {
    background: var(--accent);
    animation: pulse 1.4s ease-out infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
    }

    70% {
        box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent);
    }

    100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
    }
}

/* ===== Form controls ====================================================== */

.select-input {
    width: 100%;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color .15s;
}

.select-input:hover {
    border-color: var(--muted);
}

.select-input--compact {
    width: auto;
    height: 30px;
    padding: 0 6px;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .06em;
    color: var(--muted);
}

.property-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 32px;
}

.property-row label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--faint);
    flex-shrink: 0;
}

.property-row .select-input {
    width: 148px;
}

/* Range — restyled to the site's line/accent palette */
.property-row input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 18px;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

.property-row input[type="range"]::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 999px;
    background: var(--line);
}

.property-row input[type="range"]::-moz-range-track {
    height: 3px;
    border-radius: 999px;
    background: var(--line);
}

.property-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 13px;
    height: 13px;
    margin-top: -5px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    transition: transform .15s;
}

.property-row input[type="range"]::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
}

.property-row input[type="range"]:hover:not(:disabled)::-webkit-slider-thumb {
    transform: scale(1.15);
}

.property-row input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.property-row input[type="color"] {
    width: 44px;
    height: 28px;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    cursor: pointer;
}

.property-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.property-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.property-row input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ===== Workspace ========================================================== */

.workspace {
    position: relative;
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    background-image: radial-gradient(color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1px);
    background-size: 22px 22px;
}

.canvas-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 2rem;
}

.canvas-wrapper .canvas-container {
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.canvas-wrapper canvas {
    display: block;
}

/* ===== Image strip ======================================================== */

.image-strip {
    height: 104px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 22px;
    background: var(--bg);
    border-top: 1px solid var(--line);
    overflow-x: auto;
}

.thumbnail-wrapper {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .2s, box-shadow .25s, transform .25s;
}

.thumbnail-wrapper:hover {
    border-color: color-mix(in srgb, var(--muted) 45%, var(--line));
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.thumbnail-wrapper.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(6px);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, color .15s, border-color .15s;
}

.thumbnail-wrapper:hover .thumbnail-remove,
.thumbnail-remove:focus-visible {
    opacity: 1;
}

.thumbnail-remove:hover {
    color: var(--ink);
    border-color: var(--muted);
}

.empty-strip {
    width: 100%;
    text-align: center;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--faint);
}

/* ===== Drag & drop ======================================================== */

.drop-hint {
    position: absolute;
    inset: 12px;
    z-index: 5;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(2px);
    color: var(--accent);
    font-size: 13.5px;
    font-weight: 500;
    pointer-events: none;
}

.drop-hint svg {
    width: 22px;
    height: 22px;
}

.app-container.is-dropping .drop-hint {
    display: flex;
}

.app-container.is-dropping .sidebar {
    border-right-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.hidden {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ===== Responsive ========================================================= */

@media (max-width: 980px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        gap: 20px;
        padding: 18px 16px;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .spacer {
        display: none;
    }

    .workspace {
        min-height: 60vh;
    }

    .canvas-wrapper {
        padding: 1rem;
    }

    .nav-inner {
        padding-inline: 16px;
    }

    .image-strip {
        padding: 0 16px;
    }
}

@media (max-width: 640px) {
    .nav-right .hide-sm {
        display: none;
    }

    .image-strip {
        height: 92px;
    }

    .thumbnail-wrapper {
        width: 64px;
        height: 64px;
    }

    .thumbnail-remove {
        opacity: 1;
    }
}
