/* =============================================
   CSS Variables & Reset
   ============================================= */
:root {
  --cream: #faf8f5;
  --white: #ffffff;
  --clay: #b07d62;
  --clay-dark: #8f6249;
  --clay-light: #e8d3c5;
  --sage: #8fb0a0;
  --sage-light: #d4e6df;
  --text-dark: #2d2d2d;
  --text-mid: #5a5a5a;
  --text-light: #9a9a9a;
  --border: #e8e2da;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.16);
  --radius: 12px;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--cream);
  color: var(--text-dark);
  min-height: 100vh;
}

/* =============================================
   Hero
   ============================================= */
.hero {
  background: linear-gradient(135deg, #2d2520 0%, #4a3728 50%, #3a2e26 100%);
  color: var(--white);
  text-align: center;
  padding: 80px 24px 72px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(176,125,98,0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(143,176,160,0.15) 0%, transparent 60%);
  pointer-events: none;
}

.hero-inner { position: relative; z-index: 1; }

.hero-eyebrow {
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--clay-light);
  margin-bottom: 16px;
}

.hero-names {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero-date {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.65);
}

/* =============================================
   Filter Bar
   ============================================= */
.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.filter-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.filter-group select {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text-dark);
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 32px 7px 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239a9a9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color var(--transition);
}

.filter-group select:focus {
  outline: none;
  border-color: var(--clay);
}

.item-count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-light);
}

/* =============================================
   Registry Grid
   ============================================= */
.registry-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.registry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

/* Loading state */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 0;
  color: var(--text-light);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--clay);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { font-family: 'Playfair Display', serif; font-weight: 400; margin-bottom: 8px; color: var(--text-mid); }

/* =============================================
   Item Card
   ============================================= */
.item-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.item-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.item-card:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 2px;
}

.card-image-wrap {
  position: relative;
  width: 100%;
  padding-top: 70%;
  overflow: hidden;
  background: var(--border);
  flex-shrink: 0;
}

.card-image-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.item-card:hover .card-image-wrap img {
  transform: scale(1.04);
}

.card-image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--clay-light), var(--sage-light));
}

.card-image-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

/* Cash fund card special styling */
.item-card.cash-card .card-image-wrap {
  background: linear-gradient(135deg, var(--clay-light) 0%, var(--sage-light) 100%);
}

.cash-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.card-body {
  padding: 16px 18px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-category {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clay);
  margin-bottom: 6px;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dark);
  margin-bottom: 8px;
  flex: 1;
}

.card-price {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-top: 4px;
}

.card-price.cash-price {
  color: var(--clay);
  font-style: italic;
  font-size: 0.95rem;
}

.card-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =============================================
   Lightbox
   ============================================= */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 12, 0.72);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.lightbox-overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.25s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0,0,0,0.08);
  color: var(--text-mid);
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.lightbox-close:hover { background: rgba(0,0,0,0.16); }

/* Lightbox content layout */
.lb-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 360px;
}

.lb-image-side {
  background: var(--border);
  border-radius: 16px 0 0 16px;
  overflow: hidden;
  min-height: 300px;
  position: relative;
}

.lb-image-side img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lb-image-placeholder {
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--clay-light), var(--sage-light));
  font-size: 4rem;
}

.lb-details-side {
  padding: 40px 32px 32px;
  display: flex;
  flex-direction: column;
}

.lb-category {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clay);
  margin-bottom: 10px;
}

.lb-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 12px;
}

.lb-price {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.lb-price.cash-price {
  color: var(--clay);
  font-style: italic;
  font-size: 1.1rem;
}

.lb-description {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-mid);
  flex: 1;
  margin-bottom: 24px;
}

/* Lightbox action buttons */
.lb-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition);
  text-align: center;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--clay);
  color: var(--white);
}

.btn-primary:hover { background: var(--clay-dark); }

.btn-outline {
  background: transparent;
  color: var(--clay);
  border: 2px solid var(--clay);
}

.btn-outline:hover { background: var(--clay-light); }

.btn-sage {
  background: var(--sage);
  color: var(--white);
}

.btn-sage:hover { background: #7a9d8e; }

/* Purchase form inside lightbox */
.purchase-form { display: flex; flex-direction: column; gap: 12px; }

.purchase-form h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 400;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-field input {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  color: var(--text-dark);
  transition: border-color var(--transition);
}

.form-field input:focus {
  outline: none;
  border-color: var(--clay);
}

.form-error {
  font-size: 0.82rem;
  color: #c0392b;
  padding: 8px 12px;
  background: #fdf0ee;
  border-radius: 6px;
  display: none;
}

.form-error.visible { display: block; }

.lb-purchase-note {
  font-size: 0.82rem;
  color: var(--text-mid);
  line-height: 1.5;
  margin-bottom: 12px;
}

.lb-purchase-note strong {
  color: var(--text-dark);
  font-weight: 600;
}

.thank-you {
  text-align: center;
  padding: 24px 16px;
}

.thank-you .ty-icon { font-size: 2.5rem; margin-bottom: 12px; }

.thank-you h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.thank-you p { font-size: 0.9rem; color: var(--text-mid); }

/* =============================================
   Footer
   ============================================= */
.site-footer {
  text-align: center;
  padding: 32px 24px;
  font-size: 0.85rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

.admin-login-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-light);
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.admin-login-link:hover { opacity: 1; }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
  .filter-inner { gap: 12px; }
  .item-count { width: 100%; margin-left: 0; }

  /* ---- Mobile bottom sheet lightbox ---- */
  .lightbox-overlay {
    padding: 0;
    align-items: stretch;
  }

  .lightbox {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* CRITICAL: lightbox-inner must be in the flex chain */
  .lightbox-inner {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .lb-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .lb-image-side {
    flex-shrink: 0;
    height: 180px;
    min-height: 0 !important;
    border-radius: 0;
  }

  .lb-image-placeholder {
    height: 180px;
    min-height: 0 !important;
  }

  .lb-image-side img {
    height: 180px;
    object-fit: cover;
  }

  .lb-details-side {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px 20px 0;
  }

  .lb-description {
    flex: 1;
    min-height: 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
  }

  .lb-actions {
    flex-shrink: 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .registry-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }
}
