/* ── Pet Rescue Story Contest — hand-stitched scrapbook ─────────────
   Oat-linen background with stitched border, sage + terracotta,
   washi-tape photo cards at tilted angles, paw/heart doodles. */

:root {
  --linen: #f6efe3;
  --linen-deep: #ede2cf;
  --sage: #7d9b76;
  --sage-deep: #5d7d56;
  --terracotta: #c96f4a;
  --terracotta-deep: #a85434;
  --cream: #fffdf7;
  --ink: #4a4036;
  --ink-soft: #91836f;
  --line: #e3d7c2;
  --washi-a: rgba(125, 155, 118, 0.55);
  --washi-b: rgba(201, 111, 74, 0.5);
  --err: #c14b4b;
  --font-doodle: 'Gaegu', cursive;
  --font-serif: 'Bitter', serif;
  --font-body: 'Nunito', sans-serif;
}

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

.hidden { display: none !important; }

body {
  font-family: var(--font-body);
  background:
    repeating-linear-gradient(0deg, transparent 0 4px, rgba(74, 64, 54, 0.015) 4px 5px),
    var(--linen);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* stitched page border */
.page::before {
  content: '';
  position: fixed;
  inset: 10px;
  border: 2px dashed rgba(125, 155, 118, 0.5);
  border-radius: 14px;
  pointer-events: none;
  z-index: 0;
}

.wrap { position: relative; width: 100%; max-width: 660px; margin: 0 auto; padding: 0 24px; z-index: 1; }

main { flex: 1 0 auto; padding-bottom: 70px; }

/* ── Hero ─────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 54px 0 14px; }

.hero-inner { position: relative; }

.paw-doodle,
.heart-doodle {
  position: absolute;
  font-size: 1.9rem;
  color: var(--terracotta);
  opacity: 0.85;
}

.paw-doodle { top: -14px; left: 4%; transform: rotate(-18deg); }
.heart-doodle { bottom: -6px; right: 6%; font-size: 2.3rem; color: var(--sage); transform: rotate(12deg); }

.badge {
  display: inline-block;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--sage);
  border-radius: 999px;
  padding: 7px 18px;
  margin-bottom: 16px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1.08;
  color: var(--ink);
}

.hero .sub { margin-top: 14px; color: var(--ink-soft); font-weight: 600; max-width: 460px; margin-left: auto; margin-right: auto; }

.hero-cta { display: flex; justify-content: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ── Tabs ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; margin: 30px 0 20px; }

.tab {
  flex: 1;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 10px;
  background: transparent;
  color: var(--ink-soft);
  border: 2px dashed var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab:hover { color: var(--ink); }

.tab.is-active {
  background: var(--cream);
  color: var(--ink);
  border: 2px solid var(--sage);
  box-shadow: 3px 4px 0 rgba(125, 155, 118, 0.35);
}

/* ── Cards / notes ────────────────────────────────────────────────── */
.card {
  position: relative;
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 30px 26px;
  box-shadow: 4px 6px 0 rgba(74, 64, 54, 0.08);
  margin-bottom: 18px;
}

/* washi tape on the card */
.card::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 110px;
  height: 24px;
  background: var(--washi-a);
  opacity: 0.9;
}

.card h2 { font-family: var(--font-serif); font-weight: 700; font-size: 1.45rem; margin-bottom: 6px; }

.card-sub { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 20px; font-weight: 600; }

.note {
  margin: 18px 0;
  padding: 16px 20px;
  border-radius: 8px;
  background: var(--cream);
  border: 2px dashed var(--sage);
  text-align: center;
  font-weight: 600;
}

/* ── Dropzone ─────────────────────────────────────────────────────── */
.drop {
  position: relative;
  border: 2px dashed var(--sage);
  border-radius: 10px;
  background: rgba(125, 155, 118, 0.07);
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  overflow: hidden;
  transition: background 0.15s ease;
}

.drop:hover { background: rgba(125, 155, 118, 0.14); }

.drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.drop-inner { text-align: center; padding: 22px; }

.drop-icon { font-size: 2.2rem; display: block; margin-bottom: 8px; }

.drop-text { font-weight: 700; }

.drop-hint { color: var(--ink-soft); font-size: 0.85rem; margin-top: 4px; }

.preview { width: 100%; max-height: 300px; object-fit: cover; display: block; }

