/*
  Aleh Flower Shop (demo) - art direction
  Scene:   a florist's workbench in morning light. Quiet, so the flowers
           are the only loud thing on the page.
  Palette: warm paper ground, deep leaf green for text and lines,
           one terracotta for the main action. Flower colours come from
           the bouquet itself.
  Type:    Bellefair (display serif, Hebrew + Latin), Heebo (text),
           Amatic SC for the handwritten card only.
  Shape:   fine hairlines, almost square corners, generous white space.
*/

:root {
  --paper: #f4efe4;
  --card: #fffdf8;
  --leaf: #20392c;
  --leaf-soft: #5c7265;
  --line: rgba(32, 57, 44, 0.22);
  --sage: #dfe8dc;
  --clay: #a34526;
  --display: 'Bellefair', 'Times New Roman', serif;
  --text: 'Heebo', system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 3.5rem);
}

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

html {
  background: var(--paper);
  /* Room for the sticky summary, so a focused field is never hidden under it. */
  scroll-padding-bottom: 11rem;
  /* And for the sticky demo ribbon at the top. */
  scroll-padding-top: 5rem;
}

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

h1, h2, p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--leaf);
  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(--leaf);
  color: var(--paper);
  font-size: 0.875rem;
  text-align: center;
}
.ribbon-bar a:focus-visible { outline-color: var(--paper); }

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.25rem var(--gutter) 0;
}
.brand { color: var(--leaf-soft); }
.brand strong {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--leaf);
  margin-inline-end: 0.3em;
}
.lang { padding: 0.5rem 0; text-underline-offset: 0.3em; }

/* Workbench */
.bench {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  padding: 1.5rem var(--gutter) 3rem;
}

.show { text-align: center; }

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.3rem, 8vw, 4.25rem);
  line-height: 1.04;
  text-wrap: balance;
}
.lede {
  margin: 0.9rem auto 0;
  max-width: 34ch;
  color: var(--leaf-soft);
}

.bouquet {
  position: relative;
  inline-size: min(100%, 27rem);
  margin: 1rem auto 0;
  aspect-ratio: 400 / 460;
  animation: sway 7s ease-in-out infinite alternate;
  transform-origin: 50% 92%;
  /* Keeps the sage disc behind the bouquet even when nothing is animating. */
  isolation: isolate;
}
.bouquet::before {
  content: '';
  position: absolute;
  inset: 3% 4% 14%;
  border-radius: 50%;
  background: var(--sage);
  z-index: -1;
}
@keyframes sway {
  from { transform: rotate(-1.2deg); }
  to { transform: rotate(1.2deg); }
}
.bouquet-svg { display: block; inline-size: 100%; block-size: 100%; overflow: visible; }

.stem { cursor: pointer; }
.stem .grow { transform-box: fill-box; transform-origin: center; }
.stem.is-new .grow { animation: grow 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) backwards; }
/* Taps go through the paper, card and butterfly to the flowers under them. */
.paper-front, .paper-back, .card, .butterfly, .ribbon { pointer-events: none; }
@keyframes grow {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}
.stem:hover .grow { transform: scale(1.08); transition: transform 0.15s ease; }

.card text {
  unicode-bidi: plaintext;
  font-family: 'Amatic SC', var(--display);
  font-weight: 700;
  font-size: 21px;
  fill: var(--leaf);
}

.flutter {
  transform-box: fill-box;
  transform-origin: center;
  animation: flutter 0.28s ease-in-out infinite alternate;
}
@keyframes flutter {
  from { transform: scaleX(1); }
  to { transform: scaleX(0.35); }
}
.butterfly { animation: drift 5s ease-in-out infinite alternate; }
@keyframes drift {
  from { translate: 0 0; }
  to { translate: 26px -14px; }
}

.tip { margin-top: 0.25rem; font-size: 0.9375rem; color: var(--leaf-soft); }
.fallback { padding: 2rem; border: 1px solid var(--line); }

/* Builder */
.builder { display: grid; gap: 0; }

