/*
  Little Ready Gifts

  The page is a wrapped present seen from above: spruce paper, one red ribbon
  running down and one across, tied in a bow where they meet. The ribbon across
  carries the three lists; a gift tag slides along it to the one you're reading.
  Claiming a gift wraps it.
*/

:root {
  --spruce: #0f3a2d;       /* the wrapping paper */
  --night: #0a2a21;        /* recesses: empty photo tiles, the tag's punched hole */
  --snow: #f5f2ea;         /* type, tags, the paper on wrapped gifts */
  --sage: #a3bdae;         /* quieter type */
  --ribbon: #cc3520;
  --ribbon-light: #dc4a33;
  --ribbon-dark: #a32a18;
  --rule: rgba(245, 242, 234, 0.16);

  --expo: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;

  /* Where the ribbons sit. Everything else lines up to the right of the bow. */
  --rx: clamp(26px, 5.5vw, 120px);    /* centre of the ribbon running down */
  --rw: clamp(12px, 2.4vw, 34px);     /* its width */
  --rh: clamp(52px, 5vw, 64px);       /* height of the ribbon running across */
  --bow: clamp(54px, 12vw, 150px);
  --left: calc(var(--rx) + var(--bow) / 2 + clamp(8px, 1.6vw, 28px));
  --right: clamp(18px, 5vw, 80px);
  --tile: clamp(72px, 12vw, 112px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--spruce);
  /* A faint printed dot, staggered like gift wrap rather than a grid */
  background-image:
    radial-gradient(circle, rgba(245, 242, 234, 0.07) 1.5px, transparent 2px),
    radial-gradient(circle, rgba(245, 242, 234, 0.07) 1.5px, transparent 2px);
  background-size: 38px 38px;
  background-position: 0 0, 19px 19px;
  color: var(--snow);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--ribbon);
  color: var(--snow);
}

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  padding-bottom: clamp(40px, 7vw, 80px);
}

/* ───────── Ribbons ───────── */

.ribbon-v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--rx) - var(--rw) / 2);
  width: var(--rw);
  background: linear-gradient(
    90deg,
    var(--ribbon-dark) 0%,
    var(--ribbon) 26%,
    var(--ribbon-light) 50%,
    var(--ribbon) 74%,
    var(--ribbon-dark) 100%
  );
  transform-origin: top;
  animation: draw-down 1.3s var(--expo) both;
}

.ribbon-h {
  position: relative;
  z-index: 1;
  height: var(--rh);
  margin-top: clamp(30px, 5vw, 60px);
}

.ribbon-h__band {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    var(--ribbon-dark) 0%,
    var(--ribbon) 30%,
    var(--ribbon) 70%,
    var(--ribbon-dark) 100%
  );
  box-shadow: 0 12px 24px -14px rgba(0, 0, 0, 0.6);
  transform-origin: left;
  animation: draw-across 1.3s 0.2s var(--expo) both;
}

.bow {
  position: absolute;
  top: 50%;
  left: calc(var(--rx) - var(--bow) / 2);
  width: var(--bow);
  margin-top: calc(var(--bow) * -0.3); /* puts the knot on the crossing */
  overflow: visible;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3));
  transform-origin: 50% 40%;
  animation: tie 0.9s 0.95s var(--spring) both;
}

.bow__tail { fill: var(--ribbon-dark); }
.bow__loop { fill: var(--ribbon-light); }
.bow__inner { fill: var(--ribbon-dark); }
.bow__knot { fill: var(--ribbon); }

@keyframes draw-down {
  from { transform: scaleY(0); }
}

@keyframes draw-across {
  from { transform: scaleX(0); }
}

@keyframes tie {
  from { opacity: 0; transform: scale(0.2) rotate(-18deg); }
}

@keyframes fade {
  from { opacity: 0; }
}

/* ───────── Name and introduction ───────── */

.hero {
  padding: clamp(44px, 9vh, 100px) var(--right) 0 var(--left);
}

h1 {
  margin: 0;
  font-size: clamp(4rem, 15vw, 9.5rem);
  font-weight: 800;
  font-stretch: 75%;
  line-height: 0.86;
  letter-spacing: 0;
}

/* Each word rises out from behind its own line as the ribbons are drawn */
h1 .line {
  display: block;
  overflow: hidden;
  padding-block: 0.08em;
  margin-block: -0.08em;
}

h1 .line > span {
  display: block;
  animation: rise 1.1s var(--expo) both;
  animation-delay: calc(0.3s + var(--n) * 0.09s);
}

@keyframes rise {
  from { transform: translateY(112%); }
}

