/**
 * Ring size guide (ARKAN-202) — inc/core/ring-size-guide.php, js/ring-size-guide.js.
 * Values from the "Qtrshoe Ring Size Guide" design: product page desktop (panel
 * from the right, 420px), product page mobile (bottom sheet) and the shop filter
 * drawer (guide over the drawer).
 */

.ring-guide[hidden] {
    display: none !important;
}

.ring-guide {
    --rg-ink: #1a1a1a;
    --rg-text: #555555;
    --rg-muted: #6b6b6b;
    --rg-off: #8a8a8a;
    --rg-line: #ececec;
    --rg-rule: #e3e3e3;
    font-family: 'Inter', system-ui, sans-serif;
}

.ring-guide *,
.ring-guide *::before,
.ring-guide *::after {
    box-sizing: border-box;
}

/* ---------- Product page: panel / sheet over the page ---------- */

.ring-guide--product {
    position: fixed;
    inset: 0;
    z-index: 100000;
}

.ring-guide__scrim {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 20, 0.42);
    animation: ring-guide-fade .25s ease-out;
}

.ring-guide--product .ring-guide__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100%;
    background: #ffffff;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 28px 32px;
    animation: ring-guide-in-right .3s cubic-bezier(.2, .8, .2, 1);
}

html[dir="rtl"] .ring-guide--product .ring-guide__panel {
    right: auto;
    left: 0;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
    animation-name: ring-guide-in-left;
}

/* No page scrolling behind the open guide */
html.ring-guide-open,
html.ring-guide-open body {
    overflow: hidden;
}

@media (max-width: 1023px) {
    .ring-guide--product .ring-guide__panel,
    html[dir="rtl"] .ring-guide--product .ring-guide__panel {
        top: auto;
        left: 0;
        right: 0;
        width: auto;
        height: min(720px, calc(100% - 40px));
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.14);
        padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
        animation-name: ring-guide-in-up;
    }
}

/* ---------- Filter drawer: covers the drawer ---------- */

.ring-guide--filter {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.ring-guide--filter .ring-guide__panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 20px 28px;
}

/* ---------- Content (both) ---------- */

.ring-guide__panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--rg-text);
    outline: none;
}

.ring-guide__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ring-guide__title {
    margin: 0;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 26px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    color: var(--rg-ink);
}

.ring-guide__close {
    border: 0;
    background: none;
    padding: 10px 0;
    margin: 0;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.2;
    text-decoration: underline;
    text-underline-offset: 3px;
    color: var(--rg-ink);
    cursor: pointer;
}

.ring-guide__tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 1px solid var(--rg-rule);
}

.ring-guide__tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0 0 -1px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    padding: 10px 0 12px;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.3;
    color: var(--rg-off);
    cursor: pointer;
}

.ring-guide__tab[aria-selected="true"] {
    color: var(--rg-ink);
    border-bottom-color: var(--rg-ink);
}

.ring-guide__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* "How to measure" only on its tab; the US column and the help text only on "Find your size" */
.ring-guide[data-tab="find"] .ring-guide__measure,
.ring-guide[data-tab="measure"] .ring-guide__us,
.ring-guide[data-tab="measure"] .ring-guide__find {
    display: none;
}

.ring-guide__measure {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ring-guide__subtitle {
    margin: 4px 0 0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: 0;
    color: var(--rg-ink);
}

.ring-guide__steps {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ring-guide__steps li {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin: 0;
}

.ring-guide__step-no {
    flex: 0 0 12px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 22px;
    line-height: 1;
    color: var(--rg-ink);
}

.ring-guide__tip {
    margin: 0;
    font-style: italic;
    font-size: 11px;
    color: var(--rg-muted);
}

.ring-guide__figure {
    display: flex;
    justify-content: center;
}

.ring-guide__figure svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* cm / inches */
.ring-guide__units {
    display: flex;
    gap: 22px;
    margin: 0;
    padding: 4px 0 0;
    border: 0;
    min-width: 0;
}

.ring-guide__units label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--rg-ink);
    cursor: pointer;
}

.ring-guide__units input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
}

.ring-guide__radio {
    width: 14px;
    height: 14px;
    flex: none;
    border-radius: 999px;
    border: 1px solid #9a9a9a;
}

.ring-guide__units input:checked + .ring-guide__radio {
    border: 4px solid var(--rg-ink);
}

