/* ============================================
   Mother's Day Gift Site - Mobile-first styles
   ============================================ */
:root {
  --pink: #ff5d8f;
  --pink-light: #ffd6e3;
  --pink-bg: #fff5f8;
  --plum: #6b2c5d;
  --gold: #d9a441;
  --text: #2b1f2c;
  --muted: #7b6a78;
  --border: #f0d4dd;
  --shadow: 0 8px 24px rgba(255, 93, 143, 0.12);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #fff8fb 0%, #fff5f8 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--pink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar - mobile-first */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  flex-wrap: wrap;
  gap: 8px;
}
.brand { font-size: 18px; font-weight: 700; color: var(--plum); }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar nav a { color: var(--text); font-size: 14px; }
.topbar .hello { color: var(--muted); font-size: 13px; }
@media (min-width: 600px) {
  .topbar { padding: 14px 28px; }
  .brand { font-size: 20px; }
  .topbar nav { gap: 16px; }
  .topbar nav a { font-size: 15px; }
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 14px;
  flex: 1;
  width: 100%;
}
@media (min-width: 600px) {
  .container { padding: 32px 24px; }
}

.footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* Forms & buttons */
.btn, button.btn {
  display: inline-block;
  padding: 12px 22px;
  background: var(--pink);
  color: white;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
  transition: transform .1s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
}
.btn-danger { background: #d64545; }
.btn-secondary { background: white; color: var(--plum); border: 1px solid var(--border); }

input[type=text], input[type=email], input[type=password], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px; /* 16px+ avoids iOS zoom-on-focus */
  font-family: inherit;
  background: white;
}
input:focus, textarea:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-light); }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field { margin-bottom: 16px; }

