/* ============================================================
   Romantic corkboard pinwall — birthday page
   ============================================================ */

:root {
  --cork: #c89b6b;
  --cork-dark: #a87a4c;
  --wood: #6f4a2c;
  --paper: #fffdf7;
  --ink: #3a2c22;
  --accent: #d6455d;
  --pin: #d6455d;
  --tile: 200px;            /* base polaroid width on desktop */
  --font-hand: "Caveat", "Segoe Script", "Bradley Hand", cursive;
  --font-body: "Lora", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  /* Cork texture: layered radial speckles over a warm base */
  background-color: var(--cork);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,.06) 0 2px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.05) 0 2px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,.05) 0 2px, transparent 2px),
    radial-gradient(circle at 85% 20%, rgba(0,0,0,.05) 0 2px, transparent 2px),
    radial-gradient(circle at 10% 70%, rgba(255,255,255,.04) 0 2px, transparent 2px),
    radial-gradient(ellipse at center, var(--cork) 0%, var(--cork-dark) 100%);
  background-size: 40px 40px, 55px 55px, 48px 48px, 60px 60px, 52px 52px, 100% 100%;
  /* Wooden frame border */
  border: 14px solid var(--wood);
  border-image: linear-gradient(135deg, #7a5230, #4f3318 50%, #7a5230) 1;
  min-height: 100vh;
}

