/* Zara's Wishlist. Look borrowed from nostalgicsnacks.com:
   dusty pink paper, a giant red condensed title, painted gifts piled on top. */

:root {
  --paper: #ece2e2;
  --red: #d8343f;
  --blue: #1d3fd0;
  --ink: #2a2023;
  --ink-soft: #6d5d61;
  --white: #fbf7f5;
  --gutter: clamp(16px, 2.4vw, 32px);
  --display: 'League Gothic', 'Arial Narrow', sans-serif;
  --body: 'Bricolage Grotesque', 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* The home screen is one fixed screen: no scrolling, the pile is the page. */
body { overflow: hidden; }

/* Faint paper grain so the pink is not flat. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .3 0 0 0 0 .32 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Top bar ---------- */
.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
}
.bar > * { pointer-events: auto; margin: 0; }
.bar-hint { font-weight: 600; font-size: 15px; }
.bar-count { font-weight: 600; font-size: 15px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Giant title ---------- */
.hero {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(44px + env(safe-area-inset-top));
  z-index: 1;
  margin: 0;
  padding: 0 var(--gutter);
  font-family: var(--display);
  font-weight: 400;
  color: var(--red);
  text-transform: uppercase;
  line-height: 0.86;
  letter-spacing: 0.012em;
  text-align: center;
  user-select: none;
  /* app.js sets the font-size so the title fills the width */
}
.hero-line { display: inline; }
.hero-line + .hero-line::before { content: ' '; }
/* Portrait screens: two stacked lines, each as wide as the screen */
.hero.is-stacked .hero-line { display: block; }
.hero.is-stacked .hero-line + .hero-line::before { content: none; }

/* Title rises in once, then the gifts fall on it. */
@media (prefers-reduced-motion: no-preference) {
  .hero { animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
  @keyframes rise { from { transform: translateY(24px); opacity: 0; } }
}

/* ---------- The falling pile ---------- */
.pile {
  position: fixed;
  inset: 0;
  z-index: 10;
  touch-action: none; /* lets people drag gifts on phones */
  cursor: default;
}
.pile.is-hover { cursor: pointer; }
.pile.is-dragging { cursor: grabbing; }

.gift {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  pointer-events: none; /* physics does hit-testing; the button is here for keyboard + screen readers */
  will-change: transform;
  visibility: hidden; /* shown once physics places it */
}
.gift img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
  filter: drop-shadow(0 2px 0 rgba(42, 32, 35, 0.12));
}
.gift:focus-visible { outline: none; }
.gift:focus-visible img { filter: drop-shadow(0 0 0 var(--blue)) drop-shadow(0 0 6px var(--blue)); }
.gift.is-taken img { opacity: 0.8; }

/* "TAKEN" rubber stamp, in the blue of the reference's stamps */
.stamp {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  padding: 0.08em 0.32em 0.02em;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(18px, 22%, 44px);
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--blue);
  background: rgba(251, 247, 245, 0.88);
  border: 3px solid var(--blue);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(251, 247, 245, 0.88), inset 0 0 0 4px var(--blue);
  pointer-events: none;
  white-space: nowrap;
}
.stamp[hidden] { display: none; }
.gift .stamp { font-size: var(--stamp-size, 26px); }