/* ── Fields ───────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
  display: block;
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--linen);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease;
}

textarea { resize: vertical; line-height: 1.55; }

input:focus, textarea:focus { outline: none; border-color: var(--terracotta); }
input.error, textarea.error { border-color: var(--err); }
input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: 0.7; }

.form-error { color: var(--err); font-weight: 800; text-align: center; margin-top: 12px; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1rem;
  padding: 14px 28px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  line-height: 1.2;
}

.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--sage); outline-offset: 2px; }

.btn-primary {
  background: var(--terracotta);
  color: var(--cream);
  box-shadow: 0 5px 0 var(--terracotta-deep);
}

.btn-primary:hover:not(:disabled) { box-shadow: 0 7px 0 var(--terracotta-deep); }

.btn-ghost {
  background: var(--cream);
  color: var(--ink);
  border: 1.5px solid var(--line);
  font-size: 0.9rem;
  padding: 11px 20px;
}

.btn-ghost:hover:not(:disabled) { border-color: var(--sage); color: var(--sage-deep); }

.btn-block { width: 100%; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 253, 247, 0.4);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── My entry ─────────────────────────────────────────────────────── */
.my-photo-wrap { text-align: center; margin-bottom: 18px; }

.my-photo {
  max-width: 240px;
  width: 100%;
  border: 8px solid #fff;
  box-shadow: 0 8px 22px rgba(74, 64, 54, 0.2);
  transform: rotate(-2deg);
  margin-bottom: 12px;
}

.my-caption { font-family: var(--font-doodle); font-size: 1.25rem; color: var(--ink); }

.share-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ── Gallery ──────────────────────────────────────────────────────── */
.gallery-head { text-align: center; margin-bottom: 22px; }

.gallery-head h2 { font-family: var(--font-serif); font-weight: 700; font-size: 1.6rem; }

.gallery-sub { color: var(--ink-soft); font-weight: 600; margin-top: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}

.pet-card {
  position: relative;
  background: var(--cream);
  border: 1.5px solid var(--line);
  padding: 12px 12px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 3px 5px 0 rgba(74, 64, 54, 0.08);
}

.pet-card:nth-child(odd) { transform: rotate(-1.2deg); }
.pet-card:nth-child(even) { transform: rotate(1deg); }

.pet-card:hover { transform: rotate(0deg) translateY(-4px); box-shadow: 5px 9px 18px rgba(74, 64, 54, 0.18); }

/* washi tape strips */
.pet-card::before,
.pet-card::after {
  content: '';
  position: absolute;
  top: -10px;
  width: 56px;
  height: 18px;
  opacity: 0.9;
}

.pet-card::before { left: 10px; transform: rotate(-8deg); background: var(--washi-a); }
.pet-card::after { right: 10px; transform: rotate(7deg); background: var(--washi-b); }

.pet-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  margin-bottom: 10px;
}

.pet-caption {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pet-author { font-family: var(--font-doodle); color: var(--ink-soft); font-size: 1.05rem; margin-top: 4px; }

.pet-votes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 8px;
}

.vote-count { font-weight: 800; color: var(--sage-deep); font-size: 0.9rem; }

.vote-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 8px 18px;
  background: var(--sage);
  color: var(--cream);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.vote-btn:hover:not(:disabled) { background: var(--sage-deep); }
.vote-btn.is-voted { background: var(--linen-deep); color: var(--ink-soft); cursor: default; }

/* ── Empty / load more ────────────────────────────────────────────── */
.empty { text-align: center; padding: 44px 20px; }

.empty-icon { font-size: 2.4rem; display: block; margin-bottom: 10px; }

.empty-sub { color: var(--ink-soft); margin: 6px 0 18px; }

.load-wrap { text-align: center; margin-top: 26px; }

/* ── Lightbox ─────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(74, 64, 54, 0.9);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lb-content {
  background: var(--cream);
  border-radius: 8px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}

.lb-img { width: 100%; max-height: 55vh; object-fit: contain; display: block; background: var(--linen-deep); }

.lb-meta { padding: 18px 22px 22px; }

.lb-caption { font-weight: 700; line-height: 1.5; }

.lb-author { font-family: var(--font-doodle); color: var(--ink-soft); font-size: 1.1rem; margin-top: 6px; }

.lb-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; }

.lb-votes { font-weight: 800; color: var(--sage-deep); }

.lb-close {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 2rem;
  background: none;
  border: none;
  color: var(--cream);
  cursor: pointer;
  z-index: 2;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.6rem;
  background: rgba(255, 253, 247, 0.14);
  border: none;
  color: var(--cream);
  cursor: pointer;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  line-height: 1;
}

.lb-prev { left: 14px; }
.lb-next { right: 14px; }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  font-weight: 700;
  padding: 13px 24px;
  border-radius: 999px;
  z-index: 200;
  box-shadow: 0 10px 26px rgba(74, 64, 54, 0.4);
}

.toast-ok { background: var(--sage-deep); }

/* ── Footer ───────────────────────────────────────────────────────── */
.footer {
  flex-shrink: 0;
  text-align: center;
  padding: 24px 20px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

#wbx-powered-by-slot { margin-top: 12px; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .lb-nav { display: none; }
}