/* ---------- Greeting note ---------- */
.greeting {
  position: relative;
  width: min(92%, 520px);
  margin: 28px auto 8px;
  padding: 22px 26px 26px;
  text-align: center;
  background: var(--paper);
  background-image: linear-gradient(180deg, #fffefb, #fbf3e2);
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(0,0,0,.28), inset 0 0 0 1px rgba(0,0,0,.03);
  transform: rotate(-1.2deg);
}
.greeting__pin { display: none; }
/* Washi-tape corners */
.greeting::before,
.greeting::after {
  content: "";
  position: absolute;
  top: -12px;
  width: 92px; height: 28px;
  background:
    repeating-linear-gradient(90deg, rgba(214,69,93,.16) 0 8px, transparent 8px 16px),
    rgba(255,240,206,.78);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.greeting::before { left: -30px; transform: rotate(-40deg); }
.greeting::after  { right: -30px; transform: rotate(40deg); }
.greeting__title {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  margin: 6px 0 2px;
  color: var(--accent);
  line-height: 1.05;
}
.greeting__name {
  font-family: var(--font-hand);
  font-weight: 500;
  font-size: clamp(1.7rem, 7vw, 2.5rem);
  margin: 0;
  color: var(--ink);
}
.greeting__sub {
  margin: 10px 0 0;
  font-family: var(--font-body);
  font-style: italic;
  font-size: .95rem;
  color: #6b5848;
  line-height: 1.5;
}

/* ---------- Board ---------- */
.board {
  position: relative;
  width: min(96%, 1200px);
  margin: 10px auto 30px;
}
.board__empty {
  text-align: center;
  color: #f3e7d4;
  background: rgba(0,0,0,.18);
  padding: 18px;
  border-radius: 8px;
}
.board__empty code {
  background: rgba(255,255,255,.2);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------- Polaroid (photo) ---------- */
.pola {
  background: #fff;
  padding: 12px 12px 30px;
  box-shadow: 0 8px 18px rgba(0,0,0,.32);
  border-radius: 2px;
  width: var(--tile);
}
.pola__pin {
  position: absolute;
  top: -10px; left: 50%;
  width: 18px; height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  box-shadow: 0 3px 5px rgba(0,0,0,.4);
  background: radial-gradient(circle at 35% 30%, #fff7, #c33 60%, #7d1d2c);
}
.pola__img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 1px;
  /* shimmer while the file is still downloading */
  background: linear-gradient(100deg, #e9e4dc 35%, #f7f4ee 50%, #e9e4dc 65%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  /* grey until she taps it */
  filter: grayscale(1) contrast(.95);
  transition: filter .9s ease;
}
.pola__img.is-loaded { animation: none; background: #eee; }
.pola.is-color .pola__img { filter: none; }
.pola.is-color { animation: pola-pop .5s cubic-bezier(.3, 1.6, .5, 1); cursor: zoom-in; }
@keyframes shimmer {
  to { background-position: -200% 0; }
}
@keyframes pola-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- Gift card (reveal) ---------- */
.gift {
  width: var(--tile);
  aspect-ratio: 3 / 4;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.gift__inner {
  position: relative;
  width: 100%;
  height: 100%;
  box-shadow: 0 9px 20px rgba(0,0,0,.34);
  border-radius: 6px;
}

.gift__face {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  overflow: hidden;
  transition: opacity .35s ease;
}
/* Crossfade front -> back (no 3D flip, so back text is never mirrored) */
.gift__back { opacity: 0; visibility: hidden; }
.gift.is-open .gift__front { opacity: 0; visibility: hidden; }
.gift.is-open .gift__back { opacity: 1; visibility: visible; }
/* Unwrap: back content drifts up one piece at a time */
.gift__back > * {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .5s ease, transform .5s ease;
}
.gift.is-open .gift__back > * { opacity: 1; transform: none; }
.gift.is-open .gift__back > *:nth-child(1) { transition-delay: .15s; }
.gift.is-open .gift__back > *:nth-child(2) { transition-delay: .32s; }
.gift.is-open .gift__back > *:nth-child(3) { transition-delay: .5s; }
.gift.is-open .gift__back > *:nth-child(4) { transition-delay: .65s; }
.gift.is-open { cursor: zoom-in; }
/* Front — wrapped gift */
.gift__front {
  color: #fff;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 10px, transparent 10px 20px),
    linear-gradient(160deg, #e0667c, #b8344e);
}
.gift__front::before,
.gift__front::after { /* ribbon cross */
  content: "";
  position: absolute;
  background: rgba(255,255,255,.85);
  box-shadow: 0 0 0 1px rgba(0,0,0,.05);
}
.gift__front::before { left: 50%; top: 0; bottom: 0; width: 16%; transform: translateX(-50%); }
.gift__front::after { top: 50%; left: 0; right: 0; height: 16%; transform: translateY(-50%); }
.gift__emoji { font-size: 2.6rem; z-index: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
/* Kraft-paper gift tag */
.gift__label {
  position: relative;
  z-index: 1;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.15;
  color: #4a3526;
  background: linear-gradient(170deg, #f0e0bd, #e2cda1);
  padding: 4px 18px 6px 24px;
  border-radius: 3px;
  box-shadow: 0 3px 6px rgba(0,0,0,.3);
  transform: rotate(-3deg);
  margin-top: 10px;
}
.gift__label::before { /* punched hole with string shadow */
  content: "";
  position: absolute;
  left: 8px; top: 50%;
  width: 7px; height: 7px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: rgba(120, 84, 48, .55);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.5);
}
.gift__hint {
  z-index: 1;
  margin-top: 12px;
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(60, 20, 30, .42);
  padding: 4px 12px;
  border-radius: 999px;
}
/* Back — note paper */
.gift__back {
  color: var(--ink);
  background: var(--paper);
  background-image:
    linear-gradient(180deg, transparent 28px, rgba(120,90,60,.12) 28px, rgba(120,90,60,.12) 29px, transparent 29px);
  background-size: 100% 30px;
  justify-content: flex-start;
  padding-top: 28px;
}
.gift__back-title {
  font-family: var(--font-hand);
  font-size: 1.35rem;
  color: var(--accent);
  margin: 0 0 10px;
}
.gift__back-text {
  font-size: .95rem;
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.gift__back-link {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}
.gift__back-img {
  max-width: 100%;
  flex: 1 1 auto;       /* shrink to the space the text leaves over */
  min-height: 0;
  border-radius: 4px;
  object-fit: contain;
  cursor: zoom-in;
}
.gift__pin {
  position: absolute;
  top: -9px; left: 50%;
  width: 18px; height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  z-index: 5;
  background: radial-gradient(circle at 35% 30%, #ffe08a, #e0a32a 60%, #9a6c14);
  box-shadow: 0 3px 5px rgba(0,0,0,.4);
}

/* ---------- Item wrapper (positioned) ---------- */
.item {
  position: absolute;       /* desktop: JS sets left/top/transform */
  top: 0; left: 0;
  will-change: transform;
}

.footer {
  text-align: center;
  color: rgba(255,255,255,.55);
  font-size: .8rem;
  padding: 6px 0 16px;
}

/* ============================================================
   MOBILE — neat single-column scroll (no overlap)
   ============================================================ */
@media (max-width: 767px) {
  body { border-width: 8px; }

  .board {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    width: min(94%, 460px);
  }
  .item {
    position: static !important;   /* override JS inline absolute positioning */
    transform: none;
    width: 100%;
    max-width: 320px;
  }
  /* gentle alternating tilt for charm */
  .item:nth-child(odd)  { transform: rotate(-2deg); }
  .item:nth-child(even) { transform: rotate(2deg); }

  .pola { width: 100%; }
  .gift { width: 100%; aspect-ratio: 4 / 3; }
}

/* ---------- Pin-in page-load animation ---------- */
.pin-in {
  animation: pin-in .55s cubic-bezier(.2, .9, .3, 1.25) both;
}
@keyframes pin-in {
  from { opacity: 0; transform: translateY(-18px) scale(.88); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Fullscreen viewer (photos + opened gifts) ---------- */
.pola { cursor: pointer; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(0,0,0,.9);
  cursor: zoom-out;
}
.lightbox.is-open { display: flex; animation: lb-fade .3s ease both; }
.lightbox__content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}
.lightbox.is-open .lightbox__content {
  animation: lb-zoom .4s cubic-bezier(.2, .9, .3, 1.1) both;
}
@keyframes lb-fade { from { opacity: 0; } }
@keyframes lb-zoom {
  from { opacity: 0; transform: scale(.82); }
  to   { opacity: 1; transform: none; }
}
.lightbox__img {
  max-width: 100%;
  max-height: 86vh;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
/* A gift blown up: one big sheet of note paper */
.lightbox__note {
  cursor: auto;
  width: min(560px, 94vw);
  max-height: 86vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 34px 30px 38px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
  background-image:
    linear-gradient(180deg, transparent 30px, rgba(120,90,60,.12) 30px, rgba(120,90,60,.12) 31px, transparent 31px);
  background-size: 100% 32px;
  box-shadow: 0 16px 50px rgba(0,0,0,.55);
}
.lightbox__note .gift__back-title {
  font-size: 2.2rem;
  margin: 0;
}
.lightbox__note .gift__back-text { font-size: 1.15rem; }
.lightbox__note .gift__back-img { max-height: 56vh; cursor: auto; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .gift__face,
  .gift__back > *,
  .pola__img { transition: none; }
  .pin-in,
  .pola.is-color,
  .pola__img,
  .lightbox.is-open,
  .lightbox.is-open .lightbox__content { animation: none !important; }
}
