/*
 * «راهنمای خرید» — the homepage band and the guide page.
 * Built on the Aperina theme's role tokens and components (.btn, .choice, .steps, .alert, .badge, .progress, .switch,
 * .input-group, .cta-sticky, .toast). RTL-first, logical properties, mobile first (480 / 768 / 1024).
 */

.guide-entry :where(h2, p), .guide :where(h1, h2, p, ul, ol) { margin-block: 0; }
.guide-icon { flex: none; width: 20px; height: 20px; }

/* =========================================================
   Stepper (people, meals per week)
   ========================================================= */
.guide-stepper { display: inline-flex; align-items: center; flex: none; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-cta); background: var(--bg-raised); }
.guide-stepper button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color var(--dur-fast), color var(--dur-fast);
}
.guide-stepper button .guide-icon { width: 20px; height: 20px; }
.guide-stepper button:hover:not(:disabled) { background: color-mix(in oklab, var(--text) 7%, transparent); }
.guide-stepper button:active:not(:disabled) { background: var(--text); color: var(--bg); }
.guide-stepper button:disabled { color: var(--text-subtle); cursor: not-allowed; }
.guide-stepper button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -3px; }
.guide-stepper output { min-width: 2.5rem; text-align: center; font-size: var(--text-title); font-weight: 600; line-height: 1; }
.guide-stepper--sm button .guide-icon { width: 18px; height: 18px; }
.guide-stepper--sm output { min-width: 2.25rem; font-size: var(--text-body); }
@media (min-width: 480px) { .guide-stepper:not(.guide-stepper--sm) button { width: 48px; height: 48px; } }

/* =========================================================
   Homepage band (block aperina/guide-entry)
   ========================================================= */
.guide-entry { padding-block: var(--space-10) var(--space-12); border-block-start: 1px solid var(--divider); }
.guide-entry__card { display: grid; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-panel); background: var(--bg-raised); color: var(--text); }
.guide-entry__copy { display: grid; gap: var(--space-2); align-content: center; justify-items: start; padding: var(--space-5) var(--space-5) var(--space-4); }
.guide-entry__kicker { font-size: var(--text-label); font-weight: 500; line-height: 1.6; color: var(--text-muted); }
.guide-entry__title { font-size: var(--text-h2); font-weight: 500; line-height: var(--lh-h2); text-wrap: balance; }
.guide-entry__lede { color: var(--text-muted); max-width: 38ch; }
.guide-entry__form { display: grid; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); border-block-start: 1px dashed var(--border-strong); }
.guide-entry__people { display: grid; gap: var(--space-2); }
.guide-entry__row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); }
.guide-entry__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-sunken); color: var(--text-muted); transition: background-color var(--dur-base), color var(--dur-base); }
.guide-entry__row.is-on .guide-entry__icon { background: var(--accent-tint); color: var(--on-accent-tint); }
.guide-entry__name { display: grid; min-width: 0; }
.guide-entry__name b { font-size: var(--text-body); font-weight: 600; line-height: 1.5; }
.guide-entry__name small { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-entry__go { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding-block-start: var(--space-1); }
.guide-entry__go .btn { flex: 1; }
.guide-entry__go .btn .guide-icon { width: 18px; height: 18px; transition: translate var(--dur-base) var(--ease-out); }
.guide-entry__go .btn:hover .guide-icon { translate: -4px 0; }
.guide-entry__go .btn.is-disabled { opacity: 0.4; pointer-events: none; }
.guide-entry__note { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
@media (min-width: 768px) {
  .guide-entry { padding-block: var(--space-16); }
  .guide-entry__card { grid-template-columns: minmax(0, 6fr) minmax(0, 6fr); }
  .guide-entry__copy { padding: var(--space-8); }
  .guide-entry__form { padding: var(--space-6) var(--space-8); border-block-start: 0; border-inline-start: 1px dashed var(--border-strong); }
  .guide-entry__go .btn { flex: none; }
}
@media (min-width: 1024px) { .guide-entry__card { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }

/* =========================================================
   Guide page (block aperina/buying-guide)
   ========================================================= */
.guide { padding-block: var(--space-6) var(--space-12); background: var(--bg); color: var(--text); }
.guide__head { display: grid; gap: var(--space-2); margin-block-end: var(--space-6); }
.guide__kicker { font-size: var(--text-label); font-weight: 500; line-height: 1.6; color: var(--text-muted); }
.guide__title { font-size: clamp(2rem, 1.2rem + 3.4vw, 3.5rem); font-weight: 200; line-height: 1.3; text-wrap: balance; }
.guide__lede { color: var(--text-muted); max-width: 52ch; }

/* Steps (theme .steps) with the chosen value under each name */
.guide__steps { margin-block-end: var(--space-8); }
.guide__steps li { min-width: 0; }
.guide__steps li b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide__steps li small { display: block; min-height: 1.6em; font-size: var(--text-micro); line-height: var(--lh-micro); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide__step { display: grid; align-content: start; gap: var(--space-2); width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.guide__step:hover b { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.35em; }
.guide__step:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 4px; }

.guide__panel { display: grid; gap: var(--space-5); min-height: 40vh; align-content: start; }
.guide__panel:not([hidden]) { animation: guide-in var(--dur-slow) var(--ease-out); }
@keyframes guide-in { from { opacity: 0; translate: 0 8px; } }
.guide__q { font-size: var(--text-h3); font-weight: 600; line-height: var(--lh-h3); text-wrap: balance; }
.guide__q:focus { outline: none; }
.guide__hint { font-size: var(--text-small); line-height: var(--lh-small); color: var(--text-muted); max-width: 56ch; margin-block-start: calc(var(--space-2) * -1); }
.guide__preset { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); justify-self: start; font-size: var(--text-small); color: var(--text-muted); }
.guide__preset a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.35em; }
.guide__warn { font-size: var(--text-small); line-height: var(--lh-small); color: var(--warning); }
.guide__warn:empty { display: none; }

/* 1. People */
.guide-people { display: grid; gap: var(--space-3); }
.guide-person {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-field); background: var(--bg-raised);
  transition: border-color var(--dur-base) var(--ease-out);
}
.guide-person.is-on { border-color: var(--border-strong); }
.guide-person__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--bg-sunken); color: var(--text-muted); transition: background-color var(--dur-base), color var(--dur-base); }
.guide-person.is-on .guide-person__icon { background: var(--accent-tint); color: var(--on-accent-tint); }
.guide-person__icon .guide-icon { width: 22px; height: 22px; }
.guide-person__text { display: grid; min-width: 0; }
.guide-person__text b { font-size: var(--text-body); font-weight: 600; line-height: 1.5; }
.guide-person__text small { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }

