/* love2.us - shared renderer additions (M2.1 + M2.2).
 * Only what the dynamic card needs on top of card/style.css:
 * staggered reveal entrance, skip link, real photo frames,
 * the nine template compositions, the photo layouts, the
 * full-bleed background treatment and the manual carousel.
 * The sample card at /card/ is untouched.
 */

/* ---- staggered entrance: message, photos, signature appear in order ---- */
.card-reveal.show .rise { animation: riseIn 0.5s ease both; }
.card-reveal.show .rise-1 { animation-delay: 0.05s; }
.card-reveal.show .rise-2 { animation-delay: 0.2s; }
.card-reveal.show .rise-3 { animation-delay: 0.35s; }
.card-reveal.show .rise-4 { animation-delay: 0.5s; }
.card-reveal.show .rise-5 { animation-delay: 0.65s; }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---- skip link under the envelope ---- */
.skip-link {
  margin-top: 18px;
  background: none;
  border: none;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--pink-ink);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.skip-link:focus-visible { outline: 2px solid var(--pink-ink); outline-offset: 2px; border-radius: 6px; }

/* ---- real photos inside the frames ---- */
.photo-frames { flex-wrap: wrap; }
/* .frame is display:flex (row) in the base stylesheet: with the img
 * and the figcaption as row flex items the caption was squeezed into
 * the leftover ~15-25px strip and shattered. The figure must be a
 * block: image box on top, caption below at full frame width. */
.frame-photo { display: block; padding: 0; overflow: hidden; }
.frame-photo .frame-img { overflow: hidden; }
.frame-photo img {
  width: 100%; display: block;
}
.frame-photo .caption {
  display: block; width: 100%; box-sizing: border-box;
  font-size: 13px; color: var(--ink-soft); text-align: center;
  padding: 6px 8px 8px; background: #fff; overflow-wrap: break-word;
}

/* Long-press on a card photo must not summon the browser's image
 * menu (Android Chrome image search, iOS callout). Taps, swipes
 * and text selection elsewhere are untouched. */
.card-reveal img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- layouts ---- */
.photo-frames.layout-hero .frame {
  width: min(420px, 100%); height: auto; margin: 0 auto;
}
.photo-frames.layout-side,
.photo-frames.layout-trio,
.photo-frames.layout-grid4,
.photo-frames.layout-grid6 {
  display: grid; gap: 12px; width: 100%; max-width: 560px; margin: 0 auto 20px;
}
.photo-frames.layout-side { grid-template-columns: 1fr 1fr; }
.photo-frames.layout-trio { grid-template-columns: 1.25fr 1fr; }
.photo-frames.layout-trio .frame:first-child { grid-row: span 2; }
.photo-frames.layout-grid4 { grid-template-columns: 1fr 1fr; }
.photo-frames.layout-grid6 { grid-template-columns: repeat(3, 1fr); }
.photo-frames.layout-side .frame,
.photo-frames.layout-trio .frame,
.photo-frames.layout-grid4 .frame,
.photo-frames.layout-grid6 .frame {
  width: auto; height: auto; transform: none;
}
.photo-frames.layout-carousel .frame {
  width: min(420px, 100%); height: auto; margin: 0 auto;
}
.carousel-controls {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  margin-top: 12px;
}
.carousel-btn {
  background: #fff; border: 1.5px solid #e8e0da; border-radius: 999px;
  padding: 8px 16px; font: inherit; font-size: 14px; font-weight: 700;
  color: var(--pink-ink); cursor: pointer;
}
.carousel-counter { font-size: 14px; color: var(--ink-soft); font-weight: 700; min-width: 52px; text-align: center; }

