/* Gift Tags. Kraft tags on red baker's twine, on a warm paper page.
   Red means two things only: something you can tap, and a gift that's been got. */

:root {
  --page: #f3ebdd;
  --page-2: #ebe0cc;
  --rule: #d9c8ac;
  --ink: #2a1f17;
  --ink-2: #4f3d30;
  --ink-3: #6b5646;
  --kraft: #dfc398;
  --kraft-2: #d3b585;
  --kraft-ink: #2a1f17;
  --kraft-ink-2: #533f30;
  --ring: #f1e4cc;
  --red: #ad262d;
  --red-press: #8f1d23;
  --red-ink: #8a1b21;
  --twine-a: #b3282f;
  --twine-b: #f6eee2;
  --white: #fffaf2;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Figtree", -apple-system, "Segoe UI", system-ui, sans-serif;
  --twine: repeating-linear-gradient(-50deg, var(--twine-a) 0 3px, var(--twine-b) 3px 6px);
  --twine-h: repeating-linear-gradient(40deg, var(--twine-a) 0 3px, var(--twine-b) 3px 6px);
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .13 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--red-ink); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 6px; }

.wrap { width: 100%; max-width: 620px; margin: 0 auto; padding: 0 16px; }

/* ---------- the big hanging tag ---------- */

.hero { position: relative; display: flex; justify-content: center; padding: 0 16px 28px; }
.hero-twine {
  position: absolute; top: 0; left: 50%; width: 3px; height: 46px; margin-left: -1.5px;
  background: var(--twine); border-radius: 0 0 2px 2px; z-index: 2;
}
.hero-tag {
  position: relative; margin-top: 30px; width: min(100%, 340px);
  padding: 46px 28px 26px; text-align: center;
  background: var(--paper-grain), linear-gradient(180deg, var(--kraft), var(--kraft-2));
  clip-path: polygon(22px 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%, 0 22px);
  transform: rotate(-2.2deg); transform-origin: 50% 0;
  filter: drop-shadow(0 2px 0 rgba(90, 60, 30, .08));
}
.hero-tag .hole { left: 50%; top: 16px; margin-left: -6px; }
.eyebrow {
  margin: 0 0 4px; font: 600 12px/1 var(--body); letter-spacing: .14em; text-transform: uppercase;
  color: var(--kraft-ink-2);
}
h1 {
  margin: 0; font: 700 54px/0.95 var(--display); letter-spacing: -.02em;
  font-variation-settings: "opsz" 144, "SOFT" 60, "WONK" 1;
  color: var(--kraft-ink);
}
.to-from {
  margin: 12px 0 0; font: italic 500 19px/1.25 var(--display);
  font-variation-settings: "opsz" 30, "SOFT" 100;
  color: var(--kraft-ink);
}
.sleeps { margin: 10px 0 0; font: 600 13px/1.3 var(--body); color: var(--kraft-ink-2); }
.sleeps b { color: var(--red-ink); font-weight: 700; }

/* ---------- jump bar ---------- */

