/* ============================================
   BookGifter — Warm, loving design system
   ============================================ */

:root {
  --cream: #FDF8F3;
  --cream-2: #F8EFE6;
  --paper: #FFFFFF;
  --rose: #C9656B;
  --rose-deep: #A94851;
  --rose-soft: #F4D5D0;
  --terracotta: #E07856;
  --gold: #D4A574;
  --gold-soft: #F0DDC2;
  --cocoa: #3E2723;
  --cocoa-2: #5D4037;
  --ink: #2C1810;
  --ink-soft: #6B5A52;
  --line: rgba(62, 39, 35, 0.12);
  --line-soft: rgba(62, 39, 35, 0.06);
  --shadow-sm: 0 2px 8px rgba(62, 39, 35, 0.08);
  --shadow: 0 8px 30px rgba(62, 39, 35, 0.10);
  --shadow-lg: 0 20px 60px rgba(62, 39, 35, 0.15);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;

  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --script: 'Caveat', cursive;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 20% 10%, var(--rose-soft) 0%, transparent 35%),
    radial-gradient(circle at 80% 70%, var(--gold-soft) 0%, transparent 40%);
  background-attachment: fixed;
}

/* ============ FLOATING DECO ============ */
.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.floating-heart {
  position: absolute;
  bottom: -40px;
  left: var(--x);
  font-size: var(--s);
  color: var(--rose);
  opacity: 0;
  animation: floatUp 18s linear infinite;
  animation-delay: var(--d);
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  10% { opacity: 0.55; }
  90% { opacity: 0.55; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* ============ TOPBAR ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  background: rgba(253, 248, 243, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 20px;
}
.brand-mark { font-size: 28px; }
.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.ghost-btn {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ghost-btn:hover {
  background: var(--rose-soft);
  border-color: var(--rose);
  color: var(--rose-deep);
}

/* ============ PAGES ============ */
main { position: relative; z-index: 1; }
.page { display: none; padding: 40px 24px 80px; }
.page.active { display: block; animation: pageFade 0.5s ease both; }
@keyframes pageFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.container { max-width: 1100px; margin: 0 auto; }
.container.narrow { max-width: 720px; }

/* ============ TYPE ============ */
.kicker {
  font-family: var(--script);
  font-size: 28px;
  color: var(--rose);
  margin-bottom: 8px;
}
.script-accent {
  font-family: var(--script);
  color: var(--rose);
  font-weight: 600;
  font-size: 1.15em;
}

.section-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.15;
  text-align: center;
  margin-bottom: 12px;
  color: var(--ink);
}
.section-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 17px;
  max-width: 600px;
  margin: 0 auto 36px;
}

.step-badge {
  display: block;
  width: fit-content;
  background: var(--gold-soft);
  color: var(--cocoa-2);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin: 0 auto 20px;
}

/* ============ HERO ============ */
.page-hero {
  min-height: calc(100vh - 80px);
  display: none;
  padding: 60px 24px 80px;
}
.page-hero.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-inner { max-width: 760px; text-align: center; }
.hero-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.5px;
  margin-bottom: 24px;
  color: var(--ink);
}
.hero-title .script-accent { font-size: 1.1em; display: inline-block; }
.hero-sub {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 580px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

.hero-form {
  background: var(--paper);
  padding: 14px;
  border-radius: var(--radius-lg);
  display: flex;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}
.hero-input-wrap { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.hero-input-icon { font-size: 22px; flex-shrink: 0; }
#hero-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 16px;
  padding: 16px 0;
  color: var(--ink);
  outline: none;
  width: 100%;
  min-width: 0;
}
#hero-input::placeholder { color: var(--ink-soft); opacity: 0.7; }

.hero-features {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 40px;
}
.feature { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 14px; }
.feature-icon { font-size: 20px; }

/* ============ BUTTONS ============ */
.cta-btn {
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: white;
  border: none;
  padding: 16px 28px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(201, 101, 107, 0.35);
  transition: all 0.25s ease;
  white-space: nowrap;
}
.cta-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(201, 101, 107, 0.45); }
.cta-btn:active { transform: translateY(0); }
.cta-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.cta-btn.full { width: 100%; }
.cta-arrow { transition: transform 0.25s ease; }
.cta-btn:hover .cta-arrow { transform: translateX(4px); }

