/* ============================================================
   page-studio.v18.css — Artistic Composition Studio
   Header chrome = site (light, --ac- tokens, radius 0).
   Everything below the header = the app's black (a documented
   exception to the light-only rule — see TECHNICAL-DECISIONS.md §3).

   Studio tokens are scoped to the page (not added to tokens.css).
   Exactly three surface levels — the Wise Photos surface rule.
   ============================================================ */

/* The whole page below the header is the tool's black. */
body {
  background-color: #000000;
}

/* The onboarding banner stays off the Studio — the tool page is kept
   clean (this stylesheet loads only on /studio). */
.ac-onboarding-banner {
  display: none;
}

.studio-page-header,
.studio {
  --studio-bg: #000000;
  --studio-surface: #1c1c1e;
  --studio-surface-elevated: #2c2c2e;
  --studio-line: #ff0000;
  --studio-accent: #0269d9;
  --studio-text: #ffffff;
  --studio-text-muted: rgba(255, 255, 255, 0.65);
  --studio-focus: #7fb8ff;
  --studio-tile-size: 88px;
}

/* ----------------------------------------------------------
   Page header — a single small label on black
   ---------------------------------------------------------- */
.studio-page-header {
  max-width: var(--ac-max-width);
  margin: 0 auto;
  padding: var(--ac-sp-5) var(--ac-page-pad) var(--ac-sp-4);
}

.studio-page-header__title {
  font-family: var(--ac-font-mono);
  font-size: var(--ac-text-label);
  font-weight: 500;
  letter-spacing: var(--ac-ls-label);
  line-height: var(--ac-lh-label);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
}

/* ----------------------------------------------------------
   The dark island
   ---------------------------------------------------------- */
.studio {
  max-width: var(--ac-max-width);
  margin: 0 auto var(--ac-sp-8);
  padding: 0 var(--ac-page-pad);
}

.studio__inner {
  background: var(--studio-bg);
  color: var(--studio-text);
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------
   Workspace (canvas stack)
   ---------------------------------------------------------- */
.studio-workspace {
  position: relative;
  height: clamp(320px, 58vh, 720px);
  background: var(--studio-bg);
  overflow: hidden;
  touch-action: none;
}

.studio-workspace canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.studio-workspace.is-dragover::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--studio-accent);
  pointer-events: none;
}

/* Empty state */
.studio-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ac-sp-3);
  text-align: center;
  padding: var(--ac-sp-5);
}

.studio-empty__btn {
  width: 64px;
  height: 64px;
  border: 1px solid var(--studio-text-muted);
  border-radius: 0;
  background: var(--studio-surface);
  color: var(--studio-text);
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: background var(--ac-transition);
}

.studio-empty__btn:hover {
  background: var(--studio-surface-elevated);
}

.studio-empty__title {
  font-size: var(--ac-text-body);
  color: var(--studio-text);
  margin: 0;
}

.studio-empty__hint {
  font-size: var(--ac-text-body-sm);
  color: var(--studio-text-muted);
  margin: 0;
}

.studio-empty__privacy {
  font-family: var(--ac-font-mono);
  font-size: var(--ac-text-label);
  letter-spacing: var(--ac-ls-label);
  text-transform: uppercase;
  color: var(--studio-text-muted);
  margin: var(--ac-sp-4) 0 0;
}

/* Sign-in overlay */
.studio-signin {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  padding: var(--ac-sp-5);
}

.studio-signin__card {
  background: var(--studio-surface);
  padding: var(--ac-sp-6);
  text-align: center;
  max-width: 380px;
}

.studio-signin__title {
  font-size: var(--ac-text-h3);
  font-weight: 600;
  color: var(--studio-text);
  margin: 0 0 var(--ac-sp-3);
}

.studio-signin__text {
  font-size: var(--ac-text-body-sm);
  line-height: var(--ac-lh-body);
  color: var(--studio-text-muted);
  margin: 0 0 var(--ac-sp-5);
}

.studio-signin__btn {
  display: inline-block;
  background: var(--studio-accent);
  color: #ffffff;
  border: 0;
  border-radius: 0;
  padding: 12px 28px;
  font-family: var(--ac-font-body);
  font-size: var(--ac-text-body-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--ac-transition);
}

.studio-signin__btn:hover {
  opacity: 0.85;
}

/* Status line (a11y live region + friendly errors) — horizontally
   centered on the page. */