/* ---- full-bleed background layout: scrim = readability ---- */
.card-reveal.layout-background {
  position: relative; overflow: hidden; padding: 0; min-height: 520px;
  display: none;
}
.card-reveal.layout-background.show { display: block; }
.card-reveal.layout-background .bg-photo {
  position: absolute; inset: 0; object-fit: cover;
}
.card-reveal.layout-background .bg-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%,
    rgba(0, 0, 0, 0.45) 55%, rgba(0, 0, 0, 0.68) 100%);
}
.card-reveal.layout-background .bg-content {
  position: relative; padding: 48px 20px 24px; color: #fff;
}
.card-reveal.layout-background .bg-content h1,
.card-reveal.layout-background .bg-content .msg,
.card-reveal.layout-background .bg-content .signature {
  color: #fff; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}
.card-reveal.layout-background .bg-content .msg { margin: 0 auto 20px; }
.card-reveal.layout-background .bg-content .bg-caption {
  font-size: 14px; color: rgba(255, 255, 255, 0.9); margin: -8px 0 20px;
}
.card-reveal.layout-background .bg-content .share-box { color: var(--ink); }

/* ---- M2.3 layouts (P2) ---- */
.photo-frames.layout-hero-main .hero-main-photo {
  width: min(460px, 100%); height: auto; margin: 0 auto 12px;
}
.photo-frames.layout-hero-main .hero-main-rest {
  display: flex; gap: 10px; width: 100%; max-width: 560px; margin: 0 auto;
}
.photo-frames.layout-hero-main .hero-main-rest .frame { flex: 1; min-width: 0; }
.photo-frames.layout-strip {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px 4px 12px; -webkit-overflow-scrolling: touch;
}
.photo-frames.layout-strip .frame {
  flex: 0 0 min(300px, 78%); scroll-snap-align: center; margin: 0;
}
.photo-frames.layout-timeline {
  display: flex; flex-direction: column; gap: 20px; position: relative;
  padding-left: 26px; max-width: 480px; margin: 0 auto 20px;
}
.photo-frames.layout-timeline::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 2px; background: var(--gold); opacity: 0.7;
}
.photo-frames.layout-timeline .timeline-item { position: relative; }
.photo-frames.layout-timeline .timeline-dot {
  position: absolute; left: -26px; top: 14px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--pink); border: 2.5px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}
.photo-frames.layout-timeline .frame { width: min(420px, 100%); margin: 0; }
.photo-frames.layout-collage {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: 100%; max-width: 560px; margin: 0 auto 20px;
}
.photo-frames.layout-collage .frame { width: auto; height: auto; }
.photo-frames.layout-collage .collage-0 { grid-column: span 2; }
.photo-frames.layout-collage .collage-1 { transform: rotate(-1.5deg); }
.photo-frames.layout-collage .collage-2 { transform: rotate(1.5deg); }
.photo-frames.layout-collage .collage-3 { grid-column: span 2; transform: rotate(-0.75deg); }

/* ---- M2.3 carousel dots + keyboard focus ---- */
.photo-frames.layout-carousel:focus-visible {
  outline: 2px solid var(--pink-ink); outline-offset: 4px; border-radius: 12px;
}
.carousel-dots {
  display: flex; gap: 8px; justify-content: center; margin-top: 10px;
}
.carousel-dot {
  width: 10px; height: 10px; border-radius: 50%; border: none; padding: 0;
  background: #ddd5cf; cursor: pointer;
}
.carousel-dot.active { background: var(--pink-ink); }

/* ---- M2.3 image-load fallback ---- */
.photo-fallback {
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  justify-content: center; min-height: 140px; padding: 20px;
  background: #f6efe9; color: var(--ink-soft); font-size: 14px;
  text-align: center; border-radius: 10px;
}
.photo-retry {
  background: #fff; border: 1.5px solid #e8e0da; border-radius: 999px;
  padding: 6px 16px; font: inherit; font-size: 13px; font-weight: 700;
  color: var(--pink-ink); cursor: pointer;
}
.card-reveal.layout-background .photo-fallback {
  position: absolute; inset: 0; border-radius: 0; min-height: 0;
  background: linear-gradient(180deg, #e8d5dd 0%, #d9c2e0 100%);
}

/* ---- M2.3 background textures + text panel (P3) ---- */
.bg-texture { position: absolute; inset: 0; pointer-events: none; }
.bg-texture-grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.28; mix-blend-mode: overlay;
}
.bg-texture-paper {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  background-color: rgba(255, 248, 235, 0.10); opacity: 0.5;
}
.bg-texture-glow {
  background:
    radial-gradient(220px 160px at 18% 22%, rgba(255, 236, 190, 0.5), transparent 70%),
    radial-gradient(260px 200px at 85% 78%, rgba(255, 205, 225, 0.4), transparent 70%);
}
/* The text panel wraps only the text, not the share box: the panel
 * (0.38 black) plus the scrim carry the text's readability, while
 * the rest of the background photo stays visible. Before this fix
 * the panel was the whole content block, so it veiled most of the
 * photo - the "dark background" QIN saw on his phone. */