.card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
@media (min-width: 600px) {
  .card { padding: 28px; margin-bottom: 20px; }
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: #fde8e8; color: #9b1c1c; }
.alert-success { background: #d4f4dd; color: #1f7a3a; }
.alert-info { background: var(--pink-light); color: var(--plum); }

/* Hero / landing */
.hero {
  text-align: center;
  padding: 36px 16px;
}
.hero h1 { font-size: clamp(28px, 7vw, 44px); margin: 0 0 12px; color: var(--plum); }
.hero p { font-size: clamp(15px, 4vw, 18px); color: var(--muted); max-width: 580px; margin: 0 auto 24px; }
.hero .heart { font-size: 56px; }
@media (min-width: 600px) {
  .hero { padding: 60px 20px; }
  .hero .heart { font-size: 64px; }
}

/* Auth forms */
.auth-card { max-width: 420px; margin: 24px auto; }
.auth-card h1 { margin-top: 0; color: var(--plum); font-size: clamp(22px, 6vw, 28px); }

/* Dashboard */
.dashboard-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.dashboard-head h1 { margin: 0; color: var(--plum); font-size: clamp(22px, 6vw, 28px); }

.gift-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 600px) {
  .gift-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
}
.gift-card {
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.gift-card h3 { margin: 0 0 8px; color: var(--plum); }
.gift-card .meta { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.gift-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-published { background: #d4f4dd; color: #1f7a3a; }
.badge-draft     { background: #f0e8d4; color: #7a601f; }

/* Edit gift */
.edit-section { margin-bottom: 24px; }
.edit-section h2 { color: var(--plum); margin: 0 0 4px; font-size: clamp(18px, 5vw, 22px); }
.edit-section .help { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
@media (min-width: 600px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--pink-light);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .remove {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  background: white;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.upload-zone:hover, .upload-zone.drag {
  border-color: var(--pink);
  background: var(--pink-bg);
}
.upload-zone input[type=file] { display: none; }
.upload-zone p { margin: 0; color: var(--muted); }

/* Recorder */
.recorder {
  background: white;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}
.rec-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--pink);
  color: white;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 600px) {
  .rec-btn { width: 80px; height: 80px; font-size: 32px; }
}
.rec-btn.recording {
  background: #d64545;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 12px rgba(214,69,69,0.18); }
}
.timer { font-size: 22px; font-weight: 700; margin: 12px 0 0; color: var(--plum); }
.codec-hint { font-size: 11px; color: var(--muted); margin: 4px 0 8px; font-family: monospace; word-break: break-all; }
audio { width: 100%; margin-top: 12px; }

/* ============================================
   PUBLIC GIFT PAGE - Mobile-first grid layout
   ============================================ */
body.gift-public {
  background: #1a0d1c;
  color: white;
  margin: 0;
  /* Use the dynamic viewport so the iOS Safari URL bar doesn't crop us */
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  display: block;
}
body.gift-public .topbar,
body.gift-public .footer { display: none; }

/* Floating-tiles backdrop */
.collage-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.collage-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center,
      rgba(26,13,28,0.35) 0%,
      rgba(26,13,28,0.85) 65%,
      rgba(26,13,28,0.97) 100%);
  pointer-events: none;
}
.collage-tile {
  position: absolute;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  opacity: 0;
  filter: brightness(0.7) saturate(1.05);
  transition: opacity 1.6s ease, transform 8s ease;
}
.collage-tile.show { opacity: 0.85; }
.collage-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* The 3-row stage. This is the magic that makes mobile sing. */
.gift-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 14px 14px;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.gift-header { text-align: center; }
.gift-title {
  font-size: clamp(22px, 6.5vw, 44px);
  font-weight: 800;
  margin: 0 0 6px;
  color: #ffd6e3;
  text-shadow: 0 4px 18px rgba(0,0,0,0.7);
  line-height: 1.15;
}
.gift-message {
  font-size: clamp(13px, 3.6vw, 17px);
  margin: 0;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  line-height: 1.45;
  max-width: 600px;
  margin: 0 auto;
}

.gift-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0; /* allow shrinking */
}
.collage-center {
  position: relative;
  /* Square, sized by the smaller of: 80% viewport width, available height, max 380px */
  width: min(80vw, 55vh, 380px);
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background: #2a1a2c;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.6),
    0 0 0 4px rgba(255,255,255,0.08),
    0 0 50px rgba(255,93,143,0.22);
}
.center-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.center-img.active { opacity: 1; }

.gift-footer { text-align: center; }
.gift-from {
  font-size: clamp(13px, 3.4vw, 15px);
  font-style: italic;
  color: rgba(255,255,255,0.85);
  margin: 0 0 10px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
}
.player-card {
  background: rgba(255,255,255,0.10);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 10px 12px;
  max-width: 520px;
  margin: 0 auto;
}
.player-card audio { width: 100%; display: block; }
.audio-error {
  color: #ffd6d6;
  font-size: 13px;
  text-align: center;
  padding: 8px 4px 0;
}
.audio-error a { color: var(--pink-light); font-weight: 600; text-decoration: underline; }

/* Tap-to-start overlay */
.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,13,28,0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.start-card {
  text-align: center;
  max-width: 420px;
}
.start-emoji { font-size: 72px; }
.start-overlay h1 {
  font-size: clamp(26px, 7vw, 44px);
  color: #ffd6e3;
  margin: 6px 0 8px;
  line-height: 1.2;
}
.start-overlay p {
  color: rgba(255,255,255,0.85);
  font-size: clamp(14px, 4vw, 17px);
  margin: 0 0 22px;
}
.start-btn {
  background: var(--pink);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255,93,143,0.4);
  -webkit-tap-highlight-color: transparent;
}
.start-btn:active { transform: scale(0.98); }

/* Landscape phones - keep audio reachable, shrink hero photo a bit */
@media (max-height: 500px) and (orientation: landscape) {
  .collage-center { width: min(45vw, 70vh, 280px); }
  .gift-title { font-size: clamp(18px, 4vw, 28px); }
  .gift-message { font-size: 13px; }
}
