/* ==========================================================================
   Section headings with brand accent (home page)
   --------------------------------------------------------------------------
   Markup: include/common/section-heading.blade.php (pushes this file once).
   Behaviour: js/section-heading.js

   [badge]  <accent words> Rest
            ▬▬▬ ▪

   - Badge, accent words and bar use the brand gradient (primary pink ->
     orange, the warm tones of the home hero). On white the orange end is a
     darker shade so the words keep 3:1 contrast; on dark sections a lighter
     set is used (.title-accent--dark).
   - Entrance: when a heading scrolls into view the badge pops in, the text
     rises and the bar draws itself (.ta-hidden -> .ta-reveal, set by the JS).
   - Life: while a heading is on screen (.is-live) a ring pulses out of the
     badge, a light crosses it, the icon does its own small move and a light
     runs along the bar. Off screen nothing runs at all.
   - Hover: badge tilts and glows, the accent colours flow, the bar stretches.
   - Only transform / opacity animate in the loops. "Reduce motion" turns all
     of it off and shows the headings as they are.
   ========================================================================== */

.title-accent {
    --ta-from: var(--td-primary, #ff5463);
    --ta-mid: #f43f5e;
    --ta-to: #ea580c;
    --ta-rest: var(--td-heading, #1e1d25);
    --ta-rgb: var(--td-primary-rgb, 255, 84, 99);
    --ta-dot: rgba(var(--ta-rgb), 0.35);
    --ta-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ta-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: start;
}

.title-accent--dark {
    --ta-from: #ff7d8c;
    --ta-mid: #ff9a7a;
    --ta-to: #ffc06b;
    --ta-rest: #fff;
    --ta-dot: rgba(255, 255, 255, 0.35);
}

.title-accent--center {
    justify-content: center;
}

.title-accent--center .title-accent-body {
    align-items: center;
}

/* ---------- Badge --------------------------------------------------------- */

.title-accent-mark {
    position: relative;
    flex-shrink: 0;
    display: block;
}

.title-accent-badge {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, #ff7686 0%, var(--td-primary, #ff5463) 40%, #ea580c 100%);
    box-shadow:
        0 12px 24px -10px rgba(var(--ta-rgb), 0.75),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
    overflow: hidden;
    isolation: isolate;
    transition:
        opacity 0.45s ease,
        rotate 0.75s var(--ta-spring),
        scale 0.75s var(--ta-spring),
        box-shadow 0.35s ease;
}

/* Thin inner border so the badge looks finished on any background */
.title-accent-badge::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(255, 255, 255, 0.25);
    pointer-events: none;
}

/* Light that crosses the badge (runs only while on screen) */
.title-accent-badge::after {
    content: "";
    position: absolute;
    z-index: 0;
    top: -20%;
    bottom: -20%;
    left: -10%;
    width: 60%;
    background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, 0.55) 50%, transparent 80%);
    transform: translateX(-140%) skewX(-12deg);
    pointer-events: none;
}

.title-accent-badge svg {
    position: relative;
    z-index: 1;
    width: 25px;
    height: 25px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
    transform-origin: 50% 50%;
    transition: scale 0.45s var(--ta-spring);
}

/* Ring that pulses out of the badge */
.title-accent-halo {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    border: 2px solid rgba(var(--ta-rgb), 0.55);
    opacity: 0;
    pointer-events: none;
}

.title-accent--dark .title-accent-halo {
    border-color: rgba(255, 125, 140, 0.6);
}

/* ---------- Title --------------------------------------------------------- */

.title-accent-body {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
}

.title-accent .section-title {
    color: var(--ta-rest);
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.15;
    text-align: inherit;
    transition: opacity 0.6s ease, translate 0.7s var(--ta-ease);
}

/* Trending Products had its own smaller size; keep all headings the same */
.trending-product .section-header .title-accent .section-title {
    font-size: 30px !important;
}

@media only screen and (min-width: 768px) and (max-width: 991px) {
    .trending-product .section-header .title-accent .section-title {
        font-size: 28px !important;
    }
}

@media (max-width: 767px) {
    .trending-product .section-header .title-accent .section-title {
        font-size: 26px !important;
    }
}

