/* Size finder dialog on the product page. */

/* ---------- Entry on the product page ---------- */
.fit-entry {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
  margin: calc(var(--s-2) * -1) 0 var(--s-3);
}
.fit-trigger {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0;
  font-size: 13px; font-weight: 500;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
  transition: opacity var(--t) var(--ease);
}
.fit-trigger:hover { opacity: .65; }
.fit-trigger .fit-ico { width: 22px; height: 22px; }
.fit-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-3);
  background: var(--c-sand); border: 1px solid var(--c-sand);
  font-size: 12px; font-weight: 500; letter-spacing: .02em;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
  animation: fit-fade-in .4s var(--ease) both;
}
.fit-chip:hover { border-color: var(--c-black); }
.fit-chip__dot { width: 6px; height: 6px; background: var(--c-black); flex: none; }
.size-btn.is-fit-picked { animation: fit-pop .5s var(--ease); }

/* ---------- Icons ---------- */
.fit-ico { width: 20px; height: 20px; flex: none; }
.fit-ico path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; }

/* ---------- Dialog shell ---------- */
html.fit-lock { overflow: hidden; }
.fit-modal {
  padding: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--c-ink);
  width: min(460px, calc(100vw - 48px));
  max-width: none;
  max-height: min(760px, calc(100vh - 48px)); max-height: min(760px, calc(100dvh - 48px));
  overflow: visible;
}
.fit-modal::backdrop { background: rgba(11, 11, 11, .55); animation: fit-fade-in .3s var(--ease) both; }
.fit-modal.is-closing::backdrop { animation: fit-fade-out .24s var(--ease) both; }
.fit-sheet {
  display: flex; flex-direction: column;
  max-height: min(760px, calc(100vh - 48px)); max-height: min(760px, calc(100dvh - 48px));
  background: var(--c-white);
  animation: fit-dialog-in .38s var(--ease) backwards;
  transition: transform .3s var(--ease);
}
.fit-modal.is-closing .fit-sheet { animation: fit-dialog-out .24s var(--ease) both; }
.fit-sheet.is-dragging { transition: none; }
.fit-modal :focus-visible { outline: 2px solid var(--c-black); outline-offset: 2px; }

.fit-handle { display: none; }

.fit-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-4) var(--s-5) 0;
}
.fit-title {
  font-family: var(--f-display); font-stretch: 151%; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; font-size: 14px; line-height: 1.2;
}
.fit-x {
  width: 44px; height: 44px; margin-right: -12px;
  display: grid; place-items: center; transition: opacity var(--t) var(--ease);
}
.fit-x:hover { opacity: .6; }
.fit-x .fit-ico { width: 22px; height: 22px; }

.fit-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: var(--s-3) var(--s-5) var(--s-4);
  overscroll-behavior: contain;
}

/* ---------- Controls: one row per question ---------- */
.fit-form { display: grid; gap: var(--s-3); }
.fit-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: var(--s-3); min-width: 0; }
.fit-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--c-ink); }

.fit-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--c-black); }
.fit-seg__opt {
  min-height: 42px; min-width: 0; padding: 0 var(--s-1);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; line-height: 1.15; text-align: center;
  border-left: 1px solid var(--c-black);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.fit-seg__opt:first-child { border-left: 0; }
.fit-seg__opt:hover { background: var(--c-sand); }
.fit-seg__opt[aria-checked="true"] { background: var(--c-black); color: var(--c-white); }
.fit-seg__opt:focus-visible { outline-offset: -5px; outline-color: currentColor; }
.fit-seg__opt[aria-checked="true"]:focus-visible { outline-color: var(--c-white); }

.fit-slide { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.fit-num-wrap {
  flex: none; display: flex; align-items: baseline; justify-content: flex-end; gap: 3px;
  width: 76px; border-bottom: 1px solid var(--c-control);
}
.fit-num-wrap:focus-within { border-bottom-color: var(--c-black); outline: 2px solid var(--c-black); outline-offset: 2px; }
.fit-num {
  width: 48px; padding: 0; border: 0; border-radius: 0; background: transparent; text-align: right;
  font-family: var(--f-display); font-stretch: 151%; font-weight: 700; font-size: 20px; line-height: 40px;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.fit-num::-webkit-outer-spin-button, .fit-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fit-modal .fit-num:focus-visible { outline: none; }
.fit-unit { font-size: 12px; color: var(--c-stone-text); }

.fit-range {
  --p: 50%;
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; min-width: 0; height: 42px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y;
}
.fit-range::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--c-black) 0 var(--p), var(--c-control) var(--p) 100%);
}
.fit-range::-moz-range-track { height: 2px; background: var(--c-control); }
.fit-range::-moz-range-progress { height: 2px; background: var(--c-black); }
.fit-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -10px;
  background: var(--c-black); border: 3px solid var(--c-white); box-shadow: 0 0 0 1px var(--c-black);
  border-radius: 0; transform: rotate(45deg); transition: transform .2s var(--ease);
}
.fit-range::-moz-range-thumb {
  width: 16px; height: 16px; background: var(--c-black); border: 3px solid var(--c-white);
  box-shadow: 0 0 0 1px var(--c-black); border-radius: 0; transform: rotate(45deg);
}
.fit-range:active::-webkit-slider-thumb { transform: rotate(45deg) scale(1.15); }

