/*
 * AI size finder on the product page: web-views/products/partials/_size-finder.
 * Brand colour comes from --web-primary (set per store in the layout), so the
 * widget follows the store rather than a colour of its own.
 */

.size-finder {
    --sf-brand: var(--web-primary, #1d2a4d);
    --sf-brand-soft: var(--web-primary-10, rgba(29, 42, 77, .06));
    --sf-brand-ring: var(--web-primary-20, rgba(29, 42, 77, .13));
    --sf-ink: #1b2233;
    --sf-muted: #667085;
    --sf-line: #e4e7ec;
    --sf-field: #fff;
    --sf-soft: #f5f6f9;
    --sf-ok: #067647;
    --sf-ok-soft: #ecfdf3;
    --sf-bad: #b42318;
    --sf-bad-soft: #fef3f2;
    --sf-radius: 10px;

    margin: 4px 0 18px;
    padding: 20px;
    border: 1px solid var(--sf-line);
    border-radius: 14px;
    background: #fff;
    color: var(--sf-ink);
    font-size: 14px;
    line-height: 1.5;
}

/* Folded it is a strip, not a card: no room is taken for content that is not shown. */
.size-finder.sf-folded {
    padding: 14px 16px;
}

.size-finder [hidden],
.sf-camera[hidden] {
    display: none !important;
}

.size-finder p,
.size-finder h2,
.size-finder h3,
.size-finder ul,
.size-finder dl,
.size-finder dd {
    margin: 0;
}

.size-finder ul {
    padding: 0;
    list-style: none;
}

.sf-icon {
    flex: none;
    width: 18px;
    height: 18px;
}

.sf-icon--sm {
    width: 15px;
    height: 15px;
}

.sf-icon--xs {
    width: 12px;
    height: 12px;
}

.sf-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Header ---------- */

/* The whole header is the disclosure control, so the hit area is the full strip. */
.sf-head {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.sf-head[aria-expanded="true"] {
    margin-bottom: 16px;
}

/* Collapsed, the strip says what it is; open, it also says what it does. */
.sf-head[aria-expanded="false"] .sf-head__lead {
    display: none;
}

.sf-head__chevron {
    margin-inline-start: auto;
    color: var(--sf-muted);
    transition: transform .2s ease;
}

.sf-head[aria-expanded="true"] .sf-head__chevron {
    transform: rotate(180deg);
}

.sf-head:hover .sf-head__chevron {
    color: var(--sf-brand);
}

.sf-head:focus-visible {
    outline: 2px solid var(--sf-brand);
    outline-offset: 4px;
    border-radius: 8px;
}

.sf-head__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--sf-radius);
    background: var(--sf-brand-soft);
    color: var(--sf-brand);
}

.sf-head__icon .sf-icon {
    width: 22px;
    height: 22px;
}

.sf-head__text {
    min-width: 0;
}

.sf-head__title {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
    color: var(--sf-ink);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
}

.sf-badge {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--sf-brand-soft);
    color: var(--sf-brand);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
}

.sf-head__lead {
    display: block;
    margin-top: 2px !important;
    color: var(--sf-muted);
    font-size: 13px;
    font-weight: 400;
}

/* ---------- Method switch ---------- */

.sf-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    border-radius: 12px;
    background: #eef0f4;
}

.sf-tabs__tab {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 6px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--sf-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.sf-tabs__tab:hover {
    color: var(--sf-ink);
}

.sf-tabs__tab[aria-selected="true"] {
    background: #fff;
    color: var(--sf-brand);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
}

/* ---------- Fields ---------- */

.sf-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
    margin-bottom: 14px;
}

.sf-field {
    min-width: 0;
}