.lede {
  max-width: 30ch;
  margin: clamp(20px, 3vw, 32px) 0 0;
  color: var(--sage);
  font-size: clamp(1.1rem, 1.7vw, 1.35rem);
  line-height: 1.4;
  animation: fade 0.9s 0.9s both;
}

/* ───────── The three lists, on the ribbon ───────── */

.tabs {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 100%;
  margin: 0 var(--right) 0 var(--left);
  animation: fade 0.8s 1.05s both;
}

/* The gift tag that marks the list you're on */
.tabs__tag {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 0;
  background: var(--snow);
  clip-path: polygon(11px 0, 100% 0, 100% 100%, 11px 100%, 0 calc(100% - 11px), 0 11px);
  will-change: transform, width;
}

.tabs__tag::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 9px;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--ribbon);
}

.tabs__tag.is-ready {
  transition: transform 0.7s var(--expo), width 0.7s var(--expo);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0 16px 0 26px;
  border: 0;
  background: none;
  color: rgba(245, 242, 234, 0.88);
  font: inherit;
  font-size: 1.06rem;
  font-weight: 650;
  font-stretch: 90%;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.45s ease;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover { color: var(--snow); }
.tab[aria-selected="true"] { color: var(--ribbon-dark); }

.tab__count {
  font-size: 0.8em;
  font-weight: 500;
  opacity: 0.75;
}

.tab:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -6px;
}

/* ───────── A list ───────── */

main {
  padding: clamp(36px, 6vw, 68px) var(--right) 0 var(--left);
  animation: fade 0.9s 1.15s both;
}

#panel {
  max-width: 900px;
  outline: none;
}

h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 700;
  font-stretch: 85%;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.list-note {
  margin: 10px 0 0;
  color: var(--sage);
}

.gifts {
  margin: clamp(20px, 3vw, 32px) 0 0;
  padding: 0;
  list-style: none;
}

.gift {
  display: grid;
  grid-template-columns: var(--tile) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: clamp(14px, 2.4vw, 28px);
  padding: clamp(18px, 2.4vw, 24px) 0;
  border-top: 1px solid var(--rule);
}

.gift:last-child {
  border-bottom: 1px solid var(--rule);
}

.gift__main {
  min-width: 0;
  transition: opacity 0.6s ease;
}

.gift__name {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.45rem);
  font-weight: 650;
  font-stretch: 92%;
  line-height: 1.2;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}

.gift__name a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(245, 242, 234, 0.35);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color 0.3s ease;
}

.gift__name a:hover {
  text-decoration-color: var(--snow);
}

.gift__note {
  max-width: 52ch;
  margin: 5px 0 0;
  color: var(--sage);
  overflow-wrap: anywhere;
}

.gift__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 9px 0 0;
  font-size: 0.97rem;
}

.gift__price { font-weight: 650; }
.gift__store { color: var(--sage); }

.pick {
  padding: 1px 8px 2px;
  border-radius: 3px;
  background: var(--snow);
  color: var(--spruce);
  font-size: 0.82rem;
  font-weight: 700;
}

/* Someone else is getting it: the words step back, the photo is wrapped */
.gift.is-taken .gift__main { opacity: 0.55; }

/* ───────── Photo tile, and wrapping it ───────── */

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--night);
  overflow: hidden;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__empty {
  position: absolute;
  inset: 0;
  width: 44%;
  height: 44%;
  margin: auto;
  fill: none;
  stroke: var(--sage);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}

/* Paper slides over the photo, then a ribbon goes down, then across, then the knot */
.tile__wrap {
  position: absolute;
  inset: 0;
  background-color: var(--snow);
  background-image: radial-gradient(circle, rgba(15, 58, 45, 0.2) 1.2px, transparent 1.6px);
  background-size: 11px 11px;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.45s var(--expo) 0.25s;
}

.tile__wrap::before,
.tile__wrap::after {
  content: "";
  position: absolute;
  background: var(--ribbon);
  transition: transform 0.3s var(--expo);
}

.tile__wrap::before {
  top: 0;
  bottom: 0;
  left: 41%;
  width: 18%;
  transform: scaleY(0);
  transform-origin: top;
}

.tile__wrap::after {
  left: 0;
  right: 0;
  top: 41%;
  height: 18%;
  transform: scaleX(0);
  transform-origin: left;
}

.tile__knot {
  position: absolute;
  z-index: 1;
  top: 37%;
  left: 37%;
  width: 26%;
  height: 26%;
  border-radius: 28%;
  background: var(--ribbon-dark);
  transform: scale(0);
  transition: transform 0.25s var(--expo);
}

