/* ── PBS Rank Widget ── v1.0.0 ─────────────────────────────────────────────
   Theme: TrendyStocks dark navy — matches the stock page design
   ──────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --rkw-bg:        #080d18;
    --rkw-bg2:       #0d1424;
    --rkw-bg3:       #111827;
    --rkw-bg4:       #161f30;
    --rkw-border:    #1e2d45;
    --rkw-border2:   #243450;
    --rkw-text:      #c8d6e8;
    --rkw-muted:     #4a6080;
    --rkw-teal:      #00d4aa;
    --rkw-blue:      #4d9fff;
    --rkw-gold:      #f0b429;
    --rkw-green:     #22c55e;
    --rkw-red:       #ef4444;
    --rkw-yellow:    #eab308;
    --rkw-font:      'DM Sans', 'Segoe UI', sans-serif;
    --rkw-font-head: 'Rajdhani', 'Segoe UI', sans-serif;
    --rkw-radius:    12px;
    --card-color:    #00d4aa;
}

.rkw-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

.rkw-wrap {
    font-family: var(--rkw-font);
    background: var(--rkw-bg);
    border: 1px solid var(--rkw-border);
    border-radius: var(--rkw-radius);
    overflow: hidden;
    color: var(--rkw-text);
    position: relative;
}

/* ── Header ── */
.rkw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, #090e1a 0%, #0e1828 60%, #0a1220 100%);
    border-bottom: 1px solid var(--rkw-border);
    position: relative;
    overflow: hidden;
}
.rkw-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top right, rgba(77,159,255,.06) 0%, transparent 70%);
    pointer-events: none;
}
.rkw-header-left { display: flex; align-items: center; gap: 10px; }
.rkw-diamond { font-size: 10px; color: var(--rkw-blue); opacity: .7; }
.rkw-ticker-name {
    font-family: var(--rkw-font-head);
    font-size: 22px;
    font-weight: 700;
    color: #e8f0ff;
    letter-spacing: 2px;
}
.rkw-sector-badge {
    font-size: 11px;
    color: var(--rkw-muted);
    background: var(--rkw-bg3);
    border: 1px solid var(--rkw-border);
    border-radius: 20px;
    padding: 2px 10px;
}
.rkw-header-price {
    font-family: var(--rkw-font-head);
    font-size: 20px;
    font-weight: 600;
    color: var(--rkw-teal);
    letter-spacing: 1px;
}

/* ── Cards container ── */
.rkw-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-bottom: 1px solid var(--rkw-border);
}

@media (max-width: 720px) {
    .rkw-cards { grid-template-columns: 1fr; }
    .rkw-card  { border-right: none !important; border-bottom: 1px solid var(--rkw-border); }
}

/* ── Single card ── */
.rkw-card {
    padding: 20px 18px;
    background: var(--rkw-bg2);
    border-right: 1px solid var(--rkw-border);
    cursor: pointer;
    transition: background .18s, transform .15s;
    position: relative;
    overflow: hidden;
}
.rkw-card:last-child { border-right: none; }
.rkw-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--card-color);
    opacity: .7;
    transition: opacity .18s;
}
.rkw-card:hover {
    background: var(--rkw-bg3);
    transform: translateY(-1px);
}
.rkw-card:hover::before { opacity: 1; }

.rkw-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top center, color-mix(in srgb, var(--card-color) 6%, transparent) 0%, transparent 65%);
    pointer-events: none;
}

/* Card header */
.rkw-card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
}
.rkw-card-icon { font-size: 20px; line-height: 1; margin-top: 2px; }
.rkw-card-title {
    font-family: var(--rkw-font-head);
    font-size: 15px;
    font-weight: 700;
    color: #d8e8ff;
    letter-spacing: .5px;
}
.rkw-card-sub { font-size: 11px; color: var(--rkw-muted); margin-top: 2px; }
.rkw-badge-ineligible {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    color: var(--rkw-muted);
    background: var(--rkw-bg4);
    border: 1px solid var(--rkw-border);
    border-radius: 4px;
    padding: 2px 6px;
    letter-spacing: .5px;
}

/* ── Arc gauge ── */
.rkw-arc-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    margin-bottom: 4px;
}
.rkw-arc {
    width: 130px;
    height: 98px;
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--card-color) 25%, transparent));
}
.rkw-arc-fill { transition: stroke-dasharray .8s cubic-bezier(.4,0,.2,1); }
.rkw-arc-score {
    font-family: var(--rkw-font-head);
    font-size: 26px;
    font-weight: 700;
}
.rkw-arc-max { font-size: 10px; }

/* Grade badge */
.rkw-grade-badge {
    font-family: var(--rkw-font-head);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 3px 12px;
    border-radius: 20px;
    margin-top: -4px;
    border: 1px solid currentColor;
}
.rkw-grade-strong { color: var(--rkw-green);  border-color: rgba(34,197,94,.3);  background: rgba(34,197,94,.08); }
.rkw-grade-watch  { color: var(--rkw-yellow); border-color: rgba(234,179,8,.3);  background: rgba(234,179,8,.08); }
.rkw-grade-weak   { color: var(--rkw-muted);  border-color: var(--rkw-border);   background: var(--rkw-bg4); }