.fit-disc { margin-top: var(--s-4); font-size: 11.5px; line-height: 1.45; color: var(--c-stone-text); }

/* ---------- Live result ---------- */
.fit-foot {
  flex: none; display: grid; gap: var(--s-3);
  padding: 0 var(--s-5) var(--s-5);
  background: var(--c-white);
}
.fit-res {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--s-3) var(--s-4);
  padding: var(--s-4); background: var(--c-black); color: var(--c-white);
}
.fit-res__badge { display: flex; flex-direction: column; gap: 4px; min-width: 64px; }
.fit-res__lbl { font-size: 9px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; opacity: .6; white-space: nowrap; }
.fit-res__size {
  font-family: var(--f-display); font-stretch: 151%; font-weight: 800;
  font-size: 52px; line-height: .9; transform-origin: left center;
}
.fit-res__size.is-pop { animation: fit-pop .42s var(--ease); }
/* Room for the longest verdict, so the sheet keeps its height while the sliders move. */
.fit-res__info {
  min-width: 0; min-height: 96px; padding-left: var(--s-4); border-left: 1px solid rgba(250, 250, 248, .22);
  display: flex; flex-direction: column; justify-content: center;
}
.fit-res__conf { font-size: 13px; font-weight: 600; line-height: 1.3; }
.fit-res__zones { margin-top: 6px; display: grid; gap: 2px; font-size: 11.5px; line-height: 1.35; color: rgba(250, 250, 248, .66); }
.fit-res__zones b { margin-right: 6px; font-weight: 600; color: var(--c-white); }
.fit-scale { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.fit-scale li {
  display: grid; place-items: center; min-height: 28px;
  font-size: 12px; font-weight: 500; color: rgba(250, 250, 248, .55);
  border: 1px solid rgba(250, 250, 248, .2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.fit-scale li.is-alt { color: var(--c-white); border-color: rgba(250, 250, 248, .7); }
.fit-scale li.is-rec { background: var(--c-white); border-color: var(--c-white); color: var(--c-black); font-weight: 700; }
.fit-foot .btn { min-height: 52px; gap: var(--s-2); white-space: nowrap; }
.fit-foot .btn .fit-ico { width: 18px; height: 18px; }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 768px) {
  .fit-modal {
    width: 100%; max-width: 100%; max-height: 100%;
    margin: 0; inset: auto 0 0 0; top: auto;
  }
  .fit-sheet {
    max-height: 94vh; max-height: 94dvh;
    animation-name: fit-sheet-in;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .fit-modal.is-closing .fit-sheet { animation-name: fit-sheet-out; }
  .fit-handle {
    display: flex; justify-content: center; align-items: center; flex: none;
    height: 20px; cursor: grab; touch-action: none;
  }
  .fit-handle span { width: 40px; height: 3px; background: var(--c-line); }
  .fit-head { padding: 0 var(--s-4); }
  .fit-body { padding: var(--s-2) var(--s-4) var(--s-3); }
  .fit-foot { padding: 0 var(--s-4) var(--s-4); }
  .fit-res__size { font-size: 46px; }
}
@media (max-width: 380px) {
  .fit-row { grid-template-columns: 62px minmax(0, 1fr); gap: var(--s-2); }
  .fit-label { font-size: 10px; letter-spacing: .08em; }
  .fit-seg__opt { font-size: 12px; }
  .fit-num-wrap { width: 68px; }
  .fit-num { width: 42px; font-size: 18px; }
}
/* Low screens: nothing is dropped; the result block gives up its reserved height and .fit-body scrolls. */
@media (max-height: 640px) {
  .fit-res__info { min-height: 56px; }
}

/* ---------- Motion ---------- */
@keyframes fit-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fit-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes fit-dialog-in { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fit-dialog-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes fit-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fit-sheet-out { from { transform: none; } to { transform: translateY(100%); } }
@keyframes fit-pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .fit-modal *, .fit-modal::backdrop, .fit-chip, .size-btn.is-fit-picked {
    animation: none !important; transition: none !important;
  }
}

@media (forced-colors: active) {
  .fit-seg__opt[aria-checked="true"], .fit-scale li.is-rec { outline: 3px solid Highlight; outline-offset: -3px; }
  .fit-range::-webkit-slider-thumb { forced-color-adjust: none; }
}
