/* ==================================================
   ValidateNiche — Phase 2 polish layer
   Premium-SaaS refinements (spacing, typography, motion)
   plus shared styles for rank ribbons, chips, workspace
   and compare modals. Loaded AFTER theme.css/styles.css
   so it only refines — never fights — the base theme.
   ================================================== */

/* ---------- Motion ---------- */
@keyframes vnFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes vnPulseIn {
    0%   { opacity: 0; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes vnSpin { to { transform: rotate(360deg); } }

.niche-card {
    animation: vnFadeUp 0.45s cubic-bezier(.22,1,.36,1) both;
    transition: transform 0.25s cubic-bezier(.22,1,.36,1), box-shadow 0.25s ease, border-color 0.25s ease;
    will-change: transform;
}
.niche-card:nth-child(1) { animation-delay: 0.02s; }
.niche-card:nth-child(2) { animation-delay: 0.09s; }
.niche-card:nth-child(3) { animation-delay: 0.16s; }
.niche-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 44px rgba(0,0,0,0.35), 0 0 0 1px rgba(63,160,230,0.28);
}

@media (prefers-reduced-motion: reduce) {
    .niche-card, .vn2-modal-panel { animation: none !important; transition: none !important; }
}

/* ---------- Rank ribbon (Best Overall / Easier to Rank / Long-Term) ---------- */
.vn2-rank {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 18px 6px;
    font-size: 0.74rem; font-weight: 800;
    letter-spacing: 0.05em; text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.vn2-rank .vn2-rank-blurb {
    font-weight: 600; text-transform: none; letter-spacing: normal;
    font-size: 0.74rem; opacity: 0.75; margin-left: auto; text-align: right;
}
.vn2-rank--best  { background: linear-gradient(90deg, rgba(242,180,62,0.16), rgba(242,180,62,0.03)); color: #F8CE72; }
.vn2-rank--easy  { background: linear-gradient(90deg, rgba(63,214,128,0.14), rgba(63,214,128,0.03)); color: #6FE3A5; }
.vn2-rank--long  { background: linear-gradient(90deg, rgba(63,160,230,0.14), rgba(63,160,230,0.03)); color: #8CC9F5; }

/* ---------- Secondary stat row (Income / Reliability) ---------- */
.vn2-stat-sub {
    display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 8px; margin-bottom: 0.45rem;
}
.vn2-stat-sub > div {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 11px; padding: 7px 6px; text-align: center; min-width: 0;
}
.vn2-stat-sub .vn2-stat-label {
    font-size: 0.66rem; color: #C9D8E6; text-transform: uppercase;
    letter-spacing: 0.04em; margin-bottom: 3px;
}
.vn2-stat-sub .vn2-stat-value { font-size: 0.92rem; font-weight: 800; color: #EAF3FB; }

/* ---------- Score breakdown ("Why this scored X") ---------- */
.vn2-breakdown-toggle {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 0.5rem; margin-bottom: 0.55rem;
    background: transparent; border: 1px dashed rgba(255,255,255,0.2);
    border-radius: 10px; color: #9CC0D6; font-size: 0.8rem; font-weight: 700;
    cursor: pointer; transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.vn2-breakdown-toggle:hover { border-color: rgba(63,160,230,0.5); color: #BFE0F7; background: rgba(63,160,230,0.06); }
.vn2-breakdown { display: none; padding: 0.7rem 0.85rem 0.55rem; margin-bottom: 0.6rem;
    background: rgba(0,0,0,0.18); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; }
.vn2-breakdown.open { display: block; animation: vnPulseIn 0.2s ease both; }
.vn2-bar-row { display: grid; grid-template-columns: 88px 1fr 34px; gap: 8px; align-items: center; margin-bottom: 7px; }
.vn2-bar-label { font-size: 0.72rem; font-weight: 700; color: #C9D8E6; text-transform: uppercase; letter-spacing: 0.03em; }
.vn2-bar-track { height: 7px; border-radius: 99px; background: rgba(255,255,255,0.1); overflow: hidden; }
.vn2-bar-fill { height: 100%; border-radius: 99px; transition: width 0.7s cubic-bezier(.22,1,.36,1); }
.vn2-bar-num { font-size: 0.74rem; font-weight: 800; color: #EAF3FB; text-align: right; }
.vn2-breakdown-note { font-size: 0.73rem; color: #9CC0D6; line-height: 1.45; margin: 5px 0 0; }

/* ---------- Related chips ("People also searched") ---------- */
.vn2-related { margin-bottom: 0.8rem; }
.vn2-related-title {
    font-size: 0.68rem; font-weight: 800; color: #7C99AE;
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.vn2-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.vn2-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 11px; border-radius: 99px;
    background: rgba(63,160,230,0.1); border: 1px solid rgba(63,160,230,0.28);
    color: #BFE0F7; font-size: 0.79rem; font-weight: 600; cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.18s;
    user-select: none; max-width: 100%;
}
.vn2-chip:hover { background: rgba(63,160,230,0.22); border-color: rgba(63,160,230,0.55); transform: translateY(-1px); }
.vn2-chip--muted { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.16); color: #C9D8E6; }
.vn2-chip span.vn2-chip-tag { font-size: 0.66rem; font-weight: 800; opacity: 0.7; }

/* ---------- Toolbar (History / Favorites / Compare) ---------- */
.vn2-toolbar {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    margin: 0 0 1rem;
}
.vn2-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 99px;
    background: rgba(14,58,92,0.85); border: 1px solid rgba(91,168,212,0.3);
    color: #BFE0F7; font-size: 0.82rem; font-weight: 700; cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.vn2-pill:hover { background: rgba(26,115,192,0.35); border-color: rgba(91,168,212,0.6); transform: translateY(-1px); }

/* ---------- Favorites heart ---------- */
.vn2-fav {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
    color: #C9D8E6; font-size: 0.95rem; cursor: pointer; flex-shrink: 0;
    transition: transform 0.15s, background 0.2s, color 0.2s, border-color 0.2s;
}
.vn2-fav:hover { transform: scale(1.12); border-color: rgba(255,120,140,0.5); }
.vn2-fav.active { background: rgba(255,90,110,0.18); border-color: rgba(255,90,110,0.55); color: #FF7A90; }

/* ---------- Modals (workspace / compare / lists) ---------- */
.vn2-modal {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(8,24,40,0.82); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; opacity: 0; transition: opacity 0.2s;
}
.vn2-modal.show { opacity: 1; }
.vn2-modal-panel {
    background: linear-gradient(168deg, #0E3A5C, #0A2B44);
    border: 1px solid rgba(255,255,255,0.14); border-radius: 20px;
    width: 100%; max-width: 660px; max-height: 88vh; overflow-y: auto;
    box-shadow: 0 28px 70px rgba(0,0,0,0.55);
    animation: vnPulseIn 0.22s cubic-bezier(.22,1,.36,1) both;
    color: #EAF3FB;
}
.vn2-modal-head {
    position: sticky; top: 0; z-index: 2;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 1.1rem 1.4rem; background: #0A2B44;
    border-bottom: 1px solid rgba(255,255,255,0.1); border-radius: 20px 20px 0 0;
}
.vn2-modal-title { font-size: 1.05rem; font-weight: 800; color: #EAF3FB; }
.vn2-modal-sub { font-size: 0.78rem; font-weight: 600; color: #9CC0D6; text-transform: uppercase; letter-spacing: 0.05em; }
.vn2-modal-close {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.07);
    color: #A7BBCC; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.vn2-modal-body { padding: 1.1rem 1.4rem 1.4rem; }

.vn2-ws-section { margin-bottom: 1.1rem; }
.vn2-ws-section h4 {
    font-size: 0.72rem; font-weight: 800; color: #7C99AE;
    text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 7px;
    display: flex; align-items: center; gap: 6px;
}
.vn2-ws-list { margin: 0; padding: 0; list-style: none; }
.vn2-ws-list li {
    font-size: 0.88rem; color: #DDE9F4; line-height: 1.5;
    padding: 6px 10px; margin-bottom: 5px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 9px; display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.vn2-copy {
    flex-shrink: 0; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em;
    color: #8CC9F5; background: rgba(63,160,230,0.12); border: 1px solid rgba(63,160,230,0.3);
    border-radius: 7px; padding: 3px 8px; cursor: pointer; text-transform: uppercase;
}
.vn2-copy:hover { background: rgba(63,160,230,0.25); }
.vn2-ws-para { font-size: 0.88rem; color: #DDE9F4; line-height: 1.6; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 10px 12px; margin: 0; }

/* ---------- Compare table ---------- */
.vn2-cmp-grid { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px 10px; align-items: center; }
.vn2-cmp-metric { font-size: 0.72rem; font-weight: 800; color: #9CC0D6; text-transform: uppercase; letter-spacing: 0.04em; }
.vn2-cmp-head { font-size: 0.92rem; font-weight: 800; color: #EAF3FB; text-align: center; padding-bottom: 4px; }
.vn2-cmp-cell { text-align: center; }
.vn2-cmp-val { font-size: 0.95rem; font-weight: 800; }
.vn2-cmp-win { color: #3FD680; }
.vn2-cmp-lose { color: #C9D8E6; }

/* ---------- History panel ---------- */
.vn2-hist-group { margin-bottom: 0.9rem; }
.vn2-hist-group h4 { font-size: 0.7rem; font-weight: 800; color: #7C99AE; text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 6px; }
.vn2-hist-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin-bottom: 5px; border-radius: 10px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer; transition: background 0.18s, border-color 0.18s;
}
.vn2-hist-row:hover { background: rgba(63,160,230,0.12); border-color: rgba(63,160,230,0.4); }
.vn2-hist-score {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; font-weight: 900;
}
.vn2-hist-meta { min-width: 0; flex: 1; }
.vn2-hist-topic { font-size: 0.9rem; font-weight: 700; color: #EAF3FB; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vn2-hist-sub { font-size: 0.73rem; color: #9CC0D6; }
.vn2-hist-open { font-size: 0.72rem; font-weight: 800; color: #8CC9F5; flex-shrink: 0; }

/* ---------- AI status strip ---------- */
.vn2-ai-status {
    display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: 0 0 0.9rem; padding: 6px 13px; border-radius: 99px;
    font-size: 0.78rem; font-weight: 700;
    background: rgba(63,160,230,0.1); color: #BFE0F7;
    border: 1px solid rgba(63,160,230,0.3);
}
.vn2-ai-status .vn2-ai-done { color: #3FD680; }
.vn2-ai-status .vn2-ai-sep { opacity: 0.35; }
.vn2-ai-status.vn2-ai-status--done {
    background: rgba(63,214,128,0.1); border-color: rgba(63,214,128,0.35); color: #7FE8AE;
    transition: opacity 0.6s ease;
}
.vn2-ai-spinner {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid rgba(157,215,255,0.3); border-top-color: #9DD7FF;
    animation: vnSpin 0.8s linear infinite;
}

/* ---------- Pro hooks ---------- */
.vn2-pro-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
    margin: 1.2rem 0 0.4rem; padding: 0.75rem 0.9rem;
    background: rgba(14,58,92,0.5); border: 1px dashed rgba(91,168,212,0.3);
    border-radius: 14px;
}
.vn2-pro-label { font-size: 0.72rem; font-weight: 800; color: #7C99AE; text-transform: uppercase; letter-spacing: 0.06em; margin-right: 4px; }
.vn2-pro-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 11px; border-radius: 99px; font-size: 0.76rem; font-weight: 700;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.14);
    color: #A9C3D6; cursor: default; position: relative;
}
.vn2-pro-chip:hover { border-color: rgba(242,180,62,0.45); color: #E8D3A6; }
.vn2-pro-chip .vn2-pro-soon { font-size: 0.62rem; font-weight: 900; letter-spacing: 0.05em; color: #F2B43E; }

/* ---------- Mobile refinements ---------- */
@media (max-width: 640px) {
    .vn2-rank { padding: 6px 14px 5px; font-size: 0.68rem; }
    .vn2-rank .vn2-rank-blurb { display: none; }
    .vn2-toolbar { gap: 6px; }
    .vn2-pill { padding: 6px 11px; font-size: 0.78rem; }
    .vn2-modal { padding: 0.5rem; align-items: flex-end; }
    .vn2-modal-panel { max-height: 92vh; border-radius: 18px 18px 0 0; }
    .vn2-cmp-grid { grid-template-columns: 84px 1fr 1fr; gap: 6px 6px; }
    .vn2-stat-sub .vn2-stat-value { font-size: 0.85rem; }
}

/* Result-card density: scoped to cards rendered after a validation. */
#results-grid .niche-card .niche-card-header {
    padding: 14px 16px 7px !important;
}

#results-grid .niche-card .niche-card-header > div:first-child {
    margin-bottom: 0.45rem !important;
    gap: 7px !important;
}

#results-grid .niche-card .niche-card-header h3 {
    font-size: 1.08rem !important;
    line-height: 1.35 !important;
}

#results-grid .niche-card .niche-card-body {
    padding: 0 0.9rem 0.9rem !important;
    gap: 0.54rem;
}

#results-grid .niche-card .badge,
#results-grid .niche-card .platform-badge {
    padding: 3px 9px !important;
}

#results-grid .niche-card .metrics-grid {
    gap: 0.54rem;
}

#results-grid .niche-card .metric {
    padding: 0.72rem;
}

#results-grid .niche-card .vn-accordion-group {
    margin-top: 0.585rem !important;
}

@media (max-width: 640px) {
    #results-grid .niche-card .niche-card-body {
        padding: 0 0.765rem 0.765rem !important;
    }
}

/* Keep the complete desktop cards compact as units, not only internally. */
@media (min-width: 1101px) {
    body.layout-workspace #results > .container {
        width: 90%;
        max-width: 1512px;
    }
}
