@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ── Variables ── */
:root {
  --bg:       #f5f0e8;
  --hdr-from: #2c1a0e;
  --hdr-to:   #5c3320;
  --accent:   #b8760a;
  --accent-lt:#d4952a;
  --text:     #1e130a;
  --muted:    #7a5c40;
  --card-bg:  #fdf8f0;
  --border:   #d4c4a8;
  --radius:   10px;
  --shadow:   0 3px 16px rgba(30,10,0,0.13);
}

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

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--hdr-from), var(--hdr-to));
  color: #f5ead8;
  padding: 1.1rem 1.5rem 0.8rem;
}

.header-inner { max-width: 1100px; margin: 0 auto; }

.logo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.logo-icon { font-size: 2rem; line-height: 1; }

.logo-text h1 {
  font-family: 'Caveat', cursive;
  font-size: 2rem;
  font-weight: 700;
  color: #f0d090;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.logo-text h1 .dl {
  color: #ffc84a;
  text-shadow: 0 1px 8px rgba(255,180,30,0.55);
}

.visitor-counter {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(240,210,130,0.25);
  border-radius: 8px;
  padding: 0.35rem 0.8rem;
  min-width: 64px;
  text-align: center;
}

.visitor-counter-num {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffc84a;
  line-height: 1;
}

.visitor-counter-lbl {
  font-size: 0.62rem;
  color: rgba(240,220,170,0.6);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.1rem;
}

.logo-text .tagline {
  font-size: 0.78rem;
  color: rgba(240,220,170,0.7);
  font-style: italic;
}

/* ── Filter + Sort nav ── */
.filter-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.3rem;
}

.pill {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  border: 1.5px solid rgba(240,210,130,0.4);
  background: rgba(255,255,255,0.07);
  color: rgba(240,220,170,0.9);
  font-family: 'Lora', serif;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.pill:hover { background: rgba(184,118,10,0.35); border-color: rgba(240,210,130,0.8); }

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Sort select — gold pill with custom arrow */
.sort-sel {
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--accent);
  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='%23fff' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 11px;
  color: #fff;
  border: 1.5px solid rgba(240,210,130,0.5);
  border-radius: 20px;
  padding: 0.3rem 2.2rem 0.3rem 0.85rem;
  font-family: 'Lora', serif;
  font-size: 0.78rem;
  cursor: pointer;
  margin-left: auto;
}

.sort-sel:focus { outline: none; box-shadow: 0 0 0 2px rgba(184,118,10,0.5); }

/* ── Main grid ── */
main {
  max-width: 1100px;
  margin: 1.8rem auto;
  padding: 0 1.2rem;
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
  justify-content: center;
  gap: 1.4rem;
}

/* ── Puzzle card ── */
.puzzle-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s, box-shadow 0.18s;
}

.puzzle-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(30,10,0,0.18);
}

/* Image area — blurred bg + contained image */
.card-thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #e8dfc8;
}

.card-thumb-bg {
  position: absolute;
  inset: -15px;
  background-size: cover;
  background-position: center;
  filter: blur(14px);
  transform: scale(1.08);
  opacity: 0.75;
}

.card-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card-thumb-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(122,92,64,0.35);
}

/* Card body */
.card-body {
  padding: 0.8rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--hdr-from);
  margin-bottom: 0.15rem;
  line-height: 1.2;
}

.card-scripture {
  font-size: 0.75rem;
  color: var(--accent);
  font-style: italic;
  margin-bottom: 0.7rem;
}

.card-verse {
  font-size: 0.76rem;
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.7rem;
  line-height: 1.5;
  background: #faf5ea;
  border-radius: 0 4px 4px 0;
}

.card-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.pieces-sel {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background-color: #f0e8d8;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237a5c40' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 1.8rem 0.35rem 0.6rem;
  font-family: 'Lora', serif;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
}

.pieces-sel:focus { outline: none; border-color: var(--accent); }

.play-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.9rem;
  font-family: 'Caveat', cursive;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.play-btn:hover { background: var(--accent-lt); }

/* Extra buttons (Download / Colour) */
.extra-btns {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

.extra-btn {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 0.28rem 0.6rem;
  font-family: 'Lora', serif;
  font-size: 0.72rem;
  cursor: pointer;
  transition: filter 0.15s;
  white-space: nowrap;
}

.extra-btn:hover { filter: brightness(0.9); }

.download-btn {
  background: #d0e8f5;
  color: #1a4a6a;
}

.coloring-btn {
  background: #f5e8c8;
  color: #5c3a08;
}

/* ── Card stat badges ── */
.card-stats {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.stat-item {
  font-size: 0.68rem;
  color: var(--muted);
  background: #ede5d5;
  border-radius: 10px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

/* ── No results ── */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.2rem;
  background: var(--hdr-from);
  color: rgba(240,210,150,0.5);
  font-size: 0.78rem;
  margin-top: 2rem;
}

/* ── Footer link ── */
.footer-link {
  color: rgba(240,210,150,0.6);
  text-decoration: none;
  border-bottom: 1px dotted rgba(240,210,150,0.35);
  transition: color 0.15s;
}

.footer-link:hover { color: var(--gold, #f0d090); }

/* ── Disclaimer modal ── */
.disc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.disc-overlay.disc-open {
  display: flex;
}

.disc-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1.8rem 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(30,10,0,0.25);
}

.disc-title {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  color: var(--hdr-from);
  margin-bottom: 0.9rem;
}

.disc-box p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
  font-style: italic;
  margin-bottom: 1.2rem;
}

.disc-close {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 1.2rem;
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  cursor: pointer;
}

.disc-close:hover { background: #d4952a; }

/* ── Responsive ── */
@media (max-width: 540px) {
  .logo-text h1 { font-size: 1.5rem; }
  .puzzle-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.9rem; }
  main { padding: 0 0.7rem; margin-top: 1.2rem; }
}
