/*
  Confetti Birthday Parties (demo) - art direction
  Scene:   a craft table before a party. Cut paper, fat round shapes, and
           one invitation propped up in the middle. The colour of the room
           follows the invitation's own design.
  Palette: cream paper and near-black ink for everything that stays; one
           "theme" colour (--theme) that changes with the chosen design and
           fills the top of the page; sunny yellow for the main action.
  Type:    Secular One (chunky Hebrew display), Varela Round (soft text).
           The same two are painted onto the invitation.
  Shape:   very round, with a flat "sticker" shadow under everything pressable.
*/

:root {
  --theme: #1a1550;
  --paper: #fff8ec;
  --card: #ffffff;
  --ink: #23203a;
  --ink-soft: #5d5978;
  --line: rgba(35, 32, 58, 0.16);
  --sun: #ffc93c;
  --pink: #ff5a8a;
  --display: 'Secular One', 'Arial Black', sans-serif;
  --text: 'Varela Round', system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 3.5rem);
  --sticker: 0 5px 0 var(--ink);
}

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

html {
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--paper);
  scroll-padding-top: 4.5rem;
  scroll-padding-bottom: 9rem;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-x: hidden;
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
em { font-style: normal; }
fieldset { margin: 0; padding: 0; border: 0; min-inline-size: 0; }

:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ribbon-bar {
  position: sticky;
  top: 0;
  z-index: 6;
  padding: 0.4rem var(--gutter);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.875rem;
  text-align: center;
}
.ribbon-bar a:focus-visible { outline-color: var(--sun); }

.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1rem var(--gutter) 0;
  color: #fff;
}
.brand { opacity: 0.92; }
.brand strong { margin-inline-end: 0.4em; font-family: var(--display); font-weight: 400; font-size: 1.9rem; }
.lang { padding: 0.5rem 0; text-underline-offset: 0.3em; }
.top :focus-visible { outline-color: #fff; }

/* ---------- The invitation maker ---------- */

.maker-zone {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.6rem;
  margin-top: -4.4rem;
  padding: 6.2rem var(--gutter) 3rem;
  isolation: isolate;
}
/* The top of the page wears the colour of the chosen design, cut like paper. */
.maker-zone::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  block-size: min(34rem, 62%);
  background: var(--theme);
  transition: background-color 0.5s ease;
  clip-path: ellipse(120% 100% at 50% 0%);
}

.words { color: #fff; text-align: center; }
h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 7.5vw, 4.4rem);
  line-height: 1.05;
  text-wrap: balance;
}
h1 em { display: block; color: var(--sun); }
.words .lede { margin: 0.8rem auto 0; max-inline-size: 38ch; font-size: 1.125rem; }

/* The confetti layer is wider than the card; it must never widen the page. */
.card-col { display: grid; justify-items: center; gap: 1.1rem; overflow-x: clip; padding-inline: 0.6rem; }
.card-frame {
  position: relative;
  inline-size: min(100%, 24rem);
  rotate: -2deg;
}
.card-frame.is-fresh { animation: prop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes prop {
  from { rotate: 4deg; scale: 0.92; }
}
.card {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 1080 / 1350;
  border: 6px solid #fff;
  border-radius: 1.4rem;
  background: var(--theme);
  box-shadow: 0 10px 0 rgba(35, 32, 58, 0.18), 0 28px 50px rgba(35, 32, 58, 0.28);
}
.confetti {
  position: absolute;
  inset: -45% -40% -10%;
  inline-size: 180%;
  block-size: 155%;
  pointer-events: none;
}
.card-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem; }
.fallback { padding: 1.5rem; text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 3.2rem;
  padding: 0.5rem 1.8rem;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--sticker);
  font-family: var(--display);
  font-size: 1.125rem;
  text-decoration: none;
  cursor: pointer;
  transition: translate 0.1s ease, box-shadow 0.1s ease;
}
.btn-main { background: var(--sun); }
.btn:hover { translate: 0 -2px; box-shadow: 0 7px 0 var(--ink); }
.btn:active { translate: 0 4px; box-shadow: 0 1px 0 var(--ink); }
.btn[hidden] { display: none; }

