/* =====================================================================
   IRON PAW CHALLENGE — Statistics page (deep stats / global graphs)
   ----------------------------------------------------------------------
   - KPI strip
   - Section heading + legend chips
   - Chart card (wraps the SVG)
   - Histogram & dual-line chart styling
   - Discipline bar list, country / breed list rows
   ===================================================================== */

/* ===== KPI strip ===== */
.ip-stats-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 18px 0 22px;
}
.ip-stats-kpi {
    position: relative;
    padding: 16px 18px;
    background: linear-gradient(180deg, var(--ip-surface) 0%, var(--ip-bg-2) 100%);
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius);
    transition: transform .35s cubic-bezier(.2,.7,.2,1), border-color .25s ease;
    overflow: hidden;
}
.ip-stats-kpi::after {
    content: '';
    position: absolute;
    inset: -1px;
    background: radial-gradient(280px 180px at var(--glow-x, 50%) var(--glow-y, 50%),
                rgba(244,181,60,.10), transparent 60%);
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
}
.ip-stats-kpi:hover { border-color: var(--ip-border-strong); transform: translateY(-2px); }
.ip-stats-kpi:hover::after { opacity: 1; }
.ip-stats-kpi__value {
    font-size: 28px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--ip-text);
    letter-spacing: 0.01em;
    line-height: 1;
}
.ip-stats-kpi__label {
    margin-top: 6px;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--ip-gold);
}
.ip-stats-kpi__sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--ip-text-mute);
}

/* ===== Section header + chart card ===== */
.ip-stats-section { margin: 18px 0 6px; }
.ip-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 14px 0 6px;
}
@media (max-width: 900px) {
    .ip-stats-row { grid-template-columns: 1fr; }
}

.ip-stats-section__head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ip-stats-section__head--inset {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ip-border);
    margin-bottom: 12px;
}
.ip-stats-section__title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 0;
    color: var(--ip-text);
}
.ip-stats-section__sub {
    font-size: 12.5px;
    color: var(--ip-text-mute);
    margin-top: 4px;
}
.ip-stats-section__legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.ip-stats-legend {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--ip-text-dim);
    font-weight: 600;
}
.ip-stats-legend .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}
.ip-stats-legend .dot--gold { background: var(--ip-gold); color: var(--ip-gold); }
.ip-stats-legend .dot--blue { background: #5aa3ff;        color: #5aa3ff; }

.ip-chart-card {
    position: relative;
    background: linear-gradient(180deg, var(--ip-surface) 0%, var(--ip-bg-2) 100%);
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius);
    padding: 14px;
    transition: border-color .25s ease, transform .35s cubic-bezier(.2,.7,.2,1);
    overflow: hidden;
}
.ip-chart-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    background: radial-gradient(380px 220px at var(--glow-x, 50%) var(--glow-y, 50%),
                rgba(244,181,60,.07), transparent 60%);
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
}
.ip-chart-card:hover { border-color: var(--ip-border-strong); }
.ip-chart-card:hover::after { opacity: 1; }
.ip-chart-card--list { padding: 16px; }

