/*
 * The Art Studio Preview — transplanted presentation layer.
 *
 * These styles are ported from the old Preview donor styles.css (gallery
 * black/white visual language, DESIGN_SPEC.md). Only presentation rules for
 * the customer-facing flow are kept; old admin/dev tooling and old system
 * styling are intentionally not present.
 *
 * Documented adaptations for the new clean DOM:
 *  - `.room-image` / `.artwork-overlay` / `.preview-stage.has-room` keep the
 *    donor look but use the new app's in-flow stage + natural-pixel overlay
 *    model (`.preview-canvas` wraps room + artwork).
 *  - `#resultPanel.stale` marks a result that belongs to a previous scene.
 *  - `.dev-panel` reuses the donor dev palette for the small dev-only panel.
 */

:root {
  --heading-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --body-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --page-title-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --heading-size: 40px;
  --body-size: 16px;
  --page-title-size: 14px;
  --hero-eyebrow-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --hero-eyebrow-size: 14px;
  --hero-eyebrow-color: #ffffff;
  --public-heading-color: #ffffff;
  --public-body-color: #ffffff;
  --mobile-hero-title-size: 36px;
  --mobile-hero-eyebrow-size: 12px;
  --mobile-hero-subtitle-size: 16px;
  --color-white: #ffffff;
  --color-black: #000000;
  --color-near-black: #050505;
  --color-panel-dark: #111111;
  --color-soft-dark: #1a1a1a;
  --color-text-light: #ffffff;
  --color-text-dark: #000000;
  --color-border-light: rgba(255, 255, 255, 0.2);
  --color-border-strong-light: rgba(255, 255, 255, 0.75);
  --color-border-dark: rgba(0, 0, 0, 0.2);
  --color-accent-red: #ff0000;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-white);
  color: var(--color-text-dark);
  font-family: var(--body-font);
  font-size: var(--body-size);
  line-height: 1.6;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.page-section {
  min-height: 100vh;
  padding-top: 15vh;
  padding-bottom: 15vh;
}

.dark-section {
  background: var(--color-near-black);
  color: var(--color-text-light);
}

.light-section {
  background: var(--color-white);
  color: var(--color-text-dark);
}

/* ------------------------------------------------------------------ */
/* Navigation                                                          */
/* ------------------------------------------------------------------ */

.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.5rem 3rem;
  color: var(--color-white);
  mix-blend-mode: difference;
}

.site-logo {
  color: var(--color-accent-red);
  font-weight: 700;
  text-decoration: none;
}

.site-links {
  display: flex;
  gap: 2rem;
}

.site-links a {
  text-decoration: none;
}

.site-logo,
.site-links a,
.eyebrow,
.upload-label,
.site-footer {
  text-transform: uppercase;
  letter-spacing: 1.8px;
  font-size: var(--page-title-size);
}

/* ------------------------------------------------------------------ */
/* Hero                                                                */
/* ------------------------------------------------------------------ */

.hero {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  text-align: center;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: 980px;
  /* Donor hero text offset behavior (admin-controlled custom properties). */
  transform: translate(var(--desktop-hero-text-offset-x, 0px), var(--desktop-hero-text-offset-y, 0px));
}

/* Hero background media + overlay (donor rules, admin-controlled). */
.hero-media,
.hero-overlay {
  position: absolute;
  inset: 0;
}

.hero-media {
  z-index: 0;
  background-position: center;
  background-size: cover;
}

.hero-media img,
.hero-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  z-index: 1;
  background: var(--color-black);
  pointer-events: none;
  opacity: 0;
}

.hero-bg-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-title-mode-desktop {
  display: inline;
}

.hero-title-mode-mobile {
  display: none;
}

.hero-title-split-part {
  color: var(--hero-title-split-color, currentColor);
}

.hero-text-panel {
  position: relative;
  z-index: 2;
  width: 100%;
}

.eyebrow {
  margin: 0 0 1.25rem;
  opacity: 0.7;
}

.hero .eyebrow {
  color: var(--hero-eyebrow-color);
  font-family: var(--hero-eyebrow-font);
  font-size: var(--hero-eyebrow-size);
}

