/* ============================================================
   Sunday Assembly Potluck
   Visual direction: a card table. Felt underneath, card stock
   on top, and a deck that visibly thins as it gets picked over.
   ============================================================ */

:root {
  /* Palette */
  --felt:       #164034;
  --felt-deep:  #0E2A22;
  --felt-edge:  #081912;
  --stock:      #F6F1E4;
  --stock-2:    #E8E0C9;
  --stock-3:    #D3C9AE;
  --ink:        #1B1A16;
  --ink-soft:   #55524A;
  --suit:       #B23A2E;
  --brass:      #D7A94F;

  /* Type */
  --display: 'Bricolage Grotesque', 'Helvetica Neue', system-ui, sans-serif;
  --body:    'Newsreader', Georgia, 'Times New Roman', serif;
  --util:    'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Rhythm */
  --gap:    clamp(1.25rem, 3vw, 2rem);
  --radius: 10px;
  --lift:   0 14px 34px rgba(0, 0, 0, .38);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: clamp(1rem, .96rem + .2vw, 1.075rem);
  line-height: 1.6;
  color: var(--stock);
  background:
    radial-gradient(120% 85% at 50% 0%, var(--felt) 0%, var(--felt-deep) 58%, var(--felt-edge) 100%)
    var(--felt-deep);
  background-attachment: fixed;
}

/* Woven felt texture, kept very faint. */
.felt-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,.014) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.05)        0 1px, transparent 1px 3px);
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.1rem, 4vw, 2.5rem) 4rem;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

a { color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--stock); }

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


/* ------------------------------------------------------------
   Masthead
   ------------------------------------------------------------ */

.masthead { margin-bottom: clamp(2.25rem, 6vw, 3.5rem); }

.eyebrow {
  margin: 0 0 .9rem;
  font-family: var(--util);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brass);
}

.masthead__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.5rem, 8vw, 4.75rem);
  line-height: .95;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.masthead__meta {
  margin: 1rem 0 0;
  font-size: 1.1rem;
  color: var(--stock-3);
}
.masthead__meta span { color: var(--stock); }
.masthead__meta .sep { color: var(--brass); padding: 0 .5rem; }

.masthead__note {
  margin: .6rem 0 0;
  max-width: 42ch;
  font-style: italic;
  color: var(--stock-3);
}
.masthead__note:empty { display: none; }


/* ------------------------------------------------------------
   The deck — signature element
   ------------------------------------------------------------ */

.deck-stage {
  padding: clamp(1.6rem, 4vw, 2.5rem);
  border: 1px solid rgba(215, 169, 79, .22);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .16);
}

.deck-stage__inner {
  display: grid;
  gap: clamp(1.75rem, 5vw, 3rem);
  align-items: center;
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
}

@media (min-width: 46rem) {
  .deck-stage__inner {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
    justify-items: start;
    text-align: left;
  }
}

/* Stage that holds the stack and the one live card */
.deck {
  position: relative;
  width: min(14rem, 62vw);
  aspect-ratio: 5 / 7;
  perspective: 1400px;
}

/* Stacked card backs behind the live card. JS adds one layer per
   few remaining cards, so the pile literally gets thinner. */
.deck__stack { position: absolute; inset: 0; }

.deck__layer {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--stock-2), var(--stock-3));
  border: 1px solid rgba(0, 0, 0, .2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .3) inset;
  transform: translate(var(--x), var(--y)) rotate(var(--r));
}

.card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .62s cubic-bezier(.2, .75, .3, 1);
  cursor: pointer;
  will-change: transform;
}

.card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--lift);
  text-align: center;
}

/* Back: cross-hatch, the way a deck's back always looks */
.card__face--back {
  background:
    repeating-linear-gradient(45deg,  rgba(178, 58, 46, .5) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(178, 58, 46, .5) 0 2px, transparent 2px 7px),
    var(--stock);
  border: 1px solid var(--stock-3);
}

.card__crest {
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  background: var(--stock);
  border: 2px solid var(--suit);
  color: var(--suit);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: .02em;
}

/* Front: what you're bringing */
.card__face--front {
  transform: rotateY(180deg);
  background: var(--stock);
  border: 1px solid var(--stock-3);
  color: var(--ink);
  justify-content: center;
  gap: .3rem;
}

