/* Kiss4Peace — bespoke styling layered on top of Tailwind utilities.
   Warm, calm, minimal. Generous whitespace. Soft motion. */

:root {
  --cream: #f8f1e9;
  --sand: #e8d5c4;
  --teal: #0d5c63;
  --tealdeep: #0a4a50;
  --gold: #e9b872;
  --rose: #e8a87c;
  --ink: #2b2520;
  --muted: #6b5d52;
  --radius: 22px;
  --shadow-soft: 0 18px 50px -24px rgba(43, 37, 32, 0.45);
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(170deg, #fbf6ef 0%, var(--cream) 38%, var(--sand) 100%);
  color: var(--ink);
  overflow-x: hidden;
}

::selection { background: rgba(13, 92, 99, 0.18); }

/* -------------------------------------------------------------- ambient bg */
.bg-stage {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
}
.bg-orb {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.5;
  will-change: transform;
}
.bg-orb--1 { width: 46vmax; height: 46vmax; top: -14vmax; left: -10vmax;
  background: radial-gradient(circle at 30% 30%, rgba(232, 168, 124, 0.55), transparent 70%);
  animation: drift 26s ease-in-out infinite; }
.bg-orb--2 { width: 40vmax; height: 40vmax; bottom: -16vmax; right: -12vmax;
  background: radial-gradient(circle at 60% 40%, rgba(13, 92, 99, 0.30), transparent 70%);
  animation: drift 32s ease-in-out infinite reverse; }
.bg-orb--3 { width: 32vmax; height: 32vmax; top: 40%; left: 55%;
  background: radial-gradient(circle at 50% 50%, rgba(233, 184, 114, 0.35), transparent 70%);
  animation: drift 38s ease-in-out infinite; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(4vmax, -3vmax) scale(1.06); }
  66% { transform: translate(-3vmax, 4vmax) scale(0.96); }
}

/* -------------------------------------------------------------- screens */
.screen { animation: fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
.screen[hidden] { display: none; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------- type bits */
.eyebrow {
  font-size: 0.72rem; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--teal); font-weight: 600;
}
.hint { font-size: 0.85rem; color: var(--muted); text-align: center; }
.consent { font-size: 0.74rem; color: var(--muted); text-align: center; line-height: 1.5; }
.error { font-size: 0.85rem; color: #b3402f; text-align: center; }

/* face-detection status line */
.face-status {
  font-size: 0.85rem; text-align: center; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 0.45rem; justify-content: center;
  width: 100%;
}
.face-status[data-state="detecting"] { color: var(--muted); }
.face-status[data-state="ok"] { color: var(--teal); font-weight: 500; }
.face-status[data-state="warn"] { color: #a9762a; }
.face-status[data-state="error"] { color: #b3402f; }
.face-status .spinner { width: 14px; height: 14px; border-width: 2px; }
.stats { font-size: 0.9rem; color: var(--muted); min-height: 1.2em; }
.quote {
  font-family: 'Fraunces', Georgia, serif; font-style: italic; font-weight: 300;
  font-size: 1.05rem; color: var(--muted); line-height: 1.5; min-height: 3em;
  transition: opacity 0.8s ease; max-width: 30rem; margin: 0 auto;
}

.link-quiet {
  background: none; border: none; cursor: pointer;
  color: var(--teal); font-size: 0.9rem; font-weight: 500;
  transition: opacity 0.2s ease;
}
.link-quiet:hover { opacity: 0.7; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.85rem 1.6rem; border-radius: 999px; font-weight: 500; font-size: 0.95rem;
  border: 1px solid transparent; cursor: pointer; transition: all 0.25s ease;
  line-height: 1; text-decoration: none; white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.btn-primary {
  background: var(--teal); color: #fbf6ef;
  box-shadow: 0 10px 26px -12px rgba(13, 92, 99, 0.7);
}
.btn-primary:hover:not(:disabled) { background: var(--tealdeep); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.5); color: var(--ink);
  border-color: rgba(43, 37, 32, 0.14);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.85); border-color: rgba(43, 37, 32, 0.24); }
.btn-block { width: 100%; padding-top: 1.05rem; padding-bottom: 1.05rem; font-size: 1.02rem; }

/* -------------------------------------------------------------- fields */
.field {
  width: 100%; padding: 0.85rem 1.1rem; border-radius: 16px; resize: none;
  background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(43, 37, 32, 0.14);
  color: var(--ink); font-family: inherit; font-size: 0.95rem; line-height: 1.5;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.field::placeholder { color: rgba(107, 93, 82, 0.6); }
.field:focus { outline: none; border-color: var(--teal); background: rgba(255, 255, 255, 0.9); }

/* -------------------------------------------------------------- segmented */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: rgba(255, 255, 255, 0.5); border: 1px solid rgba(43, 37, 32, 0.1);
  border-radius: 999px; max-width: 24rem; margin: 0 auto;
}
.seg {
  border: none; background: transparent; cursor: pointer; padding: 0.6rem 0.5rem;
  border-radius: 999px; font-size: 0.85rem; font-weight: 500; color: var(--muted);
  transition: all 0.25s ease;
}
.seg--active { background: var(--cream); color: var(--ink); box-shadow: var(--shadow-soft); }

/* -------------------------------------------------------------- capture */
.capture-frame {
  position: relative; aspect-ratio: 3 / 4; max-width: 22rem; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden; background: #ded0c2;
  box-shadow: var(--shadow-soft); border: 1px solid rgba(255, 255, 255, 0.5);
}
.capture-frame video,
.capture-frame img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.capture-frame video { transform: scaleX(-1); } /* natural selfie mirror */

.guides { position: absolute; inset: 0; pointer-events: none; color: #fff; }
.guide-line {
  position: absolute; left: 50%; top: 8%; bottom: 8%; width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.85), transparent);
}
.guide-label {
  position: absolute; top: 14px; font-size: 0.66rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255,255,255,0.85);
  background: rgba(13, 92, 99, 0.35); padding: 3px 8px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.guide-label--l { left: 12px; }
.guide-label--r { right: 12px; }
.face-guide {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 58%; height: auto; color: rgba(255, 255, 255, 0.85);
}
.camera-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 1.5rem;
  background: #ded0c2; color: var(--ink);
}

/* -------------------------------------------------------------- waiting */
.pulse-rings { position: relative; width: 150px; height: 150px; }
.pulse-rings span {
  position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(13, 92, 99, 0.4);
  animation: ripple 3.2s ease-out infinite;
}
.pulse-rings span:nth-child(2) { animation-delay: 1.06s; }
.pulse-rings span:nth-child(3) { animation-delay: 2.13s; }
.pulse-core {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--gold), var(--rose));
  box-shadow: 0 0 40px 6px rgba(233, 184, 114, 0.6); animation: breathe 3.2s ease-in-out infinite;
}
@keyframes ripple {
  0% { transform: scale(0.35); opacity: 0.9; }
  100% { transform: scale(1.25); opacity: 0; }
}
@keyframes breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.12); }
}