.jump {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px max(16px, calc((100vw - 620px) / 2 + 16px));
  background: color-mix(in srgb, var(--page) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.jump::-webkit-scrollbar { display: none; }
.jump.stuck { border-bottom-color: var(--rule); }
.pill {
  flex: none; border: 1px solid var(--rule); background: var(--white); color: var(--ink-2);
  padding: 7px 13px; border-radius: 999px; font-size: 14px; font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.pill:active { transform: scale(.97); }
.pill.on { background: var(--ink); border-color: var(--ink); color: var(--page); }
.pill.sep { margin-left: 4px; }
.pill .n { font-variant-numeric: tabular-nums; opacity: .75; margin-left: 3px; }
@media (hover: hover) {
  .pill:not(.on):hover { border-color: var(--ink-3); color: var(--ink); }
}

/* ---------- a person ---------- */

.person { padding: 26px 0 10px; scroll-margin-top: 60px; }
.person + .person { border-top: 1px solid var(--rule); }
.person-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.person-head h2 {
  margin: 0; font: 650 30px/1.05 var(--display); letter-spacing: -.01em;
  font-variation-settings: "opsz" 72, "SOFT" 50;
}
.count { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.count b { color: var(--red-ink); }
.person-note { margin: -6px 0 16px; font-size: 14px; color: var(--ink-2); max-width: 46ch; }
.person.me .person-head h2 em { font-style: italic; font-weight: 500; }

/* The twine every tag in a section hangs from. */
.tags { list-style: none; margin: 0; padding: 0 0 0 30px; position: relative; display: grid; gap: 12px; }
.tags::before {
  content: ""; position: absolute; left: 9px; top: -6px; bottom: 26px; width: 3px;
  background: var(--twine); border-radius: 2px;
}
.tags:empty::before { display: none; }
.tag-row { position: relative; }
/* The loop from the twine through the tag's hole. */
.tag-row::before {
  content: ""; position: absolute; z-index: 2; left: -21px; top: calc(50% - 1.5px);
  width: 37px; height: 3px; background: var(--twine-h); border-radius: 2px;
  transform: rotate(var(--loop, 0deg)); transform-origin: 0 50%;
}
.tag-row::after {
  content: ""; position: absolute; z-index: 3; left: -24px; top: calc(50% - 4.5px);
  width: 9px; height: 9px; border-radius: 50%; background: var(--twine-a);
  box-shadow: inset -1px -1px 0 rgba(0, 0, 0, .18);
}

/* ---------- a tag ---------- */

.tag {
  position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left;
  transform: rotate(var(--tilt, 0deg)); transform-origin: 0 50%;
  filter: drop-shadow(0 1px 0 rgba(90, 60, 30, .10)) drop-shadow(0 4px 8px rgba(90, 60, 30, .10));
  transition: transform .18s cubic-bezier(.2, .8, .2, 1);
  -webkit-tap-highlight-color: transparent;
}
.tag:active { transform: rotate(var(--tilt, 0deg)) scale(.985); }
@media (hover: hover) {
  .tag:hover { transform: rotate(0deg) translateX(2px); }
}
.paper {
  display: block; position: relative; min-height: 64px;
  padding: 13px 18px 13px 36px;
  background: var(--paper-grain), linear-gradient(100deg, var(--kraft) 0%, var(--kraft-2) 100%);
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  color: var(--kraft-ink);
}
.tag.got .paper { padding-right: 70px; }
.hole {
  position: absolute; left: 11px; top: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%;
  background: var(--page); box-shadow: 0 0 0 3px var(--ring), inset 0 1px 1px rgba(60, 40, 20, .25);
}
.t-title {
  display: block; font: 600 18px/1.25 var(--display);
  font-variation-settings: "opsz" 24, "SOFT" 30;
  overflow-wrap: anywhere;
}
.t-note { display: block; margin-top: 3px; font-size: 14px; line-height: 1.35; color: var(--kraft-ink-2); overflow-wrap: anywhere; }
.t-meta {
  display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--kraft-ink-2);
}
.t-meta .got-by { color: var(--red-ink); }
.t-meta .link::before { content: "↗ "; }
.tag.removed .paper { opacity: .72; }

/* ---------- the wax seal ---------- */

.seal {
  position: absolute; right: 8px; top: 50%; width: 54px; height: 54px; margin-top: -27px; z-index: 2;
  transform: rotate(var(--seal-r, -10deg));
  filter: drop-shadow(0 1.5px 1px rgba(60, 10, 10, .35));
  pointer-events: none;
}
svg text.si { font: 700 19px var(--display); font-variation-settings: "opsz" 24, "SOFT" 100; }
.seal.stamp { animation: stamp .42s cubic-bezier(.2, .7, .2, 1) both; }
.tag.thump .paper { animation: thump .42s ease-out both; }
@keyframes stamp {
  0% { transform: rotate(var(--seal-r)) scale(1.9); opacity: 0; }
  45% { transform: rotate(var(--seal-r)) scale(.9); opacity: 1; }
  70% { transform: rotate(var(--seal-r)) scale(1.04); }
  100% { transform: rotate(var(--seal-r)) scale(1); }
}
@keyframes thump {
  0%, 35% { transform: none; }
  50% { transform: translateY(1.5px); }
  100% { transform: none; }
}

/* ---------- add buttons ---------- */

.add {
  display: flex; align-items: center; gap: 10px; width: calc(100% - 30px); margin: 12px 0 8px 30px;
  padding: 12px 16px; border: 1.5px dashed var(--ink-3); border-radius: 10px; background: transparent;
  color: var(--ink); text-align: left; transition: background-color .15s, border-color .15s;
}
.add .plus {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--red); color: var(--white); font-size: 19px; font-weight: 600; line-height: 1;
}
.add b { font-weight: 600; }
.add small { display: block; font-size: 13px; color: var(--ink-3); }
.add:active { transform: scale(.99); }
@media (hover: hover) {
  .add:hover { background: var(--page-2); border-color: var(--ink-2); }
}
.empty { margin: 0; font-size: 15px; color: var(--ink-3); font-style: italic; }
/* No tags yet means no twine, so the button sits flush. */
.empty + .add, .person-note + .add { width: 100%; margin-left: 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--rule);
  background: var(--white); color: var(--ink); font-weight: 600; font-size: 16px; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn.primary:active { background: var(--red-press); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--red-ink); }
.btn.danger.armed { background: var(--red); border-color: var(--red); color: var(--white); }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
@media (hover: hover) {
  .btn:not(.primary):not(.armed):hover { border-color: var(--ink-3); }
  .btn.primary:hover { background: var(--red-press); }
}

/* ---------- sheets ---------- */

.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--page); color: var(--ink);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(42, 31, 23, .25);
}
.sheet::backdrop { background: rgba(42, 31, 23, .38); }
.sheet[open] { animation: sheet-up .32s cubic-bezier(.2, .8, .2, 1); }
.sheet[open]::backdrop { animation: fade .25s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 20px; }
}
.sheet-body { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet-body::before {
  content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--rule);
  margin: -10px auto 16px;
}
.sheet-for { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.sheet h3 {
  margin: 0; font: 650 26px/1.15 var(--display); letter-spacing: -.01em;
  font-variation-settings: "opsz" 48, "SOFT" 40; overflow-wrap: anywhere;
}
/* The sheet opens with focus on its title, so no button looks pre-pressed. */
.sheet h3:focus { outline: none; }
.sheet .lede { margin: 8px 0 0; color: var(--ink-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.sheet .meta { margin: 10px 0 0; font-size: 13px; color: var(--ink-3); }
.sheet .status {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 0; padding: 12px 14px;
  border-radius: 12px; background: var(--page-2);
}
.sheet .status svg { flex: none; width: 40px; height: 40px; }
.sheet .status p { margin: 0; font-size: 15px; }
.sheet .status b { color: var(--red-ink); }
.actions { display: grid; gap: 10px; margin-top: 20px; }
.actions .row { display: flex; gap: 10px; }
.actions .row > * { flex: 1; }
.open-link { margin-top: 14px; }

form.edit { display: grid; gap: 14px; margin-top: 16px; }
label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
label.field span small { font-weight: 500; color: var(--ink-3); }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--white); font-size: 16px; font-weight: 400; color: var(--ink);
}
.field textarea { min-height: 76px; resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(173, 38, 45, .15); }
.secret-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--page-2); font-size: 14px; color: var(--ink-2);
}