.studio-status {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--ac-sp-3);
  width: max-content;
  max-width: calc(100% - 2 * var(--ac-sp-4));
  margin: 0;
  text-align: center;
  font-size: var(--ac-text-body-sm);
  color: var(--studio-text);
  pointer-events: none;
  z-index: 2;
}

.studio-status:empty {
  display: none;
}

/* Guide box — the iPhone GuideBoxView adapted to the site (radius 0):
   a translucent white card centered over the image with the composition
   name, one-line description, and actions. When pinned (members-only
   composition without Full Access) it never dismisses — the upsell
   doubles as a screenshot deterrent. */
.studio-guidebox {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ac-sp-2);
  background: rgba(255, 255, 255, 0.75);
  padding: calc(var(--ac-sp-5) + 14px) var(--ac-sp-5) var(--ac-sp-4);
  text-align: center;
  width: min(320px, calc(100% - 2 * var(--ac-sp-5)));
  cursor: default;
}

.studio-guidebox__name {
  font-family: var(--ac-font-body);
  font-size: var(--ac-text-body-sm);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #000000;
  margin: 0;
}

.studio-guidebox__desc {
  font-size: 13px;
  line-height: 1.45;
  color: #000000;
  margin: 0;
}

.studio-guidebox__desc:empty {
  display: none;
}

.studio-guidebox__actions {
  display: flex;
  gap: var(--ac-sp-3);
  align-items: center;
  margin-top: var(--ac-sp-1);
}

.studio-guidebox__more {
  font-size: 13px;
  font-weight: 700;
  color: #000000;
  text-decoration: none;
  border: 2px solid #000000;
  padding: 4px 12px;
}

.studio-guidebox__cta {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: var(--studio-accent);
  text-decoration: none;
  padding: 6px 14px;
}

.studio-guidebox__cta:hover,
.studio-guidebox__more:hover {
  opacity: 0.8;
}

/* "GET ALL" disc overlapping the card's top edge (locked, not entitled). */
.studio-guidebox__getall {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%) rotate(-25deg);
  width: 60px;
  height: 60px;
  border-radius: 50%; /* the app's disc — an intentional exception */
  background: var(--studio-accent);
  border: 3px solid #ffffff;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.05;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.studio-guidebox__badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #000000;
  color: #ffffff;
  font-family: var(--ac-font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  padding: 3px 10px;
}

/* ----------------------------------------------------------
   First-run instructions overlay (port of InstructionsView)
   ---------------------------------------------------------- */
.studio-instructions {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.studio-instructions__hints {
  display: flex;
  flex-direction: column;
  gap: var(--ac-sp-6);
  padding: var(--ac-sp-5);
}

.studio-instructions__hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ac-sp-2);
}