.card__corner {
  position: absolute;
  color: var(--suit);
  font-size: .95rem;
  line-height: 1;
}
.card__corner--tl { top: .7rem; left: .8rem; }
.card__corner--br { bottom: .7rem; right: .8rem; transform: rotate(180deg); }

.card__label {
  margin: 0;
  font-family: var(--util);
  font-size: .62rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.card__category {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.4rem, 5.5vw, 1.85rem);
  line-height: 1.02;
  letter-spacing: -.025em;
  text-wrap: balance;
  color: var(--ink);
}

.card__hint {
  margin: .35rem 0 0;
  font-size: .82rem;
  line-height: 1.35;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* Draw animation states */
.card.is-lifting { transform: translateY(-10%) scale(1.03); }
.card.is-flipped { transform: rotateY(180deg); }
.card.is-flipped.is-lifting { transform: translateY(-10%) scale(1.03) rotateY(180deg); }
.card.is-empty { opacity: .32; cursor: default; }

/* Call to action beside the deck */
.deck-call { width: 100%; }

.deck-count {
  margin: 0 0 .85rem;
  display: flex;
  align-items: baseline;
  gap: .55rem;
  justify-content: center;
}
@media (min-width: 46rem) { .deck-count { justify-content: flex-start; } }

.deck-count__num {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  line-height: 1;
  letter-spacing: -.04em;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}

.deck-count__word {
  font-family: var(--util);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--stock-3);
}

.deck-call__sub {
  margin: .9rem 0 0;
  max-width: 34ch;
  color: var(--stock-3);
  font-size: .96rem;
}


/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */

.btn {
  display: inline-block;
  padding: .82rem 1.5rem;
  border: 0;
  border-radius: 6px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: transform .12s ease, background-color .18s ease, color .18s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn--draw {
  background: var(--brass);
  color: var(--ink);
  padding: .95rem 1.9rem;
  font-size: 1.08rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.btn--draw:hover:not([disabled]) { background: #E8BC63; }

.btn--primary { background: var(--stock); color: var(--ink); }
.btn--primary:hover:not([disabled]) { background: #FFFDF5; }

.btn--quiet {
  background: transparent;
  color: var(--stock-3);
  box-shadow: inset 0 0 0 1px rgba(246, 241, 228, .25);
}
.btn--quiet:hover { color: var(--stock); box-shadow: inset 0 0 0 1px rgba(246, 241, 228, .55); }

.btn--tiny {
  padding: .35rem .7rem;
  font-size: .78rem;
  background: transparent;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px rgba(27, 26, 22, .22);
}
.btn--tiny:hover { color: var(--suit); box-shadow: inset 0 0 0 1px var(--suit); }


/* ------------------------------------------------------------
   Signup form
   ------------------------------------------------------------ */

.signup {
  margin-top: var(--gap);
  padding: clamp(1.4rem, 4vw, 2.25rem);
  border-radius: var(--radius);
  background: var(--stock);
  color: var(--ink);
  box-shadow: var(--lift);
}

.signup__head { margin-bottom: 1.4rem; }

.signup__holding {
  margin: .4rem 0 0;
  font-family: var(--util);
  font-size: .78rem;
  letter-spacing: .04em;
  color: var(--suit);
}
.signup__holding:empty { display: none; }

.signup .section-title { color: var(--ink); }

.field { margin-bottom: 1.15rem; border: 0; padding: 0; }

.field label,
.field legend {
  display: block;
  margin-bottom: .4rem;
  padding: 0;
  font-family: var(--util);
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.opt { text-transform: none; letter-spacing: .02em; opacity: .7; font-style: italic; }

.field input[type="text"] {
  width: 100%;
  padding: .78rem .9rem;
  font-family: var(--body);
  font-size: 1.05rem;
  color: var(--ink);
  background: #FFFDF6;
  border: 1px solid var(--stock-3);
  border-radius: 5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--suit);
  box-shadow: 0 0 0 3px rgba(178, 58, 46, .14);
}
.field input::placeholder { color: #A79E88; }

.tags { display: flex; flex-wrap: wrap; gap: .5rem; }

.tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: .4rem .8rem;
  border-radius: 999px;
  font-family: var(--util);
  font-size: .76rem;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--stock-3);
  transition: color .15s ease, box-shadow .15s ease, background-color .15s ease;
  user-select: none;
}
.tag input { position: absolute; opacity: 0; pointer-events: none; }
.tag:hover { box-shadow: inset 0 0 0 1px var(--ink-soft); }

/* .is-on is set by script; the :has() rule is the same thing for browsers
   that support it. Either one alone is enough. */
.tag.is-on,
.tag:has(input:checked) {
  background: var(--ink);
  color: var(--stock);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.tag:has(input:focus-visible) { outline: 2px solid var(--suit); outline-offset: 2px; }
.tag.is-focus { outline: 2px solid var(--suit); outline-offset: 2px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
  margin-top: 1.6rem;
}
.form-actions .btn--quiet { color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--stock-3); }
.form-actions .btn--quiet:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-soft); }

.form-msg {
  margin: .9rem 0 0;
  font-family: var(--util);
  font-size: .8rem;
  line-height: 1.5;
  color: var(--suit);
}
.form-msg:empty { display: none; }

/* Honeypot */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}