/* Family sheet */
.family { list-style: none; margin: 16px 0 0; padding: 0; }
.family li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.family li:last-child { border-bottom: 0; }
.family .who { flex: 1; min-width: 0; }
.family .who b { display: block; font: 600 17px/1.2 var(--display); overflow-wrap: anywhere; }
.family .who small { font-size: 13px; color: var(--ink-3); }
.family input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--white); font-size: 16px; }
.add-person { display: flex; gap: 10px; margin-top: 14px; }
.add-person input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--white); font-size: 16px; }

/* ---------- toast, loading, locked, footer ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px;
  background: var(--ink); color: var(--page); font-size: 15px; font-weight: 500;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { text-align: center; color: var(--ink-3); padding: 40px 0; font-style: italic; }
.locked { text-align: center; padding: 10px 0 60px; }
.locked h2 { font: 650 28px/1.15 var(--display); margin: 0 0 10px; }
.locked p { color: var(--ink-2); max-width: 34ch; margin: 0 auto 10px; }
.foot { padding-top: 26px; padding-bottom: 40px; }
.foot p { margin: 0; font-size: 13px; color: var(--ink-3); text-align: center; max-width: 44ch; margin: 0 auto; }
.wrap-summary { margin: 6px 0 0; padding: 16px 0 0; font-size: 15px; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  .seal.stamp { animation: fade .2s ease-out both; }
  .tag.thump .paper { animation: none; }
  .sheet[open], .sheet[open]::backdrop { animation: fade .15s ease-out; }
  .tag, .pill, .btn, .add { transition: none; }
}