.payment-btn {
  background: linear-gradient(135deg, #ffc439, #ffb300);
  color: #2C1810;
  box-shadow: 0 6px 20px rgba(255, 196, 57, 0.4);
}
.payment-btn:hover { box-shadow: 0 10px 28px rgba(255, 196, 57, 0.55); }
.paypal-mark {
  background: white;
  color: #003087;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  font-style: italic;
}

.text-btn {
  background: none;
  border: none;
  color: var(--rose);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.text-btn:hover { color: var(--rose-deep); }

.back-link { text-align: center; margin-top: 32px; }

/* ============ DESCRIBE ============ */
.describe-card {
  background: var(--paper);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}
#describe-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  resize: vertical;
  min-height: 140px;
  background: var(--cream-2);
  outline: none;
  transition: border-color 0.2s;
}
#describe-input:focus { border-color: var(--rose); }
.char-count { text-align: right; font-size: 13px; color: var(--ink-soft); margin-top: 6px; margin-bottom: 24px; }

.lang-selector { margin-bottom: 28px; }
.lang-label { display: block; font-size: 14px; font-weight: 500; color: var(--ink-soft); margin-bottom: 12px; }
.lang-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-pill {
  background: var(--cream-2);
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}
.lang-pill:hover { border-color: var(--rose); }
.lang-pill.active { background: var(--rose); color: white; border-color: var(--rose); }

/* ============ BOOK CARDS ============ */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 8px;
}
.book-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}
.book-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--rose-soft); }
.book-card.selected { border-color: var(--rose); box-shadow: 0 12px 40px rgba(201, 101, 107, 0.25); }

.book-cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--gold-soft), var(--rose-soft));
  overflow: hidden;
}
.book-cover { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.book-card:hover .book-cover { transform: scale(1.04); }
.book-no-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 64px;
  color: var(--cocoa);
  opacity: 0.5;
}

.book-rank {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--rose);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  font-family: var(--serif);
}

.book-info { padding: 20px 22px 24px; flex: 1; display: flex; flex-direction: column; }
.book-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author { color: var(--ink-soft); font-size: 14px; font-style: italic; margin-bottom: 12px; }
.book-reason {
  font-size: 14px;
  color: var(--cocoa-2);
  line-height: 1.55;
  flex: 1;
  padding-left: 16px;
  border-left: 3px solid var(--gold-soft);
}
.book-source {
  display: inline-block;
  margin-top: 14px;
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.book-pick {
  margin-top: 16px;
  background: var(--cream-2);
  color: var(--rose-deep);
  border: 1.5px solid transparent;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.book-card:hover .book-pick { background: var(--rose); color: white; }

/* ============ GIFT FORM ============ */
.gift-layout { display: grid; grid-template-columns: 320px 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .gift-layout { grid-template-columns: 1fr; } }

.gift-book-card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
  text-align: center;
  position: sticky;
  top: 100px;
}
.gift-book-card .book-cover-wrap {
  border-radius: var(--radius);
  margin-bottom: 16px;
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}
.gift-book-card .gift-book-title { font-family: var(--serif); font-size: 20px; font-weight: 600; margin-bottom: 4px; color: var(--ink); }
.gift-book-card .gift-book-author { color: var(--ink-soft); font-style: italic; font-size: 14px; }
.gift-book-card .change-link { display: inline-block; margin-top: 12px; }

.gift-form {
  background: var(--paper);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.field .req { color: var(--rose); }
.field .opt { color: var(--ink-soft); font-weight: 400; font-size: 13px; }
.field input, .field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--cream-2);
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus, .field textarea:focus { border-color: var(--rose); background: var(--paper); }
.field textarea { resize: vertical; min-height: 100px; }
.field small { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-soft); }

