/*
 * Clothing Tag Widget — frontend styles
 * v2.0: adds scroll-reveal, hover-amplify, slogan font variable.
 */

/* ---------- root & positioning ---------- */

.ctw-root {
    position: fixed;
    top: var(--ctw-top, 220px);
    width: var(--ctw-w, 170px);
    height: var(--ctw-h, 110px);
    pointer-events: none;
    z-index: var(--ctw-z, 9999);
    perspective: 900px;
    /* scroll-reveal starts hidden; JS + .ctw-visible reveals it */
    transition: opacity 0.6s ease-out;
}

.ctw-pos-left  { left:  var(--ctw-side, 0px); }
.ctw-pos-right { right: var(--ctw-side, 0px); }

.ctw-hide-mobile { display: none; }
@media (min-width: 769px) { .ctw-hide-mobile { display: block; } }

@media (max-width: 600px) {
    .ctw-root {
        width:  calc(var(--ctw-w, 170px) * 0.75);
        height: calc(var(--ctw-h, 110px) * 0.75);
    }
}

/* ---------- scroll reveal ---------- */

.ctw-scroll-reveal {
    opacity: 0;
}
.ctw-scroll-reveal.ctw-visible {
    opacity: 1;
}

/* ---------- anchor wraps everything ---------- */

.ctw-anchor {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ---------- the swinging body ---------- */

.ctw-body {
    position: absolute;
    inset: 0;
    will-change: transform, filter;
    pointer-events: auto;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: filter 0.35s ease;
}

.ctw-pos-left  .ctw-body { transform-origin:   0% 50%; }
.ctw-pos-right .ctw-body { transform-origin: 100% 50%; }

/* Hover amplification — extra lift shadow when cursor is directly over the tag */
.ctw-hover-amplify .ctw-body:hover {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18));
}

/* ---------- cast shadow ---------- */

.ctw-shadow {
    position: absolute;
    inset: 0;
    border-radius: 2px;
    z-index: -1;
    background: transparent;
}
.ctw-pos-left .ctw-shadow {
    box-shadow:
         3px  2px  4px rgba(0,0,0,calc(0.10 * var(--ctw-shadow, 0.35))),
         8px  4px 14px rgba(0,0,0,calc(0.16 * var(--ctw-shadow, 0.35))),
        18px  8px 26px rgba(0,0,0,calc(0.20 * var(--ctw-shadow, 0.35)));
}
.ctw-pos-right .ctw-shadow {
    box-shadow:
         -3px  2px  4px rgba(0,0,0,calc(0.10 * var(--ctw-shadow, 0.35))),
         -8px  4px 14px rgba(0,0,0,calc(0.16 * var(--ctw-shadow, 0.35))),
        -18px  8px 26px rgba(0,0,0,calc(0.20 * var(--ctw-shadow, 0.35)));
}

/* ---------- fabric face ---------- */

.ctw-face {
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background:
        radial-gradient(160% 120% at 50% 50%,
            rgba(255,255,255,0.14) 0%,
            rgba(255,255,255,0.00) 35%,
            rgba(0,0,0,0.04) 80%,
            rgba(0,0,0,0.08) 100%),
        var(--ctw-fabric, #f5f2ec);
    overflow: hidden;
    isolation: isolate;
}

.ctw-face::before,
.ctw-face::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--ctw-fabric, #f5f2ec);
    opacity: 0.7;
}
.ctw-pos-left  .ctw-face::before { right: -2px; top:    -2px; transform: rotate(-10deg); }
.ctw-pos-left  .ctw-face::after  { right: -2px; bottom: -2px; transform: rotate( 10deg); }
.ctw-pos-right .ctw-face::before { left:  -2px; top:    -2px; transform: rotate( 10deg); }
.ctw-pos-right .ctw-face::after  { left:  -2px; bottom: -2px; transform: rotate(-10deg); }

/* stitched border */
.ctw-stitch-border {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.85;
    z-index: 2;
}

/* fold shadow on attached edge */
.ctw-fold {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 18px;
    pointer-events: none;
    z-index: 3;
}
.ctw-pos-left .ctw-fold {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.10) 50%, rgba(0,0,0,0.00) 100%);
    border-radius: 2px 0 0 2px;
}
.ctw-pos-right .ctw-fold {
    right: 0;
    background: linear-gradient(to left, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.10) 50%, rgba(0,0,0,0.00) 100%);
    border-radius: 0 2px 2px 0;
}

