/* Le Chonk Studio: a photo with stickers, captions, a frame and the $CHONK tag, drawn on one canvas.
 * Builds on the tokens and form parts in style.css (.btn, .field, .seg, .swatch, .range-row, .toast).
 * Every touch target is at least 44 px. Nothing here changes the picture; the canvas only gets layers on top. */

.studio-page { padding-bottom: 120px; }

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.studio-grid > * { min-width: 0; }

/* desktop: the preview stays in view while the tools scroll on the right */
@media (min-width: 961px) {
  .studio-stage { position: sticky; top: 84px; }
}

/* ---------- stage: preview, or the drop zone while there is no picture ---------- */
.studio-stage {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  padding: 14px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.studio-stage.is-over {
  border-color: var(--orange-hi);
  box-shadow: 0 0 0 4px rgba(255, 122, 0, 0.35);
}

.studio-drop {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  min-height: clamp(280px, 52vh, 480px);
  padding: 28px 18px;
  text-align: center;
  border-radius: 18px;
  border: 2px dashed var(--border-warm);
  background:
    radial-gradient(70% 60% at 50% 30%, rgba(255, 122, 0, 0.18), rgba(0, 0, 0, 0) 70%),
    #0b0a09;
}
.studio-stage.is-over .studio-drop { border-color: var(--cream); }
.studio-drop-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(255, 122, 0, 0.35));
}
.studio-drop-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-stretch: 112%;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.studio-drop-line { max-width: 40ch; color: var(--muted); font-size: 15px; }
.studio-drop-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.studio-drop .hint-line { max-width: 42ch; }

/* the letterbox colour shows around the canvas; the canvas itself keeps the picture's exact shape */
.studio-canvas-wrap {
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: 18px;
  background: #0b0a09;
  border: 1px solid var(--border);
  min-width: 0;
}
.studio-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  touch-action: none;        /* drags stay on the layer instead of scrolling the page */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline-offset: 4px;
}

.studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.studio-toolbar .btn { min-width: 96px; }
.studio-toolbar .note { flex: 1 1 180px; min-height: 1.3em; margin: 0; }

/* ---------- controls: stacked cards ---------- */
.studio-controls { display: grid; gap: 14px; min-width: 0; }
.studio-sec {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
}
.studio-sec h2 { font-size: 20px; }
.studio-sec .field { min-width: 0; }
.studio-sec .btn { justify-self: start; max-width: 100%; }
.studio-sec .seg { min-height: 44px; }
.studio-sec .swatch { width: 44px; height: 44px; }
.studio-sec input[type="range"] { min-height: 44px; accent-color: var(--orange); }
.studio-sec #cap-top,
.studio-sec #cap-bottom,
.studio-sec #box-text { text-transform: none; }
.studio-row { display: flex; flex-wrap: wrap; gap: 10px; }
.studio-row .btn { min-width: 0; }

/* ---------- stickers ---------- */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.sticker-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-height: 44px;
  padding: 4px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: #0b0a09;
  cursor: pointer;
  transition: transform 0.15s var(--ease), border-color 0.2s;
}
.sticker-btn canvas { width: 100%; height: 100%; display: block; }
.sticker-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--border-warm); }
.sticker-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.sel-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  min-width: 0;
}
.sel-card[hidden] { display: none; }
.sel-line { font-size: 14px; font-weight: 700; color: var(--muted); overflow-wrap: anywhere; }
.sel-line.is-on { color: var(--orange-hi); }
.sel-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.sel-actions .btn { min-width: 0; padding: 0 10px; font-size: 14px; }
.sel-danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.45); }
.sel-card .sel-danger { justify-self: start; }

/* ---------- templates: contain-fit thumbnails, never cropped ---------- */
.studio-templates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.studio-tpl {
  appearance: none;
  position: relative;
  aspect-ratio: 1;
  min-height: 44px;
  padding: 4px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: #0b0a09;
  overflow: hidden;
  cursor: pointer;
}
.studio-tpl img { width: 100%; height: 100%; object-fit: contain; }
.studio-tpl[aria-pressed="true"] {
  border-color: var(--orange-hi);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.3);
}

/* ---------- export ---------- */
.studio-export {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.studio-export .btn { min-width: 0; padding: 0 12px; }
.studio-export .btn-primary { grid-column: 1 / -1; }
.studio-tips { margin-top: 18px; }

/* ---------- small phones: one column everywhere ---------- */
@media (max-width: 960px) {
  .studio-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .studio-page { padding-bottom: 132px; }
  .studio-drop { min-height: 300px; padding: 22px 14px; }
  .studio-drop-actions .btn { width: 100%; }
  .sticker-grid { gap: 8px; }
  .studio-templates { gap: 8px; }
  .studio-sec { padding: 16px; }
}

@media (max-width: 360px) {
  .studio-export { grid-template-columns: minmax(0, 1fr); }
  .studio-export .btn-primary { grid-column: auto; }
  .sel-actions { grid-template-columns: minmax(0, 1fr); }
}

/* Get chonked: one button that drops the cat onto the picture */
.chonk-cta {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: rgba(255, 122, 0, 0.08);
  border: 1px solid var(--border-warm);
}
.chonk-cta-title { font-family: var(--font-display); font-weight: 900; font-stretch: 112%; font-size: 18px; }
.chonk-cta-line { font-size: 13.5px; color: var(--muted); }
.chonk-cta .btn { margin-top: 4px; }
