/* screens.css — per-screen layout for Welcome, Capture, Review, Compose.
 * Progress / Result / Offline shells are laid out by T4.
 *
 * Signature element: the postage-stamp frame (.stamp) — a perforated postcard
 * edge punched with pure CSS radial-gradient masks — that wraps the photo through
 * Review and Compose, tying the "holiday postcard" idea together.
 */

/* Shared bottom action bar (Review / Compose). */
.screen-actions {
  display: flex;
  gap: var(--s3);
  padding: var(--s4) var(--s4)
    calc(var(--s4) + var(--safe-b))
    var(--s4);
  padding-left: calc(var(--s4) + var(--safe-l));
  padding-right: calc(var(--s4) + var(--safe-r));
  background: var(--ink);
  border-top: 1px solid var(--ink-3);
}

.screen-actions .btn {
  flex: 1 1 auto;
}

.screen-actions .btn-ghost {
  flex: 0 0 auto;
  min-width: 120px;
}

/* Shared dark top bar (Review / Compose). */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: calc(var(--s3) + var(--safe-t)) var(--s3) var(--s3);
  padding-left: calc(var(--s3) + var(--safe-l));
  padding-right: calc(var(--s3) + var(--safe-r));
}

.topbar-title {
  flex: 1 1 auto;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
}

.topbar-spacer {
  width: var(--tap);
  height: 1px;
  flex: 0 0 auto;
}

/* ============================ WELCOME ============================ */
.screen-welcome {
  background:
    radial-gradient(120% 80% at 50% -10%, #ff9a5a 0%, #e86a4a 22%, #6d3f6e 52%, var(--ink) 82%);
  overflow: hidden;
}

.welcome-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff2cf 0%, var(--gold) 55%, rgba(255, 194, 75, 0) 72%);
  animation: sun-breathe 6s ease-in-out infinite;
}

.ray {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 246, 233, 0.85);
  opacity: 0.7;
  animation: drift 9s ease-in-out infinite;
}

.ray-a {
  top: 24%;
  left: 22%;
  animation-delay: 0s;
}

.ray-b {
  top: 32%;
  left: 74%;
  width: 4px;
  height: 4px;
  animation-delay: 1.6s;
}

.ray-c {
  top: 46%;
  left: 40%;
  width: 5px;
  height: 5px;
  animation-delay: 3.1s;
}

@keyframes sun-breathe {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes drift {
  0%, 100% { transform: translateY(0); opacity: 0.35; }
  50% { transform: translateY(-10px); opacity: 0.9; }
}

.welcome-body {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s4);
  padding: var(--s6) var(--s5)
    calc(var(--s7) + var(--safe-b));
  padding-left: calc(var(--s5) + var(--safe-l));
  padding-right: calc(var(--s5) + var(--safe-r));
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--gold);
}

.brand-glyph {
  color: var(--gold);
}

.brand-word {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  color: var(--on-ink);
}

.welcome-title {
  font-size: clamp(2rem, 9vw, 2.8rem);
  color: #fff;
  text-shadow: 0 2px 18px rgba(20, 35, 59, 0.4);
}

.welcome-lede {
  max-width: 34ch;
  color: rgba(255, 255, 255, 0.92);
  font-size: 1.02rem;
  line-height: 1.5;
}

.welcome-foot {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.85rem;
}

.screen-welcome .btn-primary {
  margin-top: var(--s2);
  align-self: stretch;
}

/* ============================ CAPTURE ============================ */
.screen-capture {
  background: #000;
}

.capture-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.capture-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Mirror only the selfie preview (matches the mirrored capture in camera.js). */
.capture-video.is-front {
  transform: scaleX(-1);
}

.capture-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: calc(var(--s3) + var(--safe-t))
    calc(var(--s3) + var(--safe-r)) var(--s3)
    calc(var(--s3) + var(--safe-l));
}

.capture-hint {
  position: absolute;
  left: 50%;
  bottom: var(--s5);
  transform: translateX(-50%);
  width: min(88%, 420px);
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  background: rgba(20, 35, 59, 0.82);
  color: var(--on-ink);
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: center;
  backdrop-filter: blur(6px);
}

.capture-controls {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4)
    calc(var(--s4) + var(--safe-r))
    calc(var(--s4) + var(--safe-b))
    calc(var(--s4) + var(--safe-l));
  background: #000;
}

/* Shutter sits in the centre column; file fallback (when shown) in the first. */
.capture-controls .btn-file {
  grid-column: 1;
  justify-self: start;
}