.theme-picker { margin: 24px 0; }
.theme-picker > label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.theme-chip {
  background: var(--cream-2);
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-chip:hover { border-color: var(--rose); }
.theme-chip.active { background: var(--rose); color: white; border-color: var(--rose); }

.price-box {
  background: linear-gradient(135deg, var(--cream-2), var(--gold-soft));
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 24px 0;
  border: 1px solid var(--line-soft);
}
.price-line { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.price-line strong { font-family: var(--serif); font-size: 24px; color: var(--rose-deep); }
.price-box small { font-size: 12px; color: var(--ink-soft); }

.trust-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ============ CONFIRMATION ============ */
.page-confirm.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
}
.confirm-card {
  background: var(--paper);
  padding: 56px 48px;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line-soft);
}
.confirm-icon { font-size: 80px; margin-bottom: 20px; animation: bounce 1.2s ease infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.confirm-title { font-family: var(--serif); font-size: 36px; font-weight: 600; margin-bottom: 12px; color: var(--ink); }
.confirm-sub { font-size: 18px; color: var(--ink-soft); margin-bottom: 24px; }
.confirm-sub em { color: var(--rose); font-style: italic; font-family: var(--serif); }
.confirm-divider { width: 80px; height: 2px; background: var(--gold-soft); margin: 24px auto; border-radius: 2px; }
.confirm-detail { font-size: 15px; color: var(--ink-soft); margin-bottom: 32px; line-height: 1.7; }

/* ============ MODAL ============ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(62, 39, 35, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.open { display: flex; animation: modalFade 0.25s ease; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--paper);
  padding: 36px;
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalSlide 0.3s ease;
}
@keyframes modalSlide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-box h3 { font-family: var(--serif); font-size: 28px; font-weight: 600; margin-bottom: 8px; }
.modal-sub { color: var(--ink-soft); margin-bottom: 24px; font-size: 15px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--cream-2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--rose-soft); }

.auth-error {
  margin-top: 16px;
  padding: 12px 14px;
  background: #FFEBEE;
  border: 1px solid #FFCDD2;
  border-radius: var(--radius-sm);
  color: #C62828;
  font-size: 14px;
}

/* ============ LOADING ============ */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(253, 248, 243, 0.94);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.loading[hidden] { display: none; }
.loading-card {
  background: var(--paper);
  padding: 36px 48px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--line-soft);
}
.loading-anim { position: relative; width: 80px; height: 80px; margin: 0 auto 16px; }
.loading-book { font-size: 56px; animation: bookFloat 2s ease infinite; display: inline-block; }
@keyframes bookFloat {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}
.loading-sparks { position: absolute; inset: 0; pointer-events: none; }
.loading-sparks span { position: absolute; font-size: 18px; animation: sparkle 1.5s ease infinite; }
.loading-sparks span:nth-child(1) { top: 0; right: 0; animation-delay: 0s; }
.loading-sparks span:nth-child(2) { bottom: 10px; left: 0; animation-delay: 0.4s; }
.loading-sparks span:nth-child(3) { top: 20px; left: 10px; animation-delay: 0.8s; }
@keyframes sparkle { 0%, 100% { opacity: 0; transform: scale(0.5); } 50% { opacity: 1; transform: scale(1.2); } }
.loading p { font-family: var(--serif); font-size: 18px; color: var(--ink); font-style: italic; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 14px 22px;
  border-radius: 999px;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toastSlide 0.3s ease;
}
.toast[hidden] { display: none; }
@keyframes toastSlide {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ FOOTER ============ */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--ink-soft);
  font-size: 14px;
  position: relative;
  z-index: 1;
}
.heart-pulse { color: var(--rose); display: inline-block; animation: pulse 1.4s ease infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .topbar { padding: 14px 18px; }
  .brand-name { display: none; }
  .hero-form { flex-direction: column; padding: 16px; }
  .hero-input-wrap { padding: 4px 8px; }
  .cta-btn { padding: 14px 20px; }
  .describe-card, .gift-form { padding: 22px; }
  .confirm-card { padding: 36px 24px; }
  .modal-box { padding: 26px; }
  .gift-book-card { position: static; }
}
