:root {
  /* Humane Society of Huron Valley-inspired palette */
  --teal: #3aa8ae;
  --teal-dark: #2e878c;
  --teal-soft: #e3f2f3;
  --orange: #e8742c;
  --coral: #e88a6b;
  --sage: #b4bb7d;
  --sage-soft: #eef0dd;
  --royal: #1e50c8;
  --ink: #2b2f33;
  --muted: #5f6a70;
  --line: #e4e8ea;
  --bg-tint: #f6fbfb;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg-tint);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Inter, sans-serif;
  line-height: 1.5;
  /* room for the fixed bottom ad banner */
  padding-bottom: 124px;
  /* guard: never let an inner element widen the page and shift centering */
  overflow-x: hidden;
}

/* Header */
.site-header {
  background: #fff;
  border-bottom: 4px solid var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.55rem;
}

.brand-name { color: var(--teal-dark); }
.brand-accent { color: var(--orange); }

/* Layout — narrow column so the site edges (and ads) show */
.page {
  width: min(560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 16px;
}

.hero {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  color: var(--royal);
  font-size: clamp(2rem, 6vw, 3.3rem);
  line-height: 1.05;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto;
  font-size: 1.12rem;
  font-weight: 600;
}

/* Rotating real-puppy photos */
.puppy-rotator {
  position: relative;
  width: 100%;
  height: clamp(240px, 42vw, 360px);
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 22px;
  background: linear-gradient(135deg, var(--teal-soft), var(--sage-soft));
  box-shadow: 0 18px 50px rgba(46, 135, 140, 0.18);
}

.puppy-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
}

.puppy-slide.is-active { opacity: 1; }

/* Card + form */
.card,
.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px;
  box-shadow: 0 18px 50px rgba(46, 135, 140, 0.12);
}

.form { display: grid; gap: 20px; text-align: center; }

.field { display: grid; gap: 8px; justify-items: center; }
.field > input,
.field > select,
.field > .pup-carousel,
.field > .pup-dots { justify-self: stretch; }

.field,
.field-label {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.98rem;
}

.field-hint {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  text-align: left; /* keep typed text left-aligned even though labels are centered */
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-soft);
}

