/* ==========================================================================
   Karimeh AI Bench - visual layer
   Pure CSS - no JS, no libraries.
   ========================================================================== */

/* --- Animated bar ---------------------------------------------------- */
.kn-bar {
    position: relative;
    height: 6px;
    border-radius: 9999px;
    background: rgba(0, 141, 99, .1);
    overflow: hidden;
}
html.dark .kn-bar { background: rgba(110, 231, 183, .12); }

.kn-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #008d63 0%, #10b981 100%);
    width: 0;
    animation: kn-bar-grow .8s cubic-bezier(.22, 1, .36, 1) forwards;
}
.kn-bar-fill.amber {
    background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
}
.kn-bar-fill.rose {
    background: linear-gradient(90deg, #e11d48 0%, #fb7185 100%);
}
.kn-bar-fill.neutral {
    background: linear-gradient(90deg, #737373 0%, #a3a3a3 100%);
}

@keyframes kn-bar-grow {
    from { width: 0; }
}

/* --- Meter (VRAM/RAM) ------------------------------------------------ */
.kn-meter {
    height: 34px;
    border-radius: .75rem;
    background: rgba(0, 141, 99, .08);
    border: 1px solid rgba(0, 141, 99, .2);
    position: relative;
    overflow: hidden;
}
html.dark .kn-meter {
    background: rgba(110, 231, 183, .08);
    border-color: rgba(110, 231, 183, .2);
}

.kn-meter-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: .75rem;
    background: linear-gradient(90deg, #008d63 0%, #10b981 100%);
    animation: kn-meter-grow 1s cubic-bezier(.22, 1, .36, 1) forwards;
    transition: width .5s ease;
}
.kn-meter-fill.warn {
    background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
}
.kn-meter-fill.danger {
    background: linear-gradient(90deg, #e11d48 0%, #fb7185 100%);
}

.kn-meter-label {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 .875rem;
    font-size: .8125rem;
    font-weight: 600;
    color: #171717;
}
html.dark .kn-meter-label { color: #f5f5f5; }

@keyframes kn-meter-grow { from { width: 0; } }

/* --- Histogram ------------------------------------------------------- */
.kn-histogram {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    padding-bottom: 22px;
    position: relative;
}
.kn-histogram-bar {
    flex: 1;
    min-width: 0;
    background: rgba(0, 141, 99, .15);
    border-radius: 4px 4px 0 0;
    height: 0;
    animation: kn-hg-grow .7s cubic-bezier(.22, 1, .36, 1) forwards;
    position: relative;
    transition: background-color .15s;
}
.kn-histogram-bar:hover { background: rgba(0, 141, 99, .35); }
.kn-histogram-bar.has-value { background: #008d63; }
.kn-histogram-bar.has-value:hover { background: #007552; }
html.dark .kn-histogram-bar { background: rgba(110, 231, 183, .15); }
html.dark .kn-histogram-bar.has-value { background: #10b981; }

.kn-histogram-bar span {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: ui-monospace, monospace;
    font-size: 10px;
    color: #a3a3a3;
    white-space: nowrap;
}

@keyframes kn-hg-grow { from { height: 0; } }

/* --- Card hover lift ------------------------------------------------- */
.kn-lift {
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.kn-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -12px rgba(15, 23, 42, .12);
}
html.dark .kn-lift:hover {
    box-shadow: 0 12px 28px -12px rgba(0, 0, 0, .6);
}

/* --- Answer card gradients ------------------------------------------ */
.kn-hero-answer {
    background:
      radial-gradient(circle at 100% 0%, rgba(0, 141, 99, .12), transparent 60%),
      linear-gradient(135deg, #ffffff 0%, #f8faf9 100%);
}
html.dark .kn-hero-answer {
    background:
      radial-gradient(circle at 100% 0%, rgba(16, 185, 129, .18), transparent 60%),
      linear-gradient(135deg, #0f1112 0%, #14181a 100%);
}

/* --- Pulse for "live" values ---------------------------------------- */
@keyframes kn-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}
.kn-pulse { animation: kn-pulse 2.4s ease-in-out infinite; }

/* --- Chip group ------------------------------------------------------ */
.kn-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
}
.kn-chip {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .375rem .75rem;
    border-radius: 9999px;
    border: 1px solid rgb(229 229 229);
    background: #fff;
    font-size: .8125rem;
    font-weight: 500;
    color: rgb(64 64 64);
    transition: all .15s;
    cursor: pointer;
    white-space: nowrap;
}
.kn-chip:hover {
    border-color: #008d63;
    color: #008d63;
    background: rgba(0, 141, 99, .04);
}
.kn-chip.active {
    background: #008d63;
    border-color: #008d63;
    color: #fff;
}
html.dark .kn-chip {
    border-color: rgb(38 38 38);
    background: #171717;
    color: rgb(212 212 212);
}
html.dark .kn-chip:hover {
    border-color: #10b981;
    color: #6ee7b7;
    background: rgba(16, 185, 129, .08);
}
html.dark .kn-chip.active {
    background: #008d63;
    border-color: #008d63;
    color: #fff;
}

/* --- Rank medal ------------------------------------------------------ */
.kn-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: rgba(0, 141, 99, .1);
    color: #008d63;
}
.kn-rank-1 { background: #fef3c7; color: #b45309; }
.kn-rank-2 { background: #e5e5e5; color: #525252; }
.kn-rank-3 { background: #ffedd5; color: #c2410c; }
html.dark .kn-rank { background: rgba(110, 231, 183, .14); color: #6ee7b7; }
html.dark .kn-rank-1 { background: rgba(245, 158, 11, .18); color: #fcd34d; }
html.dark .kn-rank-2 { background: rgba(163, 163, 163, .2); color: #e5e5e5; }
html.dark .kn-rank-3 { background: rgba(249, 115, 22, .18); color: #fdba74; }

/* --- Big number emphasis -------------------------------------------- */
.kn-big-num {
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
    line-height: 1;
}

/* --- Section header -------------------------------------------------- */
.kn-section-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgb(163 163 163);
    margin-bottom: .75rem;
}
html.dark .kn-section-head { color: rgb(115 115 115); }
.kn-section-head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgb(245 245 245);
    margin-left: .5rem;
}
html.dark .kn-section-head::after { background: rgb(38 38 38); }

/* --- Stagger animation for card grids -------------------------------- */
.kn-stagger > * {
    opacity: 0;
    animation: kn-fade-up .5s cubic-bezier(.22, 1, .36, 1) forwards;
}
.kn-stagger > *:nth-child(1) { animation-delay: 0ms; }
.kn-stagger > *:nth-child(2) { animation-delay: 40ms; }
.kn-stagger > *:nth-child(3) { animation-delay: 80ms; }
.kn-stagger > *:nth-child(4) { animation-delay: 120ms; }
.kn-stagger > *:nth-child(5) { animation-delay: 160ms; }
.kn-stagger > *:nth-child(6) { animation-delay: 200ms; }
.kn-stagger > *:nth-child(7) { animation-delay: 240ms; }
.kn-stagger > *:nth-child(8) { animation-delay: 280ms; }

@keyframes kn-fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .kn-bar-fill, .kn-meter-fill, .kn-histogram-bar, .kn-stagger > * {
        animation: none !important;
        width: inherit;
        height: inherit;
        opacity: 1;
    }
}


/* ==========================================================================
   Compare page - chart components
   ========================================================================== */

/* Two-column layout for GPU cards */
.kn-vs-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) {
    .kn-vs-grid { grid-template-columns: 1fr 1fr; }
}

/* Metric row chart - one bar per GPU */
.kn-metric-row {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    align-items: center;
    gap: .875rem;
    padding: .625rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
}
.kn-metric-row:last-child { border-bottom: 0; }
html.dark .kn-metric-row { border-bottom-color: rgba(255, 255, 255, .05); }

.kn-metric-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    font-size: .8125rem;
    font-weight: 600;
    color: rgb(38 38 38);
}
html.dark .kn-metric-label { color: rgb(229 229 229); }
.kn-metric-label .kn-metric-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kn-metric-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: .625rem;
}
.kn-metric-value {
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-variant-numeric: tabular-nums;
    font-size: .875rem;
    font-weight: 700;
    color: rgb(23 23 23);
    min-width: 3.5rem;
    text-align: right;
}
html.dark .kn-metric-value { color: rgb(245 245 245); }

/* Winner badge (small crown) */
.kn-crown {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    font-size: 10px;
    background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%);
    color: #78350f;
    flex-shrink: 0;
}
.kn-crown svg {
    width: 11px;
    height: 11px;
}
html.dark .kn-crown {
    background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
    color: #fcd34d;
}

/* Per-GPU header card */
.kn-gpu-card {
    border-radius: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid rgb(229 229 229);
    position: relative;
    overflow: hidden;
}
html.dark .kn-gpu-card {
    background: #171717;
    border-color: rgb(38 38 38);
}

.kn-gpu-card.is-winner::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #fcd34d 0%, #f59e0b 100%);
}

/* Head-to-head model block */
.kn-h2h-model {
    border-radius: 1rem;
    border: 1px solid rgb(229 229 229);
    background: #fff;
    padding: 1rem;
}
html.dark .kn-h2h-model {
    border-color: rgb(38 38 38);
    background: #171717;
}

/* Specs comparison row */
/* Specs comparison row - responsive grid, 2..4 GPU columns */
.kn-specs-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.kn-specs-wrap .kn-specs-inner {
    min-width: 100%;
}

.kn-spec-row {
    display: grid;
    gap: .75rem;
    align-items: center;
    padding: .75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
    font-size: .875rem;
}
.kn-spec-row:last-child { border-bottom: 0; }
html.dark .kn-spec-row { border-bottom-color: rgba(255, 255, 255, .05); }

/* Column templates by GPU count */
.kn-spec-row.cols-2 {
    grid-template-columns: minmax(120px, 160px) repeat(2, minmax(0, 1fr));
}
.kn-spec-row.cols-3 {
    grid-template-columns: minmax(110px, 150px) repeat(3, minmax(0, 1fr));
}
.kn-spec-row.cols-4 {
    grid-template-columns: minmax(100px, 140px) repeat(4, minmax(0, 1fr));
}

/* Ensure readable min-width on narrow screens - scroll happens in .kn-specs-wrap */
.kn-spec-row.cols-2 { min-width: 480px; }
.kn-spec-row.cols-3 { min-width: 640px; }
.kn-spec-row.cols-4 { min-width: 780px; }

.kn-spec-name {
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: rgb(163 163 163);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kn-spec-value {
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-variant-numeric: tabular-nums;
    color: rgb(38 38 38);
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
html.dark .kn-spec-value { color: rgb(229 229 229); }

.kn-spec-value.is-better {
    font-weight: 700;
    color: #008d63;
}
html.dark .kn-spec-value.is-better { color: #6ee7b7; }

/* Header row: bold GPU names */
.kn-spec-row.is-header .kn-spec-name {
    color: rgb(115 115 115);
}
html.dark .kn-spec-row.is-header .kn-spec-name {
    color: rgb(163 163 163);
}
.kn-spec-row.is-header {
    border-bottom: 2px solid rgb(229 229 229);
}
html.dark .kn-spec-row.is-header {
    border-bottom-color: rgb(38 38 38);
}

/* --- Form input icon spacing: ensures placeholder never touches leading icon --- */
.kn-cb-input {
    padding-left: 2.75rem !important;
}