/* ============================================================================
   Sign Studio Pro — live WYSIWYG sign designer with QR, AR preview, print export
   getyourcrocsoff.com

   A real poster studio. Two-pane Liquid-Glass layout: a live SVG/HTML sign
   (the preview IS the output) + a frosted control stack. Print-true PNG export
   with crop marks and bleed, a working vendored QR, and an on-your-actual-door
   perspective preview. Uses the site's apple-polish design tokens so it reads
   native; honors light/dark and prefers-reduced-motion.
   ============================================================================ */

#sign-studio {
    --ssp-radius: var(--radius-lg, 22px);
    --ssp-radius-sm: var(--radius, 14px);
    --ssp-glass-light: color-mix(in oklab, var(--surface, #fff) 70%, transparent);
    --ssp-glass-dark: color-mix(in oklab, var(--surface, #1d1d1f) 64%, transparent);
    --ssp-glass: var(--ssp-glass-light);
    --ssp-line: color-mix(in oklab, var(--ink, #1d1d1f) 12%, transparent);
    --ssp-line-soft: color-mix(in oklab, var(--ink, #1d1d1f) 7%, transparent);
    --ssp-spec: color-mix(in oklab, #fff 70%, transparent);
    --ssp-accent: var(--accent, #ff6a1f);
    --ssp-accent-press: var(--accent-press, #e85a14);
    --ssp-ease: var(--ease-spring, cubic-bezier(0.32, 0.72, 0, 1));
    position: relative;
}
[data-theme="dark"] #sign-studio { --ssp-glass: var(--ssp-glass-dark); --ssp-spec: color-mix(in oklab, #fff 12%, transparent); }

#sign-studio .ssp-head { max-width: 760px; margin-bottom: 26px; }
#sign-studio .ssp-head h2 { margin: 8px 0 10px; }
#sign-studio .ssp-head p { color: var(--ink-3, #6e6e73); max-width: 60ch; }

/* ---- The two-pane studio ------------------------------------------------- */
.ssp-studio {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 22px;
    align-items: start;
}
@media (max-width: 960px) { .ssp-studio { grid-template-columns: 1fr; } }

/* Glass panel base */
.ssp-glass {
    position: relative;
    background: var(--ssp-glass);
    border: 1px solid var(--ssp-line);
    border-radius: var(--ssp-radius);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    box-shadow:
        inset 0 1px 0 var(--ssp-spec),
        0 1px 2px color-mix(in oklab, var(--ink, #1d1d1f) 8%, transparent),
        0 22px 48px -28px color-mix(in oklab, var(--ink, #1d1d1f) 50%, transparent);
}

/* ---- Stage (left, the live WYSIWYG sign) --------------------------------- */
.ssp-stage { padding: 20px; min-height: 460px; display: flex; flex-direction: column; }
.ssp-stage-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 16px;
}
.ssp-stage-bar .ssp-eyebrow {
    font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--ink-3, #6e6e73);
    display: inline-flex; align-items: center; gap: 7px;
}
.ssp-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ssp-accent);
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--ssp-accent) 60%, transparent);
    animation: ssp-pulse 2.4s var(--ssp-ease) infinite; }
@keyframes ssp-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ssp-accent) 55%, transparent); }
    70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.ssp-size-tag {
    font-size: 12px; font-weight: 600; color: var(--ink-2, #424245);
    padding: 4px 10px; border-radius: 999px;
    background: color-mix(in oklab, var(--ink, #1d1d1f) 6%, transparent);
    border: 1px solid var(--ssp-line-soft); font-variant-numeric: tabular-nums;
}

/* The framed sign surface: aspect-locked, lives on a soft pedestal */
.ssp-canvas-wrap {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 8px; border-radius: var(--ssp-radius-sm);
    background:
        radial-gradient(120% 90% at 50% 0%, color-mix(in oklab, var(--ssp-accent) 7%, transparent), transparent 60%),
        color-mix(in oklab, var(--ink, #1d1d1f) 3%, transparent);
    overflow: hidden;
}
.ssp-sign-frame {
    position: relative;
    width: 100%;
    max-width: 460px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 60px -30px rgba(0,0,0,0.55), 0 4px 12px -6px rgba(0,0,0,0.3);
    transition: aspect-ratio 0.5s var(--ssp-ease), box-shadow 0.4s var(--ssp-ease);
    aspect-ratio: 8 / 10;
}
/* The SVG sign fills the frame; it's the true WYSIWYG output */
.ssp-sign-svg { display: block; width: 100%; height: 100%; }

/* Subtle specular sweep over the sign, decorative only */
.ssp-sign-frame::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(120deg, transparent 40%, rgba(255,255,255,0.10) 50%, transparent 60%);
    opacity: 0; transition: opacity 0.4s ease;
}
.ssp-sign-frame:hover::after { opacity: 1; }

/* ---- Controls (right) ---------------------------------------------------- */
.ssp-controls { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.ssp-field { display: flex; flex-direction: column; gap: 8px; }
.ssp-field > label, .ssp-field-label {
    font-size: 12px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
    color: var(--ink-3, #6e6e73);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.ssp-field input[type="text"], .ssp-field textarea {
    width: 100%; box-sizing: border-box;
    font: inherit; font-size: 15px; color: var(--ink, #1d1d1f);
    background: color-mix(in oklab, var(--surface, #fff) 60%, transparent);
    border: 1px solid var(--ssp-line); border-radius: var(--ssp-radius-sm);
    padding: 11px 13px; resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ssp-field textarea { min-height: 64px; line-height: 1.4; }
.ssp-field input[type="text"]:focus, .ssp-field textarea:focus {
    outline: none; border-color: color-mix(in oklab, var(--ssp-accent) 60%, var(--ssp-line));
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--ssp-accent) 16%, transparent);
}
.ssp-charcount { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink-4, #86868b); text-transform: none; letter-spacing: 0; }
.ssp-charcount.ssp-over { color: var(--ssp-accent-press); }

/* Segmented control (templates, sizes, fonts) */
.ssp-seg {
    display: flex; flex-wrap: wrap; gap: 6px;
    background: color-mix(in oklab, var(--ink, #1d1d1f) 5%, transparent);
    border: 1px solid var(--ssp-line-soft);
    border-radius: var(--ssp-radius-sm); padding: 5px;
}
.ssp-seg button {
    flex: 1 1 auto; min-width: 58px;
    font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2, #424245);
    background: transparent; border: 0; border-radius: 9px; padding: 8px 10px;
    cursor: pointer; transition: transform 0.18s var(--ssp-ease), background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}
.ssp-seg button:hover { color: var(--ink, #1d1d1f); transform: translateY(-1px); }
.ssp-seg button[aria-pressed="true"] {
    color: var(--ink, #1d1d1f);
    background: color-mix(in oklab, var(--surface, #fff) 88%, transparent);
    box-shadow: 0 1px 2px rgba(0,0,0,0.12), inset 0 1px 0 var(--ssp-spec);
}
[data-theme="dark"] .ssp-seg button[aria-pressed="true"] { background: color-mix(in oklab, var(--surface, #1d1d1f) 96%, transparent); }

/* Accent swatches */
.ssp-swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.ssp-swatch {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer; padding: 0;
    border: 2px solid color-mix(in oklab, var(--ink, #1d1d1f) 14%, transparent);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.4);
    transition: transform 0.18s var(--ssp-ease), box-shadow 0.2s ease, border-color 0.2s ease;
}
.ssp-swatch:hover { transform: scale(1.12); }
.ssp-swatch[aria-pressed="true"] {
    border-color: var(--ink, #1d1d1f);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--surface, #fff) 100%, transparent), 0 0 0 5px currentColor;
}

/* Toggle row (QR, foot motif) */
.ssp-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border-radius: var(--ssp-radius-sm);
    background: color-mix(in oklab, var(--ink, #1d1d1f) 4%, transparent);
    border: 1px solid var(--ssp-line-soft);
}
.ssp-toggle-txt { display: flex; flex-direction: column; gap: 2px; }
.ssp-toggle-txt b { font-size: 14px; color: var(--ink, #1d1d1f); }
.ssp-toggle-txt span { font-size: 12px; color: var(--ink-3, #6e6e73); }
.ssp-switch {
    position: relative; width: 46px; height: 27px; flex: 0 0 auto;
    border-radius: 999px; border: 0; cursor: pointer; padding: 0;
    background: color-mix(in oklab, var(--ink, #1d1d1f) 18%, transparent);
    transition: background 0.25s var(--ssp-ease);
}
.ssp-switch::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.25s var(--ssp-ease);
}
.ssp-switch[aria-checked="true"] { background: var(--ssp-accent); }
.ssp-switch[aria-checked="true"]::after { transform: translateX(19px); }

.ssp-qr-input { margin-top: 4px; }
.ssp-qr-input[hidden] { display: none; }

/* Action buttons */
.ssp-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.ssp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
    border-radius: 999px; padding: 13px 18px; border: 1px solid transparent;
    transition: transform 0.18s var(--ssp-ease), box-shadow 0.2s ease, background 0.2s ease;
}
.ssp-btn-primary {
    color: #fff; background: var(--ssp-accent);
    box-shadow: 0 8px 22px -10px color-mix(in oklab, var(--ssp-accent) 80%, transparent);
}
.ssp-btn-primary:hover { transform: translateY(-2px); background: var(--ssp-accent-press); }
.ssp-btn-primary:active { transform: translateY(0); }
.ssp-btn-ghost {
    color: var(--ink, #1d1d1f);
    background: color-mix(in oklab, var(--surface, #fff) 64%, transparent);
    border-color: var(--ssp-line);
}
.ssp-btn-ghost:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--ssp-accent) 50%, var(--ssp-line)); }

/* Export popover */
.ssp-export-wrap { position: relative; }
.ssp-popover {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 10px);
    z-index: 30; padding: 8px; display: grid; gap: 4px;
    border-radius: var(--ssp-radius-sm);
    transform-origin: bottom center;
    opacity: 0; transform: translateY(8px) scale(0.97); pointer-events: none;
    transition: opacity 0.2s var(--ssp-ease), transform 0.2s var(--ssp-ease);
}
.ssp-popover.ssp-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.ssp-popover button {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    font: inherit; font-size: 14px; font-weight: 500; color: var(--ink, #1d1d1f);
    background: transparent; border: 0; border-radius: 9px; padding: 10px 12px; cursor: pointer;
    text-align: left; transition: background 0.16s ease;
}
.ssp-popover button:hover { background: color-mix(in oklab, var(--ssp-accent) 14%, transparent); }
.ssp-popover button small { color: var(--ink-4, #86868b); font-variant-numeric: tabular-nums; }

/* ---- AR door overlay ----------------------------------------------------- */
.ssp-door {
    margin-top: 22px;
    padding: 0; overflow: hidden;
}
.ssp-door-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 18px; border-bottom: 1px solid var(--ssp-line-soft);
}
.ssp-door-head .ssp-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); display: inline-flex; gap: 7px; align-items: center; }
.ssp-door-body { padding: 16px 18px; }
.ssp-dropzone {
    position: relative;
    border: 1.5px dashed color-mix(in oklab, var(--ink, #1d1d1f) 22%, transparent);
    border-radius: var(--ssp-radius-sm);
    min-height: 240px;
    display: flex; align-items: center; justify-content: center;
    text-align: center; color: var(--ink-3, #6e6e73);
    background: color-mix(in oklab, var(--ink, #1d1d1f) 3%, transparent);
    overflow: hidden; cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.ssp-dropzone.ssp-drag { border-color: var(--ssp-accent); background: color-mix(in oklab, var(--ssp-accent) 8%, transparent); }
.ssp-dropzone.ssp-has-photo { cursor: default; min-height: 320px; align-items: stretch; }
.ssp-drop-hint { display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 24px; }
.ssp-drop-hint .glyph { width: 30px; height: 30px; color: var(--ssp-accent); }
.ssp-drop-hint b { color: var(--ink-2, #424245); font-size: 15px; }
.ssp-drop-hint span { font-size: 13px; }

/* The composited door stage */
.ssp-door-stage { position: relative; width: 100%; user-select: none; touch-action: none; }
.ssp-door-stage img.ssp-door-photo { display: block; width: 100%; border-radius: var(--ssp-radius-sm); }
.ssp-door-sign {
    position: absolute; cursor: grab; touch-action: none;
    border-radius: 4px; overflow: visible;
    filter: drop-shadow(0 10px 18px rgba(0,0,0,0.4));
    will-change: transform;
}
.ssp-door-sign:active { cursor: grabbing; }
.ssp-door-sign svg, .ssp-door-sign img { display: block; width: 100%; height: 100%; border-radius: 4px; }
.ssp-door-handle {
    position: absolute; right: -9px; bottom: -9px; width: 20px; height: 20px;
    border-radius: 50%; background: var(--ssp-accent); border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4); cursor: nwse-resize; touch-action: none;
}
.ssp-door-tools { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.ssp-door-tools .ssp-btn { flex: 1 1 auto; font-size: 14px; padding: 10px 14px; }

/* Toast confirmation */
.ssp-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
    z-index: 9000; padding: 12px 18px; border-radius: 999px;
    font-size: 14px; font-weight: 600; color: var(--ink, #1d1d1f);
    background: var(--ssp-glass); border: 1px solid var(--ssp-line);
    -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
    box-shadow: 0 18px 40px -18px rgba(0,0,0,0.5), inset 0 1px 0 var(--ssp-spec);
    opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ssp-ease), transform 0.3s var(--ssp-ease);
    display: inline-flex; align-items: center; gap: 9px;
}
.ssp-toast.ssp-show { opacity: 1; transform: translate(-50%, 0); }
.ssp-toast .glyph { width: 16px; height: 16px; color: var(--ssp-accent); }

/* Launch button injected near the legacy sign card */
.ssp-launch {
    display: inline-flex; align-items: center; gap: 9px;
    margin-top: 18px;
    font-size: 15px; font-weight: 600; color: #fff;
    background: var(--accent, #ff6a1f); border: 0; border-radius: 999px;
    padding: 13px 20px; cursor: pointer;
    box-shadow: 0 10px 26px -12px color-mix(in oklab, var(--accent, #ff6a1f) 80%, transparent);
    transition: transform 0.18s var(--ease-spring, ease), background 0.2s ease;
}
.ssp-launch:hover { transform: translateY(-2px); background: var(--accent-press, #e85a14); }
.ssp-launch .glyph { width: 17px; height: 17px; }

/* Reveal animation reuse */
#sign-studio .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s var(--ssp-ease), transform 0.6s var(--ssp-ease); }
#sign-studio .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    #sign-studio *, #sign-studio *::before, #sign-studio *::after {
        animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .ssp-live-dot { animation: none; }
}