/* 2. Occasions: choice cards with a photo */
.guide-occasions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.guide-occasion { padding: 0; gap: 0; overflow: hidden; border-radius: var(--radius-cta); }
.guide-occasion__media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg-muted); }
.guide-occasion__media img { width: 100%; height: 100%; object-fit: cover; }
.guide-occasion__span { position: absolute; inset-block-start: var(--space-2); inset-inline-start: var(--space-2); padding: 2px var(--space-3); border-radius: var(--radius-pill); background: rgb(239 233 225 / 0.94); color: var(--ap-mocha, #322D29); font-size: var(--text-micro); line-height: var(--lh-micro); font-weight: 500; }
.guide-occasion__check { position: absolute; inset-block-start: var(--space-2); inset-inline-end: var(--space-2); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--on-primary); opacity: 0; scale: 0.6; transition: opacity var(--dur-fast), scale var(--dur-base) var(--ease-out); }
.guide-occasion__check .guide-icon { width: 16px; height: 16px; }
.choice:has(input:checked) .guide-occasion__check { opacity: 1; scale: 1; }
.guide-occasion__body { display: grid; gap: 2px; padding: var(--space-3); }
.guide-occasion__name { font-size: var(--text-small); font-weight: 600; line-height: 1.6; }
.guide-occasion__text { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }

.guide-menu { border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--bg-raised); }
.guide-menu summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 48px; padding: var(--space-2) var(--space-4); font-size: var(--text-label); font-weight: 500; cursor: pointer; }
.guide-menu summary::-webkit-details-marker { display: none; }
.guide-menu summary .guide-icon { width: 18px; height: 18px; transition: rotate var(--dur-base) var(--ease-out); }
.guide-menu[open] summary .guide-icon { rotate: 180deg; }
.guide-menu summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.guide-menu__list { list-style: none; margin: 0; padding: 0 var(--space-4) var(--space-2); border-block-start: 1px solid var(--divider); }
.guide-menu__list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding-block: var(--space-2); border-block-end: 1px solid var(--divider); }
.guide-menu__list li:last-child { border-block-end: 0; }
.guide-menu__name { display: grid; min-width: 0; }
.guide-menu__name b { font-size: var(--text-small); font-weight: 600; line-height: 1.6; }
.guide-menu__name small { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-menu__list li.is-off .guide-menu__name { color: var(--text-muted); }
.guide-menu__list .switch { min-height: 44px; }
.guide-menu__list .switch span { font-size: var(--text-caption); color: var(--text-muted); }
.guide-menu__list .guide-stepper output { min-width: 2rem; font-size: var(--text-body); }

/* 3. Budget */
.guide-budgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.guide-budget { padding: var(--space-4); text-align: center; justify-items: center; }
.guide-budget b { font-size: var(--text-title); font-weight: 600; line-height: 1.4; }
.guide-budget small { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-budget-custom { display: grid; gap: var(--space-2); max-width: 360px; }
.guide-budget-custom .input { font-size: var(--text-title); font-weight: 500; }

/* 4. Basket */
.guide-basket { display: grid; align-content: start; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-panel); background: var(--bg-raised); color: var(--text); }
.guide-basket__head { display: grid; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-4); border-block-end: 1px dashed var(--border-strong); }
.guide-basket__label { font-size: var(--text-label); font-weight: 500; color: var(--text-muted); }
.guide-basket__total { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); font-weight: 500; line-height: 1.3; }
.guide-basket__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--text-small); line-height: var(--lh-small); color: var(--text-muted); }
.guide-basket__meta span { unicode-bidi: isolate; }
.guide-meter { display: grid; gap: 6px; }
.guide-meter__text { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-1) var(--space-3); font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-meter__text b { color: var(--text); font-weight: 600; }
.guide-meter .progress { border-radius: var(--radius-pill); }
.guide-meter .progress > span { border-radius: inherit; }
.guide-meter.is-ok .progress > span { background: var(--success); }
.guide-meter.is-over .progress > span { background: var(--error); }
.guide-basket .alert { margin: var(--space-4) var(--space-5) 0; }
.guide-basket .alert .guide-icon { width: 20px; height: 20px; margin-block-start: 3px; }
.guide-basket .empty { margin: var(--space-5); }
.guide-basket .empty .guide-icon { width: 40px; height: 40px; color: var(--text-subtle); }

