/* ==========================================================================
   Viola — Reusable components
   ========================================================================== */

/* ---- Buttons ---- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.85em 2em;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--fs-sm);
  transition: transform var(--dur-fast) var(--ease-bounce), box-shadow var(--dur-fast) var(--ease-brand), background var(--dur-fast) var(--ease-brand), color var(--dur-fast) var(--ease-brand);
}

.btn--primary {
  background: var(--button-bg);
  color: var(--button-text);
  box-shadow: 0 10px 26px -10px rgba(126, 57, 115, 0.55);
}

.btn--primary:hover {
  background: var(--button-bg-hover);
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 18px 30px -10px rgba(126, 57, 115, 0.55);
}

.btn--outline {
  border: 2.5px solid var(--button-outline-border);
  color: var(--color-brand-primary);
  background: transparent;
}

.btn--outline:hover {
  background: var(--color-brand-primary);
  color: var(--color-text-inverse);
  transform: translateY(-3px) rotate(1deg);
}

.btn--light {
  background: var(--color-surface);
  color: var(--color-brand-primary);
  box-shadow: 0 10px 26px -12px rgba(27, 8, 22, 0.5);
}

.btn--light:hover {
  background: var(--color-brand-tint);
  transform: translateY(-3px);
}

.btn:active {
  transform: translateY(0) scale(0.96);
}

/* DS interaction model: hover lightened above, press darkens */
.btn--primary:active {
  background: var(--button-bg-active);
}

.btn--lg {
  padding: 1em 2.6em;
  font-size: var(--fs-base);
}

/* ---- Eyebrow chip + section heading ---- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--color-brand-primary);
  background: var(--chip-bg);
  border: 1.5px solid var(--color-brand-tint);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  margin-block-end: var(--space-3);
}

.eyebrow::before {
  content: "";
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--color-brand-primary);
}

.section-heading {
  text-align: center;
  max-width: 640px;
  margin-inline: auto;
  margin-block-end: var(--space-5);
}

.section-heading h2 {
  font-size: var(--fs-2xl);
  line-height: 1.35;
}

.section-heading p {
  margin-block-start: var(--space-2);
  color: var(--color-text-muted);
}

/* ---- Shared page hero (about / products / blog / contact) ---- */
.page-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding-block: var(--space-6) var(--space-5);
  /* DS: flat surfaces only — no gradients */
}

.page-hero__inner {
  position: relative;
  max-width: 720px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.page-hero h1 {
  font-size: var(--fs-3xl);
}

/* Headings are brand purple now (base.css); the accent span pops via the
   decorative outline cut instead of a color swap — DS-sanctioned display use */
.page-hero h1 .accent {
  font-family: var(--font-fa-outline);
}

.page-hero p {
  margin-block-start: var(--space-3);
  color: var(--color-text-muted);
  max-width: 56ch;
  margin-inline: auto;
}

.page-hero__mascot {
  inline-size: 96px;
  margin-inline: auto;
  margin-block-end: var(--space-3);
}

/* ---- Card ---- */
.card {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-brand), box-shadow var(--dur-base) var(--ease-brand), border-color var(--dur-base) var(--ease-brand);
}

.card:hover {
  transform: translateY(-8px);
  border-color: var(--color-brand-tint);
  box-shadow: var(--card-shadow-hover);
}

/* ---- Branded media fallback (no photo yet → mascot on pattern) ---- */
.media-fallback {
  position: relative;
  inline-size: 100%;
  block-size: 100%;
  display: grid;
  place-items: center;
  background-color: var(--color-surface-alt);
  background-image: var(--pattern-url);
  background-size: 240px auto;
  background-blend-mode: normal;
}

.media-fallback::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(250, 243, 249, 0.88);
}

.media-fallback img {
  position: relative;
  inline-size: 45%;
  max-block-size: 70%;
  object-fit: contain;
  transition: transform var(--dur-base) var(--ease-bounce);
}

.card:hover .media-fallback img {
  transform: scale(1.12) rotate(-3deg);
}

/* ---- Product card ---- */
.product-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--color-surface-alt);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-card__media > img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-brand), opacity var(--dur-base) ease;
}

.card:hover .product-card__media > img {
  transform: scale(1.06);
}

