/* === RADAR-SCAN.CSS ===
 * Market Radar - Hero визуал (замена brain-pipeline)
 * Радар сканирует район: ваше объявление в центре + конкуренты на орбитах + Listing Score
 * Сохраняем OKLCH палитру brain (--gold, --electric, --border)
 */


/* === Hero alignment: на странице с радаром колонки прижаты к верху ===
 * Виновник: brain-sections.css задает .mkt-hero-grid { display: grid !important }
 * → правая колонка .mkt-hero-visual stretches на всю высоту grid-row.
 * Внутри радар короткий (~700px), грид-row высокий (~860px по левой колонке)
 * → 170px пустоты сверху. Решение: align-self: start у .mkt-hero-visual. */
.mkt-hero-grid:has(.radar-scan) {
    align-items: flex-start;
    align-content: start;
}
.mkt-hero-grid:has(.radar-scan) > .mkt-hero-visual {
    align-self: start !important;
    /* brain-sections.css задает min-height: 580px + height: 100% + display: flex; align-items: center
     * → радар центрируется в высокой колонке. Переопределяем: */
    height: auto !important;
    min-height: 0 !important;
    align-items: flex-start !important;
}

/* === Контейнер === */
.radar-scan {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 20px;
    isolation: isolate;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(255, 215, 0, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 70%, rgba(0, 240, 255, 0.06) 0%, transparent 55%),
        linear-gradient(135deg, rgba(20, 20, 20, 0.6), rgba(10, 10, 10, 0.4));
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.4),
        inset 0 0 80px rgba(0, 240, 255, 0.03);
    overflow: hidden;
}

/* Соединительный flow scope → console */
.radar-scan::before {
    content: none;
}

/* === SCOPE - круговой радар (фикс квадрат 320×320, центрируется в radar-scan) === */
.rs-scope {
    position: relative;
    width: 320px;
    height: 320px;
    max-width: 100%;
    margin: 0 auto;
    align-self: center;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    z-index: 2;
}

/* Концентрические круги радара */
.rs-rings {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.rs-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px dashed rgba(0, 240, 255, 0.18);
    pointer-events: none;
}

.rs-ring-1 { width: 320px; height: 320px; border-color: rgba(0, 240, 255, 0.20); }
.rs-ring-2 { width: 240px; height: 240px; border-color: rgba(0, 240, 255, 0.25); border-style: dotted; }
.rs-ring-3 { width: 160px; height: 160px; border-color: rgba(255, 215, 0, 0.30); }

/* Перекрестье координат (cross-hairs) */
.rs-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 320px;
    pointer-events: none;
    opacity: 0.25;
}
.rs-crosshair::before,
.rs-crosshair::after {
    content: "";
    position: absolute;
    background: linear-gradient(90deg, transparent, var(--electric), transparent);
}
.rs-crosshair::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
}
.rs-crosshair::after {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: linear-gradient(180deg, transparent, var(--electric), transparent);
}

/* Вращающаяся "стрелка" сканера (sweep) */
.rs-sweep {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 320px;
    height: 320px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    background: conic-gradient(
        from 0deg,
        rgba(0, 240, 255, 0.45) 0deg,
        rgba(0, 240, 255, 0.15) 30deg,
        transparent 60deg,
        transparent 360deg
    );
    mask: radial-gradient(circle, transparent 0px, transparent 60px, black 60px, black 160px);
    -webkit-mask: radial-gradient(circle, transparent 0px, transparent 60px, black 60px, black 160px);
    animation: rs-sweep-rotate 4.5s linear infinite;
    z-index: 1;
}

@keyframes rs-sweep-rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Центральная карточка - ваше объявление + Listing Score */
.rs-target {
    position: relative;
    width: 156px;
    height: 156px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    z-index: 3;
    background:
        radial-gradient(circle, rgba(0, 240, 255, 0.18) 0%, rgba(0, 0, 0, 0.6) 70%);
    border: 1.5px solid rgba(255, 215, 0, 0.55);
    box-shadow:
        0 0 30px rgba(255, 215, 0, 0.25),
        inset 0 0 30px rgba(0, 240, 255, 0.15);
    animation: rs-target-pulse 3.2s ease-in-out infinite;
}