.guide-basket__list { list-style: none; margin: 0; padding: 0 var(--space-5); }
/* Phones: the name gets the whole row beside the photo, and the amount and price sit under it. From 480px: three columns. */
.guide-line { display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "img text" "img amt"; gap: var(--space-1) var(--space-3); align-items: start; padding-block: var(--space-3); border-block-end: 1px solid var(--divider); }
.guide-line:last-child { border-block-end: 0; }
.guide-line__img { grid-area: img; width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-field); background: var(--bg-muted); }
.guide-line__text { grid-area: text; display: grid; gap: 2px; min-width: 0; }
.guide-line__name { font-size: var(--text-small); font-weight: 600; line-height: 1.6; color: inherit; text-decoration: none; }
.guide-line__name:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.35em; }
.guide-line__meta { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-line__meta span { unicode-bidi: isolate; }
.guide-line__flags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-block-start: 2px; }
.guide-line__amt { grid-area: amt; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--space-3); line-height: 1.6; }
@media (min-width: 480px) {
  .guide-line { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "img text amt"; gap: var(--space-3); align-items: center; }
  .guide-line__amt { display: grid; justify-items: end; text-align: end; white-space: nowrap; }
}
.guide-line__amt b { font-size: var(--text-body); font-weight: 600; }
.guide-line__amt small { font-size: var(--text-caption); color: var(--text-muted); }
.guide-line.is-dropped { opacity: 0.55; }
.guide-line.is-dropped .guide-line__name { text-decoration: line-through; text-decoration-thickness: 1px; }
.guide-basket__foot { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-5); border-block-start: 1px solid var(--border-strong); }
.guide-basket__foot .btn .guide-icon { width: 18px; height: 18px; }
.guide-basket__note { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-basket__result { margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-field); background: var(--success-tint); color: var(--success); font-size: var(--text-small); line-height: var(--lh-small); }
.guide-basket__result.is-bad { background: var(--warning-tint); color: var(--warning); }
.guide-basket__fit { min-height: 44px; font-size: var(--text-small); }

/* Other stylesheets must not draw on the guide's controls: the switches and cards paint themselves (::after), so their
   ::before stays empty whatever else is loaded (the toolbar's colour scheme once put its tick on every checkbox). */
.guide .switch input[type="checkbox"]::before, .guide .choice input[type="radio"]::before { content: none; }

/*
 * Step buttons: «قبلی» and «ادامه». Every rule is here (no theme component underneath), because on phones three things
 * meet at the bottom of the screen: this bar, the theme's bottom navigation and the theme's cart bar.
 * - Phones (below 768px): a full-width bar that sticks right above the bottom navigation. The buttons are a grid, so they
 *   can never wrap onto two rows: «قبلی» takes what it needs, «ادامه» takes the rest. On the last step the bar only has
 *   «قبلی» and rests at the end of the basket.
 * - From 768px: a plain row at the end of the step.
 * tests/aperina-guide/layout.test.mjs checks these rules at every width.
 */