/* Small "Rain again" button, bottom-right above the pile */
.rain {
  position: fixed;
  right: var(--gutter);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  font-family: var(--body);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.rain:hover { background: #fff; color: var(--blue); }
.rain:active { transform: translateY(2px); box-shadow: none; }
.rain:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- Detail view ---------- */
.detail {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--paper);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  align-items: center;
  gap: 16px var(--gutter);
  padding: calc(64px + env(safe-area-inset-top)) var(--gutter) calc(32px + env(safe-area-inset-bottom));
}
.detail[hidden] { display: none; }
.detail:focus { outline: none; }
.detail .bar { position: fixed; background: linear-gradient(var(--paper) 70%, transparent); padding-bottom: 12px; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  padding: 4px 8px 4px 0;
}
.back:hover { color: var(--red); }
.back:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* Giant gift name across the top, fully readable, like the home title.
   The art overlaps only its bottom edge, the way the pile overlaps "ZARA'S WISHLIST". */
.detail-name {
  grid-column: 1 / -1;
  grid-row: 1;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  color: var(--red);
  text-transform: uppercase;
  text-align: center;
  line-height: 0.86;
  letter-spacing: 0.012em;
  user-select: none;
  /* app.js sets the size so the name fills the width */
}
.detail-name-text { display: inline-block; }

.detail-art {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
  min-height: 0;
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: calc(var(--name-h, 120px) * -0.32);
}
.detail-art img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(42, 32, 35, 0.12));
}
.stamp-big { font-size: clamp(36px, 7vw, 84px); border-width: 5px; }

.detail-text {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  max-width: 34ch;
}
.detail-by { margin: 0 0 6px; font-weight: 800; font-size: 15px; color: var(--blue); }
.detail-blurb { margin: 0; font-size: 17px; }

.detail-actions {
  grid-column: 3;
  grid-row: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  max-width: 300px;
  justify-self: end;
  width: 100%;
}
.detail-price {
  margin: 0 0 2px;
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--ink);
}
.detail-blurb a { color: var(--blue); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.detail-blurb a:hover { color: var(--red); }
.detail-blurb a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }
.links { display: flex; flex-direction: column; gap: 10px; }
.links[hidden] { display: none; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  font-family: var(--body);
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn-buy { background: var(--white); color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.btn-buy:hover { background: #fff; }
.btn-claim { background: var(--blue); color: var(--white); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.btn-claim:hover { background: #1834b0; }
.btn-claim[disabled] { opacity: 0.6; cursor: wait; }
.btn[hidden], .btn-undo[hidden] { display: none; }

.claim-note { margin: 0; font-size: 14px; line-height: 1.4; color: var(--ink-soft); text-align: center; }
.claim-note[hidden] { display: none; }
.detail-msg { margin: 2px 0 0; font-weight: 600; font-size: 15px; text-align: center; }
.detail-msg:empty { min-height: 1.5em; }
.detail-msg.is-error { color: var(--red); }
.btn-undo {
  align-self: center;
  background: none;
  border: 0;
  padding: 6px 4px;
  font-family: var(--body);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-undo:hover { color: var(--ink); }
.btn-undo:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* Detail opens with the art dropping in, matching the falling pile */
@media (prefers-reduced-motion: no-preference) {
  .detail:not([hidden]) .detail-art img { animation: drop 0.55s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
  .detail:not([hidden]) .detail-name { animation: fade 0.35s ease-out both; }
  @keyframes drop { from { transform: translateY(-40px) rotate(-4deg); opacity: 0; } }
  @keyframes fade { from { opacity: 0; } }
}

/* Short screens (phone held sideways): smaller price so it stays on one line */
@media (max-height: 500px) and (min-width: 821px) {
  .detail-price { font-size: 24px; }
  .detail-actions { gap: 8px; }
  .btn { min-height: 46px; }
}

/* ---------- Phones and narrow screens: stack the detail view ---------- */
@media (max-width: 820px) {
  .bar-hint { font-size: 14px; }
  .bar-count { font-size: 14px; }
  .detail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding-top: calc(56px + env(safe-area-inset-top));
  }
  .detail-name { flex: none; }
  .detail-art { flex: none; margin-top: calc(var(--name-h, 80px) * -0.14); }
  .detail-art img { max-height: 34vh; }
  .detail-price { font-size: 30px; }
  .detail-text { max-width: none; }
  .detail-actions { max-width: none; justify-self: auto; }
}

/* Short phones: shrink the art so the claim button shows without scrolling */
@media (max-width: 820px) and (max-height: 700px) {
  .detail { gap: 12px; }
  .detail-art img { max-height: 28vh; }
}