h1,
.section-title {
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 300;
  line-height: 1.1;
  text-transform: uppercase;
}

.hero h1 {
  color: var(--public-heading-color);
}

h1 {
  font-size: calc(var(--heading-size) * 1.5);
  letter-spacing: -2px;
}

.section-title {
  font-size: var(--heading-size);
  letter-spacing: -1px;
}

.hero-copy,
.section-copy {
  max-width: 650px;
  margin: 1.5rem 0 2.5rem;
  opacity: 0.72;
}

.hero-copy {
  color: var(--public-body-color);
  margin-left: auto;
  margin-right: auto;
}

/* Primary hero journey CTA: scrolls to the Step 01 upload section. */
.hero-cta-row {
  margin: 0;
}

.hero-cta {
  gap: 0.65rem;
  padding: 1rem 2.25rem;
  background: var(--color-white);
  border-color: var(--color-white);
  color: var(--color-black);
}

.hero-cta:hover,
.hero-cta:focus-visible {
  background: transparent;
  color: var(--color-white);
}

.hero-cta-arrow {
  font-size: 1.05em;
  line-height: 1;
  animation: hero-cta-nudge 2.4s ease-in-out infinite;
}

@keyframes hero-cta-nudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-cta-arrow {
    animation: none;
  }
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 1rem 2.5rem;
  border: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: var(--body-font);
  font-size: 0.8rem;
  letter-spacing: 2px;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}

.btn:hover,
.btn:focus-visible {
  background: currentColor;
  color: var(--color-white);
}

.dark-btn:hover,
.dark-btn:focus-visible {
  color: var(--color-black);
}

.btn:focus-visible,
input:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.subtle {
  opacity: 0.75;
}

/* ------------------------------------------------------------------ */
/* Upload section                                                      */
/* ------------------------------------------------------------------ */

.preview-flow-steps {
  display: grid;
  gap: 0.8rem;
  max-width: 720px;
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
}

.preview-flow-steps li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 0;
  border-top: 1px solid var(--color-border-dark);
  color: var(--color-text-dark);
  font-size: 1rem;
  line-height: 1.45;
}

.preview-flow-steps li:last-child {
  border-bottom: 1px solid var(--color-border-dark);
}

.preview-flow-step-number {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
}

.upload-panel {
  display: grid;
  gap: 1rem;
  max-width: 720px;
  margin-top: 2rem;
  padding: 2rem 0;
  border-top: 1px solid var(--color-border-dark);
  border-bottom: 1px solid var(--color-border-dark);
}

.studio-handoff-upload-callout {
  display: grid;
  gap: 0.75rem;
  padding: 1.25rem;
  border: 1px solid var(--color-black);
  background: var(--color-black);
  color: var(--color-white);
}

.studio-handoff-upload-callout[hidden] {
  display: none;
}

.studio-handoff-ready,
.studio-handoff-upload-instruction {
  margin: 0;
}

.studio-handoff-ready {
  font-family: var(--heading-font);
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.studio-handoff-upload-instruction {
  max-width: 34rem;
  opacity: 0.78;
}

.artwork-thumb {
  max-height: 140px;
  width: auto;
  margin-top: 0.5rem;
  background: transparent;
}

.upload-panel.is-studio-handoff-ready #uploadButton {
  justify-self: start;
  border-color: var(--color-black);
  background: var(--color-black);
  color: var(--color-white);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.helper-text,
.message {
  margin: 0;
  opacity: 0.7;
}

.message {
  min-height: 1.6em;
  margin-top: 1.5rem;
}

.message[data-kind="ok"] {
  color: var(--color-black);
  opacity: 1;
  border-left: 2px solid var(--color-black);
  padding-left: 1rem;
}

.message[data-kind="error"],
.message.error {
  color: var(--color-black);
  opacity: 1;
  border-left: 2px solid var(--color-accent-red);
  padding-left: 1rem;
}

.privacy-note {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  opacity: 0.65;
  max-width: 520px;
}

/* ------------------------------------------------------------------ */
/* Editor section                                                      */
/* ------------------------------------------------------------------ */

.editor-section .section-copy {
  color: rgba(255, 255, 255, 0.72);
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 3rem;
  align-items: start;
  margin-top: 3rem;
}

.preview-shell {
  min-width: 0;
  border: 1px solid var(--color-border-light);
  background: var(--color-panel-dark);
  padding: 1rem;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
  overflow: hidden;
  background: var(--color-soft-dark);
  touch-action: pan-y pinch-zoom;
}

.preview-stage.empty {
  border: 1px solid var(--color-border-light);
}

.empty-state {
  max-width: 360px;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.64);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 0.78rem;
}