.guide__nav {
  --guide-gutter: var(--gutter, clamp(16px, 4vw, 40px));
  position: sticky; z-index: var(--z-sticky, 20);
  inset-block-end: calc(var(--bottom-nav-h, 0px) + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "hint hint" "prev next"; align-items: center; gap: var(--space-2) var(--space-3);
  margin-block-start: var(--space-6); margin-inline: calc(var(--guide-gutter) * -1); padding: var(--space-3) var(--guide-gutter);
  background: color-mix(in oklab, var(--bg) 94%, transparent); backdrop-filter: blur(12px);
  border-block-start: 1px solid var(--border);
}
.guide__nav[data-step="1"] { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hint" "next"; }
.guide__nav[data-step="4"] { position: static; grid-template-areas: "hint hint" "prev ."; background: none; backdrop-filter: none; border-block-start-color: var(--divider); }
.guide__nav [hidden] { display: none; }
.guide__nav .btn { --btn-h: 48px; padding-inline: var(--space-4); }
.guide__nav .btn .guide-icon { width: 18px; height: 18px; }
.guide__nav [data-nav-prev] { grid-area: prev; }
.guide__nav [data-nav-next] { grid-area: next; inline-size: 100%; min-inline-size: 0; }
/* The unflipped arrow (←) means forward in right-to-left text, as elsewhere on the site; «قبلی» points back (→). */
.guide__nav [data-nav-prev] .guide-icon { scale: -1 1; }
.guide__nav-hint { grid-area: hint; font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide__nav-hint:empty { display: none; }

/* One floating bar at a time, as on the theme's product pages (buy bar instead of cart bar): on the guide page the shop's
   cart bar is off. The cart stays one tap away in the bottom navigation, and the basket step links to it. */
.has-aperina-guide .cart-bar { display: none; }
@media (min-width: 768px) {
  .guide { padding-block: var(--space-12) var(--space-16); }
  .guide__head { margin-block-end: var(--space-8); }
  .guide-occasions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
  .guide-occasion__body { padding: var(--space-4); }
  .guide-budgets { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
  .guide__nav, .guide__nav[data-step] {
    position: static; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "prev hint next";
    margin-inline: 0; padding: var(--space-5) 0 0; background: none; backdrop-filter: none; border-block-start: 1px solid var(--divider);
  }
  .guide__nav .btn { --btn-h: var(--control-md, 48px); padding-inline: var(--space-6); }
  .guide__nav .btn-lg { --btn-h: var(--control-lg, 56px); padding-inline: var(--space-8); }
  .guide__nav [data-nav-next] { inline-size: auto; }
  .guide__nav-hint { min-inline-size: 0; text-align: center; }
  .guide-cheats { margin-block-start: var(--space-16); }
}

/* Cheat sheet: «یک کیلو، چند نفر؟». The margin keeps it clear of the step buttons above it, at every width. */
.guide-cheats { margin-block-start: var(--space-12); padding-block: var(--space-10) var(--space-16); border-block-start: 1px solid var(--divider); }
.guide-cheats__head { display: grid; gap: var(--space-2); margin-block-end: var(--space-5); }
.guide-cheats__title { font-size: var(--text-h3); font-weight: 600; line-height: var(--lh-h3); }
.guide-cheats__lede { font-size: var(--text-small); line-height: var(--lh-small); color: var(--text-muted); max-width: 52ch; }
.guide-cheats__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.guide-cheat { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-cta); background: var(--bg-raised); }
.guide-cheat__media { position: relative; aspect-ratio: 5 / 3; overflow: hidden; background: var(--bg-muted); }
.guide-cheat__media img { width: 100%; height: 100%; object-fit: cover; }
.guide-cheat__people { position: absolute; inset-block-start: var(--space-2); inset-inline-start: var(--space-2); padding: 2px var(--space-3); border-radius: var(--radius-pill); background: rgb(239 233 225 / 0.94); color: var(--ap-mocha, #322D29); font-size: var(--text-micro); line-height: var(--lh-micro); font-weight: 500; }
.guide-cheat__body { display: grid; gap: 2px; padding: var(--space-3) var(--space-3) var(--space-4); }
.guide-cheat__name { font-size: var(--text-small); font-weight: 600; line-height: 1.6; }
.guide-cheat__per { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.guide-cheat__per b { color: var(--text); font-weight: 600; }
.guide-cheat__tip { font-size: var(--text-micro); line-height: var(--lh-micro); color: var(--text-muted); }
@media (min-width: 768px) { .guide-cheats__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); } .guide-cheat__body { padding: var(--space-4); } }
@media (min-width: 1024px) { .guide-cheats__grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Toast from the guide: the icon reads as success */
.toast .guide-icon { width: 18px; height: 18px; }

@media (prefers-reduced-motion: reduce) {
  .guide__panel:not([hidden]) { animation: none; }
  .guide-occasion__check, .guide-person, .guide-person__icon, .guide-entry__icon, .guide-entry__go .btn .guide-icon { transition: none; }
}