.shutter {
  grid-column: 2;
  justify-self: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.shutter-ring {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px #000, 0 0 0 7px #fff;
  transition: transform var(--dur) ease, background-color var(--dur) ease;
}

.shutter:active .shutter-ring {
  transform: scale(0.9);
  background: var(--gold);
}

/* ============================ REVIEW / COMPOSE stamp ============================ */
.stamp {
  --r: 6px;   /* perforation radius */
  --g: 13px;  /* perforation spacing */
  margin: 0;
  padding: 12px;
  background: var(--paper);
  border-radius: 4px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.45));
  -webkit-mask:
    radial-gradient(circle var(--r) at 50% 0,    #0000 98%, #000) repeat-x 50% 0    / var(--g) 51%,
    radial-gradient(circle var(--r) at 50% 100%, #0000 98%, #000) repeat-x 50% 100% / var(--g) 51%,
    radial-gradient(circle var(--r) at 0 50%,    #0000 98%, #000) repeat-y 0 50%    / 51% var(--g),
    radial-gradient(circle var(--r) at 100% 50%, #0000 98%, #000) repeat-y 100% 50% / 51% var(--g),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - var(--g)) calc(100% - var(--g));
          mask:
    radial-gradient(circle var(--r) at 50% 0,    #0000 98%, #000) repeat-x 50% 0    / var(--g) 51%,
    radial-gradient(circle var(--r) at 50% 100%, #0000 98%, #000) repeat-x 50% 100% / var(--g) 51%,
    radial-gradient(circle var(--r) at 0 50%,    #0000 98%, #000) repeat-y 0 50%    / 51% var(--g),
    radial-gradient(circle var(--r) at 100% 50%, #0000 98%, #000) repeat-y 100% 50% / 51% var(--g),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - var(--g)) calc(100% - var(--g));
  position: relative;
}

.stamp-photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 2px;
  background: #e9dcc4;
}

.stamp-postmark {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 3px 8px;
  border: 2px solid rgba(33, 48, 74, 0.55);
  border-radius: var(--r-pill);
  color: rgba(33, 48, 74, 0.65);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  transform: rotate(-8deg);
}

/* ============================ REVIEW ============================ */
.review-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4)
    calc(var(--s5) + var(--safe-r)) var(--s4)
    calc(var(--s5) + var(--safe-l));
}

.review-body .stamp {
  max-width: 100%;
}

/* ============================ COMPOSE ============================ */
.compose-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding: var(--s2)
    calc(var(--s4) + var(--safe-r)) var(--s5)
    calc(var(--s4) + var(--safe-l));
}

.compose-lead {
  display: flex;
  align-items: center;
  gap: var(--s4);
}

.compose-thumb {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 3px solid var(--paper);
  background: var(--ink-2);
}

.compose-lead-copy {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

/* ---- Auto-director ---- */
.auto-direct {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.btn-auto-direct {
  align-self: flex-start;
  padding: 0 var(--s4);
  min-height: 44px;
}

.btn-auto-direct:disabled {
  opacity: 0.6;
  cursor: default;
}

.auto-direct-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: currentColor;
  animation: r-spin 0.8s linear infinite;
}

.auto-direct-status {
  font-size: 0.85rem;
  color: var(--on-ink-dim);
  line-height: 1.4;
  min-height: 1em;
}

.auto-direct-status:empty {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.field-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--on-ink-dim);
  letter-spacing: 0.02em;
}

.field-hint {
  font-weight: 500;
  color: var(--on-ink-dim);
  opacity: 0.85;
}

.prompt-input {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: var(--s4);
  border-radius: var(--r);
  border: 2px solid var(--ink-3);
  background: var(--ink-2);
  color: var(--on-ink);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.4;
}

.prompt-input::placeholder {
  color: var(--on-ink-dim);
  opacity: 0.8;
}

.prompt-input:focus-visible {
  outline: 3px solid var(--gold);
  border-color: var(--gold);
}

.prompt-counter {
  align-self: flex-end;
  font-size: 0.82rem;
  color: var(--on-ink-dim);
  font-variant-numeric: tabular-nums;
}

.prompt-counter.is-limit {
  color: var(--gold);
  font-weight: 700;
}

/* ---- Extend: scenes 2..4 ---- */
.extend-helper {
  color: var(--on-ink-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

.scenes-list {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.scene-field {
  padding: var(--s3);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--ink-3);
}

.scene-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

.scene-field-label {
  color: var(--on-ink-dim);
}

.btn-scene-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--ink-3);
  color: var(--on-ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-scene-remove:active {
  background: var(--coral);
  color: var(--on-coral);
}

.scene-prompt-input {
  min-height: 64px;
}

.btn-add-scene {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  border: 1.5px dashed rgba(245, 239, 227, 0.4);
  background: transparent;
  color: var(--on-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  align-self: flex-start;
}

.btn-add-scene:active {
  background: rgba(255, 255, 255, 0.06);
}

/* Advanced disclosure */
.advanced {
  border-top: 1px solid var(--ink-3);
  padding-top: var(--s3);
}

.advanced-summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--on-ink-dim);
  min-height: var(--tap);
  display: flex;
  align-items: center;
  list-style: none;
}

.advanced-summary::-webkit-details-marker {
  display: none;
}

.advanced-summary::before {
  content: "▸";
  margin-right: var(--s2);
  transition: transform var(--dur) ease;
}

.advanced[open] .advanced-summary::before {
  transform: rotate(90deg);
}

.advanced-inner {
  padding-top: var(--s3);
}

.seed-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r);
  border: 2px solid var(--ink-3);
  background: var(--ink-2);
  color: var(--on-ink);
  font: inherit;
  font-size: 1rem;
}

.seed-input:focus-visible {
  outline: 3px solid var(--gold);
  border-color: var(--gold);
}

.content-note {
  padding: var(--s4);
  border-radius: var(--r);
  background: rgba(47, 191, 166, 0.1);
  border: 1px solid rgba(47, 191, 166, 0.35);
  color: var(--on-ink-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Larger phones: cap content width and centre for a tidy postcard feel. */
@media (min-width: 640px) {
  .welcome-body,
  .compose-body,
  .screen-actions {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }
}