.preview-stage.has-room {
  width: 100%;
  height: min(70vh, 760px);
  height: min(70dvh, 760px);
  min-height: min(360px, 70vh);
  min-height: min(360px, 70dvh);
  background: #000000;
}

.preview-stage.has-room .empty-state {
  display: none;
}

/* New clean DOM: the room photo and the placed artwork share one shrink-wrap
 * canvas so the authoritative natural-pixel overlay stays aligned with the
 * displayed room image. */
.preview-canvas {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}

.room-image {
  display: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(64vh, 700px);
  max-height: min(64dvh, 700px);
  object-fit: contain;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.preview-stage.has-room .room-image {
  display: block;
}

.artwork-overlay {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
  z-index: 2;
}

.artwork-overlay.is-dragging {
  cursor: grabbing;
}

/* Placement preparation: the room is visible, but the artwork is not yet
 * advertised or interactive until the prepare window completes. */
.artwork-overlay {
  transition: opacity 300ms ease;
}

.preview-stage.is-preparing .artwork-overlay {
  opacity: 0;
  pointer-events: none;
}

.placement-preparing {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
  background: rgba(5, 5, 5, 0.72);
  color: var(--color-white);
}

.placement-preparing-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.placement-preparing-note {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.72;
}

@media (prefers-reduced-motion: reduce) {
  .artwork-overlay {
    transition: none;
  }
}

/* ------------------------------------------------------------------ */
/* Control panel                                                       */
/* ------------------------------------------------------------------ */

.control-panel {
  display: grid;
  gap: 2rem;
  padding: 2rem 0;
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}

.checkbox-control {
  grid-template-columns: 1fr auto;
}

.checkbox-control input {
  grid-column: auto;
  width: auto;
  accent-color: var(--color-white);
}

.action-stack,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.action-stack {
  flex-direction: column;
}

.preview-generation-status {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--color-black);
  background: rgba(255, 255, 255, 0.68);
  color: var(--color-black);
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-line;
}

.preview-generation-status[data-kind="error"],
.preview-generation-status.error {
  border-left-color: var(--color-accent-red);
}

/* Small dev-only panel (donor dev palette). */
.dev-panel {
  display: grid;
  gap: 0.85rem;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid rgba(223, 198, 68, 0.48);
  background: #151515;
  color: #f4f2e9;
}

.dev-panel .btn {
  justify-self: start;
}

.dev-panel .debug {
  margin: 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  opacity: 0.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.composite-preview {
  max-width: 100%;
  border: 1px solid var(--color-border-light);
}

/* ------------------------------------------------------------------ */
/* Result section                                                      */
/* ------------------------------------------------------------------ */

.result-section {
  min-height: auto;
}

/* Result reveal: loader exits, then the result fades/slides in. */
#resultPanel.fable-result-reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 380ms ease, transform 380ms ease;
}

#resultPanel.fable-result-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  #resultPanel.fable-result-reveal {
    transform: none;
    transition-duration: 180ms;
  }
}

.result-panel {
  display: grid;
  gap: 2rem;
  padding: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: var(--color-near-black);
  color: var(--color-white);
}

.result-copy p:last-child {
  max-width: 720px;
  margin-bottom: 0;
  opacity: 0.72;
}

.result-actions {
  align-items: center;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}

/* Donor-compatible red result download treatment. */
.result-actions .result-download {
  border-color: var(--color-accent-red);
  background: var(--color-accent-red);
  color: var(--color-white);
}