.form { display: grid; gap: 1rem; align-content: start; }
.step {
  padding: 1.1rem 1.1rem 1.2rem;
  border: 2.5px solid var(--ink);
  border-radius: 1.4rem;
  background: var(--card);
  box-shadow: var(--sticker);
}
.step legend {
  float: inline-start;
  inline-size: 100%;
  margin-bottom: 0.8rem;
  padding: 0;
  font-family: var(--display);
  font-size: 1.35rem;
}
.step legend + * { clear: both; }
.step legend span {
  display: inline-grid;
  place-items: center;
  inline-size: 1.9rem;
  block-size: 1.9rem;
  margin-inline-end: 0.5rem;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 1rem;
}

.themes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
.theme {
  display: grid;
  gap: 0.25rem;
  justify-items: center;
  padding: 0.3rem 0.2rem 0.35rem;
  border: 2.5px solid transparent;
  border-radius: 0.9rem;
  background: transparent;
  font-size: 0.8125rem;
  line-height: 1.2;
  cursor: pointer;
  transition: translate 0.15s ease;
}
.theme span { max-inline-size: 100%; overflow-wrap: anywhere; }
.theme img {
  display: block;
  inline-size: 100%;
  block-size: auto;
  border-radius: 0.6rem;
  border: 2px solid var(--line);
}
.theme:hover { translate: 0 -3px; }
.theme[aria-pressed='true'] { border-color: var(--ink); background: #fff3c4; box-shadow: 0 4px 0 var(--ink); }

.field { display: grid; gap: 0.3rem; margin-top: 0.7rem; }
.field span, .counter-name { font-size: 0.9375rem; color: var(--ink-soft); }
.field input {
  inline-size: 100%;
  min-block-size: 3rem;
  padding: 0.5rem 1rem;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}
.hint { margin-top: 0.45rem; font-size: 0.9375rem; color: #b3261e; }
.field input[aria-invalid='true'] { border-color: #b3261e; }
@media (max-width: 26rem) {
  .theme { padding-inline: 0; font-size: 0.6875rem; }
}
.row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 0.6rem; }

.counter { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 0.6rem; margin-top: 0.9rem; }
.counter button {
  inline-size: 2.9rem;
  block-size: 2.9rem;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.counter button[aria-disabled='true'] { opacity: 0.35; cursor: not-allowed; }
.counter output { min-inline-size: 2.4rem; text-align: center; font-family: var(--display); font-size: 1.9rem; line-height: 1; }

/* ---------- The party ---------- */

.plan { padding: 3rem var(--gutter) 2.5rem; }
h2 { font-family: var(--display); font-weight: 400; line-height: 1.08; text-wrap: balance; }
.plan > h2 { font-size: clamp(2rem, 6.5vw, 3.6rem); }
.plan > h2 em { color: var(--pink); }
.plan .lede { margin-top: 0.6rem; max-inline-size: 44ch; color: var(--ink-soft); font-size: 1.125rem; }
.plan h3 { margin: 1.8rem 0 0.7rem; font-family: var(--display); font-weight: 400; font-size: 1.35rem; }

.packs { display: grid; gap: 0.8rem; margin-top: 1.6rem; }
.pack {
  display: grid;
  gap: 0.15rem;
  padding: 1rem 1.2rem 1.1rem;
  border: 2.5px solid var(--ink);
  border-radius: 1.4rem;
  background: var(--card);
  box-shadow: var(--sticker);
  text-align: start;
  cursor: pointer;
  transition: translate 0.1s ease, background-color 0.2s ease;
}
.pack strong { font-family: var(--display); font-weight: 400; font-size: 1.4rem; }
.pack span { color: var(--ink-soft); }
.pack b { margin-top: 0.3rem; font-family: var(--display); font-weight: 400; font-size: 1.5rem; color: #c2255c; }
.pack:hover { translate: 0 -2px; }
.pack[aria-pressed='true'] { background: #fff3c4; }
.pack[aria-pressed='true'] strong::after { content: ' ✓'; }

.slider {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.2rem 1rem;
  margin-top: 1.8rem;
  max-inline-size: 34rem;
}
.slider-q { font-family: var(--display); font-size: 1.35rem; }
.slider output { font-family: var(--display); font-size: 1.35rem; color: #c2255c; white-space: nowrap; }
.slider input { grid-column: 1 / -1; }
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 100%;
  block-size: 3rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track { block-size: 12px; border: 2.5px solid var(--ink); border-radius: 99px; background: var(--card); }
input[type='range']::-moz-range-track { block-size: 8px; border: 2.5px solid var(--ink); border-radius: 99px; background: var(--card); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  inline-size: 34px;
  block-size: 34px;
  margin-top: -14px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 3px 0 var(--ink);
}
input[type='range']::-moz-range-thumb { inline-size: 30px; block-size: 30px; border: 2.5px solid var(--ink); border-radius: 50%; background: var(--pink); box-shadow: 0 3px 0 var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chips button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-block-size: 3rem;
  padding: 0.35rem 1.1rem;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: translate 0.1s ease, background-color 0.2s ease;
}
.chips b { color: #c2255c; white-space: nowrap; }
.chips button:hover { translate: 0 -2px; }
.chips button[aria-pressed='true'] { background: #fff3c4; }
.chips button[aria-pressed='true']::before { content: '✓'; font-weight: 700; }

.summary {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 2rem calc(var(--gutter) * -1) 0;
  padding: 0.8rem var(--gutter) 1.1rem;
  border-top: 2.5px solid var(--ink);
  background: var(--paper);
}
.summary-line { font-weight: 700; }
.over { font-size: 0.9375rem; color: var(--ink-soft); }
.total { font-family: var(--display); font-size: 2.2rem; line-height: 1; }
.summary .btn { grid-column: 1 / -1; justify-self: start; }

/* ---------- Facts and footer ---------- */

.facts { display: grid; gap: 1rem; padding: 1rem var(--gutter) 3.5rem; }
.facts article { padding: 1.3rem 1.3rem 1.5rem; border: 2.5px solid var(--ink); border-radius: 1.4rem; background: var(--card); box-shadow: var(--sticker); }
.facts h2 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.facts p { color: var(--ink-soft); }

.foot {
  display: grid;
  gap: 1.5rem;
  justify-items: center;
  padding: 4rem var(--gutter) 5rem;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
}
.foot p { font-family: var(--display); font-size: clamp(1.6rem, 4.2vw, 2.5rem); line-height: 1.15; max-inline-size: 24ch; text-wrap: balance; }
.foot .btn { color: var(--ink); border-color: var(--paper); box-shadow: 0 5px 0 var(--pink); }
.foot .btn:hover { box-shadow: 0 7px 0 var(--pink); }
.foot :focus-visible { outline-color: var(--sun); }

/* ---------- Sheet ---------- */

dialog {
  inline-size: min(31rem, calc(100vw - 2rem));
  padding: 1.8rem;
  border: 2.5px solid var(--ink);
  border-radius: 1.6rem;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 8px 0 var(--ink);
}
dialog::backdrop { background: rgba(35, 32, 58, 0.62); }
dialog h2 { font-size: 1.6rem; }
.bubble {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border: 2.5px solid var(--ink);
  border-radius: 1.1rem;
  background: #e3f6ee;
  white-space: pre-line;
  text-align: start;
  overflow-wrap: anywhere;
}
.note { margin-bottom: 1.5rem; color: var(--ink-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }

@media (min-width: 40rem) {
  .packs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary { grid-template-columns: minmax(0, 1fr) auto auto; margin-inline: 0; padding-inline: 0; }
  .summary .btn { grid-column: auto; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 60rem) {
  .maker-zone {
    grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
    grid-template-areas: 'words words' 'card form';
    column-gap: 3.5rem;
    max-inline-size: 72rem;
    margin-inline: auto;
  }
  .words { grid-area: words; }
  /* Here the page itself keeps the confetti in, so it can fly past the column. */
  .card-col { grid-area: card; position: sticky; top: 4.6rem; align-self: start; overflow-x: visible; }
  .form { grid-area: form; }
  .maker-zone::before { inset-inline: calc(50% - 50vw); inline-size: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  .card-frame.is-fresh { animation: none; }
  .btn, .theme, .pack, .chips button { transition: none; }
  .btn:hover, .btn:active, .theme:hover, .pack:hover, .chips button:hover { translate: none; }
  .maker-zone::before { transition: none; }
}
