/* Secret Santa. Suite object language: paper sheets on a dotted table, tape, tags, chunky pressed buttons.
   Shape rule: sheets 16px, inputs 10px, buttons and chips full pill. One accent: cranberry. */
@layer reset, base, components, views;

@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque-400-800.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Kalam"; src: url("/fonts/kalam-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
  ul, ol { list-style: none; }
  fieldset { border: 0; min-width: 0; }
  button, input, select, textarea { font: inherit; color: inherit; }
  img, svg { display: block; max-width: 100%; }
  [hidden] { display: none !important; }
}

@layer base {
  :root {
    color-scheme: light dark;
    --table: #e9efe9;
    --dot: #c6d3ca;
    --paper: #fbfcf8;
    --paper-2: #f1f5f1;
    --ink: #15231d;
    --muted: #4a5a52;
    --line: #cfd9d2;
    --accent: #b42630;
    --accent-press: #84161e;
    --accent-ink: #fffafa;
    --accent-soft: #f7e3e4;
    --tape: rgb(240 225 170 / 0.8);
    --shadow: 0 1px 0 rgb(21 35 29 / 0.06), 0 10px 30px -12px rgb(21 35 29 / 0.28);
    --focus: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent);
    --r-sheet: 16px;
    --r-input: 10px;
    --font: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
    --hand: "Kalam", "Bricolage Grotesque", cursive;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --table: #0e1613;
      --dot: #1e2b25;
      --paper: #16211c;
      --paper-2: #1c2a24;
      --ink: #e5eee9;
      --muted: #a6b6ad;
      --line: #2c3c34;
      --accent: #ee6b72;
      --accent-press: #b8434b;
      --accent-ink: #1d0c0e;
      --accent-soft: #3a1d20;
      --tape: rgb(240 225 170 / 0.32);
      --shadow: 0 1px 0 rgb(0 0 0 / 0.3), 0 14px 34px -14px rgb(0 0 0 / 0.7);
    }
  }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
  body {
    min-height: 100dvh;
    display: flex; flex-direction: column;
    font-family: var(--font); font-size: 17px; line-height: 1.55; color: var(--ink);
    background-color: var(--table);
    background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px);
    background-size: 22px 22px;
    -webkit-font-smoothing: antialiased;
  }
  main { flex: 1; }
  a { color: var(--accent); text-underline-offset: 3px; }
  h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; font-weight: 750; text-wrap: balance; }
  h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); }
  h2 { font-size: clamp(1.45rem, 3.2vw, 1.9rem); }
  h3 { font-size: 1.15rem; }
  em { font-style: normal; color: var(--accent); }
  :focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
  .ico { width: 1.15em; height: 1.15em; flex: none; fill: currentColor; }
  .wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
  .narrow { width: min(680px, 100% - 24px); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .skip { position: absolute; left: 12px; top: -60px; z-index: 30; background: var(--paper); padding: 8px 14px; border-radius: 999px; }
  .skip:focus { top: 12px; }
}

