/* =================================================================
   Inline owner editor — applied only when populate.js adds
   body.is-owner-editor (the signed-in owner viewing their own /i/<slug>).
   Guests never load any of these styles' effects because the classes
   are never added for them.
   Mobile-first; touch targets >= 44px.
   ================================================================= */

/* Leave room for the fixed toolbar so it never covers content/back button. */
body.has-uv-toolbar { padding-top: 56px; }

/* ---------------- Floating toolbar ---------------- */
.uv-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 56px;
  box-sizing: border-box;
  background: rgba(28, 22, 16, 0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fdf8ec;
  font-family: 'General Sans', system-ui, sans-serif;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}
.uv-toolbar__brand {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.uv-toolbar__status {
  font-size: 12px;
  color: #b9a98f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.uv-toolbar__status.is-dirty { color: #f4c66a; }
.uv-toolbar__spacer { flex: 1 1 auto; }

.uv-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  min-height: 40px;
  min-width: 44px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.uv-btn--save {
  background: #c4912b;
  color: #1c1610;
}
.uv-btn--save:disabled {
  background: #5a4d38;
  color: #9b8c70;
  cursor: default;
}
.uv-btn--publish {
  background: #3f9d6a;
  color: #fff;
}
.uv-btn--ghost {
  background: transparent;
  color: #d9cbb2;
  border: 1px solid rgba(217, 203, 178, 0.4);
}

/* ---------------- Editable text affordance ---------------- */
/* Persistent "edit me" cue: editable text gets a subtle hover/focus tint +
   ring, and a pencil badge in the corner on hover so owners can tell at a
   glance what they can change. Only active in owner-editor mode. */
body.is-owner-editor .uv-editable {
  position: relative;
  cursor: text;
  border-radius: 4px;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}
body.is-owner-editor .uv-editable:hover,
body.is-owner-editor .uv-editable:focus {
  background-color: rgba(255, 220, 100, 0.12);
  box-shadow: 0 0 0 2px rgba(196, 145, 43, 0.35);
  outline: none;
}
body.is-owner-editor .uv-editable::after {
  content: '\270E';
  position: absolute;
  top: -10px;
  right: -14px;
  font-size: 11px;
  color: rgba(196, 145, 43, 0.9);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.6;
  transition: opacity 150ms ease;
  pointer-events: none;
}
body.is-owner-editor .uv-editable:hover::after,
body.is-owner-editor .uv-editable:focus::after { opacity: 1; }

/* Draft mode (anonymous, instant-edit): mobile-first affordance.
   Always show a soft dashed ring + persistent pencil cue so first-time
   visitors immediately see what's tappable. No hover dependency. */
body.uv-mode-draft .uv-editable {
  box-shadow: 0 0 0 1px rgba(196, 145, 43, 0.28);
  background-color: rgba(255, 220, 100, 0.06);
}
body.uv-mode-draft .uv-editable::after { opacity: 1; }
body.uv-mode-draft .uv-editable:hover,
body.uv-mode-draft .uv-editable:focus {
  background-color: rgba(255, 220, 100, 0.18);
  box-shadow: 0 0 0 2px rgba(196, 145, 43, 0.55);
}

/* ---------------- Polaroid edit affordances ---------------- */
.uv-poly-editable { cursor: pointer; }

/* Full-frame tap target. Sits above the SVG/img so a tap anywhere on the
   photo opens the action. Transparent until hover/empty. */
.uv-poly-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-family: 'General Sans', system-ui, sans-serif;
}
.uv-poly-overlay__label {
  pointer-events: none;
  font-size: 13px;
  font-weight: 600;
  color: #1c1610;
  background: rgba(253, 248, 236, 0.92);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 140ms ease;
}
/* Empty slots: always show the "+ Add photo" prompt over a dashed frame. */
.uv-poly-editable:not(.uv-poly-filled) .polaroid__photo {
  outline: 2px dashed rgba(196, 145, 43, 0.7);
  outline-offset: -6px;
}
.uv-poly-editable:not(.uv-poly-filled) .uv-poly-overlay__label { opacity: 1; }
/* Filled slots: reveal "Edit photo" on hover/focus. */
.uv-poly-filled .uv-poly-overlay:hover .uv-poly-overlay__label,
.uv-poly-filled .uv-poly-overlay:focus .uv-poly-overlay__label { opacity: 1; }

.uv-poly-busy { opacity: 0.6; pointer-events: none; }

/* ---------------- Polaroid action menu ---------------- */
.uv-poly-menu {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(28, 22, 16, 0.97);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  min-width: 140px;
}
.uv-poly-menu__btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 14px;
  font-family: 'General Sans', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #c4912b;
  color: #1c1610;
}
.uv-poly-menu__btn--danger { background: #c0492f; color: #fff; }
.uv-poly-menu__btn--ghost {
  background: transparent;
  color: #d9cbb2;
  border: 1px solid rgba(217, 203, 178, 0.4);
}
/* Replace is a <label> wrapping a real file input. Must be position:relative so
   the input's inset:0 fills the label, giving iOS a full-size native tap target
   that opens the picker on the first tap (no JS click() forwarding). */
.uv-poly-menu__replace {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.uv-poly-menu__replace input.uv-poly-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* In owner mode, override the reveal animation so polaroids are always
   visible & tappable even before scene-4 scrolls into view (the owner needs
   to reach every slot without scrolling through the whole cinematic intro). */
body.is-owner-editor .polaroid {
  opacity: 1;
  transform: rotate(var(--fr, 0deg));
  animation: none;
}

/* ---------------- Sticky bottom save bar (mobile) ---------------- */
.uv-floatbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100000;
  display: none;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(28, 22, 16, 0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}
.uv-floatbar .uv-btn--lg { width: 100%; min-height: 48px; font-size: 16px; }
.uv-btn--lg { min-height: 48px; }
/* Secondary row in draft floatbar — quiet "Save for later · Start over" link
   buttons under the big "Get it live" CTA. Keeps the primary action loud and
   the escape hatches quiet. */
.uv-floatbar__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}
.uv-floatbar__quiet {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  color: rgba(217, 203, 178, 0.75);
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  min-height: 32px;
  cursor: pointer;
}
.uv-floatbar__quiet:hover,
.uv-floatbar__quiet:focus { color: #fff; outline: none; }
.uv-floatbar__quiet:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.uv-floatbar__sep { color: rgba(217, 203, 178, 0.4); font-size: 13px; }
.uv-btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
@media (max-width: 640px) {
  body.is-owner-editor.uv-dirty .uv-floatbar { display: block; }
  /* In draft mode, show the floatbar from first touch — dirty or not — so the
     "Get it live" CTA is visible immediately. */
  body.uv-mode-draft .uv-floatbar { display: block; }
}

/* ---------------- First-time tour overlay ---------------- */
.uv-tour {
  position: fixed; inset: 0;
  z-index: 100001;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(20, 14, 8, 0.6);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.uv-tour__card {
  background: #fdf8ec;
  color: #2a2018;
  width: 100%; max-width: 320px;
  border-radius: 16px;
  padding: 22px 22px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  font-family: 'General Sans', system-ui, sans-serif;
}
.uv-tour__title {
  margin: 0 0 14px;
  font-size: 20px; line-height: 1.25; font-weight: 700;
}
.uv-tour__list {
  list-style: none; margin: 0 0 18px; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.uv-tour__list li {
  position: relative;
  padding-left: 28px;
  font-size: 14px; line-height: 1.45; color: #5a4a3a;
}
.uv-tour__list li::before {
  content: '\2713';
  position: absolute; left: 0; top: 0;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(196, 145, 43, 0.18);
  color: #b07f1f; font-size: 12px; font-weight: 700;
}
.uv-tour__go { width: 100%; min-height: 46px; font-size: 15px; }

/* ---------------- Save success toast ---------------- */
.uv-toast {
  position: fixed;
  left: 50%; top: 64px;
  transform: translateX(-50%);
  z-index: 100002;
  width: calc(100% - 24px); max-width: 420px;
  box-sizing: border-box;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #24301f;
  color: #f3f0e6;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  font-family: 'General Sans', system-ui, sans-serif;
  font-size: 14px;
}
.uv-toast__msg { flex: 1 1 100%; font-weight: 600; }
.uv-toast__btn {
  -webkit-appearance: none; appearance: none;
  border: 0; border-radius: 999px;
  padding: 0 14px; min-height: 36px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.uv-toast__btn--primary { background: #4fae7a; color: #0c160f; }
.uv-toast__btn--ghost { background: transparent; color: #d9cbb2; border: 1px solid rgba(217, 203, 178, 0.4); }
.uv-toast__close {
  margin-left: auto;
  -webkit-appearance: none; appearance: none;
  background: transparent; border: 0; color: #b9a98f;
  font-size: 18px; line-height: 1; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
}

/* Narrow phones: keep the toolbar usable at 390px and below. */
@media (max-width: 420px) {
  .uv-toolbar { gap: 6px; padding: 6px 8px; }
  .uv-toolbar__brand { display: none; }
  .uv-btn { padding: 0 12px; font-size: 13px; min-height: 36px; }
  .uv-toolbar__status { display: none; }
}

/* ---------------- SVG-text edit overlay ----------------
   The title ("Cielito"/"Lindo") and honoree ("Baby Mateo") are rendered as
   SVG <text> elements for typography control. SVG text doesn't accept
   contenteditable on iOS/Android, so in owner mode we drop a transparent
   button over the parent SVG that opens a sheet (.uv-edit-sheet). The dashed
   ring + corner pencil on the SVG itself (via .uv-editable--svg) makes the
   tap target obvious. */
.uv-svg-edit-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 44px;
  font-family: 'General Sans', system-ui, sans-serif;
}
.uv-svg-edit-overlay__cue {
  pointer-events: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1c1610;
  background: rgba(253, 248, 236, 0.94);
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0.7;
  transform: translateY(0);
  transition: opacity 160ms ease, transform 160ms ease;
  margin-bottom: 6px;
}
body.is-owner-editor .uv-svg-edit-overlay__cue { opacity: 0.7; transform: translateY(0); }
.uv-svg-edit-overlay:hover .uv-svg-edit-overlay__cue,
.uv-svg-edit-overlay:focus .uv-svg-edit-overlay__cue {
  opacity: 1;
  transform: translateY(0);
}
/* In draft mode the cue is always visible so first-time mobile visitors
   don't have to discover it via hover. */
body.uv-mode-draft .uv-svg-edit-overlay__cue { opacity: 1; transform: translateY(0); }

/* ---------------- Cinema SVG cue pulse animation (first-time) ---------------- */
@keyframes uvCuePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
body.is-owner-editor.uv-show-cue-pulse .uv-svg-edit-overlay__cue { animation: uvCuePulse 1.2s ease-in-out 3; }
@media (prefers-reduced-motion: reduce) {
  body.is-owner-editor.uv-show-cue-pulse .uv-svg-edit-overlay__cue { animation: none; }
}

/* First-time draft mode pencil cue pulse */
body.uv-mode-draft.uv-show-cue-pulse .uv-editable::after { animation: uvCuePulse 1.2s ease-in-out 3; }
@media (prefers-reduced-motion: reduce) {
  body.uv-mode-draft.uv-show-cue-pulse .uv-editable::after { animation: none; }
}

/* The SVG itself gets the same dashed ring as plain editable text in draft
   mode. We re-declare the rule against the SVG class so it picks up the
   bounding-box highlight. */
body.uv-mode-draft .uv-editable--svg {
  outline: 2px dashed rgba(196, 145, 43, 0.55);
  outline-offset: 4px;
  border-radius: 6px;
}
body.is-owner-editor .uv-editable--svg {
  outline: 1px dashed rgba(196, 145, 43, 0.4);
  outline-offset: 4px;
  border-radius: 6px;
}

/* ---------------- Edit sheet (bottom-sheet modal) ----------------
   Used for fields that can't be edited inline (SVG text). One short input,
   Save / Cancel, dismissed by backdrop tap. iOS-keyboard friendly. */
.uv-edit-sheet {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: 'General Sans', system-ui, sans-serif;
}
.uv-edit-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.uv-edit-sheet__card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: #fbf6ec;
  color: #1c1610;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.35);
  animation: uvEditSheetIn 220ms cubic-bezier(.2,.7,.2,1);
}
@media (min-width: 520px) {
  .uv-edit-sheet { align-items: center; }
  .uv-edit-sheet__card { border-radius: 18px; margin: 0 16px; }
}
@keyframes uvEditSheetIn {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.uv-edit-sheet__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(28, 22, 16, 0.7);
  margin-bottom: 8px;
}
.uv-edit-sheet__input {
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(28, 22, 16, 0.18);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 18px;
  background: #fff;
  color: #1c1610;
  min-height: 48px;
}
.uv-edit-sheet__input:focus {
  outline: none;
  border-color: #c4912b;
  box-shadow: 0 0 0 3px rgba(196, 145, 43, 0.25);
}
.uv-edit-sheet__actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  justify-content: flex-end;
}
.uv-edit-sheet__btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  min-height: 44px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.uv-edit-sheet__btn--ghost {
  background: transparent;
  color: rgba(28, 22, 16, 0.65);
}
.uv-edit-sheet__btn--ghost:hover { color: #1c1610; }
.uv-edit-sheet__btn--primary {
  background: #1c1610;
  color: #fbf6ec;
}
.uv-edit-sheet__btn--primary:hover { background: #2a2118; }

/* ---------------- Drawer field → canvas highlight pulse (T2) ---------------- */
@keyframes uvHighlightPulse {
  0%   { box-shadow: 0 0 0 0   rgba(196, 145, 43, 0.5); }
  50%  { box-shadow: 0 0 0 12px rgba(196, 145, 43, 0.0); }
  100% { box-shadow: 0 0 0 0   rgba(196, 145, 43, 0.0); }
}
.uv-highlight-pulse {
  animation: uvHighlightPulse 1.4s ease-out;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  .uv-highlight-pulse { animation: none; outline: 2px solid currentColor; outline-offset: 4px; }
}