/* double-stitched seam */
.ctw-seam {
    position: absolute;
    top:    3%;
    bottom: 3%;
    width:  6px;
    pointer-events: none;
    z-index: 4;
}
.ctw-pos-left  .ctw-seam { left:  5px; }
.ctw-pos-right .ctw-seam { right: 5px; }

.ctw-seam-stitch {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 1;
}

/* hairline at very edge */
.ctw-body::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: rgba(0, 0, 0, 0.28);
    z-index: 5;
    pointer-events: none;
}
.ctw-pos-left  .ctw-body::before { left:  0; }
.ctw-pos-right .ctw-body::before { right: 0; }

/* ---------- size tab flush to screen edge ---------- */

.ctw-size-tab {
    position: absolute;
    top: -22px;
    height: 20px;
    min-width: 48px;
    width: auto;
    padding: 0 10px;
    background: var(--ctw-seam, #c9b89a);
    color: rgba(0, 0, 0, 0.72);
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow:
        inset 0 -3px 5px rgba(0,0,0,0.08),
        0 1px 3px        rgba(0,0,0,0.18);
    z-index: 1;
    will-change: transform;
}
.ctw-pos-left  .ctw-size-tab { left: 0;  border-radius: 0 3px 3px 0; }
.ctw-pos-right .ctw-size-tab { right: 0; border-radius: 3px 0 0 3px; }

.ctw-size-tab::before {
    content: "";
    position: absolute;
    top: 3px;
    bottom: 3px;
    width: 0;
}
.ctw-pos-left  .ctw-size-tab::before { left:  3px; border-left:  1px dashed rgba(0,0,0,0.3); }
.ctw-pos-right .ctw-size-tab::before { right: 3px; border-right: 1px dashed rgba(0,0,0,0.3); }

.ctw-size-text {
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.ctw-size-icon {
    width: 20px;
    height: 14px;
    display: block;
    color: inherit;
    opacity: 0.95;
    flex-shrink: 0;
}

/* ---------- content: logo + slogan ---------- */

.ctw-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8% 10%;
    color: var(--ctw-text, #2b2622);
    text-align: center;
    z-index: 2;
}
.ctw-pos-left  .ctw-content { padding-left:  16%; }
.ctw-pos-right .ctw-content { padding-right: 16%; }

.ctw-logo,
.ctw-logo-placeholder {
    max-width: 80%;
    max-height: 55%;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0.5px 0 rgba(0,0,0,0.12));
    opacity: 0.92;
}
.ctw-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ctw-text, #2b2622);
    opacity: 0.5;
}

/* Slogan — font is driven by the --ctw-slogan-font variable */
.ctw-slogan {
    font-family: var(--ctw-slogan-font, 'Brush Script MT', 'Segoe Script', cursive, serif);
    font-size: clamp(11px, calc(var(--ctw-h, 110px) / 7), 22px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.5px;
    color: var(--ctw-text, #2b2622);
    opacity: 0.88;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 0.5px 0 rgba(0,0,0,0.08);
}
/* Some fonts (Playfair, Lora) read better as italic */
.ctw-slogan-italic .ctw-slogan {
    font-style: italic;
}

/* ---------- noise + weave + highlight ---------- */

.ctw-noise {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    mix-blend-mode: multiply;
    opacity: 0.38;
    z-index: 1;
}

.ctw-texture {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(0deg,
            rgba(0,0,0,0.025) 0px, rgba(0,0,0,0.025) 1px,
            transparent 1px, transparent 2px),
        repeating-linear-gradient(90deg,
            rgba(0,0,0,0.02) 0px, rgba(0,0,0,0.02) 1px,
            transparent 1px, transparent 2px);
    mix-blend-mode: multiply;
    opacity: 0.7;
    z-index: 1;
}

.ctw-highlight {
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: soft-light;
    z-index: 1;
}
.ctw-pos-left .ctw-highlight {
    background: linear-gradient(100deg,
        rgba(255,255,255,0.00)  0%,
        rgba(255,255,255,0.18)  30%,
        rgba(255,255,255,0.00)  55%,
        rgba(0,0,0,0.07)        100%);
}
.ctw-pos-right .ctw-highlight {
    background: linear-gradient(260deg,
        rgba(255,255,255,0.00)  0%,
        rgba(255,255,255,0.18)  30%,
        rgba(255,255,255,0.00)  55%,
        rgba(0,0,0,0.07)        100%);
}

/* ---------- link wrapper & keyboard focus ---------- */

.ctw-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    outline: none;
    border-radius: 2px;
}
.ctw-link:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 3px;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .ctw-body,
    .ctw-size-tab,
    .ctw-root {
        transition: none !important;
        animation: none !important;
    }
}
