:root {
  --paper: #eaf1f5;
  --tag: #fffdf8;
  --ink: #22304a;
  --muted: #5e6b80;
  --edge: #c9d6e0;
  --honey: #f2b840;
  --honey-edge: #d99d22;
  --on-honey: #22304a;
  --stamp: #2f8a78;
  --danger: #b4443a;
  --shadow: rgba(34, 48, 74, 0.14);
  --serif: 'Young Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121925;
    --tag: #1c2534;
    --ink: #e6ecf3;
    --muted: #9aa7ba;
    --edge: #2c384a;
    --stamp: #63c2ad;
    --danger: #e07a6f;
    --shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
}

a { color: inherit; }

:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
h1 { font-size: clamp(2.2rem, 7vw, 3.8rem); line-height: 1.05; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; line-height: 1.2; margin-bottom: 1rem; }
h3 { font-size: 1.2rem; line-height: 1.25; }

small { font-size: 0.85rem; }
.muted, .hint { color: var(--muted); }
.hint { display: block; font-size: 0.85rem; margin-top: 0.25rem; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
}
.brand { font-family: var(--serif); font-size: 1.05rem; text-decoration: none; }

.lang { display: inline-flex; border: 1.5px solid var(--edge); border-radius: 999px; padding: 2px; }
.lang button {
  font: 600 0.8rem/1 var(--sans);
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
.lang button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }

/* ---------- page ---------- */
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 2rem) 5rem;
}

.intro { max-width: 40rem; margin: 1.5rem 0 2.5rem; }
.intro .meta { color: var(--muted); margin: 0 0 0.5rem; }
.lede { font-size: 1.15rem; font-weight: 300; margin: 1rem 0 0; white-space: pre-line; }

.panel {
  background: var(--tag);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: clamp(1.1rem, 3vw, 1.75rem);
  margin-bottom: 1.25rem;
  max-width: 44rem;
}
.panel.quiet { background: transparent; }

details.panel > summary {
  font-family: var(--serif);
  font-size: 1.25rem;
  cursor: pointer;
  list-style-position: outside;
}
details.panel[open] > summary { margin-bottom: 1rem; }

.notice {
  background: var(--tag);
  border-left: 4px solid var(--danger);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  max-width: 40rem;
}

.mine-list { margin: 0; padding-left: 1.2rem; }
.mine-list li { margin: 0.35rem 0; }

/* ---------- forms ---------- */
.form { display: grid; gap: 1rem; }
.form label, .imagepick { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }
.form label small, .imagepick small { font-weight: 400; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }

input, textarea {
  font: 400 1rem/1.4 var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--edge);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  width: 100%;
  min-width: 0;
}
input:focus, textarea:focus { border-color: var(--stamp); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--stamp) 25%, transparent); }
textarea { resize: vertical; }

.check { grid-template-columns: auto 1fr; align-items: start; gap: 0.75rem !important; font-weight: 400 !important; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; accent-color: var(--stamp); }

.copyfield { display: flex; gap: 0.5rem; }
.copyfield input { flex: 1; }

.links .linkrow { margin-bottom: 1rem; }
.links .linkrow:last-child { margin-bottom: 0; }
.linklabel { display: block; font-size: 0.95rem; margin-bottom: 0.35rem; }

.imagebox { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-weight: 400; }
.imagebox img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--edge); background: var(--paper); }
.imageactions { display: grid; gap: 0.4rem; justify-items: start; }
.filebtn { position: relative; display: inline-flex !important; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; }
.filebtn:focus-within { outline: 3px solid var(--stamp); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  font: 600 0.95rem/1.2 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.primary { background: var(--honey); border-color: var(--honey-edge); color: var(--on-honey); }
.btn.primary:hover { background: var(--honey-edge); }
.btn.link { border: 0; padding: 0.25rem 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 400; }
.btn.link:hover { background: none; }
.btn.danger { color: var(--danger); }
.form > .btn { justify-self: start; }

/* ---------- gift list: hanging tags ---------- */
#listSection { margin-top: 3rem; }
.listhead { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.listhead h2 { margin: 0; font-size: 2rem; }
.listhead p { margin: 0; }
#listIntro { margin: 0.5rem 0 0; max-width: 40rem; }

.tags {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 2.25rem 1.5rem;
  /* the shadow sits on the list so it follows each tag's clipped shape */
  filter: drop-shadow(0 1px 0 var(--edge)) drop-shadow(0 8px 14px var(--shadow));
}

.tag {
  --notch: 22px;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--tag);
  padding: 2.1rem 1rem 1.1rem;
  clip-path: polygon(var(--notch) 0, calc(100% - var(--notch)) 0, 100% var(--notch), 100% 100%, 0 100%, 0 var(--notch));
  transform: rotate(var(--tilt, 0deg));
  transform-origin: 50% 0;
}
/* the punched hole */
.tag::before {
  content: '';
  position: absolute;
  top: 0.75rem;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 1px 2px var(--shadow);
}

.tagimg {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  margin-bottom: 0.9rem;
}
.tagimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { width: 100%; height: 100%; display: grid; place-items: center; font-size: 3rem; opacity: 0.7; }
.is-claimed .tagimg img, .is-claimed .placeholder { filter: grayscale(0.6) opacity(0.75); }

.stamp {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  text-align: center;
  font: 400 0.95rem/1.1 var(--serif);
  color: var(--stamp);
  background: color-mix(in srgb, var(--tag) 88%, transparent);
  border: 3px double var(--stamp);
  border-radius: 50%;
  transform: rotate(-14deg);
  padding: 0.4rem;
}
.stamp.thunk { animation: thunk 420ms cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes thunk {
  from { opacity: 0; transform: rotate(-24deg) scale(1.7); }
  to   { opacity: 1; transform: rotate(-14deg) scale(1); }
}

.tagbody { flex: 1; }
.tagbody p { margin: 0.3rem 0 0; }
.price { font-weight: 600; }
.note { color: var(--muted); font-size: 0.92rem; }
.itemlink { display: inline-block; margin-top: 0.5rem; font-size: 0.92rem; text-underline-offset: 3px; overflow-wrap: anywhere; }

.tagactions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; margin-top: 1rem; }
.tagactions .btn.primary { width: 100%; }
.tagactions .who { margin: 0; width: 100%; font-size: 0.92rem; color: var(--stamp); font-weight: 600; }

.empty {
  margin-top: 1.5rem;
  padding: 2rem;
  border: 2px dashed var(--edge);
  border-radius: 14px;
  color: var(--muted);
  max-width: 40rem;
}

/* ---------- dialog & toast ---------- */
dialog {
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--tag);
  color: var(--ink);
  padding: 1.5rem;
  width: min(26rem, calc(100vw - 2rem));
}
dialog::backdrop { background: rgba(18, 25, 37, 0.45); }
dialog h2 { margin-bottom: 0.25rem; }
.claimitem { margin: 0; color: var(--muted); }
.dialogactions { display: flex; justify-content: flex-end; gap: 0.75rem; }

#toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 1rem);
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  max-width: calc(100vw - 2rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms, transform 180ms;
  z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .stamp.thunk { animation: none; }
  #toast { transition: none; }
}

@media (max-width: 520px) {
  .tag { transform: none; }
  .tagimg { aspect-ratio: 16 / 10; }
  .copyfield { flex-direction: column; }
  .copyfield .btn { align-self: flex-start; }
}
[hidden] { display: none !important; }
