/* ==========================================================================
   Serita implant cost calculator

   Deliberately NOT set here, so the theme stays in charge:
     - font-family / @font-face  -> everything inherits from the theme
     - width / max-width         -> put this inside your own .container
   The desktop result column IS sticky - on .sc-resultcol, never on .sc-result.
   See the note above that rule before moving it.

   Every rule is scoped under .serita-calc so nothing leaks into the theme.
   ========================================================================== */

.serita-calc {
  --sc-ink:      #251825;
  --sc-muted:    #6f5c6c;
  --sc-line:     #e0ddcf;
  --sc-hair:     #ece2e7;
  --sc-accent:   #a43691;
  --sc-tint:     #f3e2e8;
  --sc-cta:      #ea9aee;
  --sc-cta-hi:   #fbb7ff;
  --sc-panel:    #f7f3f5;
  --sc-radius:   8px;
  --sc-control:  48px;

  direction: rtl;
  text-align: right;
  box-sizing: border-box;

  /* No max-width and no horizontal padding: the width comes from whatever
     wrapper you drop this into (your .container). Vertical padding only. */
  width: 100%;
  padding: 32px 0;

  /* font-family and font-size are inherited from the theme on purpose. */
  line-height: 1.7;
  color: var(--sc-ink);
}
.serita-calc *,
.serita-calc *::before,
.serita-calc *::after { box-sizing: inherit; }

/* Form controls do not inherit type by default in any browser - this pulls the
   theme's font down into them rather than declaring one. */
.serita-calc button,
.serita-calc input,
.serita-calc select,
.serita-calc optgroup,
.serita-calc option { font-family: inherit; }