@keyframes rs-target-pulse {
    0%, 100% {
        box-shadow:
            0 0 30px rgba(255, 215, 0, 0.25),
            inset 0 0 30px rgba(0, 240, 255, 0.15);
    }
    50% {
        box-shadow:
            0 0 48px rgba(255, 215, 0, 0.45),
            inset 0 0 40px rgba(0, 240, 255, 0.25);
    }
}

/* SVG круговая шкала Listing Score */
.rs-score-ring {
    position: absolute;
    inset: -6px;
    transform: rotate(-90deg);
    pointer-events: none;
}
.rs-score-ring circle {
    fill: none;
    stroke-width: 4;
}
.rs-score-ring .rs-score-track {
    stroke: rgba(255, 255, 255, 0.06);
}
.rs-score-ring .rs-score-progress {
    stroke: url(#rs-score-gradient);
    stroke-linecap: round;
    stroke-dasharray: 0 1000;
    transition: stroke-dasharray 1.2s var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
    filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.6));
}

/* Контент внутри центрального круга */
.rs-target-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    line-height: 1;
}

.rs-score-label {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 9px;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.rs-score-value {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-weight: 700;
    font-size: 44px;
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 215, 0, 0.6);
    line-height: 0.9;
    letter-spacing: -1px;
}

.rs-score-max {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 10px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.6));
    letter-spacing: 1px;
    margin-top: 2px;
}

.rs-score-tag {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 8px;
    color: var(--electric);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    margin-top: 6px;
    padding: 2px 6px;
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 4px;
    background: rgba(0, 240, 255, 0.06);
}

/* Конкуренты на орбитах (6 шт.)
 * Центрирование через top:50%/left:50% + transform translate(-50%,-50%)
 * Орбитальная позиция через CSS-vars --a (угол в deg) и --r (радиус в px)
 * НЕ ИСПОЛЬЗОВАТЬ margin отрицательный - используем transform для всего сразу */
.rs-competitor {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    z-index: 2;
    background: rgba(15, 15, 15, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(6px);
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    will-change: transform;
    transform:
        translate(-50%, -50%)
        rotate(var(--a, 0deg))
        translateY(calc(var(--r, 130px) * -1))
        rotate(calc(var(--a, 0deg) * -1));
    transition: filter 0.3s var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
}

/* Цветовая дифференциация по уровню Listing Score конкурента */
.rs-competitor[data-tier="hot"]   { border-color: rgba(74, 222, 128, 0.6); color: #4ade80; box-shadow: 0 0 12px rgba(74, 222, 128, 0.35); }
.rs-competitor[data-tier="warm"]  { border-color: rgba(255, 215, 0, 0.6); color: var(--gold); box-shadow: 0 0 12px rgba(255, 215, 0, 0.3); }
.rs-competitor[data-tier="cold"]  { border-color: rgba(148, 163, 184, 0.5); color: rgba(203, 213, 225, 0.85); }

.rs-competitor::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 9px;
    color: var(--text-muted, rgba(255, 255, 255, 0.55));
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.rs-competitor:hover::after {
    opacity: 1;
}

/* Пульсация конкурента при обнаружении
 * ВАЖНО: НЕ трогаем transform (он держит орбитальную позицию).
 * Анимируем box-shadow + filter brightness для glow-эффекта */
.rs-competitor.is-detected {
    animation: rs-detect-pulse 0.9s ease-out;
}
@keyframes rs-detect-pulse {
    0% {
        filter: brightness(1);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    }
    50% {
        filter: brightness(1.6);
        box-shadow:
            0 4px 10px rgba(0, 0, 0, 0.4),
            0 0 28px 6px rgba(0, 240, 255, 0.6);
    }
    100% {
        filter: brightness(1);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    }
}

/* Угловые метки координат района (N/E/S/W) */
.rs-compass {
    position: absolute;
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 9px;
    color: rgba(0, 240, 255, 0.55);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    pointer-events: none;
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.35);
}
.rs-compass-n { top: 8px;    left: 50%; transform: translateX(-50%); }
.rs-compass-s { bottom: 8px; left: 50%; transform: translateX(-50%); }
.rs-compass-w { left: 8px;   top: 50%;  transform: translateY(-50%); }
.rs-compass-e { right: 8px;  top: 50%;  transform: translateY(-50%); }

/* === CONSOLE - Bloomberg-окно snizu === */
.rs-console {
    flex: 0 0 auto;
    background: linear-gradient(180deg, #0a0e14 0%, #050810 100%);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 14px;
    overflow: hidden;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.6),
        0 0 32px rgba(0, 240, 255, 0.08),
        inset 0 0 20px rgba(0, 240, 255, 0.06);
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Сканлиния */
.rs-console::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--electric) 50%, transparent 100%);
    animation: rs-scanline 4s linear infinite;
    pointer-events: none;
    z-index: 4;
    opacity: 0.6;
}
@keyframes rs-scanline {
    0%   { transform: translateY(0); opacity: 0; }
    10%  { opacity: 0.6; }
    90%  { opacity: 0.6; }
    100% { transform: translateY(320px); opacity: 0; }
}