/* Hover shot (<name>2.png, client convention 2026-07-11): stacked on the
   main photo. On hover the MAIN photo fades OUT and only the hover shot
   stays (client 2026-07-14 — transparent PNGs showed both stacked at once).
   :has() guard: only hide the main img while its hover twin actually exists
   (the twin removes itself onerror → cards without a 2-file keep the photo). */
.card:hover .product-card__media > img:has(+ .product-card__img-alt) {
  opacity: 0;
}

.product-card__img-alt {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--dur-base) ease, transform var(--dur-slow) var(--ease-brand);
}

.card:hover .product-card__img-alt {
  opacity: 1;
}

.product-card__price {
  margin-block-start: var(--space-2);
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--color-brand-primary);
}

.product-card__body {
  padding: var(--space-4);
}

.product-card__category {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--chip-text);
  margin-block-end: var(--space-1);
}

.product-card__name {
  font-size: var(--fs-md);
}

.product-card__desc {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin-block-start: var(--space-2);
  line-height: 1.75;
}

.product-card__badge {
  display: inline-block;
  margin-block-start: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--color-brand-primary);
  color: var(--color-text-inverse);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
}

/* ---- Category tabs (products page) ---- */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-block-end: var(--space-5);
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-brand-tint);
  background: var(--color-surface);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  transition: background var(--dur-fast) var(--ease-brand), color var(--dur-fast) var(--ease-brand), border-color var(--dur-fast) var(--ease-brand), transform var(--dur-fast) var(--ease-bounce);
}

.category-tab img {
  inline-size: 30px;
  block-size: 30px;
  object-fit: contain;
  transition: transform var(--dur-fast) var(--ease-bounce);
}

.category-tab:hover {
  transform: translateY(-2px);
  border-color: var(--color-brand-tertiary);
  color: var(--color-brand-primary);
}

.category-tab:hover img {
  transform: rotate(-8deg) scale(1.15);
}

.category-tab[aria-selected="true"] {
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  color: var(--color-text-inverse);
}

.category-tab[aria-selected="true"] img {
  filter: brightness(0) invert(1);
}

/* ==========================================================================
   Promo banner slots (client 2026-07-11: "the site needs more soul").
   Every slot points at a FIXED filename in assets/images/banners/ and
   self-activates the moment the client uploads that file; while the file
   is missing, onerror hides the slot (or reveals the old mascot fallback),
   so nothing ever looks broken. Export sizes are 2× the layout box:
     home-about.png        1160 × 870   (4:3   — home, beside "درباره ویولا")
     home-cat-big-cookie.png / home-cat-side-cookie.png / home-cat-bread.png
                            760 × 475   (16:10 — home category cards)
     products-big-cookie.png / products-side-cookie.png / products-bread.png
                           2360 × 520   (~4.5:1 — wide strip per category)
     about-story.png       1160 × 870   (4:3   — about page, story section)
     contact-side.png      1160 × 650   (16:9  — contact page, above the map)
   ========================================================================== */
.promo-banner {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
}

/* slots ship hidden and only appear after their image really loads — the
   explicit display rules below must not beat the hidden attribute */
.promo-banner[hidden],
.category-card__banner[hidden],
.category-section__banner[hidden] {
  display: none;
}

.promo-banner img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-brand);
}

.promo-banner:hover img {
  transform: scale(1.03);
}

.promo-banner--about,
.promo-banner--story { aspect-ratio: 4 / 3; }

.promo-banner--contact {
  aspect-ratio: 16 / 9;
  margin-block-end: var(--space-4);
}

/* ---- Flavor chip ---- */
.chip {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--chip-bg);
  color: var(--chip-text);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
}

/* ---- Category card (home) ---- */
.category-card {
  position: relative;
  text-align: center;
  padding: var(--space-5) var(--space-4);
  overflow: visible;
}

/* Promo banner inside the card (home-cat-<id>.png, 760×475). When it loads,
   products.js stamps .has-banner on the card and the mascot steps aside;
   while the file is missing the banner removes itself and the mascot stays. */
.category-card__banner {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin-block-end: var(--space-3);
}

.category-card__banner img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-brand);
}

.category-card:hover .category-card__banner img {
  transform: scale(1.05);
}

.category-card.has-banner .category-card__mascot {
  display: none;
}

