/* XEL portrait studio — the camera button, the flash, and the glass darkroom. */

/* ---------- camera button on #xel-stage ---------- */

.studio-cam {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  z-index: 3;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  transition: transform 0.2s var(--ease-boing), box-shadow 0.2s, border-color 0.2s;
}
.studio-cam:hover,
.studio-cam:focus-visible {
  transform: translateY(-3px) rotate(-8deg) scale(1.08);
  border-color: var(--seafoam);
  box-shadow: var(--glow-seafoam);
}
.studio-cam:active {
  transform: scale(0.9);
}
.studio-cam:focus-visible {
  outline: 2px solid var(--seafoam);
  outline-offset: 2px;
}

/* ---------- the flash ---------- */

.studio-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: var(--r-lg);
  background: #ffffff;
  pointer-events: none;
  animation: studio-flash 0.5s ease-out both;
}
@keyframes studio-flash {
  0% { opacity: 0; }
  12% { opacity: 0.95; }
  100% { opacity: 0; }
}

/* ---------- modal root ---------- */

#studio-root {
  position: fixed;
  inset: 0;
  z-index: 88; /* below toasts (89), above panels and games */
  pointer-events: none;
}

.st-modal {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.st-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 3, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: st-fade-in 0.25s ease both;
}

.st-shell {
  position: relative;
  width: min(96vw, 940px);
  max-height: min(94svh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop), var(--glow-violet);
  animation: st-pop-in 0.42s var(--ease-boing) both;
  overflow: hidden;
}

.st-modal.closing .st-shell { animation: st-pop-out 0.24s ease both; }
.st-modal.closing .st-backdrop { animation: st-fade-out 0.24s ease both; }

@keyframes st-fade-in { from { opacity: 0; } }
@keyframes st-fade-out { to { opacity: 0; } }
@keyframes st-pop-in {
  from { opacity: 0; transform: scale(0.88) translateY(24px); }
}
@keyframes st-pop-out {
  to { opacity: 0; transform: scale(0.92) translateY(14px); }
}

.st-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.15rem 0.75rem;
  border-bottom: 1px solid rgba(157, 123, 255, 0.18);
}

.st-title {
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  background: linear-gradient(120deg, var(--seafoam), var(--violet), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.st-close {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(157, 123, 255, 0.4);
  background: rgba(157, 123, 255, 0.14);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s var(--ease-boing), background 0.2s, box-shadow 0.2s;
}
.st-close:hover {
  background: rgba(255, 92, 122, 0.25);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 0 16px rgba(255, 92, 122, 0.4);
}

/* ---------- body: preview + controls ---------- */

.st-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1.1rem;
  padding: 1rem 1.15rem;
  overflow-y: auto;
  min-height: 0;
}
.st-body::-webkit-scrollbar { width: 8px; }
.st-body::-webkit-scrollbar-thumb { background: rgba(157, 123, 255, 0.35); border-radius: 4px; }

.st-preview {
  position: relative;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.st-canvas {
  width: 100%;
  height: auto;
  max-height: 56svh;
  object-fit: contain;
  display: block;
  border-radius: var(--r-md);
  border: 1px solid rgba(157, 123, 255, 0.3);
  background: #05020c;
  box-shadow: var(--shadow-pop);
}

/* re-snapshot flash lives over the preview, not the stage */
.st-preview.flashing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  background: #ffffff;
  pointer-events: none;
  animation: studio-flash 0.5s ease-out both;
}

.st-resnap-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.st-resnap { font-size: 0.88rem; padding: 0.45rem 0.9rem; }
.st-resnap-note {
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* ---------- control groups ---------- */

.st-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.st-legend {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.4rem;
}

.st-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.st-chip {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--ink-dim);
  background: rgba(157, 123, 255, 0.1);
  border: 1px solid rgba(157, 123, 255, 0.3);
  border-radius: var(--r-pill);
  padding: 0.32rem 0.75rem;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform 0.18s var(--ease-boing), box-shadow 0.18s,
    border-color 0.18s, background 0.18s, color 0.18s;
}
.st-chip:hover { transform: translateY(-2px); border-color: var(--violet); color: var(--ink); }
.st-chip:active { transform: scale(0.95); }
.st-chip:focus-visible {
  outline: 2px solid var(--seafoam);
  outline-offset: 2px;
}
.st-chip[aria-pressed='true'] {
  color: #072019;
  background: linear-gradient(135deg, var(--seafoam), #4fd8bd);
  border-color: var(--seafoam);
  box-shadow: var(--glow-seafoam);
  font-weight: 600;
}

.st-custom-label {
  display: block;
  margin: 0.55rem 0 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.st-custom {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink);
  background: rgba(7, 3, 18, 0.55);
  border: 1px solid rgba(157, 123, 255, 0.35);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.st-custom::placeholder { color: var(--ink-faint); }
.st-custom:focus {
  outline: none;
  border-color: var(--seafoam);
  box-shadow: var(--glow-seafoam);
}

/* ---------- actions ---------- */

.st-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.8rem 1.15rem 1rem;
  border-top: 1px solid rgba(157, 123, 255, 0.18);
}

.st-action-btns {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.st-action-btns .btn { font-size: 0.92rem; }

.st-download {
  background: linear-gradient(135deg, rgba(125, 249, 224, 0.3), rgba(92, 225, 255, 0.18));
  border-color: rgba(125, 249, 224, 0.5);
}
.st-download:hover { box-shadow: var(--glow-seafoam); }

.st-status {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.82rem;
  color: var(--seafoam);
  letter-spacing: 0.02em;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .st-body { grid-template-columns: 1fr; }
  .st-canvas { max-height: 42svh; }
  .st-shell { max-height: 96svh; }
  .studio-cam { width: 42px; height: 42px; font-size: 1.1rem; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .st-shell, .st-backdrop { animation-duration: 0.01s; animation-delay: 0s; }
  .studio-flash,
  .st-preview.flashing::after {
    animation-duration: 0.2s;
    animation-name: studio-flash-soft;
  }
  .studio-cam:hover, .studio-cam:focus-visible, .st-close:hover { transform: none; }
  .st-chip:hover { transform: none; }
}
@keyframes studio-flash-soft {
  0% { opacity: 0; }
  30% { opacity: 0.4; }
  100% { opacity: 0; }
}