.title-accent-text {
    color: var(--ta-from);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .title-accent-text {
        /* 200% wide and mirrored: hover slides it to show the colours flowing back */
        background-image: linear-gradient(95deg,
                var(--ta-from) 0%, var(--ta-mid) 25%, var(--ta-to) 50%,
                var(--ta-mid) 75%, var(--ta-from) 100%);
        background-size: 200% 100%;
        background-position: 0% 0;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        /* keep descenders (g, y) inside the painted area */
        padding-bottom: 0.08em;
        transition: background-position 0.8s var(--ta-ease);
    }
}

/* ---------- Bar under the title ------------------------------------------ */

.title-accent-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.title-accent-bar {
    position: relative;
    display: block;
    width: 56px;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--ta-from), var(--ta-to));
    overflow: hidden;
    transform-origin: left center;
    transition: width 0.5s var(--ta-ease), scale 0.7s var(--ta-ease);
}

[dir="rtl"] .title-accent-bar {
    background: linear-gradient(270deg, var(--ta-from), var(--ta-to));
    transform-origin: right center;
}

/* Light that runs along the bar (only while on screen) */
.title-accent-bar::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
    transform: translateX(-110%);
}

.title-accent-dot {
    display: block;
    width: 10px;
    height: 4px;
    border-radius: 4px;
    background: var(--ta-dot);
    transition: opacity 0.4s ease, scale 0.5s var(--ta-spring), background-color 0.3s ease;
}

/* ---------- Entrance (heading scrolls into view) -------------------------- */

.title-accent.ta-hidden .title-accent-badge {
    opacity: 0;
    scale: 0.4;
    rotate: -25deg;
}

.title-accent.ta-hidden .section-title {
    opacity: 0;
    translate: 0 16px;
}

.title-accent.ta-hidden .title-accent-text {
    background-position: 100% 0;
}

.title-accent.ta-hidden .title-accent-bar {
    scale: 0 1;
}

.title-accent.ta-hidden .title-accent-dot {
    opacity: 0;
    scale: 0;
}

.title-accent.ta-instant *,
.title-accent.ta-instant *::before,
.title-accent.ta-instant *::after {
    transition: none !important;
}

/* Order of the entrance; .ta-reveal is only there while it plays */
.title-accent.ta-reveal .section-title {
    transition-delay: 0.12s;
}

.title-accent.ta-reveal .title-accent-bar {
    transition-delay: 0s, 0.3s;
}

.title-accent.ta-reveal .title-accent-dot {
    transition-delay: 0.6s, 0.6s, 0s;
}

/* ---------- Life while on screen ------------------------------------------ */

.title-accent.is-live .title-accent-halo {
    animation: taPing 3.4s cubic-bezier(0, 0, 0.2, 1) 0.8s infinite;
}

.title-accent.is-live .title-accent-badge::after {
    animation: taShine 5.5s ease-in-out 1.6s infinite;
}

.title-accent.is-live .title-accent-bar::after {
    animation: taBarLight 3.6s ease-in-out 1.2s infinite;
}

@keyframes taPing {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    45%,
    100% {
        transform: scale(1.45);
        opacity: 0;
    }
}

@keyframes taShine {
    0% {
        transform: translateX(-140%) skewX(-12deg);
    }

    28%,
    100% {
        transform: translateX(260%) skewX(-12deg);
    }
}

@keyframes taBarLight {
    0% {
        transform: translateX(-110%);
    }

    40%,
    100% {
        transform: translateX(260%);
    }
}

/* Each icon has its own small move */
.title-accent.is-live [data-icon="trophy"] svg {
    transform-origin: 50% 90%;
    animation: taWobble 4.5s ease-in-out 1s infinite;
}

.title-accent.is-live [data-icon="flame"] svg {
    transform-origin: 50% 100%;
    animation: taFlicker 1.8s ease-in-out infinite;
}

.title-accent.is-live [data-icon="trending"] svg {
    animation: taClimb 3.2s ease-in-out 0.6s infinite;
}

.title-accent.is-live [data-icon="sparkles"] svg {
    animation: taTwinkle 2.8s ease-in-out infinite;
}

.title-accent.is-live [data-icon="star"] svg {
    animation: taStarTurn 4s ease-in-out 0.8s infinite;
}

.title-accent.is-live [data-icon="newspaper"] svg {
    transform-origin: 30% 90%;
    animation: taFlip 4.2s ease-in-out 1s infinite;
}

.title-accent.is-live [data-icon="history"] svg {
    animation: taRewind 4.5s ease-in-out 1s infinite;
}

.title-accent.is-live [data-icon="users"] svg {
    animation: taHop 3.6s ease-in-out 0.8s infinite;
}