.category-card__mascot {
  inline-size: 170px;
  block-size: 170px;
  margin-inline: auto;
  margin-block-end: var(--space-3);
  object-fit: contain;
  transition: transform var(--dur-base) var(--ease-bounce);
}

.category-card:hover .category-card__mascot {
  transform: scale(1.1) rotate(-4deg);
}

.category-card h3 {
  font-size: var(--fs-lg);
}

.category-card__chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-block: var(--space-3) var(--space-4);
}

/* ---- Process steps (a real sequence: order → bake → deliver) ---- */
.steps {
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

@media (max-width: 860px) {
  .steps {
    grid-template-columns: 1fr;
  }
}

.step {
  counter-increment: step;
  position: relative;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-4) var(--space-4);
  text-align: center;
  box-shadow: var(--card-shadow);
}

.step::before {
  content: counter(step, persian);
  position: absolute;
  inset-block-start: -22px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  inline-size: 44px;
  block-size: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-brand-primary);
  color: var(--color-text-inverse);
  font-weight: 700;
  font-size: var(--fs-md);
  box-shadow: 0 8px 18px -8px rgba(126, 57, 115, 0.6);
}

.step h3 {
  font-size: var(--fs-md);
  margin-block-start: var(--space-2);
}

.step p {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin-block-start: var(--space-2);
  line-height: 1.75;
}

.step__icon {
  inline-size: 64px;
  block-size: 64px;
  margin-inline: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--color-brand-primary);
}

/* ---- Blog card ---- */
.blog-card__media {
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--color-surface-alt);
  overflow: hidden;
}

.blog-card__media > img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-brand);
}

.card:hover .blog-card__media > img {
  transform: scale(1.05);
}

.blog-card__body {
  padding: var(--space-4);
}

.blog-card__date {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.blog-card__title {
  font-size: var(--fs-md);
  margin-block: var(--space-2);
  line-height: 1.6;
}

.blog-card__excerpt {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  line-height: 1.8;
}

.blog-card__link {
  display: inline-block;
  margin-block-start: var(--space-3);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--color-brand-primary);
  transition: transform var(--dur-fast) var(--ease-brand);
}

.card:hover .blog-card__link {
  transform: translateX(-4px);
}

/* ---- Form ---- */
.form-field {
  display: grid;
  gap: var(--space-2);
  margin-block-end: var(--space-4);
}

.form-field label {
  font-weight: 700;
  font-size: var(--fs-sm);
}

.form-field input,
.form-field textarea {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border-soft);
  background: var(--color-surface);
  transition: border-color var(--dur-fast) var(--ease-brand), box-shadow var(--dur-fast) var(--ease-brand);
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 4px rgba(126, 57, 115, 0.12);
}

.form-note {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1.5px dashed var(--color-brand-tint);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-block-end: var(--space-4);
}

/* ---- Text utilities ---- */
.section-copy {
  margin-block-start: var(--space-3);
  color: var(--color-text-muted);
}

.value-card {
  padding: var(--space-5) var(--space-4);
  text-align: center;
}

.value-card p {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin-block-start: var(--space-2);
  line-height: 1.8;
}

.value-icon {
  inline-size: 60px;
  block-size: 60px;
  margin-inline: auto;
  margin-block-end: var(--space-3);
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--color-brand-primary);
  display: grid;
  place-items: center;
  transition: transform var(--dur-fast) var(--ease-bounce);
}

.card:hover .value-icon {
  transform: scale(1.12) rotate(-6deg);
}

/* ---- Info tile (contact page) ---- */
.info-tile {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
}

.info-tile__icon {
  inline-size: 50px;
  block-size: 50px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  display: grid;
  place-items: center;
  color: var(--color-brand-primary);
}

.map-placeholder {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border-soft);
  background-color: var(--color-surface-alt);
  background-image: var(--pattern-url);
  background-size: 280px auto;
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  font-weight: 700;
  text-align: center;
  padding: var(--space-4);
}

.map-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(250, 243, 249, 0.9);
}

.map-placeholder span {
  position: relative;
}