.step {
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}
.step h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.6rem;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.step h2 span {
  font-family: var(--text);
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
  color: var(--clay);
  margin-inline-end: 0.6em;
}
.step-note { font-size: 0.9375rem; color: var(--leaf-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1.25rem; }
.chips button {
  min-height: 2.75rem;
  padding: 0.35rem 1rem;
  border: 1px solid var(--leaf);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.chips button:hover { background: var(--sage); }
.chips button[aria-pressed='true'] { background: var(--leaf); color: var(--paper); }

.buckets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.75rem, 1fr));
  gap: 0.6rem;
}
.bucket {
  position: relative;
  display: grid;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
}
.bucket-add {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  padding: 0.6rem 0.4rem 0.5rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: center;
}
.bucket-add svg {
  inline-size: 4rem;
  block-size: 4rem;
  overflow: visible;
  transition: transform 0.2s ease;
}
.bucket-add:hover svg { transform: translateY(-3px) rotate(-4deg); }
.bucket-add[aria-disabled='true'] { cursor: not-allowed; opacity: 0.5; }
.bucket-name { font-weight: 500; line-height: 1.2; }
.bucket-price { font-size: 0.875rem; color: var(--leaf-soft); }
.bucket-less {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--sage);
  cursor: pointer;
  font-weight: 500;
}
.bucket-less[hidden] { display: none; }
.bucket-less b {
  display: inline-grid;
  place-items: center;
  min-inline-size: 1.5rem;
  block-size: 1.5rem;
  padding-inline: 0.3rem;
  border-radius: 999px;
  background: var(--leaf);
  color: var(--paper);
  font-size: 0.875rem;
}
.full { margin-top: 0.75rem; color: var(--clay); font-weight: 500; }
.full[hidden] { display: none; }

.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatches + .swatches { margin-top: 0.75rem; }
.swatches button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding-block: 0.3rem;
  padding-inline: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}
.swatches button i {
  inline-size: 1.9rem;
  block-size: 1.9rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--swatch);
}
.swatches button[aria-pressed='true'] { border-color: var(--leaf); box-shadow: inset 0 0 0 1px var(--leaf); }

.field { display: grid; gap: 0.4rem; margin-bottom: 0.5rem; }
.field span { font-weight: 500; }
.field textarea,
.field input {
  min-height: 3rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
  resize: vertical;
}
.field input { max-inline-size: 16rem; }
.field ::placeholder { color: #5f7367; }

.summary {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-inline: calc(var(--gutter) * -1);
  padding: 0.9rem var(--gutter) 1rem;
  border-top: 1px solid var(--leaf);
  background: var(--paper);
}
.summary-line span { color: var(--leaf-soft); margin-inline-start: 0.4em; }
.total {
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1;
}
.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.6rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--leaf);
  border-radius: 3px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.btn-main { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn-main:hover { background: var(--leaf); border-color: var(--leaf); }
.btn-main:disabled { background: transparent; border-color: var(--line); color: var(--leaf-soft); cursor: not-allowed; }
.btn-quiet { background: transparent; color: var(--leaf); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--leaf); }

/* Facts and footer */
.facts {
  display: grid;
  padding: 0 var(--gutter);
  border-top: 1px solid var(--line);
}
.facts article { padding: 2rem 0; border-bottom: 1px solid var(--line); }
.facts h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}
.facts p { color: var(--leaf-soft); max-width: 36ch; }

.foot {
  display: grid;
  gap: 1.5rem;
  justify-items: center;
  padding: 4rem var(--gutter) 5rem;
  text-align: center;
}
.foot p {
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.15;
  max-width: 24ch;
  text-wrap: balance;
}

/* Order sheet */
dialog {
  width: min(31rem, calc(100vw - 2rem));
  padding: 2rem;
  border: 1px solid var(--leaf);
  border-radius: 3px;
  background: var(--card);
  color: var(--leaf);
}
dialog::backdrop { background: rgba(32, 57, 44, 0.55); }
dialog h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1.2; }
.bubble {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border-radius: 3px;
  background: var(--sage);
  white-space: pre-line;
  text-align: start;
  overflow-wrap: anywhere;
}
.note { margin-bottom: 1.5rem; color: var(--leaf-soft); }

@media (min-width: 62rem) {
  .bench {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 4rem;
    align-items: start;
    padding-block: 2rem 4rem;
  }
  .show {
    position: sticky;
    top: 4.5rem;
    text-align: start;
  }
  .lede { margin-inline: 0; }
  .bouquet { inline-size: min(100%, 30rem); }
  .tip { text-align: center; }
  .summary { margin-inline: 0; padding-inline: 0; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts article { padding-block: 2.5rem 3rem; padding-inline: 0 2rem; border-bottom: 0; }
  .facts article + article { padding-inline-start: 2rem; border-inline-start: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .bouquet,
  .stem.is-new .grow,
  .flutter,
  .butterfly { animation: none; }
  .stem:hover .grow,
  .bucket-add:hover svg { transform: none; }
  .btn, .chips button, .bucket-add svg { transition: none; }
}