button {
  border: none;
  background: var(--orange);
  color: #fff;
  border-radius: 999px;
  padding: 15px 24px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover { background: #cf6320; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.65; cursor: progress; }

.loading {
  color: var(--teal-dark);
  font-weight: 700;
  text-align: center;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* Style picker — one pup shown at a time, centered in the card */
.pup-carousel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.pup-nav {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
}
.pup-nav:hover { background: #d3eaeb; }

/* The stage holds all cards stacked; only the active one is displayed, so it
   is always centered and can never overflow the white card. */
.pup-stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  touch-action: pan-y;
}

.style-card {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  user-select: none;
}
.style-card.is-active { display: flex; animation: pupIn 0.25s ease; }

@keyframes pupIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}

.style-card input { position: absolute; opacity: 0; pointer-events: none; }

.card-media {
  position: relative;
  /* 100% = the stage width (already minus the arrows), so it can never
     overflow the row on narrow screens. */
  width: min(240px, 100%);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 4px solid var(--teal-dark);
  box-shadow: 0 14px 34px rgba(46, 135, 140, 0.3);
}

.card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Emoji only shows when the real preview image is missing/not yet built. */
.card-emoji {
  font-size: 4.5rem;
  line-height: 1;
  display: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}
.card-media.no-preview .card-emoji { display: block; }

.card-media::after {
  content: "✓ Selected";
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  background: var(--teal-dark);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.style-title { font-size: 1.15rem; font-weight: 800; color: var(--teal-dark); }

/* Position dots */
.pup-dots { display: flex; justify-content: center; gap: 7px; margin-top: 12px; }
.pup-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: width 0.2s ease, background 0.2s ease;
}
.pup-dot.is-on { width: 22px; background: var(--teal-dark); }

/* Per-style fallback gradients (only visible until previews are generated) */
.c1 { background: linear-gradient(135deg, #ffd27a, #ff9a3c); }
.c2 { background: linear-gradient(135deg, #e9b97a, #b9793f); }
.c3 { background: linear-gradient(135deg, #a0e7e5, #ffaebc); }
.c4 { background: linear-gradient(135deg, #ffb347, #ff8e53); }
.c5 { background: linear-gradient(135deg, #86a8e7, #7f7fd5); }
.c6 { background: linear-gradient(135deg, #43cea2, #185a9d); }
.c7 { background: linear-gradient(135deg, #ff9a9e, #fecfef); }
.c8 { background: linear-gradient(135deg, #f6d365, #fda085); }

/* Result */
.result { margin-top: 26px; }

.result-card {
  text-align: center;
  border-top: 6px solid var(--teal);
}

.result-card h2 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  color: var(--royal);
}

.result-card p { color: var(--muted); }

.qr-wrap {
  margin: 20px auto;
  width: min(380px, 100%);
  background: #fff;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
}

.qr-wrap img { width: 100%; display: block; border-radius: 14px; }

.download {
  display: inline-block;
  background: var(--teal);
  color: #fff;
  border-radius: 999px;
  padding: 14px 24px;
  font-weight: 800;
  text-decoration: none;
}

.download:hover { background: var(--teal-dark); }

.hidden { display: none; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 22px 16px;
  margin-top: 36px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.site-footer p { margin: 0; }

/* ============================ Banner ads ============================ */
.ad-slot { z-index: 40; }

/* Left vertical rail — desktop only, lives in the left margin */
.ad-slot--left {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 168px;
  display: none;
}

/* Bottom banner — fixed across the viewport */
.ad-slot--bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 104px;
  display: flex;
  justify-content: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
}

/* Show the left rail once there's room beside the narrow 560px column */
@media (min-width: 1024px) {
  .ad-slot--left { display: block; }
}

.ad-creative {
  position: relative;
  display: flex;
  width: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  font-family: inherit;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ad-creative:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24); }

/* Image slot — polished placeholder until /ads/<id>.png is generated */
.ad-media {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--ad-bg, var(--teal));
  overflow: hidden;
}
.ad-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ad-emoji {
  font-size: 2.4rem;
  line-height: 1;
  color: #fff;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.ad-cat {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 3px 8px;
  border-radius: 999px;
}

.ad-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  min-width: 0;
}
.ad-title { font-weight: 800; font-size: 1rem; color: var(--ink); }
.ad-sub { font-size: 0.82rem; color: var(--muted); }
.ad-cta { margin-top: 4px; font-weight: 800; font-size: 0.82rem; color: var(--orange); }

/* Tiny "Ad" disclosure */
.ad-creative::after {
  content: "Ad";
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Left rail: image on top, body below */
.ad-slot--left .ad-creative { flex-direction: column; }
.ad-slot--left .ad-media { width: 100%; height: 132px; }
.ad-slot--left .ad-emoji { font-size: 3rem; }

/* Bottom banner: image left, body right */
.ad-slot--bottom .ad-creative { flex-direction: row; align-items: stretch; max-width: 660px; }
.ad-slot--bottom .ad-media { width: 84px; }
.ad-slot--bottom .ad-body { justify-content: center; }
.ad-slot--bottom .ad-cta { margin-top: 2px; }

/* ============================ Film ad modal ============================ */
.ad-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: rgba(15, 25, 30, 0.82);
  padding: 0 16px;
}
.ad-modal.open { display: flex; }

.ad-modal-panel {
  width: min(760px, 100%);
  margin-top: -100vh;
  background: #14181b;
  color: #fff;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  padding: 14px 16px 20px;
  transition: margin-top 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.ad-modal.open .ad-modal-panel { margin-top: 0; }

.ad-tag {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 800;
  color: #c7d0d4;
  text-align: center;
  padding: 4px 0 10px;
}

.ad-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}
.ad-video iframe,
.ad-video #adPlayer { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Transparent layer prevents pausing / using player controls */
.ad-video-block { position: absolute; inset: 0; cursor: default; }

.ad-email {
  margin-top: 14px;
  text-align: center;
}
.ad-email label { font-weight: 700; font-size: 0.95rem; }
.ad-email label span { color: #9aa6ab; font-weight: 500; }
.ad-email-row {
  display: flex;
  gap: 8px;
  max-width: 420px;
  margin: 10px auto 0;
}
.ad-email-row input {
  flex: 1;
  border: 2px solid #2c343a;
  background: #0e1113;
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
}
.ad-email-row input:focus { border-color: var(--teal); box-shadow: none; outline: none; }
.ad-email-row button {
  flex: none;
  background: var(--orange);
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
  color: #fff;
}
.ad-email-done { color: var(--sage); font-weight: 700; margin: 12px 0 0; }

/* Skip area — centered at the bottom of the modal */
.ad-skip {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
}
.ad-countdown { color: #9aa6ab; font-size: 0.88rem; font-weight: 700; }
.ad-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #14181b;
  font-size: 1.2rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.ad-close:hover { background: #e9eef0; }

@media (max-width: 560px) {
  .ad-slot--bottom { height: 92px; padding: 8px; }
  .ad-slot--bottom .ad-emoji { font-size: 1.7rem; }
}