/* -------------------------------------------------------------- reveal */
.kiss-frame {
  position: relative; max-width: 36rem; margin: 0 auto; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-soft); background: var(--cream);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
#kiss-canvas { display: block; width: 100%; height: auto; }
.kiss-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: 0.6rem; color: var(--muted); font-size: 0.9rem; background: var(--cream);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(13, 92, 99, 0.25); border-top-color: var(--teal);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* text-only attribution under the composite (we never show the raw halves) */
.reveal-attrib {
  font-size: 0.92rem; color: var(--muted); letter-spacing: 0.02em;
}

.msg-card {
  background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(43, 37, 32, 0.1);
  border-radius: 16px; padding: 1rem 1.2rem; text-align: left;
}
.msg-card .msg-from { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal); }
.msg-card .msg-body { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.05rem; margin-top: 0.25rem; }

/* -------------------------------------------------------------- modal / gallery */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(43, 37, 32, 0.45); backdrop-filter: blur(6px);
  animation: fade 0.3s ease both;
}
.modal-panel {
  position: relative; width: 100%; max-width: 56rem; max-height: 88vh; overflow-y: auto;
  background: var(--cream); border-radius: 26px 26px 0 0; padding: 1.8rem 1.5rem 2.5rem;
  box-shadow: 0 -20px 60px -20px rgba(43, 37, 32, 0.5);
  animation: sheet-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-panel { border-radius: 26px; max-height: 84vh; padding: 2.2rem; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-close {
  background: none; border: none; font-size: 1.8rem; line-height: 1; color: var(--muted);
  cursor: pointer; width: 40px; height: 40px; border-radius: 50%; transition: background 0.2s ease;
}
.modal-close:hover { background: rgba(43, 37, 32, 0.08); }

.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
@media (min-width: 560px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }
.gallery-item {
  display: block; border-radius: 16px; overflow: hidden; aspect-ratio: 1 / 1;
  position: relative; box-shadow: var(--shadow-soft); cursor: pointer;
  transition: transform 0.3s ease; background: var(--sand);
}
.gallery-item:hover { transform: translateY(-3px); }
/* gallery shows the COMPOSITE (final image), rendered to a canvas — never raw halves */
.gallery-item .gi-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.5s ease;
}
.gallery-item .gi-canvas.is-ready { opacity: 1; }

/* -------------------------------------------------------------- footer */
.site-footer {
  position: relative; z-index: 10;
  text-align: center; padding: 1.6rem 1rem 2rem;
  font-size: 0.78rem; letter-spacing: 0.04em; color: var(--muted);
}
.site-footer a {
  color: var(--teal); text-decoration: none; font-weight: 500;
  border-bottom: 1px solid transparent; transition: border-color 0.2s ease;
}
.site-footer a:hover { border-color: var(--teal); }

/* -------------------------------------------------------------- a11y + motion */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}