.result-actions .result-download:hover,
.result-actions .result-download:focus-visible {
  background: var(--color-white);
  color: var(--color-accent-red);
}

.protected-preview-frame {
  position: relative;
  overflow: hidden;
  -webkit-touch-callout: none;
  user-select: none;
}

.result-image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: min(68vh, 760px);
  height: min(68dvh, 760px);
  min-height: min(320px, 52dvh);
  border: 1px solid var(--color-border-light);
  background: var(--color-panel-dark);
}

.result-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 0;
  background: var(--color-panel-dark);
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.result-image[hidden] {
  display: none;
}

#resultPanel.stale .result-panel {
  border-color: var(--color-accent-red);
}

#resultPanel.stale #resultNote {
  color: rgba(255, 255, 255, 0.92);
}

/* ------------------------------------------------------------------ */
/* Footer                                                              */
/* ------------------------------------------------------------------ */

.site-footer {
  padding: 2rem 0;
  background: var(--color-white);
  color: var(--color-black);
}

.site-footer p {
  margin: 0;
  opacity: 0.72;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 720px) {
  .result-image-frame {
    height: min(58vh, 560px);
    height: min(58dvh, 560px);
    min-height: min(240px, 50dvh);
  }
}

@media screen and (max-width: 900px) {
  .site-nav {
    padding: 1.5rem;
  }

  .site-links {
    gap: 1rem;
  }

  .editor-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .control-panel {
    max-width: none;
  }

  .preview-stage.has-room {
    height: min(66vh, 680px);
    height: min(66dvh, 680px);
    min-height: min(300px, 66vh);
    min-height: min(300px, 66dvh);
  }
}

@media screen and (max-width: 768px) {
  .container {
    padding: 0 1.5rem;
  }

  .page-section {
    min-height: auto;
    padding-top: 10vh;
    padding-bottom: 10vh;
  }

  .site-nav {
    align-items: flex-start;
  }

  .site-links {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
  }

  .site-logo,
  .site-links a,
  .eyebrow,
  .upload-label,
  .site-footer {
    font-size: 0.72rem;
  }

  h1 {
    font-size: var(--mobile-hero-title-size);
    letter-spacing: -1px;
  }

  .hero-title-mode-desktop {
    display: none;
  }

  .hero-title-mode-mobile {
    display: inline;
  }

  .hero-inner {
    transform: translate(var(--mobile-hero-text-offset-x, 0px), var(--mobile-hero-text-offset-y, 0px));
  }

  .hero .eyebrow {
    font-size: var(--mobile-hero-eyebrow-size);
  }

  .hero-copy {
    font-size: var(--mobile-hero-subtitle-size);
  }

  .section-title {
    font-size: calc(var(--heading-size) * 0.8);
    margin-bottom: 2rem;
  }

  .preview-shell,
  .result-panel {
    padding: 1rem;
  }

  .preview-stage {
    min-height: 300px;
  }

  .preview-stage.has-room {
    height: min(64vh, 580px);
    height: min(64dvh, 580px);
    min-height: min(260px, 64vh);
    min-height: min(260px, 64dvh);
  }

  .action-stack,
  .result-actions {
    display: grid;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ------------------------------------------------------------------ */
/* Customer generation allowance                                       */
/* ------------------------------------------------------------------ */

.allowance-panel {
  display: grid;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-light);
}

.allowance-title {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  font-size: var(--page-title-size);
  opacity: 0.9;
}

.allowance-message {
  margin: 0;
  opacity: 0.8;
}

.allowance-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.allowance-label {
  text-transform: uppercase;
  letter-spacing: 1.8px;
  font-size: var(--page-title-size);
  opacity: 0.8;
}

.allowance-input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--color-border-light);
  border-radius: 0;
  color: inherit;
  font-family: var(--body-font);
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  outline: none;
}

.allowance-input:focus {
  border-color: var(--color-border-strong-light, rgba(255, 255, 255, 0.5));
}

.allowance-consent {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  opacity: 0.65;
}

.allowance-status.error {
  color: #ff9b91;
}
