/* Studio: upload + result frame with a drag-to-compare slider.
   iOS Safari drops the HDR gain map from any image inside a stacking context
   (clip-path, overflow, transform, z-index, opacity), so .is-ios shows one
   plain <img> with an Original/HDR toggle instead of the slider. */

.studio {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 56px;
    align-items: start;
    padding: 40px 0 48px;
}

.studio-copy { padding-top: 8px; }

.studio h1 {
    font-size: clamp(2.4rem, 4.1vw, 3.75rem);
    line-height: 1.02;
    font-variation-settings: 'wdth' 116;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 22px;
    text-wrap: balance;
}

.studio-lede {
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--ink-2);
    max-width: 34ch;
    margin-bottom: 30px;
}

.studio-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.studio-actions [hidden] { display: none; }
.btn-big { font-size: 1.1rem; padding: 16px 28px; }
.studio-hint { color: var(--ink-2); font-size: 0.95rem; margin-bottom: 6px; }
.studio-fine { color: var(--ink-3); font-size: 0.9rem; }
@media (pointer: coarse) { .studio-hint { display: none; } }

.studio-frame { display: flex; flex-direction: column; width: fit-content; max-width: 100%; }

.compare {
    --pos: 50%;
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 16px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 24px 60px -12px rgba(0, 0, 0, 0.7);
    user-select: none;
    -webkit-user-select: none;
}

.compare-before,
.compare-after {
    display: block;
    border-radius: 16px;
    -webkit-user-drag: none;
}

.compare-before {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(70vh, 720px);
}

.compare-after {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: inset(0 0 0 var(--pos));
}

.compare-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--pos);
    width: 2px;
    margin-left: -1px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.compare-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.compare-knob::before,
.compare-knob::after {
    content: '';
    position: absolute;
    top: 50%;
    margin-top: -6px;
    border: 6px solid transparent;
}
.compare-knob::before { left: 7px; border-right-color: #111; }
.compare-knob::after { right: 7px; border-left-color: #111; }

.compare-range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: ew-resize;
    touch-action: pan-y;
}
.compare:has(.compare-range:focus-visible) .compare-knob { outline: 3px solid var(--blue); outline-offset: 3px; }

.compare-labels { display: flex; justify-content: space-between; max-width: 100%; margin-top: 12px; font-size: 0.9rem; font-weight: 600; color: var(--ink-2); }
.compare-labels span:first-child::before { content: '\2190\00a0'; }
.compare-labels span:last-child::after { content: '\00a0\2192'; }

/* While processing there is nothing to compare yet. */
.studio[data-state="processing"] .compare-line,
.studio[data-state="processing"] .compare-range,
.studio[data-state="processing"] .compare-labels { visibility: hidden; }

/* iOS: one standalone image and a toggle. */
.studio-toggle { display: none; }
.is-ios .studio-toggle { display: inline-flex; }
.is-ios .compare { box-shadow: none; }
.is-ios .compare-before,
.is-ios .compare-line,
.is-ios .compare-range,
.is-ios .compare-labels { display: none; }
.is-ios .compare-after {
    position: static;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(70vh, 720px);
    clip-path: none;
}

.is-dragging .compare { outline: 2px dashed var(--blue); outline-offset: 8px; }

.studio-caption { color: var(--ink-3); font-size: 0.9rem; margin: 6px 2px 0; overflow-wrap: anywhere; }

.studio-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 24px;
    margin-top: 16px;
}

.studio-toggle { border: 1px solid var(--rule); border-radius: 999px; padding: 3px; }
.studio-toggle button {
    font: inherit;
    font-weight: 600;
    color: var(--ink-2);
    background: transparent;
    border: 0;
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
}
.studio-toggle button[aria-pressed="true"] { background: var(--blue); color: var(--white); }

.studio-strength { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 0.95rem; }
.studio-strength[hidden] { display: none; }
.studio-strength input { width: 150px; accent-color: var(--blue); }
.studio-strength output { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 10ch; }

#share-btn[hidden] { display: none; }

.studio-status { margin-top: 14px; min-height: 1.5em; color: var(--ink); font-variant-numeric: tabular-nums; }
.studio-status.is-error { color: #ffb4a8; }
.studio[data-state="processing"] .studio-status::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 10px;
    border: 2px solid var(--rule);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: -1px;
}

.studio-note { color: var(--ink-3); font-size: 0.9rem; max-width: 62ch; }

.studio-examples { display: flex; gap: 8px; }
.studio-examples[hidden] { display: none; }
.studio-examples button {
    width: 64px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: none;
    cursor: pointer;
}
.studio-examples button img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 7px; }
.studio-examples button[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), 0 0 14px rgba(10, 132, 255, 0.5); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
    white-space: nowrap;
}

@media (max-width: 900px) {
    /* Phone order: headline, the slider, then the button and the words. */
    .studio { grid-template-columns: 1fr; gap: 0; padding-top: 8px; }
    .studio-copy { display: contents; }
    .studio h1 { order: 1; margin-bottom: 18px; }
    .studio-stage { order: 2; margin-bottom: 20px; }
    .studio-actions { order: 3; }
    .studio-lede { order: 4; max-width: 44ch; margin: 6px 0 10px; font-size: 1.05rem; }
    .studio-hint { order: 5; }
    .studio-fine { order: 6; }
    .compare-before, .is-ios .compare-after { max-height: 62vh; }
    .studio-actions .btn { flex: 1 1 auto; }
}