.serita-calc :focus-visible { outline: 2px solid var(--sc-accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.sc-title { font-size: 1.6em; font-weight: 700; letter-spacing: -0.3px; margin: 0 0 24px; }
.sc-grid  { display: flex; flex-direction: column; gap: 24px; }

.sc-card {
  background: #fff;
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius);
  padding: 24px 20px;
}
/* The sticky column. Sticky lives HERE, not on .sc-result: this element is the
   grid item, so its containing block is the full-height grid area, which is what
   gives the card room to travel. Put sticky on the card instead and it pins
   itself to a parent of identical height and never moves. */
.sc-resultcol { /* static until the desktop breakpoint */ }

.sc-result {
  background: var(--sc-panel);
  border-radius: var(--sc-radius);
  padding: 24px 20px;
}

/* Sticky is clipped by any ancestor whose overflow is not visible, so make sure
   the component's own wrappers never do that. A theme wrapper still can - see
   the console snippet in the README for finding it. */
.serita-calc,
.serita-calc .sc-grid,
.serita-calc .sc-resultcol { overflow: visible; }
.sc-divider { height: 36px; }
.sc-h { font-size: 1em; font-weight: 700; margin: 0 0 16px; }
.sc-h--tight { margin-bottom: 6px; }
.sc-label { font-size: 0.9em; font-weight: 500; color: var(--sc-muted); margin-bottom: 10px; }
.sc-note  { font-size: 0.75em; font-weight: 400; color: var(--sc-muted); line-height: 1.7; }
.sc-lede  { font-size: 0.85em; font-weight: 400; color: var(--sc-muted); margin: 0 0 16px; }

/* ---------- progress ---------- */
.sc-steps { display: flex; gap: 8px; margin-bottom: 28px; }
.sc-step  { flex: 1; }
.sc-step__bar { height: 2px; border-radius: 2px; margin-bottom: 8px; background: var(--sc-line); }
.sc-step.is-done .sc-step__bar { background: var(--sc-accent); }
.sc-step__text { font-size: 0.75em; font-weight: 500; color: var(--sc-muted); }

/* ---------- stepper ---------- */
.sc-countrow { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.sc-stepper {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--sc-line); border-radius: var(--sc-radius);
  padding: 1px; height: var(--sc-control);
}
.sc-stepper__btn {
  width: 44px; height: 44px; font-size: 1.3em; font-weight: 500;
  color: var(--sc-ink); background: none; border: none;
  border-radius: var(--sc-radius); cursor: pointer;
}
.sc-stepper__btn:hover { background: var(--sc-hair); }
.sc-stepper__val {
  min-width: 56px; text-align: center;
  font-size: 1.15em; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ---------- chips / cards / segments ---------- */
.sc-chip {
  height: var(--sc-control); padding: 0 18px;
  font-size: 0.9em; font-weight: 500; color: var(--sc-ink);
  background: #fff; border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius); cursor: pointer;
}
.sc-chip[aria-pressed="true"] { font-weight: 700; background: var(--sc-tint); border-color: var(--sc-accent); }

.sc-brands { display: flex; flex-direction: column; gap: 8px; }
.sc-brand {
  display: block; text-align: start; padding: 16px;
  background: #fff; border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius); cursor: pointer;
}
.sc-brand[aria-pressed="true"] { background: var(--sc-tint); border-color: var(--sc-accent); }
.sc-brand__name  { font-size: 1em; font-weight: 700; margin-bottom: 6px; }
.sc-brand__desc  { font-size: 0.85em; font-weight: 400; color: var(--sc-muted); line-height: 1.7; }
.sc-brand__price { font-size: 0.85em; font-weight: 500; color: var(--sc-ink); margin-top: 10px; }

.sc-seg {
  display: flex; height: var(--sc-control); margin-bottom: 24px;
  border: 1px solid var(--sc-line); border-radius: var(--sc-radius); overflow: hidden;
}
.sc-seg__btn {
  flex: 1; height: 100%; font-size: 0.9em; font-weight: 500;
  color: var(--sc-muted); background: transparent; border: none;
  border-radius: 7px; cursor: pointer;
}
.sc-seg__btn[aria-pressed="true"] { font-weight: 700; color: var(--sc-ink); background: var(--sc-tint); }
/* «بدون پیش‌پرداخت» is unavailable on the 36/48-month plans - same treatment as
   the disabled CTA below, so the state reads the same everywhere. */
.serita-calc .sc-seg__btn[disabled] { color: var(--sc-muted); background: transparent; cursor: not-allowed; }

/* ---------- add-ons ---------- */
.sc-addons { display: flex; flex-direction: column; }
.sc-addon {
  display: flex; align-items: center; gap: 12px;
  height: var(--sc-control); padding: 0;
  background: none; border: none; border-bottom: 1px solid var(--sc-hair);
  cursor: pointer; text-align: start; color: var(--sc-ink);
}
.sc-addon__box {
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: var(--sc-radius); border: 1px solid var(--sc-line); background: #fff;
}
.sc-addon[aria-pressed="true"] .sc-addon__box {
  border-color: var(--sc-accent); background: var(--sc-accent);
  background-image:
    linear-gradient(45deg,  transparent 46%, #fff 46%, #fff 54%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, #fff 46%, #fff 54%, transparent 54%);
  background-size: 12px 12px; background-position: center; background-repeat: no-repeat;
}
.sc-addon__name  { flex: 1; text-align: start; font-size: 0.9em; font-weight: 500; }
.sc-addon__price { font-size: 0.85em; font-weight: 400; color: var(--sc-muted); }

/* ---------- range ----------
   WordPress themes almost always ship a blanket `input { ... }` rule - border,
   padding, height, background, sometimes appearance. Any one of those turns a
   range input into an undraggable bar. These resets are !important because a
   theme selector like `.entry-content input[type="range"]` matches with the
   same specificity as ours and can win purely by load order. */
.sc-rangehead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.sc-rangehead__val { font-size: 1em; font-weight: 700; font-variant-numeric: tabular-nums; }

.serita-calc input[type="range"].sc-range {
  -webkit-appearance: none !important;
     -moz-appearance: none !important;
          appearance: none !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  outline: none;
  min-height: 0 !important;
  max-width: none !important;
  height: var(--sc-control);
  width: 100%;
  display: block;
  cursor: pointer;
  pointer-events: auto !important;
  opacity: 1 !important;
  touch-action: manipulation;      /* stop mobile browsers stealing the drag */
  position: relative;
  z-index: 1;
}
.serita-calc input[type="range"].sc-range::-webkit-slider-runnable-track {
  height: 2px; background: var(--sc-line); border-radius: 2px; border: 0;
}
.serita-calc input[type="range"].sc-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  height: 22px; width: 22px; margin-top: -10px;
  border-radius: var(--sc-radius);
  background: #fff; border: 1.5px solid var(--sc-accent);
  box-shadow: none; cursor: grab; pointer-events: auto;
}
.serita-calc input[type="range"].sc-range::-webkit-slider-thumb:active { cursor: grabbing; }
.serita-calc input[type="range"].sc-range::-moz-range-track {
  height: 2px; background: var(--sc-line); border: 0; border-radius: 2px;
}
.serita-calc input[type="range"].sc-range::-moz-range-thumb {
  height: 22px; width: 22px; border-radius: var(--sc-radius);
  background: #fff; border: 1.5px solid var(--sc-accent);
  box-shadow: none; cursor: grab;
}
.serita-calc input[type="range"].sc-range::-moz-focus-outer { border: 0; }

.sc-rangefoot {
  display: flex; justify-content: space-between;
  font-size: 0.75em; color: var(--sc-muted); margin: -6px 0 26px;
}
.sc-months { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- result ---------- */
.sc-row { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; }
.sc-row--gap { padding-bottom: 20px; }
.sc-row__label { font-size: 0.9em; font-weight: 500; color: var(--sc-muted); }
.sc-num { font-size: 1.15em; font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-monthly { border-top: 1px solid var(--sc-hair); padding-top: 20px; }
/* «قسط ماهانه» is now the first thing on the result card (قیمت کل and the down
   payment moved into «جزئیات هزینه»), so its separator would sit on the card's
   top edge - drop it there only. Spacing only, no colour change. */
.sc-result > .sc-monthly:first-child { border-top: 0; padding-top: 0; }
.sc-monthly__val {
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
  font-size: 2em; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.6px; font-variant-numeric: tabular-nums;
}
.sc-monthly__unit { font-size: 0.5em; font-weight: 500; color: var(--sc-muted); }

/* Amounts stay blurred until the visitor identifies themselves. */
.sc-locked .sc-num          { filter: blur(6px); user-select: none; }
.sc-locked .sc-monthly__val { filter: blur(9px); user-select: none; }
.sc-locked .sc-break__val   { filter: blur(4px); user-select: none; }
.sc-num, .sc-monthly__val, .sc-break__val { transition: filter .35s ease; }

/* ---------- gate ---------- */
.sc-gate {
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--sc-hair);
  display: flex; flex-direction: column; gap: 8px;
}
.sc-gate__title { font-size: 0.9em; font-weight: 700; }

.serita-calc .sc-field,
.serita-calc .sc-select {
  width: 100%; height: var(--sc-control);
  padding: 0 12px; font-size: 0.9em;
  color: var(--sc-ink); background: #fff;
  border: 1px solid var(--sc-line); border-radius: var(--sc-radius);
  margin: 0; box-shadow: none; max-width: none;
}
.serita-calc .sc-select {
  padding: 0 12px 0 32px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-repeat: no-repeat; background-position: left 12px center;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236f5c6c' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
.serita-calc .sc-select.is-empty { color: var(--sc-muted); }

.serita-calc .sc-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px; padding: 0 24px;
  font-size: 1em; font-weight: 700;
  color: var(--sc-ink); background: var(--sc-cta);
  border: none; border-radius: var(--sc-radius); cursor: pointer;
  text-decoration: none; text-transform: none;
}
.serita-calc .sc-btn:hover { background: var(--sc-cta-hi); color: var(--sc-ink); }
.serita-calc .sc-btn--gate { height: var(--sc-control); min-height: var(--sc-control); margin-top: 4px; font-size: 0.9em; }
.serita-calc .sc-btn[disabled] { color: var(--sc-muted); background: #efe8ec; cursor: not-allowed; }
.sc-hint { font-size: 0.75em; font-weight: 400; color: var(--sc-muted); line-height: 1.7; }
.sc-hint.is-error { font-weight: 500; color: var(--sc-accent); }

/* ---------- breakdown ---------- */
.sc-break__toggle {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; min-height: 44px; margin-top: 16px; padding: 0;
  font-size: 0.9em; font-weight: 500;
  color: var(--sc-ink); background: none; border: none;
  border-top: 1px solid var(--sc-hair); cursor: pointer;
}
.sc-break__list { padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.sc-break__row  { display: flex; justify-content: space-between; font-size: 0.85em; color: var(--sc-muted); }
.sc-break__val  { font-variant-numeric: tabular-nums; color: var(--sc-ink); }
.sc-cta-wrap { margin-top: 24px; }
.sc-fineprint { font-size: 0.75em; color: var(--sc-muted); line-height: 1.7; margin: 20px 0 0; }

/* ---------- mobile summary bar ----------
   Was position:sticky and did not stick, for the same overflow reason as
   .sc-result. It now sits in normal flow at the end of the component. */
.sc-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 0; margin-top: 24px;
  border-top: 1px solid var(--sc-line);
}
.sc-bar__label { font-size: 0.75em; font-weight: 500; color: var(--sc-muted); }
.sc-bar__val   { font-size: 1.15em; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.serita-calc.sc-locked .sc-bar__val { filter: blur(6px); user-select: none; }
.serita-calc .sc-bar__btn {
  height: 44px; padding: 0 18px; flex-shrink: 0;
  font-size: 0.9em; font-weight: 700; color: var(--sc-ink);
  background: var(--sc-cta); border: none; border-radius: var(--sc-radius); cursor: pointer;
}
.serita-calc .sc-bar__btn:hover { background: var(--sc-cta-hi); }

.sc-hidden { display: none !important; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .serita-calc { padding: 48px 0; }
  .sc-title  { font-size: 2em; margin-bottom: 40px; }
  .sc-grid   { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 40px; align-items: start; }
  .sc-card   { padding: 40px; }
  .sc-result { padding: 28px; }

  /* align-self:start keeps the column from stretching to the row height, which
     would leave it nothing to slide against. top: must be set - sticky with no
     inset behaves exactly like static. */
  .sc-resultcol {
    position: -webkit-sticky;
    position: sticky;
    top: 32px;
    align-self: start;
  }
  .sc-divider { height: 48px; }
  .sc-brands { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 12px; }
  .sc-monthly__val { font-size: 2.3em; }
  .sc-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sc-num, .sc-monthly__val, .sc-break__val { transition: none; }
}