/* ==========================================================================
   Cookie Wave — the bye-bye puppet (home hero), Claude Design handoff
   2026-07-09, replacing the old PNG rig. Inline SVG in index.html + these
   selectors/keyframes copied VERBATIM from the approved reference
   (Cookie Wave.html): 4s seamless loop — anticipation, three waves decaying
   ±17°→±9°, overshoot settle, double blink; gentle bob/breath throughout.
   ⚠ The arm+hand is ONE bone (the thumb is drawn into the arm path) — never
   split it at the wrist. Pivots are SVG user units of viewBox 230 138 382 302
   and REQUIRE transform-box: view-box: shoulder 378,266 · eyes 446.5,225.5 /
   509.5,225.5 · feet 460,424.
   ========================================================================== */
.cookie-wave {
  position: relative;
}

.cookie-wave__svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
}

.cookie-wave #puppet,
.cookie-wave #armRig,
.cookie-wave #eyeL,
.cookie-wave #eyeR { transform-box: view-box; }

.cookie-wave #puppet {
  transform-origin: 460px 424px;
  animation: v-bob 4s ease-in-out infinite;
}

.cookie-wave #armRig {
  transform-origin: 378px 266px;
  animation: v-wave 4s ease-in-out infinite;
}

.cookie-wave #eyeL {
  transform-origin: 446.5px 225.5px;
  animation: v-blink 4s linear infinite;
}

.cookie-wave #eyeR {
  transform-origin: 509.5px 225.5px;
  animation: v-blink 4s linear infinite;
}

@keyframes v-bob {
  0%   { transform: rotate(0deg) scaleY(1); }
  10%  { transform: rotate(-2.2deg) scaleY(1.012); }
  35%  { transform: rotate(-2.2deg) scaleY(0.995); }
  58%  { transform: rotate(-2.2deg) scaleY(1.01); }
  72%  { transform: rotate(0deg) scaleY(1); }
  86%  { transform: rotate(0deg) scaleY(1.008); }
  100% { transform: rotate(0deg) scaleY(1); }
}

/* anticipation, 3 waves, overshoot settle */
@keyframes v-wave {
  0%   { transform: rotate(0deg); }
  5%   { transform: rotate(0deg); }
  9%   { transform: rotate(7deg); }
  17%  { transform: rotate(-17deg); }
  27%  { transform: rotate(14deg); }
  37%  { transform: rotate(-15deg); }
  47%  { transform: rotate(12deg); }
  56%  { transform: rotate(-9deg); }
  64%  { transform: rotate(4.5deg); }
  71%  { transform: rotate(-1.5deg); }
  77%  { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

@keyframes v-blink {
  0%, 78%   { transform: scaleY(1); }
  80%       { transform: scaleY(0.05); }
  82%, 86%  { transform: scaleY(1); }
  88%       { transform: scaleY(0.05); }
  90%, 100% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-wave #puppet,
  .cookie-wave #armRig,
  .cookie-wave #eyeL,
  .cookie-wave #eyeR { animation: none; }
}

/* soft ground shadow under the feet (site element, kept from the old rig).
   Physical left/right, not logical: the artwork never flips under RTL. */
.cookie-wave__shadow {
  position: absolute;
  left: 38%;
  right: 20%;
  bottom: 0.5%;
  block-size: 7%;
  border-radius: 50%;
  background: rgba(126, 57, 115, 0.13);
  filter: blur(7px);
}

/* ==========================================================================
   Croissant parachutist — the chef character under his real-croissant
   canopy. The component only owns the look + sway/landing motion; where it
   floats (fixed gutter position, scroll progress) belongs to the page
   (see css/pages/home.css .parachutist and js/parachute.js).
   ========================================================================== */
.croissant-parachute img,
.croissant-parachute-img {
  inline-size: 100%;
  transform-origin: 50% 6%;
  animation: para-sway 5.5s ease-in-out infinite;
}

.croissant-parachute.is-landed img,
.croissant-parachute-img.is-landed {
  animation: para-land 0.7s var(--ease-bounce) both;
}

@keyframes para-sway {
  0%, 100% { transform: rotate(-5deg) translateX(-6px); }
  50% { transform: rotate(5deg) translateX(6px); }
}

@keyframes para-land {
  0% { transform: rotate(-2deg) scaleY(1); }
  45% { transform: rotate(0) scaleY(0.94); }
  100% { transform: rotate(0) scaleY(1); }
}