@keyframes taWobble {

    0%,
    60%,
    100% {
        transform: rotate(0);
    }

    66% {
        transform: rotate(-12deg);
    }

    72% {
        transform: rotate(10deg);
    }

    78% {
        transform: rotate(-6deg);
    }

    84% {
        transform: rotate(3deg);
    }
}

@keyframes taFlicker {

    0%,
    100% {
        transform: scale(1, 1);
    }

    25% {
        transform: scale(0.94, 1.08) translateY(-1px);
    }

    50% {
        transform: scale(1.04, 0.96);
    }

    75% {
        transform: scale(0.97, 1.05) translateY(-0.5px);
    }
}

@keyframes taClimb {

    0%,
    50%,
    100% {
        transform: translate(0, 0);
    }

    65% {
        transform: translate(2px, -3px);
    }

    80% {
        transform: translate(0, 0);
    }

    88% {
        transform: translate(1px, -1.5px);
    }
}

@keyframes taTwinkle {

    0%,
    100% {
        transform: scale(1) rotate(0);
    }

    50% {
        transform: scale(1.14) rotate(14deg);
    }
}

/* A five-point star looks the same after 72deg, so the loop has no jump */
@keyframes taStarTurn {

    0%,
    55% {
        transform: rotate(0) scale(1);
    }

    75% {
        transform: rotate(72deg) scale(1.15);
    }

    90%,
    100% {
        transform: rotate(72deg) scale(1);
    }
}

@keyframes taFlip {

    0%,
    62%,
    100% {
        transform: rotate(0);
    }

    70% {
        transform: rotate(-9deg) translateY(-1px);
    }

    80% {
        transform: rotate(5deg);
    }

    88% {
        transform: rotate(-2deg);
    }
}

@keyframes taRewind {

    0%,
    55% {
        transform: rotate(0);
    }

    85%,
    100% {
        transform: rotate(-360deg);
    }
}

@keyframes taHop {

    0%,
    58%,
    100% {
        transform: translateY(0);
    }

    68% {
        transform: translateY(-3px);
    }

    78% {
        transform: translateY(0);
    }

    86% {
        transform: translateY(-1.5px);
    }
}

/* ---------- Hover (real mouse only) --------------------------------------- */

@media (hover: hover) and (pointer: fine) {
    .title-accent:hover .title-accent-badge {
        rotate: -8deg;
        scale: 1.08;
        box-shadow:
            0 16px 30px -10px rgba(var(--ta-rgb), 0.9),
            0 0 0 4px rgba(var(--ta-rgb), 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }

    .title-accent:hover .title-accent-badge svg {
        scale: 1.12;
    }

    .title-accent:hover .title-accent-text {
        background-position: 100% 0;
    }

    .title-accent:hover .title-accent-bar {
        width: 92px;
    }

    .title-accent:hover .title-accent-dot {
        background-color: var(--ta-to);
        scale: 1.25;
    }
}

/* ---------- Layout fixes per section ------------------------------------- */

/* Customer Reviews / Popular Sellers: title centred, slider arrows at the end */
@media (max-width: 767px) {
    .section-header-3 .title-accent--center {
        justify-content: flex-start;
    }

    .section-header-3 .title-accent--center .title-accent-body {
        align-items: flex-start;
    }

    .section-header-3:has(.view-all-button) .title-accent {
        padding-inline-end: 84px;
    }
}

/* ---------- Smaller screens ---------------------------------------------- */

@media (max-width: 767px) {
    .title-accent {
        gap: 12px;
    }

    .title-accent-badge,
    .title-accent-halo {
        width: 44px;
        height: 44px;
        border-radius: 13px;
    }

    .title-accent-badge svg {
        width: 21px;
        height: 21px;
    }

    .title-accent-body {
        gap: 7px;
    }

    .title-accent-bar {
        width: 44px;
        height: 3px;
    }

    .title-accent-dot {
        height: 3px;
    }
}

@media (max-width: 400px) {
    .title-accent .section-title,
    .trending-product .section-header .title-accent .section-title {
        font-size: 23px !important;
    }
}

/* ---------- Reduce motion ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

    .title-accent *,
    .title-accent *::before,
    .title-accent *::after {
        animation: none !important;
        transition: none !important;
    }

    .title-accent-badge::after,
    .title-accent-bar::after {
        display: none;
    }
}