.gift.is-wrapped .tile__wrap {
  clip-path: inset(0);
  transition: clip-path 0.55s var(--expo);
}

.gift.is-wrapped .tile__wrap::before {
  transform: none;
  transition: transform 0.45s var(--expo) 0.38s;
}

.gift.is-wrapped .tile__wrap::after {
  transform: none;
  transition: transform 0.45s var(--expo) 0.56s;
}

.gift.is-wrapped .tile__knot {
  transform: none;
  transition: transform 0.5s var(--spring) 0.86s;
}

/* ───────── Claiming ───────── */

.gift__claim {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 10.5rem;
  text-align: right;
}

.gift__claim[hidden] { display: none; }

.btn {
  padding: 11px 18px 12px;
  border: 0;
  border-radius: 4px;
  background: var(--ribbon);
  color: var(--snow);
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  font-stretch: 92%;
  cursor: pointer;
  transition: background-color 0.3s ease, scale 0.4s var(--expo);
}

.btn:hover { background: var(--ribbon-dark); }
.btn:active { scale: 0.97; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.claim-status {
  color: var(--sage);
  font-size: 0.97rem;
  animation: fade 0.6s 0.3s both;
}

.claim-status--mine {
  color: var(--snow);
  font-weight: 650;
}

.text-btn {
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.gift__claim .text-btn {
  color: var(--sage);
  animation: fade 0.6s 0.3s both;
}

.gift__claim .text-btn:hover { color: var(--snow); }

.btn:focus-visible,
.text-btn:focus-visible,
.gift__name a:focus-visible,
.who-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.empty {
  margin: 0;
  padding: 28px 0;
  border-block: 1px solid var(--rule);
  color: var(--sage);
}

/* ───────── Footer ───────── */

.foot {
  padding: clamp(40px, 6vw, 72px) var(--right) 0 var(--left);
  color: var(--sage);
  font-size: 0.95rem;
  animation: fade 0.9s 1.25s both;
}

.foot p { margin: 0 0 4px; }
.foot .text-btn { margin-left: 4px; }
.foot .text-btn:hover { color: var(--snow); }

/* ───────── Gift-tag dialogs ───────── */

.tag {
  width: min(400px, calc(100% - 32px));
  padding: 56px 28px 28px;
  border: 0;
  background: var(--snow);
  color: var(--spruce);
  clip-path: polygon(28px 0, calc(100% - 28px) 0, 100% 28px, 100% 100%, 0 100%, 0 28px);
  transform-origin: 50% 0;
}

.tag[open] {
  animation: hang 0.7s var(--expo);
}

@keyframes hang {
  from { opacity: 0; transform: translateY(-14px) rotate(-4deg); }
}

.tag::backdrop {
  background: rgba(6, 24, 19, 0.74);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade 0.4s ease;
}

/* The punched hole */
.tag::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--night);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.5);
}

.tag h2 {
  font-size: 2rem;
}

.tag p {
  margin: 8px 0 22px;
  color: #36594c;
}

.tag__options {
  display: grid;
  gap: 8px;
}

.who-btn {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 13px 16px 14px;
  border: 1.5px solid var(--spruce);
  border-radius: 4px;
  background: none;
  color: var(--spruce);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.who-btn:hover {
  background: var(--spruce);
  color: var(--snow);
}

.who-btn__label { font-weight: 700; }
.who-btn__hint { font-size: 0.92rem; opacity: 0.78; }

.tag input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--spruce);
  border-radius: 4px;
  background: #fff;
  color: var(--spruce);
  font: inherit; /* 17px, so phones don't zoom in */
}

.tag input::placeholder { color: #7d968b; }

.tag input:focus-visible {
  outline: 2px solid var(--ribbon);
  outline-offset: 2px;
}

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

/* ───────── Messages ───────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px 13px;
  border-radius: 4px;
  background: var(--snow);
  color: var(--spruce);
  font-weight: 600;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  translate: -50% 14px;
  pointer-events: none;
  transition: opacity 0.35s ease, translate 0.6s var(--expo);
}

.toast.is-on {
  opacity: 1;
  translate: -50% 0;
}

/* ───────── Phones ───────── */

@media (max-width: 640px) {
  .gift {
    grid-template-columns: var(--tile) minmax(0, 1fr);
    align-items: start;
  }

  .gift__claim {
    grid-column: 2;
    align-items: flex-start;
    min-width: 0;
    margin-top: 12px;
    text-align: left;
  }

  .tab {
    padding: 0 10px 0 22px;
    font-size: 0.98rem;
  }
}

/* ───────── Reduced motion ───────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