/* ===== SVG chart styling ===== */
.ip-chart-svg {
    width: 100%;
    height: auto;
    display: block;
    font-family: var(--ip-font);
}
.ip-chart-bar {
    fill: rgba(244,181,60,.55);
    transition: fill .25s ease;
}
.ip-chart-bar:hover { fill: var(--ip-gold); }
.ip-chart-ytick {
    fill: var(--ip-text-mute);
    font-size: 10px;
    text-anchor: end;
}
.ip-chart-xtick {
    fill: var(--ip-text-mute);
    font-size: 10px;
    text-anchor: middle;
    letter-spacing: 0.04em;
}
.ip-chart-barlabel {
    fill: var(--ip-text-dim);
    font-size: 10px;
    text-anchor: middle;
    font-weight: 700;
}
.ip-chart-line {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: ip-chart-draw 1.4s cubic-bezier(.2,.7,.2,1) forwards;
    filter: drop-shadow(0 0 4px currentColor);
}
.ip-chart-line--blue { color: #5aa3ff; }
.ip-chart-line--gold { color: var(--ip-gold); animation-delay: .25s; }

@keyframes ip-chart-draw {
    to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ip-chart-line { animation: none; stroke-dashoffset: 0; }
}

/* ===== Discipline bar list ===== */
.ip-stats-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ip-stats-bar {
    display: grid;
    grid-template-columns: 110px 1fr 50px;
    align-items: center;
    gap: 12px;
    font-size: 12.5px;
}
.ip-stats-bar__label {
    color: var(--ip-text-dim);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ip-stats-bar__track {
    height: 8px;
    border-radius: 4px;
    background: rgba(255,255,255,.04);
    overflow: hidden;
    position: relative;
}
.ip-stats-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(244,181,60,.55), var(--ip-gold));
    border-radius: 4px;
    width: 0;
    transition: width 1.1s cubic-bezier(.2,.7,.2,1);
    box-shadow: 0 0 8px rgba(244,181,60,.35);
}
[data-reveal].is-revealed .ip-stats-bar__fill { /* width applied inline */ }
.ip-stats-bar__fill--time    { background: linear-gradient(90deg, rgba(90,163,255,.4),  #5aa3ff);        box-shadow: 0 0 8px rgba(90,163,255,.3); }
.ip-stats-bar__fill--reps    { background: linear-gradient(90deg, rgba(74,222,128,.4),  #4ade80);        box-shadow: 0 0 8px rgba(74,222,128,.3); }
.ip-stats-bar__fill--height  { background: linear-gradient(90deg, rgba(244,181,60,.4),  var(--ip-gold)); box-shadow: 0 0 8px rgba(244,181,60,.35); }
.ip-stats-bar__fill--maxtime { background: linear-gradient(90deg, rgba(196,163,255,.4), #c4a3ff);        box-shadow: 0 0 8px rgba(196,163,255,.3); }
.ip-stats-bar__value {
    text-align: right;
    color: var(--ip-text);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

/* ===== Country / breed list rows ===== */
.ip-stats-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ip-stats-row-item {
    display: grid;
    grid-template-columns: 22px 22px 1fr 90px 60px;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--ip-border);
    transition: background .2s ease;
}
.ip-stats-row-item:last-child { border-bottom: 0; }
.ip-stats-row-item:hover { background: rgba(255,255,255,.025); }
.ip-stats-row-item__rank {
    color: var(--ip-text-mute);
    font-weight: 900;
    font-size: 13px;
    text-align: center;
}
.ip-stats-row-item__name {
    color: var(--ip-text);
    font-weight: 700;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ip-stats-row-item__bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,.04);
    overflow: hidden;
}
.ip-stats-row-item__bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, rgba(244,181,60,.45), var(--ip-gold));
    border-radius: 3px;
    width: 0;
    transition: width 1.1s cubic-bezier(.2,.7,.2,1) .2s;
    box-shadow: 0 0 6px rgba(244,181,60,.3);
}
.ip-stats-row-item__val {
    text-align: right;
    color: var(--ip-text);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

/* Country/breed rows without a flag column collapse left */
.ip-stats-row-item:not(:has(.ip-flag)) {
    grid-template-columns: 22px 1fr 90px 60px;
}

@media (max-width: 600px) {
    .ip-stats-bar { grid-template-columns: 100px 1fr 44px; }
    .ip-stats-row-item { grid-template-columns: 22px 22px 1fr 70px 48px; gap: 8px; }
    .ip-stats-row-item:not(:has(.ip-flag)) { grid-template-columns: 22px 1fr 70px 48px; }
}

/* ===================================================================
   Compare Dogs widget — head-to-head bars + dog picker.
   Two opposing bars (blue for A, gold for B) grow from the centre
   discipline label outward to make the comparison instantly readable.
   =================================================================== */
.ip-compare-wrap { margin-top: 22px; }

.ip-compare {
    padding: 18px;
}
.ip-compare__pickers {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 14px;
    margin-bottom: 14px;
}
.ip-compare__picker-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ip-text-mute);
    margin-bottom: 6px;
}
.ip-compare__select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255,255,255,.02);
    color: var(--ip-text);
    border: 1px solid var(--ip-border);
    border-radius: 6px;
    padding: 9px 30px 9px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1l5 5 5-5" stroke="%237a839a" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color .2s ease;
}
.ip-compare__select:focus { outline: none; border-color: rgba(90,163,255,.4); }
.ip-compare__vs {
    align-self: center;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(244,181,60,.12);
    border: 1px solid rgba(244,181,60,.35);
    color: var(--ip-gold);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.1em;
}