.studio-instructions__hint p {
  color: #ffffff;
  font-size: 19px;
  font-weight: 600;
  text-align: center;
  margin: 0;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.studio-instructions__icon {
  width: 48px;
  height: 48px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hint loops mirror the app's 2.9s beats (grow-settle, nudge around). */
@keyframes studio-hint-zoom {
  0% { transform: scale(1); }
  14% { transform: scale(1.35); }
  28% { transform: scale(1); }
  100% { transform: scale(1); }
}

@keyframes studio-hint-drag {
  0%, 31% { transform: translate(0, 0); }
  38% { transform: translate(-10px, 0); }
  45% { transform: translate(10px, 0); }
  52% { transform: translate(0, -10px); }
  59% { transform: translate(0, 10px); }
  66%, 100% { transform: translate(0, 0); }
}

.studio-instructions__icon--zoom {
  animation: studio-hint-zoom 2.9s infinite;
}

.studio-instructions__icon--drag {
  animation: studio-hint-drag 2.9s infinite;
}

@media (prefers-reduced-motion: reduce) {
  .studio-instructions__icon--zoom,
  .studio-instructions__icon--drag {
    animation: none;
  }
}

/* ----------------------------------------------------------
   Settings popover additions
   ---------------------------------------------------------- */
.studio-settings-popover {
  min-width: 260px;
}

.studio-sizes-popover__label {
  font-size: 12px;
  line-height: 1.4;
  color: var(--studio-text-muted);
  text-align: center;
  margin: 0;
}

.studio-chip--link {
  text-decoration: none;
  display: inline-block;
}

/* Unsupported browser notice */
.studio-unsupported {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--ac-sp-6);
  color: var(--studio-text);
  font-size: var(--ac-text-body-sm);
  line-height: var(--ac-lh-body);
}

/* ----------------------------------------------------------
   Divider — kept in the markup for structure, drawn invisible
   (seamless black between workspace, carousel, and toolbar)
   ---------------------------------------------------------- */
.studio-divider {
  height: 0;
}

/* ----------------------------------------------------------
   Composition carousel
   ---------------------------------------------------------- */
/* Row: [left arrow] [scrolling tile strip] [right arrow] — the arrows
   live in their own gutters, never overlapping the tiles. */
.studio-carousel-row {
  display: flex;
  align-items: flex-start;
  /* Breathing room between the workspace and the tiles — spacing lives
     here so the canvas keeps its full size and ratio. */
  margin-top: var(--ac-sp-6);
  background: var(--studio-bg);
}

.studio-carousel-arrow {
  flex: 0 0 auto;
  width: 36px;
  height: 44px;
  /* Center the 22px icon on the tile ARTWORK (square, --studio-tile-size),
     which starts below the carousel's top padding. */
  margin-top: calc(var(--ac-sp-4) + var(--studio-tile-size) / 2 - 22px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--studio-text-muted);
  cursor: pointer;
  transition: color var(--ac-transition);
}

.studio-carousel-arrow:hover {
  color: var(--studio-text);
}

/* 22×22 icon; stroke tuned so the rendered line weight matches the
   toolbar icons (1.5 units on a 24 grid at 25px ≈ 1.56px). */
.studio-carousel-arrow svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Shown only when there is somewhere to scroll in that direction.
   visibility (not display) keeps the gutters stable. */
.studio-carousel-arrow.is-hidden {
  visibility: hidden;
}

.studio-carousel {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: var(--ac-sp-2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  /* Extra top padding gives the floating selection dot room (the scroll
     container clips anything above its padding box). */
  padding: var(--ac-sp-4) 0 var(--ac-sp-3);
  background: var(--studio-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--studio-surface-elevated) var(--studio-bg);
}

.studio-tile {
  position: relative;
  flex: 0 0 auto;
  width: var(--studio-tile-size);
  padding: 0;
  border: 2px solid transparent;
  border-radius: 0;
  background: var(--studio-bg); /* same black as the rest of the tool */
  cursor: pointer;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
}

.studio-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* Selection indicator — a single white dot centered ABOVE the selected
   tile (mirroring the gap it used to sit inside), like the iPad app. */
.studio-tile.is-selected::after {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--studio-text);
  pointer-events: none;
}

.studio-tile__name {
  display: block;
  padding: 4px 4px 5px;
  font-family: var(--ac-font-body);
  font-size: 10px;
  line-height: 1.25;
  color: var(--studio-text-muted);
  text-align: center;
  min-height: 30px;
}

.studio-tile__badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-family: var(--ac-font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 5px;
  background: var(--studio-surface);
  color: var(--studio-text);
}

/* Lock badge — shown only when the visitor is not a member.
   Cosmetic only; capability always follows the server. */
.studio-tile__badge--lock {
  display: none;
  top: 4px;
  left: auto;
  right: 4px;
  padding: 2px 4px;
}

.studio-tile__badge--lock::before {
  content: '\1F512';
  font-size: 10px;
}

body:not(.is-member) .studio-tile__badge--lock {
  display: block;
}

/* Members have everything — the FREE labels are meaningless for them. */
body.is-member .studio-tile__badge--free {
  display: none;
}

/* ----------------------------------------------------------
   Toolbar
   ---------------------------------------------------------- */
.studio-toolbar {
  position: relative; /* anchors the Sizes popover */
  background: var(--studio-bg);
}

/* ----------------------------------------------------------
   Sizes popover (mirrors the iPad SizesPopoverCard)
   ---------------------------------------------------------- */
.studio-sizes-popover {
  position: absolute;
  bottom: calc(100% + var(--ac-sp-2));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  min-width: 300px;
  max-width: min(420px, calc(100vw - 2 * var(--ac-sp-4)));
  background: var(--studio-surface);
  padding: var(--ac-sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--ac-sp-3);
}

.studio-sizes-popover__main {
  display: flex;
  flex-direction: column;
  gap: var(--ac-sp-2);
}

.studio-sizes-popover__main.is-inactive .studio-sizes-popover__row,
.studio-sizes-popover__main.is-inactive #studio-painting-rows,
#studio-photo-chips.is-inactive,
#studio-painting-rows.is-inactive {
  opacity: 0.5;
}