/* ------------------------------------------------------------
   Section furniture
   ------------------------------------------------------------ */

.table-section,
.needed-section { margin-top: clamp(2.5rem, 7vw, 4rem); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .7rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid rgba(246, 241, 228, .18);
}

.section-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  letter-spacing: -.03em;
}

.section-count {
  margin: 0;
  font-family: var(--util);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brass);
  white-space: nowrap;
}

.empty {
  margin: 0;
  padding: 1.6rem 0;
  color: var(--stock-3);
  font-style: italic;
}


/* ------------------------------------------------------------
   Dishes on the table
   ------------------------------------------------------------ */

.dishes {
  display: grid;
  gap: .9rem;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
}

.dish {
  position: relative;
  padding: 1.1rem 1.15rem 1.15rem;
  border-radius: 8px;
  background: var(--stock);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .26);
}

.dish--mine { box-shadow: 0 4px 14px rgba(0, 0, 0, .26), inset 0 0 0 2px var(--brass); }

.dish__cat {
  margin: 0 0 .5rem;
  font-family: var(--util);
  font-size: .64rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--suit);
}
.dish__cat--free { color: var(--ink-soft); }

.dish__dish {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.22rem;
  line-height: 1.15;
  letter-spacing: -.02em;
  text-wrap: pretty;
}

.dish__who {
  margin: .35rem 0 0;
  font-size: .95rem;
  color: var(--ink-soft);
}

.dish__note {
  margin: .55rem 0 0;
  font-size: .87rem;
  font-style: italic;
  color: var(--ink-soft);
}

.dish__flags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .65rem;
}

.flag {
  padding: .17rem .5rem;
  border-radius: 999px;
  font-family: var(--util);
  font-size: .63rem;
  letter-spacing: .05em;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--stock-3);
}

.dish__tools { margin-top: .85rem; display: flex; gap: .45rem; }


/* ------------------------------------------------------------
   Still needed
   ------------------------------------------------------------ */

.needed { list-style: none; margin: 0; padding: 0; }

.need {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px dotted rgba(246, 241, 228, .16);
}
.need:last-child { border-bottom: 0; }

.need__name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -.015em;
}

.need__pips {
  display: flex;
  gap: .28rem;
  margin-left: auto;
  flex-shrink: 0;
}

.pip {
  width: .58rem;
  height: .82rem;
  border-radius: 2px;
  background: var(--brass);
}
.pip--gone { background: transparent; box-shadow: inset 0 0 0 1px rgba(246, 241, 228, .3); }

.need__tally {
  font-family: var(--util);
  font-size: .72rem;
  color: var(--stock-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}


/* ------------------------------------------------------------
   Footer + toast
   ------------------------------------------------------------ */

.foot {
  margin-top: clamp(3rem, 8vw, 5rem);
  padding-top: 1.4rem;
  border-top: 1px solid rgba(246, 241, 228, .14);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem;
  font-family: var(--util);
  font-size: .72rem;
  color: var(--stock-3);
}
.foot p { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translate(-50%, 130%);
  max-width: min(30rem, calc(100vw - 2rem));
  padding: .8rem 1.2rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--stock);
  font-family: var(--util);
  font-size: .82rem;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  transition: transform .35s cubic-bezier(.2, .8, .3, 1);
  z-index: 50;
}
.toast.is-up { transform: translate(-50%, 0); }
.toast.is-bad { background: var(--suit); }


/* ------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------ */

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