.ip-compare__headline {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    padding: 12px 0 14px;
    border-bottom: 1px solid var(--ip-border);
    margin-bottom: 14px;
}
.ip-compare__side {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.ip-compare__side--b { justify-content: flex-end; }
.ip-compare__name {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1;
}
.ip-compare__sub {
    font-size: 11px;
    color: var(--ip-text-mute);
    margin-top: 4px;
    letter-spacing: 0.04em;
}
.ip-compare__metric-row {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.ip-compare__metric {
    font-size: 22px;
    font-weight: 900;
    color: var(--ip-text);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.ip-compare__metric-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ip-gold);
}

.ip-compare__rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ip-compare__row {
    display: grid;
    grid-template-columns: 1fr 130px 1fr;
    align-items: center;
    gap: 12px;
    font-size: 12.5px;
}
.ip-compare__row-label {
    text-align: center;
    color: var(--ip-text);
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: 12px;
}
.ip-compare__bar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ip-compare__bar--a { justify-content: flex-end; }
.ip-compare__bar--b { justify-content: flex-start; }

.ip-compare__bar-track {
    height: 8px;
    flex: 1;
    background: rgba(255,255,255,.04);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    max-width: 100%;
}
.ip-compare__bar-track span {
    display: block;
    height: 100%;
    border-radius: 4px;
    width: 0;
    transition: width 1.1s cubic-bezier(.2,.7,.2,1) .15s;
}
.ip-compare__bar-track--a {
    transform: scaleX(-1); /* mirror so A grows right-to-left toward centre */
    transform-origin: right center;
}
.ip-compare__bar-track--a span {
    background: linear-gradient(90deg, rgba(90,163,255,.4), #5aa3ff);
    box-shadow: 0 0 8px rgba(90,163,255,.35);
}
.ip-compare__bar-track--b span {
    background: linear-gradient(90deg, rgba(244,181,60,.55), var(--ip-gold));
    box-shadow: 0 0 8px rgba(244,181,60,.35);
}
.ip-compare__bar-val {
    min-width: 44px;
    text-align: center;
    color: var(--ip-text-dim);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    transition: color .2s ease;
}
.ip-compare__bar-val.is-win { color: var(--ip-gold); }

.ip-compare__footnote {
    margin-top: 12px;
    font-size: 11.5px;
    color: var(--ip-text-mute);
    text-align: center;
    letter-spacing: 0.02em;
}

@media (max-width: 700px) {
    .ip-compare__pickers { grid-template-columns: 1fr; }
    .ip-compare__vs { display: none; }
    .ip-compare__headline { grid-template-columns: 1fr; text-align: center; }
    .ip-compare__side, .ip-compare__side--b { justify-content: center; }
    .ip-compare__row { grid-template-columns: 1fr; gap: 4px; }
    .ip-compare__bar--a { order: 1; }
    .ip-compare__row-label { order: 2; }
    .ip-compare__bar--b { order: 3; }
    .ip-compare__bar-track--a { transform: none; }
}