@layer components {
  /* top bar */
  .top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px max(16px, calc((100% - 1120px) / 2)); background: color-mix(in srgb, var(--table) 86%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.1rem; color: var(--ink); text-decoration: none; min-height: 44px; }
  .brand .ico { color: var(--accent); width: 1.5em; height: 1.5em; }

  /* paper + tape */
  .paper { position: relative; background: var(--paper); border-radius: var(--r-sheet); box-shadow: var(--shadow); }
  .sheet { padding: clamp(20px, 4vw, 34px); }
  .sheet + .sheet { margin-top: 18px; }
  .tape { position: absolute; top: -11px; left: 50%; width: 92px; height: 24px; transform: translateX(-50%) rotate(-3deg);
    background: linear-gradient(180deg, rgb(255 255 255 / 0.25), transparent 40%), var(--tape);
    clip-path: polygon(0 8%, 4% 0, 8% 10%, 12% 0, 88% 0, 92% 10%, 96% 0, 100% 8%, 100% 92%, 96% 100%, 92% 90%, 88% 100%, 12% 100%, 8% 90%, 4% 100%, 0 92%); }
  .kicker { font-family: var(--hand); font-weight: 700; color: var(--accent); font-size: 1.25rem; line-height: 1.2; margin-bottom: 6px; }

  /* buttons: pill, chunky, pressed */
  .btn { --b: var(--accent); --bp: var(--accent-press); --bi: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
    border: 0; border-radius: 999px; background: var(--b); color: var(--bi); font-weight: 700; font-size: 1rem; text-decoration: none;
    white-space: nowrap; cursor: pointer; box-shadow: 0 4px 0 var(--bp); transform: translateY(0);
    transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease), background 0.2s; }
  .btn:hover { filter: brightness(1.05); }
  .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--bp); }
  .btn:disabled { opacity: 0.55; cursor: progress; }
  .btn-small { min-height: 44px; padding: 0 16px; font-size: 0.95rem; }
  .btn-big { min-height: 56px; padding: 0 30px; font-size: 1.1rem; }
  .btn-ghost { --b: var(--paper); --bp: var(--line); --bi: var(--ink); box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--line); }
  .btn-ghost:active { box-shadow: inset 0 0 0 2px var(--line), 0 1px 0 var(--line); }
  .btn-danger { --b: var(--accent-soft); --bp: var(--accent); --bi: var(--accent); }

  /* forms */
  fieldset + fieldset { margin-top: 26px; padding-top: 22px; border-top: 2px dashed var(--line); }
  legend { display: flex; align-items: baseline; gap: 10px; width: 100%; font-weight: 750; font-size: 1.15rem; margin-bottom: 12px; padding: 0; }
  .count { font-family: var(--hand); color: var(--accent); font-size: 1.05rem; }
  .field { display: grid; gap: 6px; margin-bottom: 16px; }
  label, .label { font-weight: 650; font-size: 0.97rem; }
  .opt { font-weight: 450; color: var(--muted); font-size: 0.88rem; }
  input, select, textarea { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-input); background: var(--paper);
    border: 2px solid var(--line); color: var(--ink); transition: border-color 0.15s; }
  input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--ink)); }
  input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--r-input); }
  textarea { resize: vertical; line-height: 1.45; }
  [aria-invalid="true"] { border-color: var(--accent); }
  .help { color: var(--muted); font-size: 0.92rem; }
  .err { color: var(--accent); font-weight: 650; font-size: 0.92rem; }
  .form-error { background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: var(--r-input); margin: 14px 0; font-weight: 600; }
  .row2 { display: grid; gap: 0 16px; grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 640px) { .row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
  .adder { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .adder .btn { min-height: 48px; }

  /* chips */
  .chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip { display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 14px; border-radius: 999px; background: var(--paper-2);
    box-shadow: inset 0 0 0 2px var(--line); font-weight: 600; animation: pop 0.25s var(--ease); max-width: 100%; }
  .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chip button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
  .chip button:hover { background: var(--accent-soft); color: var(--accent); }
  .empty { color: var(--muted); font-size: 0.95rem; font-style: italic; }
  @keyframes pop { from { transform: scale(0.85); opacity: 0; } }

  .apart-picker { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); align-items: center; }
  .amp { font-family: var(--hand); color: var(--muted); font-size: 1.1rem; text-align: center; }
  @media (min-width: 640px) { .apart-picker { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; } }
  .pairs { display: grid; gap: 8px; margin-top: 10px; }
  .pairs li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--paper-2); font-weight: 600; }
  .pairs li span { min-width: 0; flex: 1; }
  .pairs button { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
  .pairs button:hover { background: var(--accent-soft); color: var(--accent); }

  .submit-row { display: grid; gap: 10px; justify-items: start; margin-top: 26px; padding-top: 22px; border-top: 2px dashed var(--line); }

  /* meta chips */
  .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .meta li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--paper-2); font-weight: 600; font-size: 0.93rem; }
  .meta .ico { color: var(--accent); }

  /* the gift: wrapping paper that lifts off to reveal a tag */
  .gift { position: relative; overflow: hidden; border-radius: 14px; min-height: 230px; background: var(--paper-2); isolation: isolate; }
  .gift-inside { display: grid; align-content: center; justify-items: center; gap: 4px; min-height: inherit; padding: 28px 22px; text-align: center; }
  .gift-label { font-weight: 650; color: var(--muted); }
  .gift-name { font-family: var(--hand); font-weight: 700; font-size: clamp(2.6rem, 9vw, 3.6rem); line-height: 1.15; color: var(--accent); padding-bottom: 4px; overflow-wrap: anywhere; }
  .gift-wish { color: var(--ink); width: min(100%, 46ch); margin-top: 14px; text-align: left; overflow-wrap: anywhere; }
  .gift-wish:empty { display: none; }
  .gift-wish .wish-box { padding: 14px 16px; border-radius: var(--r-input); background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); white-space: pre-line; }
  .gift-wish .wish-title { display: block; font-family: var(--hand); font-weight: 700; color: var(--accent); font-size: 1.1rem; margin-bottom: 2px; white-space: normal; }
  .gift-wish .wish-empty { text-align: center; }
  .gift-wrap { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; border: 0; padding: 0; cursor: pointer; color: var(--accent-ink);
    background:
      linear-gradient(90deg, transparent calc(50% - 14px), #f3c74d calc(50% - 14px), #f3c74d calc(50% + 14px), transparent calc(50% + 14px)),
      linear-gradient(0deg, transparent calc(50% - 14px), #f3c74d calc(50% - 14px), #f3c74d calc(50% + 14px), transparent calc(50% + 14px)),
      repeating-linear-gradient(135deg, var(--accent) 0 22px, var(--accent-press) 22px 44px);
    transition: transform 0.75s var(--ease), opacity 0.75s var(--ease); }
  .gift-wrap:focus-visible { box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 7px var(--ink); border-radius: 14px; }
  .gift-tag { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 999px; background: var(--paper); color: var(--ink);
    font-weight: 750; font-size: 1.05rem; box-shadow: 0 4px 0 rgb(0 0 0 / 0.25); transform: rotate(-3deg); transition: transform 0.2s var(--ease); }
  .gift-tag .ico { color: var(--accent); }
  .gift-wrap:hover .gift-tag { transform: rotate(0deg) scale(1.04); }
  .gift-wrap:active .gift-tag { transform: rotate(0deg) scale(0.98); }
  .gift.is-open .gift-wrap { transform: translateY(-125%) rotate(-5deg); opacity: 0; pointer-events: none; }
  .gift.is-open .gift-name { animation: land 0.6s 0.25s var(--ease) both; }
  .gift.is-busy .gift-tag { animation: wiggle 0.5s ease-in-out infinite; }
  @keyframes land { from { transform: translateY(14px) scale(0.92); opacity: 0; } }
  @keyframes wiggle { 50% { transform: rotate(3deg); } }
  .gift-big { min-height: 300px; }
  .gift-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; margin-top: 16px; text-align: center; }
  .secret-hint { display: inline-flex; align-items: center; gap: 6px; }

  /* toast */
  .toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 40; transform: translateX(-50%);
    background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px; font-weight: 650; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

  /* loading skeletons */
  .loading { display: grid; gap: 14px; padding-top: 24px; }
  .skel { border-radius: 12px; background: linear-gradient(90deg, var(--paper-2), var(--paper), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
  .skel-title { height: 44px; width: 70%; }
  .skel-line { height: 18px; width: 45%; }
  .skel-block { height: 260px; }
  .skel-gift { height: 320px; }
  @keyframes shimmer { to { background-position: -200% 0; } }

  .notice { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; margin: 20px 0 22px; border-radius: var(--r-sheet);
    background: var(--accent-soft); border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
  .notice > .ico { color: var(--accent); margin-top: 3px; width: 1.4em; height: 1.4em; }
  .notice > div { flex: 1; min-width: 0; display: grid; gap: 10px; justify-items: start; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  }
}

@layer views {
  /* home */
  .hero { display: grid; gap: 40px; align-items: center; padding: clamp(24px, 6vw, 72px) 0 clamp(40px, 7vw, 88px); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 56px; } }
  .hero h1 { max-width: 13ch; }
  .lede { margin-top: 16px; font-size: 1.15rem; color: var(--muted); max-width: 40ch; }
  .hero-ctas { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 12px; }
  .demo-sheet { padding: 22px; transform: rotate(1.2deg); }
  .demo-hi { font-family: var(--hand); font-weight: 700; font-size: 1.2rem; margin-bottom: 12px; }
  .demo-foot { margin-top: 12px; color: var(--muted); font-size: 0.9rem; }

  .how { padding-bottom: clamp(40px, 7vw, 80px); }
  .how h2 { max-width: 22ch; }
  .tags { display: grid; gap: 22px; margin-top: 30px; grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 900px) { .tags { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; } }
  /* gift tags: clipped top corners + a punched hole; the shadow lives on the li so clip-path doesn't eat it */
  .tag { position: relative; filter: drop-shadow(0 8px 14px rgb(21 35 29 / 0.16)); }
  @media (prefers-color-scheme: dark) { .tag { filter: drop-shadow(0 10px 16px rgb(0 0 0 / 0.5)); } }
  .tag-body { position: relative; padding: 40px 24px 26px; background: var(--paper); border-radius: 0 0 var(--r-sheet) var(--r-sheet);
    clip-path: polygon(34px 0, calc(100% - 34px) 0, 100% 34px, 100% 100%, 0 100%, 0 34px); }
  .tag-body::before { content: ""; position: absolute; top: 14px; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 999px; background: var(--table); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 55%, var(--paper)); }
  .tag .ico { width: 30px; height: 30px; color: var(--accent); margin: 6px 0 10px; }
  .tag p { color: var(--muted); margin-top: 6px; }
  .tag-a { transform: rotate(-1.5deg); }
  .tag-b { transform: rotate(1deg); }
  .tag-c { transform: rotate(-0.8deg); }

  .create { width: min(760px, 100% - 24px); padding-bottom: clamp(48px, 8vw, 96px); }
  .create h2 { margin-bottom: 18px; }

  .faq { padding-bottom: clamp(48px, 8vw, 96px); }
  .faq-grid { display: grid; gap: 26px 40px; margin-top: 22px; grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 760px) { .faq-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
  .faq dt { font-weight: 750; font-size: 1.08rem; }
  .faq dd { color: var(--muted); margin-top: 4px; max-width: 52ch; }

  /* organizer */
  #view-organizer, #view-person, #view-error { padding: 12px 0 64px; }
  .org-head h1, .p-head h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); overflow-wrap: anywhere; }
  .org-note { margin-top: 14px; white-space: pre-line; color: var(--ink); }
  .progress { margin-top: 16px; font-weight: 650; }
  .progress strong { color: var(--accent); }
  .people { display: grid; gap: 10px; margin-top: 18px; }
  .person { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--paper-2); grid-template-columns: minmax(0, 1fr); }
  .person-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
  .person-name { font-weight: 750; font-size: 1.08rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .state { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
    background: var(--paper); color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }
  .state.is-opened { background: var(--accent); color: var(--accent-ink); box-shadow: none; transform: rotate(-2deg); }
  .person-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .person-actions .btn { flex: 1 1 auto; }
  .person-remove { width: 44px; padding: 0; flex: none !important; }
  @media (min-width: 640px) {
    .person { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
    .person-actions .btn { flex: none; }
  }
  .locked { display: flex; gap: 10px; align-items: flex-start; background: var(--paper-2); padding: 12px 14px; border-radius: var(--r-input); margin-bottom: 14px; font-weight: 600; }
  #org-editors { margin-top: 14px; }
  .edit-details { margin-top: 14px; border-top: 2px dashed var(--line); padding-top: 12px; }
  .edit-details summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 700; list-style: none; }
  .edit-details summary::-webkit-details-marker { display: none; }
  .edit-details summary .ico { color: var(--accent); }
  .edit-details[open] summary { margin-bottom: 10px; }
  .edit-details .help { margin-bottom: 12px; }

  /* participant */
  .p-head { padding: 18px 4px 22px; }
  .p-gift-sheet { padding: clamp(14px, 3vw, 22px); }
  #p-note { white-space: pre-line; }
  #p-note::before { content: "From your organizer"; display: block; font-family: var(--hand); font-weight: 700; color: var(--accent); font-size: 1.1rem; margin-bottom: 4px; }
  #wish-form h2 { margin-bottom: 6px; }
  #wish-form textarea { margin-top: 12px; }
  .wish-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 12px; }
  .status { color: var(--muted); font-weight: 600; font-size: 0.93rem; }
  .wish-empty { color: var(--muted); font-style: italic; }

  .big-ico { width: 44px; height: 44px; color: var(--accent); margin-bottom: 12px; }
  #view-error h1 { font-size: 1.8rem; margin-bottom: 8px; }
  #view-error p { color: var(--muted); margin-bottom: 18px; }

  .foot { padding: 28px 0 36px; color: var(--muted); font-size: 0.92rem; border-top: 2px dashed var(--line); }
}