.studio-sizes-popover__row {
  display: flex;
  align-items: center;
  gap: var(--ac-sp-2);
}

.studio-sizes-popover__row--center {
  justify-content: center;
}

.studio-sizes-popover__icon {
  flex: 0 0 28px;
  display: inline-flex;
  justify-content: center;
  color: var(--studio-text);
}

.studio-sizes-popover__icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.studio-sizes-popover__chips {
  display: inline-flex;
  gap: var(--ac-sp-2);
  flex-wrap: wrap;
}

#studio-painting-rows {
  display: flex;
  flex-direction: column;
  gap: var(--ac-sp-2);
}

.studio-chip {
  border: 0;
  border-radius: 0;
  background: var(--studio-surface-elevated);
  color: var(--studio-text);
  font-family: var(--ac-font-body);
  font-size: 13px;
  line-height: 1.2;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.studio-chip:hover:not(:disabled) {
  background: #3a3a3c;
}

.studio-chip:disabled {
  cursor: default;
}

.studio-chip.is-active {
  background: var(--studio-text);
  color: #000000;
}

.studio-chip--wide {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.studio-sizes-popover__caption {
  font-size: 12px;
  line-height: 1.4;
  color: var(--studio-text-muted);
  text-align: center;
  margin: var(--ac-sp-1) 0 0;
}

.studio-sizes-popover__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.25);
}

.studio-sizes-popover__reset {
  align-self: flex-start;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--studio-text);
  font-family: var(--ac-font-body);
  font-size: 14px;
  padding: 4px 0;
  cursor: pointer;
}

.studio-sizes-popover__reset:hover {
  color: var(--studio-focus);
}

.studio-toolbar__inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  padding: var(--ac-sp-2) var(--ac-sp-4) var(--ac-sp-3);
}

.studio-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--studio-text); /* enabled: white — icon + label follow currentColor */
  font-family: var(--ac-font-body);
  cursor: pointer;
}

.studio-tool svg {
  width: 25px;
  height: 25px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.studio-tool__label {
  font-size: 12px;
  line-height: 1.2;
  color: currentColor;
}

/* Disabled/dimmed: gray instead of white (same gray the old 50%-opacity
   white produced on black). */
.studio-tool.is-dimmed {
  color: rgba(255, 255, 255, 0.5);
}

/* Mode toggle icon states (mirrors the iPad's rectangle /
   inset.filled.center.rectangle pair):
   Image mode — just the box; Canvas mode — the box with a filled
   inner box. */
.studio-tool .studio-tool__inner-rect {
  display: none;
}

.studio-tool.is-canvas-mode .studio-tool__inner-rect {
  display: block;
  fill: currentColor;
  stroke: none;
}

.studio-tool:disabled {
  cursor: default;
}

/* ----------------------------------------------------------
   Focus visibility inside the dark workspace (≥3:1 contrast)
   ---------------------------------------------------------- */
.studio *:focus-visible {
  outline: 2px solid var(--studio-focus);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   Privacy note under the island
   ---------------------------------------------------------- */
.studio-privacy-note {
  max-width: var(--ac-max-width);
  margin: 0 auto var(--ac-sp-8);
  padding: var(--ac-sp-5) var(--ac-page-pad) 0;
  font-size: var(--ac-text-body-sm);
  color: rgba(255, 255, 255, 0.55);
}

/* ----------------------------------------------------------
   Responsive — phone layout (<768px)
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .studio {
    padding: 0;
  }

  .studio-page-header {
    padding-top: var(--ac-sp-6);
  }

  .studio-workspace {
    height: clamp(280px, 48vh, 560px);
  }

  .studio-page-header,
  .studio {
    --studio-tile-size: 68px;
  }

  .studio-carousel-arrow {
    width: 28px;
  }

  .studio-tile__name {
    display: none;
  }

  /* Icons only on phones (mirrors the iPhone toolbar) */
  .studio-tool__label {
    display: none;
  }

  .studio-toolbar__inner {
    padding: var(--ac-sp-2) var(--ac-sp-2);
  }

  .studio-privacy-note {
    padding: 0 var(--ac-page-pad-mobile);
  }
}