.sf-label {
    display: block;
    margin-bottom: 6px;
    color: var(--sf-ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

.sf-label__optional {
    color: var(--sf-muted);
    font-weight: 400;
}

.sf-input {
    position: relative;
}

.sf-input input {
    width: 100%;
    height: 44px;
    padding-block: 0;
    padding-inline: 12px 46px;
    border: 1px solid var(--sf-line);
    border-radius: var(--sf-radius);
    outline: none;
    background: var(--sf-field);
    color: var(--sf-ink);
    font: inherit;
    font-size: 15px;
    -moz-appearance: textfield;
    appearance: textfield;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.sf-input input::-webkit-outer-spin-button,
.sf-input input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.sf-input input::placeholder {
    color: #98a2b3;
    font-size: 14px;
}

.sf-input input:focus {
    border-color: var(--sf-brand);
    box-shadow: 0 0 0 3px var(--sf-brand-ring);
}

.sf-input input[aria-invalid="true"] {
    border-color: var(--sf-bad);
    box-shadow: 0 0 0 3px rgba(180, 35, 24, .12);
}

.sf-input__unit {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 12px;
    display: flex;
    align-items: center;
    color: var(--sf-muted);
    font-size: 13px;
    pointer-events: none;
}

.sf-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.sf-choice__option {
    height: 44px;
    padding: 0 8px;
    border: 1px solid var(--sf-line);
    border-radius: var(--sf-radius);
    background: #fff;
    color: var(--sf-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.sf-choice__option:hover {
    border-color: #c5cad3;
}

.sf-choice__option[aria-checked="true"] {
    border-color: var(--sf-brand);
    background: var(--sf-brand-soft);
    color: var(--sf-brand);
    box-shadow: inset 0 0 0 1px var(--sf-brand);
}

.sf-choice[aria-invalid="true"] .sf-choice__option {
    border-color: var(--sf-bad);
}

.sf-hint {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin: -4px 0 14px !important;
    color: var(--sf-muted);
    font-size: 12px;
}

.sf-hint .sf-icon {
    margin-top: 2px;
}

/* ---------- Buttons ---------- */

.sf-btn {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--sf-radius);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.sf-btn--block {
    width: 100%;
}

.sf-btn--primary {
    background: var(--sf-brand);
    color: #fff;
}

.sf-btn--primary:hover {
    box-shadow: 0 4px 12px var(--sf-brand-ring);
    color: #fff;
}

.sf-btn--outline {
    border-color: var(--sf-line);
    background: #fff;
    color: var(--sf-ink);
}

.sf-btn--outline:hover {
    border-color: var(--sf-brand);
    color: var(--sf-brand);
}

.sf-btn:active {
    transform: translateY(1px);
}

.sf-btn[disabled] {
    opacity: .72;
    cursor: progress;
    transform: none;
}

.sf-tabs__tab:focus-visible,
.sf-choice__option:focus-visible,
.sf-btn:focus-visible,
.sf-link:focus-visible {
    outline: 2px solid var(--sf-brand);
    outline-offset: 2px;
}

.sf-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sf-spin .7s linear infinite;
}

.sf-btn[disabled] .sf-icon {
    display: none;
}

@keyframes sf-spin {
    to {
        transform: rotate(360deg);
    }
}

.sf-actions {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 8px;
}

.sf-link {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--sf-brand);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.sf-link:hover {
    text-decoration: underline;
}

/* ---------- Photo method ---------- */

.sf-tips {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: var(--sf-radius);
    background: var(--sf-soft);
}

.sf-tips__title {
    margin-bottom: 6px !important;
    font-size: 13px;
    font-weight: 700;
}

.sf-tips__list li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: #344054;
    font-size: 13px;
}

.sf-tips__list li + li {
    margin-top: 4px;
}

.sf-tips__list .sf-icon {
    margin-top: 3px;
    color: var(--sf-ok);
}

.sf-preview__img {
    display: block;
    width: 100%;
    max-height: 320px;
    margin-bottom: 10px;
    border-radius: var(--sf-radius);
    background: #0b0f19;
    object-fit: contain;
}

/* ---------- Messages ---------- */

.sf-alert,
.sf-status {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--sf-radius);
    font-size: 13px;
}

.sf-alert {
    background: var(--sf-bad-soft);
    color: var(--sf-bad);
}

.sf-status {
    background: var(--sf-brand-soft);
    color: var(--sf-brand);
}

.sf-alert .sf-icon,
.sf-status .sf-icon {
    margin-top: 1px;
}

/* ---------- Result ---------- */

.sf-result {
    margin-top: 16px;
    overflow: hidden;
    border: 1px solid var(--sf-line);
    border-radius: 12px;
    animation: sf-rise .25s ease-out;
}

@keyframes sf-rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

.sf-result__head {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    background: var(--sf-brand-soft);
}

.sf-result__size {
    display: grid;
    flex: none;
    place-items: center;
    min-width: 58px;
    height: 58px;
    padding: 0 10px;
    border-radius: 12px;
    background: var(--sf-brand);
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .02em;
    direction: ltr;
}

.sf-result__summary {
    min-width: 0;
}

.sf-result__label {
    color: var(--sf-muted);
    font-size: 12px;
    font-weight: 600;
}

.sf-result__note {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin-top: 2px;
    color: #344054;
    font-size: 13px;
}

.sf-result__note .sf-icon {
    margin-top: 2px;
}

.sf-result__note--ok {
    color: var(--sf-ok);
    font-weight: 600;
}

.sf-result__sub {
    color: var(--sf-muted);
    font-size: 12px;
    font-weight: 400;
}

.sf-result__body {
    padding: 4px 16px 0;
}

.sf-result__body:empty {
    display: none;
}

.sf-result__section {
    padding: 12px 0;
}

.sf-result__section + .sf-result__section {
    border-top: 1px dashed var(--sf-line);
}

.sf-result__title {
    margin-bottom: 8px !important;
    color: var(--sf-muted);
    font-size: 12px;
    font-weight: 700;
}

.sf-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sf-tag {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--sf-soft);
    color: #475467;
    font-size: 13px;
}

.sf-tag b {
    color: var(--sf-ink);
    direction: ltr;
    unicode-bidi: isolate;
}

.sf-fit__row {
    display: flex;
    gap: 12px;
    align-items: baseline;
    font-size: 13px;
}

.sf-fit__row + .sf-fit__row {
    margin-top: 4px;
}

.sf-fit__row dt {
    flex: none;
    min-width: 56px;
    color: var(--sf-muted);
    font-weight: 600;
}

.sf-fit__row dd {
    color: #344054;
}

.sf-fit__pair b {
    color: var(--sf-ink);
    direction: ltr;
    unicode-bidi: isolate;
}

.sf-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.sf-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    border-radius: var(--sf-radius);
    background: var(--sf-soft);
}

