/* =========================================================
   RETROBASS R-26
   Phase 9: Analoger Digital-Tuner
   ========================================================= */

.radio-tuner {
    position: relative;

    display: grid;
    grid-template-columns: auto minmax(110px, 1fr) auto;
    align-items: end;
    gap: clamp(7px, 1vw, 12px);

    width: min(94%, 330px);
    margin-top: clamp(8px, 1.25vw, 14px);
    padding:
        clamp(5px, 0.65vw, 8px)
        clamp(6px, 0.85vw, 10px);

    border-top: 1px solid rgba(221, 127, 29, 0.10);
    border-bottom: 1px solid rgba(221, 127, 29, 0.10);

    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(213, 109, 17, 0.025),
            transparent
        );

    transition:
        opacity 180ms ease,
        filter 180ms ease;
}

/* ---------------------------------------------------------
   Frequenzanzeige
   --------------------------------------------------------- */

.radio-tuner__readout {
    display: grid;
    grid-template-columns: auto auto;
    align-items: end;
    column-gap: 3px;

    min-width: clamp(53px, 8vw, 74px);
}

.radio-tuner__channel {
    grid-column: 1 / -1;

    margin-bottom: 2px;

    color: rgba(218, 119, 21, 0.56);

    font-size: clamp(0.27rem, 0.48vw, 0.39rem);
    letter-spacing: 0.12em;
}

.radio-tuner__frequency {
    color: #eca04a;

    font-size: clamp(0.62rem, 1.18vw, 0.92rem);
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.04em;

    font-variant-numeric: tabular-nums;

    text-shadow:
        0 0 6px rgba(225, 128, 31, 0.30);
}

.radio-tuner__unit {
    padding-bottom: 1px;

    color: rgba(222, 128, 30, 0.54);

    font-size: clamp(0.24rem, 0.42vw, 0.34rem);
    letter-spacing: 0.06em;
}

/* ---------------------------------------------------------
   Skala
   --------------------------------------------------------- */

.radio-tuner__scale {
    min-width: 0;
}

.radio-tuner__numbers {
    display: flex;
    justify-content: space-between;

    color: rgba(217, 119, 23, 0.42);

    font-size: clamp(0.22rem, 0.39vw, 0.31rem);
    font-variant-numeric: tabular-nums;
}

.radio-tuner__track {
    position: relative;

    height: clamp(13px, 1.8vw, 18px);
    margin-top: 2px;

    border-top: 1px solid rgba(225, 132, 35, 0.26);

    background:
        linear-gradient(
            180deg,
            rgba(227, 130, 31, 0.025),
            transparent
        );
}

.radio-tuner__ticks {
    position: absolute;
    inset: 0;

    opacity: 0.54;

    background:
        repeating-linear-gradient(
            90deg,
            rgba(224, 129, 30, 0.48) 0,
            rgba(224, 129, 30, 0.48) 1px,
            transparent 1px,
            transparent 8%
        );
}

/* mittlere Striche */

.radio-tuner__track::before {
    content: "";

    position: absolute;
    inset: 0;

    opacity: 0.42;

    background:
        repeating-linear-gradient(
            90deg,
            rgba(224, 129, 30, 0.42) 0,
            rgba(224, 129, 30, 0.42) 1px,
            transparent 1px,
            transparent 4%
        );

    mask-image:
        linear-gradient(
            180deg,
            #000 0 38%,
            transparent 38%
        );
}

/* Zeiger */

.radio-tuner__needle {
    position: absolute;
    z-index: 3;

    top: -4px;
    left: var(--tuner-position, 2.5%);

    width: 2px;
    height: calc(100% + 5px);

    border-radius: 2px;

    background:
        linear-gradient(
            180deg,
            #f4c978,
            #bb7020
        );

    box-shadow:
        0 0 4px rgba(238, 163, 70, 0.72),
        0 0 9px rgba(213, 111, 19, 0.28);

    transform: translateX(-50%);

    transition:
        left 580ms cubic-bezier(0.25, 0.85, 0.3, 1);
}

.radio-tuner__needle::before {
    content: "";

    position: absolute;

    top: -3px;
    left: 50%;

    width: 6px;
    height: 3px;

    border-radius: 2px 2px 0 0;

    background: #c88a3e;

    transform: translateX(-50%);
}

/* ---------------------------------------------------------
   Signalstärke
   --------------------------------------------------------- */

.radio-tuner__signal {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.radio-tuner__signal > span {
    color: rgba(219, 120, 22, 0.43);

    font-size: clamp(0.22rem, 0.38vw, 0.30rem);
    letter-spacing: 0.09em;
}

.radio-tuner__signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;

    height: 12px;
}