/* Upside row (long-term card) */
.rkw-upside-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 6px 0 12px;
    position: relative;
    z-index: 1;
}
.rkw-signal { font-size: 12px; font-weight: 700; }
.rkw-signal-buy  { color: var(--rkw-green); }
.rkw-signal-hold { color: var(--rkw-yellow); }
.rkw-signal-sell { color: var(--rkw-red); }
.rkw-upside-val  { font-size: 13px; font-weight: 600; }
.rkw-upside-val.pos { color: var(--rkw-gold); }
.rkw-upside-val.neg { color: var(--rkw-red); }

/* ── Sub-score bars ── */
.rkw-bars {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 14px;
    position: relative;
    z-index: 1;
}
.rkw-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rkw-bar-label {
    font-size: 10px;
    color: var(--rkw-muted);
    min-width: 64px;
    text-align: right;
    letter-spacing: .2px;
}
.rkw-bar-track {
    flex: 1;
    height: 4px;
    background: var(--rkw-bg4);
    border-radius: 2px;
    overflow: hidden;
}
.rkw-bar-fill {
    height: 100%;
    background: var(--card-color);
    border-radius: 2px;
    opacity: .8;
    transition: width .7s cubic-bezier(.4,0,.2,1);
}
.rkw-bar-score {
    font-size: 10px;
    color: var(--rkw-muted);
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Key metrics ── */
.rkw-metrics {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    position: relative;
    z-index: 1;
}
.rkw-metric {
    flex: 1;
    background: var(--rkw-bg4);
    border: 1px solid var(--rkw-border);
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
}
.rkw-metric-label { font-size: 9px; color: var(--rkw-muted); text-transform: uppercase; letter-spacing: .4px; }
.rkw-metric-value { font-size: 13px; font-weight: 600; color: var(--rkw-text); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ── Footer ── */
.rkw-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    font-size: 11px;
    color: var(--rkw-muted);
    background: var(--rkw-bg);
}
.rkw-link { color: var(--rkw-blue); text-decoration: none; font-size: 12px; }
.rkw-link:hover { color: var(--rkw-teal); text-decoration: underline; }

/* ── Not found ── */
.rkw-not-found {
    padding: 40px;
    text-align: center;
    color: var(--rkw-muted);
    font-size: 14px;
}

/* ── Modal ── */
.rkw-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.8);
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
.rkw-modal.open { display: flex; }
.rkw-modal-inner {
    background: var(--rkw-bg2);
    border: 1px solid var(--rkw-border2);
    border-radius: var(--rkw-radius);
    padding: 28px;
    max-width: 520px;
    width: 94%;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.rkw-modal-close {
    position: absolute;
    top: 14px; right: 16px;
    background: none; border: none;
    color: var(--rkw-muted); font-size: 18px; cursor: pointer;
    line-height: 1;
}
.rkw-modal-close:hover { color: var(--rkw-text); }

/* Modal content */
.rkw-modal-title {
    font-family: var(--rkw-font-head);
    font-size: 18px;
    font-weight: 700;
    color: var(--rkw-text);
    letter-spacing: 1px;
    margin-bottom: 20px;
    padding-right: 24px;
}
.rkw-modal-title span { color: var(--card-color, var(--rkw-teal)); }

.rkw-modal-score-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}
.rkw-modal-big-score {
    font-family: var(--rkw-font-head);
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
}
.rkw-modal-score-info { flex: 1; }
.rkw-modal-grade { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 4px; }
.rkw-modal-eligibility { font-size: 11px; color: var(--rkw-muted); }

/* Modal blocks */
.rkw-modal-blocks { display: flex; flex-direction: column; gap: 8px; }
.rkw-modal-blk {
    background: var(--rkw-bg3);
    border: 1px solid var(--rkw-border);
    border-radius: 7px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.rkw-modal-blk-name { font-size: 12px; color: var(--rkw-muted); min-width: 80px; }
.rkw-modal-blk-bar { flex: 1; height: 5px; background: var(--rkw-bg4); border-radius: 3px; overflow: hidden; }
.rkw-modal-blk-fill { height: 100%; border-radius: 3px; transition: width .6s; }
.rkw-modal-blk-pts { font-size: 12px; font-weight: 600; color: var(--rkw-text); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

/* Modal upside section */
.rkw-modal-upside {
    background: linear-gradient(135deg, #141008 0%, #1a1508 100%);
    border: 1px solid rgba(240,180,41,.25);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
}
.rkw-modal-upside-title { font-size: 11px; color: var(--rkw-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.rkw-modal-upside-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rkw-modal-up-item { text-align: center; }
.rkw-modal-up-label { font-size: 9px; color: var(--rkw-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.rkw-modal-up-val { font-family: var(--rkw-font-head); font-size: 18px; font-weight: 700; color: var(--rkw-gold); }
.rkw-modal-up-val.neg { color: var(--rkw-red); }

/* Scroll */
.rkw-wrap ::-webkit-scrollbar { width: 5px; }
.rkw-wrap ::-webkit-scrollbar-track { background: var(--rkw-bg); }
.rkw-wrap ::-webkit-scrollbar-thumb { background: var(--rkw-border2); border-radius: 3px; }

/* Animations */
@keyframes rkwFadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }
.rkw-card { animation: rkwFadeIn .35s ease both; }
.rkw-card:nth-child(1) { animation-delay: .05s; }
.rkw-card:nth-child(2) { animation-delay: .12s; }
.rkw-card:nth-child(3) { animation-delay: .19s; }
