@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Inter:wght@400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --bg:     #0f0a1f;
  --panel:  rgba(255, 255, 255, 0.1);
  --card:   #1a1433;
  --green:  #00ff88;
  --pink:   #c71585;
  --purple: #6b4e9e;
  --text:   #ffffff;
  --muted:  rgba(255, 255, 255, 0.75);
  --radius: 10px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  padding: 2rem 1rem;
  text-align: center;
}

h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.8rem;
  margin: 0;
}

.subtitle {
  font-size: 1.3rem;
  opacity: 0.95;
  margin-top: 0.5rem;
}

/* ── Layout ────────────────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ── Info Bars ─────────────────────────────────────────────────── */
.instructions,
.status-bar {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.instructions p,
.status-bar p {
  margin: 0;
  line-height: 1.5;
}

/* ── Counter ───────────────────────────────────────────────────── */
.counter {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin: 1rem 0 1.25rem;
}

.counter.locked {
  color: var(--green);
}

/* ── Gallery Grid ──────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

/* ── Gallery Card ──────────────────────────────────────────────── */
.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  aspect-ratio: 1 / 1;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 4px solid transparent;
  border-radius: var(--radius);
  transition: all 0.25s ease;
  pointer-events: none;
}

.card.selected::after {
  border-color: var(--green);
  box-shadow: 0 0 0 6px rgba(0, 255, 136, 0.28);
}

.card.dimmed:not(.selected) {
  opacity: 0.45;
  filter: grayscale(0.15);
}

/* ── Select Button (on card) ───────────────────────────────────── */
.select-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  border: none;
  background: rgba(0, 0, 0, 0.68);
  color: white;
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  z-index: 4;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.select-btn:hover {
  transform: scale(1.06);
}

.card.selected .select-btn {
  background: var(--green);
  color: #000;
}

/* ── Pulse Animation ───────────────────────────────────────────── */
.pulse {
  animation: pulseGlow 0.45s ease;
}

@keyframes pulseGlow {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.025); }
  100% { transform: scale(1); }
}

/* ── Action Buttons Row ────────────────────────────────────────── */
.actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* ── Button Styles ─────────────────────────────────────────────── */
.submit-btn,
.secondary-btn,
.preview-btn,
.comment-btn,
.landing-btn {
  border: none;
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.submit-btn,
.comment-btn,
.landing-btn {
  background: var(--green);
  color: #000;
  /* box-shadow: 0 8px 20px rgba(0, 255, 136, 0.35); */
}

.submit-btn:disabled,
.comment-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ── Error Message ─────────────────────────────────────────────── */
.error-msg {
  color: #ff8d8d;
  text-align: center;
  margin: 1rem 0 0;
}

.modal-form-error {
  color: #ff8d8d;
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: center;
  margin: 0.5rem 0 0;
}

.modal-form-error[hidden] {
  display: none;
}

#reviewModal .modal-form-error {
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
}

/* ── Modals ────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

/* ── Landing vs gallery: toggled via body.app--landing / body.app--gallery */
#landingScreen {
  position: fixed;
  inset: 0;
  align-items: flex-start;
  justify-content: center;
  background: #f4f4f4;
  z-index: 2000;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

body.app--landing #landingScreen {
  display: flex;
}

body.app--gallery #landingScreen {
  display: none !important;
}

body.app--landing #galleryPage {
  display: none !important;
}

body.app--gallery #galleryPage {
  display: block;
}

/* ── Landing Page ──────────────────────────────────────────────── */
.landing-inner {
  width: 100%;
  max-width: 760px;
  text-align: center;
  color: #222;
}

.landing-thumbs {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 0 0 1.25rem;
}

.landing-thumbs img {
  width: min(160px, 28vw);
  aspect-ratio: 1;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  background: white;
}

.landing-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.1rem;
  margin: 0 0 24px;
  color: #222;
}

.landing-card {
  max-width: 760px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 28px 30px;
  text-align: left;
  line-height: 1.65;
  font-size: 1rem;
}

.landing-card p {
  margin: 0 0 16px;
  color: #333;
}

.landing-card a {
  color: #6b4e9e;
}

.landing-actions {
  text-align: center;
  margin-top: 28px;
}

.landing-btn {
  background: linear-gradient(135deg, #6b4e9e, #c71585);
  color: white;
  min-width: 210px;
}

/* ── Modal Content ─────────────────────────────────────────────── */
.modal-content {
  background: #1a1433;
  padding: 1rem;
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  text-align: center;
}

.modal-content h2 {
  margin-top: 0;
}

/* ── Preview (Lightbox) Modal ──────────────────────────────────── */
.preview-inner {
  max-width: 94vw;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.preview-inner img {
  max-width: 92vw;
  max-height: 72vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  background: white;
}

.preview-caption {
  font-size: 1rem;
  opacity: 0.95;
  text-align: center;
}

.preview-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

.preview-select {
  background: var(--green);
  color: #000;
}

.preview-close,
.preview-nav {
  background: #ffffff;
  color: #000;
}

/* ── Review Modal ──────────────────────────────────────────────── */
#reviewModal .modal-content {
  max-width: min(600px, 94vw);
}

.selection-list {
  margin: 1rem 0 1.25rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  text-align: left;
  line-height: 1.5;
}

.review-thumbs-intro {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.selection-list .review-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}

.review-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.review-thumb img {
  width: 100%;
  height: 100px;
  aspect-ratio: 828 / 1225;
  object-fit: cover;
  display: block;
}

.review-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.2rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  color: #fff;
  text-align: center;
}

.tiny {
  font-size: 0.92rem;
  color: var(--muted);
}

.review-form-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.review-form-fields .email-field {
  margin-top: 0;
}

/* ── Form Fields ───────────────────────────────────────────────── */
.comment-box, .email-field {
  width: 100%;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
}

.comment-box {
  min-height: 120px;
  resize: vertical;
}

/* ── Comment / Thank-You Actions ───────────────────────────────── */
.comment-actions {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1rem;
  align-items: center;
}

.comment-secondary {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: none;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: underline;
}

.final-message {
  line-height: 1.6;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 700px) {
  h1              { font-size: 2.2rem; }
  .subtitle       { font-size: 1.05rem; }
  .counter        { font-size: 1.25rem; }
  .preview-inner img { max-height: 62vh; }
  .landing-title  { font-size: 1.8rem; }
  .landing-thumbs img { width: min(80px, 30vw); }
  .landing-card   { padding: 22px 18px; }
}

@media (max-width: 767.98px) {
  body {
    font-size: 14px;
    line-height: 18px;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(113px, 1fr));
  }

  .selection-list .review-thumbs {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }

  .review-thumb img {
    height: 48px;
  }
}