.sf-stat__value {
    color: var(--sf-ink);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.sf-stat__value small {
    color: var(--sf-muted);
    font-size: 11px;
    font-weight: 600;
}

.sf-stat__label {
    color: var(--sf-muted);
    font-size: 12px;
}

.sf-result__foot {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid var(--sf-line);
}

/* The size option the finder chose, on the product's own option chips. */
.checkbox-alphanumeric--style-1 label.sf-recommended {
    position: relative;
    overflow: visible;
}

.checkbox-alphanumeric--style-1 label.sf-recommended::after {
    content: "";
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #067647 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 10px no-repeat;
    box-shadow: 0 0 0 2px #fff;
}

/* ---------- Full-screen camera (moved under <body> by the script) ---------- */

html.sf-no-scroll,
html.sf-no-scroll body {
    overflow: hidden;
}

.sf-camera {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
    background: #000;
}

.sf-camera__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sf-camera__frame {
    position: absolute;
    inset: 12% 20% 22%;
    border: 2px dashed rgba(255, 255, 255, .65);
    border-radius: 48% 48% 24px 24px / 22% 22% 24px 24px;
    pointer-events: none;
}

.sf-camera__hint {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    inset-inline: 72px;
    margin: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

.sf-camera__close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    inset-inline-end: 12px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    cursor: pointer;
}

.sf-camera__close .sf-icon {
    width: 22px;
    height: 22px;
}

.sf-camera__shutter {
    position: relative;
    width: 72px;
    height: 72px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .35);
    cursor: pointer;
}

.sf-camera__shutter:active {
    transform: scale(.94);
}

/* ---------- Body model dialog (appended to <body>) ---------- */

.sf-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(12, 17, 29, .72);
}

.sf-modal__dialog {
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 16px;
    border-radius: 14px;
    background: #fff;
}

.sf-modal__head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sf-modal__title {
    margin: 0;
    color: #1b2233;
    font-size: 16px;
    font-weight: 700;
}

.sf-modal__note {
    margin: 0;
    color: #667085;
    font-size: 13px;
}

.sf-modal__close {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid #e4e7ec;
    border-radius: 50%;
    background: #fff;
    color: #1b2233;
    cursor: pointer;
}

.sf-modal__img {
    display: block;
    width: 100%;
    max-height: 65vh;
    border-radius: 10px;
    object-fit: contain;
}

@media (max-width: 575.98px) {
    .size-finder {
        padding: 16px;
    }

    .sf-grid {
        gap: 12px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sf-result,
    .sf-spinner {
        animation: none;
    }

    .sf-tabs__tab,
    .sf-choice__option,
    .sf-btn,
    .sf-input input {
        transition: none;
    }
}
