/* =============================================================================
   Octobyte Color Swatches — front-end
   The clickable <a> IS the circle (ring via border) and the colour/image is
   CONTAINED inside it via absolute insets — so the dot has no width/height of
   its own that a theme's generic `span`/`a` rules could squash into an oval.
   ============================================================================= */

.octobyte-ocs-swatches {
    --ocs-size: 30px;          /* colour dot diameter      */
    --ocs-gap: 13px;           /* space between swatches    */
    --ocs-pad: 4px;            /* air between dot and ring  */
    --ocs-ring: #0f172a;       /* active ring colour        */
    --ocs-edge: rgba(15, 23, 42, 0.14);
    --ocs-tip-bg: #0f172a;

    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ocs-gap);
    margin: 16px 0;
    padding: 0;
    list-style: none;
}

.octobyte-ocs--sm { --ocs-size: 24px; --ocs-gap: 11px; --ocs-pad: 3px; }
.octobyte-ocs--md { --ocs-size: 30px; --ocs-gap: 13px; --ocs-pad: 4px; }
.octobyte-ocs--lg { --ocs-size: 40px; --ocs-gap: 16px; --ocs-pad: 5px; }

/* Wrapper + "COLOUR: <name>" label */
.octobyte-ocs { margin: 14px 0; }
.octobyte-ocs .octobyte-ocs-swatches { margin: 0; }

.octobyte-ocs-label {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.3;
    color: #0f172a;
}
.octobyte-ocs-label-key {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    color: #64748b;
}
.octobyte-ocs-label-val {
    font-weight: 600;
}

/* Shop / archive loop context (auto-injection after the product title) */
li.product .octobyte-ocs { margin: 8px 0 4px; }
li.product .octobyte-ocs-label { font-size: 12px; margin-bottom: 6px; }

/* Alignment (left default / center / right) */
.octobyte-ocs--align-left .octobyte-ocs-swatches { justify-content: flex-start; }
.octobyte-ocs--align-center .octobyte-ocs-swatches { justify-content: center; }
.octobyte-ocs--align-right .octobyte-ocs-swatches { justify-content: flex-end; }
.octobyte-ocs--align-center .octobyte-ocs-label { text-align: center; }
.octobyte-ocs--align-right .octobyte-ocs-label { text-align: right; }

/* The circle = the clickable. Outer size = dot + air on both sides + 1px ring.
   width AND height are forced equal (with aspect-ratio as a backup) so it can
   never become an oval; the dot inside is positioned, never sized. */
.octobyte-ocs-swatches .octobyte-ocs-swatch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: calc(var(--ocs-size) + var(--ocs-pad) * 2 + 2px) !important;
    height: calc(var(--ocs-size) + var(--ocs-pad) * 2 + 2px) !important;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: none;
    line-height: 0;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

/* The colour/image fills the circle, leaving `--ocs-pad` of air to the ring. */
.octobyte-ocs-swatches .octobyte-ocs-swatch-dot {
    position: absolute;
    top: var(--ocs-pad);
    right: var(--ocs-pad);
    bottom: var(--ocs-pad);
    left: var(--ocs-pad);
    border-radius: 50%;
    background-color: #f1f5f9;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 0 0 1px var(--ocs-edge);
}

/* Square variant */
.octobyte-ocs--square .octobyte-ocs-swatch { border-radius: 9px; }
.octobyte-ocs--square .octobyte-ocs-swatch-dot { border-radius: 6px; }

/* Hover / focus / active states */
.octobyte-ocs-swatch:hover {
    transform: translateY(-1px);
    border-color: var(--ocs-edge);
}

.octobyte-ocs-swatch:focus-visible {
    outline: none;
    border-color: var(--ocs-ring);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.18);
}

.octobyte-ocs-swatch.is-active {
    border-color: var(--ocs-ring);
}

/* On-hover colour-name tooltip */
.octobyte-ocs-swatch-name {
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    z-index: 5;
    padding: 6px 9px;
    border-radius: 6px;
    background: var(--ocs-tip-bg);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: 0;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
}

.octobyte-ocs-swatch-name::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--ocs-tip-bg);
}

.octobyte-ocs-swatch:hover .octobyte-ocs-swatch-name,
.octobyte-ocs-swatch:focus-visible .octobyte-ocs-swatch-name {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Editor empty-state hint (never shown on the front-end) */
.octobyte-ocs-empty {
    padding: 10px 14px;
    border: 1px dashed rgba(15, 23, 42, 0.25);
    border-radius: 8px;
    color: #64748b;
    font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
    .octobyte-ocs-swatch,
    .octobyte-ocs-swatch-name { transition: none; }
    .octobyte-ocs-swatch:hover { transform: none; }
}
