/* ============================================================================
   image_editor.css — Phase R5b — crop+rotate avatar canvas styling.

   Lives inside a YStage takeover (data-color drives accent if needed).
   The .yie-overlay overlays the canvas with a square / circle / rectangle
   masked window — the inner cutout shows the live composition; the outer
   ring is a soft scrim.
   ========================================================================= */

.yie-stage {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    color: #fef4e8;
    background:
        radial-gradient(ellipse at 50% -10%, rgba(255, 157, 61, 0.18), transparent 55%),
        linear-gradient(180deg, rgba(28, 18, 10, 0.96), rgba(10, 6, 3, 0.98));
    overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────── */

.yie-stage .yie-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 181, 108, 0.2);
    background: rgba(28, 18, 10, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.yie-stage .yie-back {
    appearance: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255, 181, 108, 0.25);
    background: rgba(0, 0, 0, 0.3);
    color: #fef4e8;
    font-size: 16px; cursor: pointer;
    display: grid; place-items: center;
    transition: background .15s ease, border-color .15s ease;
}
.yie-stage .yie-back:hover { background: rgba(255, 157, 61, 0.18); border-color: rgba(255, 181, 108, 0.5); }
.yie-stage .yie-title { font-size: 15px; font-weight: 600; }
.yie-stage .yie-sub   { font-size: 11.5px; color: #d8c5ad; opacity: .85; margin-top: 2px; }
.yie-stage .yie-save {
    appearance: none;
    border: 1px solid rgba(255, 181, 108, 0.6);
    background: linear-gradient(180deg, #ffb56c, #ff9d3d);
    color: #2a1404;
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 600; font-size: 13.5px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(255, 110, 30, 0.32);
    transition: transform .12s ease, box-shadow .15s ease;
}
.yie-stage .yie-save:hover  { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(255, 110, 30, 0.4); }
.yie-stage .yie-save:active { transform: translateY(0); }

/* ── Stage area (canvas + overlay) ──────────────────────────────── */

.yie-stage .yie-stage-area {
    position: relative;
    overflow: hidden;
    background: #000;
    touch-action: none;
}
.yie-stage .yie-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    background: #0a0a10;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.yie-stage .yie-canvas:active { cursor: grabbing; }

/* The overlay paints a darkened ring around the visible crop window.
   --yie-crop-w and --yie-crop-h are set by JS in CSS px. */
.yie-stage .yie-overlay {
    position: absolute; inset: 0;
    pointer-events: none;
    --yie-crop-w: 80%;
    --yie-crop-h: 80%;
}
.yie-stage .yie-overlay-mask {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.55);
}
/* Square (circular) crop window — radial mask. */
.yie-stage .yie-overlay[data-aspect="square"] .yie-overlay-mask {
    -webkit-mask: radial-gradient(circle at center, transparent calc(var(--yie-crop-w) / 2 - 1px), black calc(var(--yie-crop-w) / 2));
            mask: radial-gradient(circle at center, transparent calc(var(--yie-crop-w) / 2 - 1px), black calc(var(--yie-crop-w) / 2));
}
/* Rectangular crop window — composite mask using two gradients gated on the
   crop box dimensions. The transparent area is the crop rect; everything
   else is the dark scrim. */
.yie-stage .yie-overlay[data-aspect="wide"] .yie-overlay-mask,
.yie-stage .yie-overlay[data-aspect="tall"] .yie-overlay-mask {
    -webkit-mask:
        linear-gradient(black, black) center / var(--yie-crop-w) var(--yie-crop-h) no-repeat,
        linear-gradient(black, black);
    -webkit-mask-composite: xor;
            mask:
        linear-gradient(black, black) center / var(--yie-crop-w) var(--yie-crop-h) no-repeat,
        linear-gradient(black, black);
            mask-composite: exclude;
}
/* Crop ring outline. */
.yie-stage .yie-overlay-ring {
    position: absolute;
    top: 50%; left: 50%;
    width: var(--yie-crop-w);
    height: var(--yie-crop-h);
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 1px rgba(255, 157, 61, 0.5),
                0 6px 22px rgba(0, 0, 0, 0.4);
}
.yie-stage .yie-overlay[data-aspect="square"] .yie-overlay-ring { border-radius: 50%; }
.yie-stage .yie-overlay[data-aspect="wide"]   .yie-overlay-ring,
.yie-stage .yie-overlay[data-aspect="tall"]   .yie-overlay-ring { border-radius: 14px; }

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

.yie-stage .yie-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 18px 22px;
    border-top: 1px solid rgba(255, 181, 108, 0.2);
    background: rgba(28, 18, 10, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
@media (min-width: 720px) {
    .yie-stage .yie-controls {
        grid-template-columns: 1fr 1fr auto;
        align-items: center;
    }
}
.yie-stage .yie-rot-label {
    display: grid;
    grid-template-columns: 70px 1fr 64px;
    gap: 12px;
    align-items: center;
    font-size: 12px;
    color: #d8c5ad;
}
.yie-stage .yie-rot {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 181, 108, 0.18);
    border-radius: 999px;
    outline: none;
}
.yie-stage .yie-rot::-webkit-slider-thumb {
    appearance: none; -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffb56c, #ff9d3d);
    border: 1px solid #ff9d3d;
    box-shadow: 0 4px 10px rgba(255, 110, 30, 0.3);
    cursor: pointer;
}
.yie-stage .yie-rot::-moz-range-thumb {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffb56c, #ff9d3d);
    border: 1px solid #ff9d3d;
    box-shadow: 0 4px 10px rgba(255, 110, 30, 0.3);
    cursor: pointer;
}
.yie-stage .yie-rot-val {
    font-variant-numeric: tabular-nums;
    color: #ffb56c;
    text-align: right;
    font-size: 12px;
}
.yie-stage .yie-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    justify-content: center;
}
.yie-stage .yie-action {
    appearance: none;
    border: 1px solid rgba(255, 181, 108, 0.32);
    background: rgba(0, 0, 0, 0.4);
    color: #fef4e8;
    border-radius: 999px;
    padding: 7px 12px;
    font: inherit; font-size: 12.5px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.yie-stage .yie-action:hover {
    background: rgba(255, 157, 61, 0.18);
    border-color: rgba(255, 181, 108, 0.5);
}

@media (prefers-reduced-motion: reduce) {
    .yie-stage .yie-back,
    .yie-stage .yie-save,
    .yie-stage .yie-action { transition: none; }
}