.card-reveal.layout-background .bg-text-panel {
  background: rgba(0, 0, 0, 0.38); border-radius: 18px;
  padding: 28px 18px 20px; margin: 0 0 20px;
}

/* ---- template compositions (not just palettes) ---- */
.card-reveal.tpl-birthday-elegant h1,
.card-reveal.tpl-love-elegant h1,
.card-reveal.tpl-anniversary-elegant h1 {
  font-family: var(--font-serif); letter-spacing: 0.5px;
}
.card-reveal.tpl-birthday-elegant,
.card-reveal.tpl-anniversary-elegant {
  background: linear-gradient(180deg, #fffdf6 0%, #fdf6e3 100%);
}
.tpl-birthday-elegant .frame-photo { border-radius: 140px 140px 16px 16px; }
.tpl-birthday-elegant .deco-rules,
.tpl-anniversary-elegant .deco-rules { color: var(--gold); font-size: 20px; letter-spacing: 10px; }
.card-reveal.tpl-birthday-minimal,
.card-reveal.tpl-anniversary-minimal { text-align: left; }
.card-reveal.tpl-birthday-minimal h1,
.card-reveal.tpl-anniversary-minimal h1 { font-size: 32px; }
.card-reveal.tpl-birthday-minimal .msg,
.card-reveal.tpl-anniversary-minimal .msg { margin: 0 0 20px; max-width: 44ch; }
.tpl-birthday-minimal .photo-frames,
.tpl-anniversary-minimal .photo-frames { justify-content: flex-start; }
.tpl-birthday-minimal .frame-photo,
.tpl-anniversary-minimal .frame-photo { width: min(280px, 100%); }
.tpl-love-cute .frame-photo {
  border: 5px solid #fff; box-shadow: var(--shadow);
}
.tpl-love-cute .frame-photo:nth-child(odd) { transform: rotate(-2deg); }
.tpl-love-cute .frame-photo:nth-child(even) { transform: rotate(2deg); }
.card-reveal.tpl-love-romantic h1,
.card-reveal.tpl-anniversary-romantic h1 {
  font-family: var(--font-display);
}
.tpl-love-romantic .deco-hearts,
.tpl-anniversary-romantic .deco-hearts { color: var(--pink-ink); }
.card-reveal.tpl-anniversary-romantic {
  background: #fff; border: 1.5px solid #f0dcd9; border-radius: 20px;
  margin: 12px; padding: 8px 8px 24px;
}
.tpl-anniversary-elegant .frame-photo { width: min(480px, 100%); }
.card-reveal.tpl-love-elegant.show {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "title title" "msg photos" "sig sig" "share share";
  gap: 0 20px; align-items: start;
}
.card-reveal.tpl-love-elegant h1 { grid-area: title; }
.card-reveal.tpl-love-elegant .msg { grid-area: msg; margin: 0; text-align: left; }
.card-reveal.tpl-love-elegant .photo-frames { grid-area: photos; }
.card-reveal.tpl-love-elegant .signature { grid-area: sig; margin-top: 20px; }
.card-reveal.tpl-love-elegant .share-box { grid-area: share; }
@media (max-width: 600px) {
  .card-reveal.tpl-love-elegant.show {
    grid-template-columns: 1fr;
    grid-template-areas: "title" "photos" "msg" "sig" "share";
  }
  .card-reveal.tpl-love-elegant .msg { margin: 0 auto 20px; text-align: center; }
}

/* ---- reduced motion: no entrance animation, no flap transition ---- */
@media (prefers-reduced-motion: reduce) {
  .card-reveal.show .rise { animation: none !important; }
}

/* ---- placeholder icons (no-photo cards) ----
 * Two image sets rotate per card (watercolor A / soft 3D C). The img
 * fills its 96x120 frame; cover crops the square art to the frame. */
.photo-frames.layout-empty .frame { overflow: hidden; }
.photo-frames.layout-empty .frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: inherit;
}