.rs-console-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(0, 240, 255, 0.08) 0%, rgba(0, 240, 255, 0.02) 100%);
    border-bottom: 1px solid rgba(0, 240, 255, 0.18);
    flex-shrink: 0;
}

.rs-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.rs-dot-r { background: #ff5f57; box-shadow: 0 0 8px rgba(255, 95, 87, 0.5); }
.rs-dot-y { background: #febc2e; box-shadow: 0 0 8px rgba(254, 188, 46, 0.5); }
.rs-dot-g { background: #28c840; box-shadow: 0 0 8px rgba(40, 200, 64, 0.5); }

.rs-console-title {
    margin-left: auto;
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 11px;
    color: var(--electric);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.rs-console-title::before {
    content: "●";
    color: #28c840;
    font-size: 8px;
    animation: rs-blink 1.4s ease-in-out infinite;
}
@keyframes rs-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

.rs-console-body {
    flex: 0 0 auto;
    /* ФИКСИРОВАННАЯ высота - typewriter не дергает верстку при печати/стирании */
    height: 280px;
    padding: 16px 22px 12px;
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 13px;
    line-height: 1.65;
    color: #b8e8ff;
    position: relative;
    overflow: hidden;
}

/* Background grid */
.rs-console-body::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 240, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 240, 255, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
}

.rs-console-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    position: relative;
    z-index: 1;
}

.rs-console-text .rs-num {
    color: var(--gold);
    font-weight: 700;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}
.rs-console-text .rs-pct-up {
    color: #4ade80;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}
.rs-console-text .rs-pct-down {
    color: #f87171;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(248, 113, 113, 0.5);
}
.rs-console-text .rs-arrow {
    color: var(--gold);
    font-weight: 700;
    margin-right: 6px;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
}
.rs-console-text .rs-ok {
    color: #4ade80;
}
.rs-console-text .rs-warn {
    color: #fbbf24;
}

.rs-console-cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    background: var(--gold);
    margin-left: 2px;
    vertical-align: text-bottom;
    box-shadow: 0 0 6px var(--gold);
    animation: rs-cursor-blink 0.9s steps(2, start) infinite;
    position: relative;
    z-index: 1;
}
@keyframes rs-cursor-blink {
    0%, 49%   { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.rs-console-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border-top: 1px solid rgba(0, 240, 255, 0.15);
    background: rgba(0, 240, 255, 0.04);
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 10px;
    color: var(--text-muted, rgba(255, 255, 255, 0.55));
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.rs-stat {
    display: flex;
    align-items: center;
    gap: 5px;
}
.rs-stat-icon {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #28c840;
    box-shadow: 0 0 6px #28c840;
}
.rs-stat-electric .rs-stat-icon { background: var(--electric); box-shadow: 0 0 6px var(--electric); }
.rs-stat-gold .rs-stat-icon { background: var(--gold); box-shadow: 0 0 6px var(--gold); }

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    .rs-sweep,
    .rs-target,
    .rs-console::before,
    .rs-console-cursor,
    .rs-console-title::before {
        animation: none !important;
    }
}

/* === Mobile === */
@media (max-width: 960px) {
    .radar-scan {
        gap: 14px;
        padding: 14px;
    }

    .rs-scope { width: 260px; height: 260px; }
    .rs-ring-1, .rs-crosshair, .rs-sweep { width: 260px; height: 260px; }
    .rs-ring-2 { width: 200px; height: 200px; }
    .rs-ring-3 { width: 130px; height: 130px; }

    .rs-target { width: 130px; height: 130px; }
    .rs-score-value { font-size: 38px; }

    .rs-competitor { width: 38px; height: 38px; font-size: 11px; --r: 108px; }

    .rs-console-body { height: 240px; }
}

@media (max-width: 480px) {
    .rs-scope { width: 220px; height: 220px; }
    .rs-ring-1, .rs-crosshair, .rs-sweep { width: 220px; height: 220px; }
    .rs-ring-2 { width: 170px; height: 170px; }
    .rs-ring-3 { width: 115px; height: 115px; }

    .rs-target { width: 115px; height: 115px; }
    .rs-score-value { font-size: 32px; }

    .rs-competitor { width: 34px; height: 34px; font-size: 10px; --r: 92px; }
}

/* ==================================================== */
/* === LIGHT THEME ==================================== */
/* ==================================================== */
html.light-theme .radar-scan {
    background:
        radial-gradient(ellipse at 30% 30%, rgba(184, 134, 11, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 70%, rgba(14, 116, 144, 0.10) 0%, transparent 55%),
        linear-gradient(135deg, #ffffff 0%, #faf6ee 100%);
    border: 1px solid rgba(184, 134, 11, 0.22);
    box-shadow:
        0 20px 60px rgba(80, 60, 30, 0.15),
        inset 0 0 80px rgba(14, 116, 144, 0.04);
}

html.light-theme .rs-ring { border-color: rgba(14, 116, 144, 0.25); }
html.light-theme .rs-ring-3 { border-color: rgba(184, 134, 11, 0.35); }
html.light-theme .rs-crosshair { opacity: 0.18; }
html.light-theme .rs-crosshair::before { background: linear-gradient(90deg, transparent, #0e7490, transparent); }
html.light-theme .rs-crosshair::after  { background: linear-gradient(180deg, transparent, #0e7490, transparent); }

html.light-theme .rs-sweep {
    background: conic-gradient(
        from 0deg,
        rgba(14, 116, 144, 0.35) 0deg,
        rgba(14, 116, 144, 0.10) 30deg,
        transparent 60deg,
        transparent 360deg
    );
}

html.light-theme .rs-target {
    background: radial-gradient(circle, rgba(14, 116, 144, 0.10) 0%, #ffffff 70%);
    border: 1.5px solid rgba(184, 134, 11, 0.55);
    box-shadow:
        0 0 30px rgba(184, 134, 11, 0.25),
        inset 0 0 30px rgba(14, 116, 144, 0.10);
}

html.light-theme .rs-score-value { color: #b8860b; text-shadow: 0 0 12px rgba(184, 134, 11, 0.4); }
html.light-theme .rs-score-label { color: #6b5a30; }
html.light-theme .rs-score-max   { color: #4a3a1a; }
html.light-theme .rs-score-tag   { color: #0e7490; border-color: rgba(14, 116, 144, 0.4); background: rgba(14, 116, 144, 0.08); }

html.light-theme .rs-competitor {
    background: #ffffff;
    border-color: rgba(184, 134, 11, 0.30);
    color: #4a3a1a;
    box-shadow: 0 2px 6px rgba(80, 60, 30, 0.10);
}
html.light-theme .rs-competitor[data-tier="hot"]   { border-color: rgba(21, 128, 61, 0.55); color: #15803d; }
html.light-theme .rs-competitor[data-tier="warm"]  { border-color: rgba(184, 134, 11, 0.55); color: #b8860b; }
html.light-theme .rs-compass { color: rgba(14, 116, 144, 0.6); }

html.light-theme .rs-console {
    background: linear-gradient(180deg, #ffffff 0%, #faf6ee 100%);
    border: 1px solid rgba(14, 116, 144, 0.25);
    box-shadow: 0 8px 24px rgba(80, 60, 30, 0.12);
}
html.light-theme .rs-console-header {
    background: linear-gradient(180deg, rgba(14, 116, 144, 0.08) 0%, rgba(14, 116, 144, 0.02) 100%);
    border-bottom: 1px solid rgba(14, 116, 144, 0.20);
}
html.light-theme .rs-console-title { color: #0e7490; }
html.light-theme .rs-console-body  { color: #1a1a1a; }
html.light-theme .rs-num           { color: #b8860b; }
html.light-theme .rs-pct-up        { color: #15803d; }
html.light-theme .rs-pct-down      { color: #b91c1c; }
html.light-theme .rs-arrow         { color: #b8860b; }
html.light-theme .rs-console-status {
    background: rgba(14, 116, 144, 0.06);
    border-top: 1px solid rgba(14, 116, 144, 0.15);
    color: #4a3a1a;
}