.radio-tuner__signal-bars i {
    display: block;

    width: 2px;

    border-radius: 1px;

    background: rgba(224, 130, 33, 0.19);

    transition:
        background 230ms ease,
        box-shadow 230ms ease,
        opacity 230ms ease;
}

.radio-tuner__signal-bars i:nth-child(1) {
    height: 32%;
}

.radio-tuner__signal-bars i:nth-child(2) {
    height: 48%;
}

.radio-tuner__signal-bars i:nth-child(3) {
    height: 65%;
}

.radio-tuner__signal-bars i:nth-child(4) {
    height: 82%;
}

.radio-tuner__signal-bars i:nth-child(5) {
    height: 100%;
}

.radio-tuner[data-signal="1"]
.radio-tuner__signal-bars i:nth-child(-n + 1),

.radio-tuner[data-signal="2"]
.radio-tuner__signal-bars i:nth-child(-n + 2),

.radio-tuner[data-signal="3"]
.radio-tuner__signal-bars i:nth-child(-n + 3),

.radio-tuner[data-signal="4"]
.radio-tuner__signal-bars i:nth-child(-n + 4),

.radio-tuner[data-signal="5"]
.radio-tuner__signal-bars i:nth-child(-n + 5) {
    background: #dc862c;

    box-shadow:
        0 0 4px rgba(220, 130, 39, 0.40);
}

/* ---------------------------------------------------------
   Suchlauf
   --------------------------------------------------------- */

.receiver.is-tuning .radio-interface__title,
.receiver.is-tuning .radio-interface__subtitle,
.receiver.is-tuning .radio-interface__visualizer {
    opacity: 0.20;
    filter: blur(1.2px);
}

.receiver.is-tuning .radio-tuner__frequency {
    animation: tuner-frequency-flicker 170ms linear infinite;
}

.receiver.is-tuning .radio-tuner__needle {
    transition-duration: 720ms;

    animation: tuner-needle-search 720ms ease-in-out;
}

.receiver.is-tuning .radio-tuner__signal-bars i {
    background: rgba(224, 130, 33, 0.16);
    box-shadow: none;
}

.receiver.is-tuning .radio-tuner {
    filter: brightness(1.08);
}

/* kurzes Einrasten */

.receiver.has-tuner-lock .radio-tuner__needle {
    animation: tuner-lock 260ms ease;
}

.receiver.has-tuner-lock .radio-tuner__frequency {
    animation: tuner-frequency-lock 420ms ease;
}

/* ---------------------------------------------------------
   Anpassung des vorhandenen Visualizers
   --------------------------------------------------------- */

.radio-tuner + .radio-interface__visualizer {
    height: clamp(12px, 2vw, 20px);
    margin-top: clamp(4px, 0.7vw, 8px);
}

/* ---------------------------------------------------------
   Animationen
   --------------------------------------------------------- */

@keyframes tuner-frequency-flicker {
    0%,
    100% {
        opacity: 0.40;
    }

    50% {
        opacity: 0.92;
    }
}

@keyframes tuner-needle-search {
    0% {
        transform: translateX(-50%);
    }

    38% {
        transform: translateX(-50%) translateX(7px);
    }

    67% {
        transform: translateX(-50%) translateX(-4px);
    }

    100% {
        transform: translateX(-50%);
    }
}

@keyframes tuner-lock {
    0%,
    100% {
        transform: translateX(-50%);
    }

    35% {
        transform: translateX(-50%) scaleX(1.7);
    }
}

@keyframes tuner-frequency-lock {
    0% {
        opacity: 0.36;
        text-shadow: none;
    }

    45% {
        opacity: 1;

        text-shadow:
            0 0 10px rgba(239, 161, 71, 0.72);
    }

    100% {
        opacity: 1;

        text-shadow:
            0 0 6px rgba(225, 128, 31, 0.30);
    }
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 480px) {
    .radio-tuner {
        grid-template-columns: auto minmax(80px, 1fr) auto;

        width: 98%;
        margin-top: 5px;
        padding: 4px;
    }

    .radio-tuner__numbers span:nth-child(even) {
        display: none;
    }

    .radio-tuner__signal > span {
        display: none;
    }

    .radio-tuner + .radio-interface__visualizer {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .receiver.is-tuning .radio-tuner__frequency,
    .receiver.is-tuning .radio-tuner__needle,
    .receiver.has-tuner-lock .radio-tuner__needle,
    .receiver.has-tuner-lock .radio-tuner__frequency {
        animation-duration: 1ms;
    }

    .radio-tuner__needle {
        transition-duration: 1ms;
    }
}