.ring-guide__units input:focus-visible + .ring-guide__radio {
    outline: 2px solid var(--rg-ink);
    outline-offset: 2px;
}

.ring-guide__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Chart */
.ring-guide__table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 12px;
    border: 1px solid var(--rg-line);
}

.ring-guide__table thead tr {
    background: #f5f5f3;
}

.ring-guide__table th {
    padding: 10px 4px;
    font-weight: 500;
    color: var(--rg-text);
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
    border-right: 1px solid var(--rg-line);
}

.ring-guide__table th:last-child {
    border-right: 0;
}

.ring-guide__table tbody tr {
    border-bottom: 1px solid var(--rg-line);
    color: var(--rg-ink);
    font-weight: 400;
}

.ring-guide__table td {
    padding: 10px 4px;
    text-align: center;
    border-right: 1px solid var(--rg-line);
}

.ring-guide__table td:last-child {
    border-right: 0;
}

.ring-guide__table td.ring-guide__eu {
    border-left: 3px solid transparent;
}

/* US sizes such as "3¾" read left to right on Arabic pages too (else "¾3") */
.ring-guide__table td.ring-guide__us {
    direction: ltr;
    unicode-bidi: isolate;
}

html[dir="rtl"] .ring-guide__table td,
html[dir="rtl"] .ring-guide__table th {
    border-right: 0;
    border-left: 1px solid var(--rg-line);
}

html[dir="rtl"] .ring-guide__table td:last-child,
html[dir="rtl"] .ring-guide__table th:last-child {
    border-left: 0;
}

html[dir="rtl"] .ring-guide__table td.ring-guide__eu {
    border-right: 3px solid transparent;
}

/* Product: in stock bold, sold out grey, selected marked */
.ring-guide--product .ring-guide__table tr.is-available {
    font-weight: 600;
}

.ring-guide--product .ring-guide__table tr.is-soldout {
    color: #9a9a9a;
}

/* Filter: the chosen sizes */
.ring-guide--filter .ring-guide__table tbody tr {
    color: var(--rg-text);
}

.ring-guide--filter .ring-guide__table tr.is-selected {
    color: var(--rg-ink);
    font-weight: 600;
}

.ring-guide__table tr.is-selected {
    font-weight: 600;
}

.ring-guide__table tr.is-selected td.ring-guide__eu {
    border-left-color: #2f3b36;
}

html[dir="rtl"] .ring-guide__table tr.is-selected td.ring-guide__eu {
    border-left-color: var(--rg-line);
    border-right-color: #2f3b36;
}

/* Help + advisor */
.ring-guide__find {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ring-guide__find p {
    margin: 0;
}

.ring-guide__advisor {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid var(--rg-ink);
    background: #ffffff;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--rg-ink);
    text-decoration: none;
    transition: background .2s, color .2s;
}

.ring-guide__advisor:hover,
.ring-guide__advisor:focus-visible {
    background: var(--rg-ink);
    color: #ffffff;
    text-decoration: none;
}

.ring-guide__close:focus-visible,
.ring-guide__tab:focus-visible,
.ring-guide__advisor:focus-visible {
    outline: 2px solid var(--rg-ink);
    outline-offset: 2px;
}

/* ---------- "Size guide" link beside the Size label (product page) ---------- */

.ring-guide-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px auto;
    border: 0;
    background: none;
    padding: 8px 0;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.2;
    text-decoration: underline;
    text-underline-offset: 3px;
    color: #1a1a1a;
    cursor: pointer;
}

html[dir="rtl"] .ring-guide-link {
    margin: 0 auto 10px 0;
}

.ring-guide-link[hidden] {
    display: none;
}

/* The ruler shows on desktop, as in the design; phones have the text alone */
@media (max-width: 1023px) {
    .ring-guide-link svg {
        display: none;
    }
}

/* ---------- Motion ---------- */

@keyframes ring-guide-fade { from { opacity: 0; } }
@keyframes ring-guide-in-right { from { transform: translateX(32px); opacity: 0; } }
@keyframes ring-guide-in-left { from { transform: translateX(-32px); opacity: 0; } }
@keyframes ring-guide-in-up { from { transform: translateY(40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .ring-guide__scrim,
    .ring-guide--product .ring-guide__panel {
        animation: none;
    }
}
