/* SPDX-License-Identifier: Apache-2.0 */
/* AGY-Nexus /web/v9 — Card 3 Pool Split Tug-of-War & Card 4 Quota & Resets */

@layer views {
  /* Balanced 4-Card Vertical Rhythm */
  .v9-stage .va-kpi-gauge-card { container-type: inline-size; justify-content: flex-start; }
  .v9-stage .va-kpi-gauge-card > .va-kpi-gauge-stats:last-child { margin-block-start: auto; }
  .v9-stage .va-kpi-gauge-head { flex-wrap: nowrap; min-inline-size: 0; gap: 0.35rem; }
  .v9-stage .va-kpi-gauge-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-inline-size: 0; }
  .v9-qr-offline-note { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); line-height: 1.35; }
  .v9-kpi-foot {
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .v9-kpi-foot > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Card 3: Pool Split Hero & Opposing Dual-Fill Track */
  .v9-split-hero {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem;
    white-space: nowrap;
    min-inline-size: 0;
    overflow: hidden;
  }
  .v9-split-side { display: inline-flex; align-items: baseline; gap: 0.24rem; min-inline-size: 0; white-space: nowrap; }
  .v9-split-pct {
    font-family: var(--font-mono);
    font-variant-numeric: var(--font-nums);
    font-size: clamp(0.94rem, 1.1vw, 1.15rem);
    font-weight: 700;
    line-height: 1.15;
  }
  .v9-split-side.is-gemini .v9-split-pct { color: var(--v9-pool-gemini); }
  .v9-split-side.is-partner .v9-split-pct { color: var(--v9-pool-partner); }
  .v9-split-lbl { font-size: var(--ts-xs); font-weight: 600; color: var(--text-secondary); }

  .v9-split-bar-wrap { position: relative; padding-block-start: 6px; margin-block: 0.05rem; }
  .v9-split-track {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 2px;
    inline-size: 100%;
    block-size: 8px;
    border-radius: var(--radius-pill, 999px);
    background: var(--v9-quota-track, var(--bg-elevated));
    border: 1px solid var(--border-hairline);
    overflow: hidden;
  }
  .v9-split-fill-g, .v9-split-fill-p { block-size: 100%; transition: flex-basis 0.25s ease, inline-size 0.25s ease; }
  .v9-split-fill-g { background: var(--v9-pool-gemini); }
  .v9-split-fill-p { background: var(--v9-pool-partner); margin-inline-start: auto; }
  .v9-split-guide {
    position: absolute;
    inset-block-start: 4px;
    block-size: 12px;
    inline-size: 2px;
    margin-inline-start: -1px;
    background: var(--text-primary);
    border-radius: 1px;
    pointer-events: none;
    z-index: 2;
  }
  .v9-split-caret {
    position: absolute;
    inset-block-start: -1px;
    inline-size: 8px;
    block-size: 5px;
    margin-inline-start: -4px;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 3;
  }
  .v9-split-24h,
  .v9-split-recent {
    font-family: var(--font-mono);
    font-variant-numeric: var(--font-nums);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.18rem 0.55rem;
    min-inline-size: 0;
  }
  .v9-split-recent-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    white-space: nowrap;
  }
  .v9-split-win-lbl {
    font-weight: 700;
    color: var(--text-secondary);
  }
  .v9-split-win-val {
    color: var(--text-primary);
  }

  /* Card 4: Quota & Resets Status Pill & Remaining Progress Rows */
  .v9-qr-pill { flex-shrink: 0; white-space: nowrap; }
  .v9-qr-pill.is-ok::before { background: var(--v9-quota-ok); }
  .v9-qr-pill[data-state="muted"] {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding-inline: 0.42rem;
    color: var(--text-muted);
  }
  .v9-qr-pill[data-state="muted"]::before { display: none; }
  .v9-qr-list { display: flex; flex-direction: column; gap: 0.32rem; }
  .v9-qr-list.is-dimmed progress.v9-qr-prog { opacity: 0.65; }
  .v9-qr-row { display: flex; flex-direction: column; gap: 0.18rem; min-inline-size: 0; }
  .v9-qr-lbl-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.28rem;
    font-family: var(--font-mono);
    font-variant-numeric: var(--font-nums);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
  }
  .v9-qr-lbl { overflow: hidden; text-overflow: ellipsis; min-inline-size: 0; }
  .v9-qr-lbl strong { color: var(--text-primary); font-weight: 700; }
  .v9-qr-rst { color: var(--text-muted); flex-shrink: 0; }
  .v9-qr-prefix-short { display: none; }
  .v9-qr-prefix-full { display: inline; }

  /* Semantic <progress> Quota Bar following modern-web-guidance */
  progress.v9-qr-prog {
    appearance: none;
    display: block;
    inline-size: 100%;
    block-size: 5px;
    border: 0 solid;
    border-radius: var(--radius-pill, 999px);
    background: var(--v9-quota-track, var(--bg-elevated));
    overflow: clip;
  }
  progress.v9-qr-prog::-webkit-progress-bar { background: transparent; }
  progress.v9-qr-prog::-webkit-progress-value {
    background: var(--v9-prog-fill, var(--v9-quota-ok));
    border-radius: var(--radius-pill, 999px);
    transition: inline-size 0.3s;
  }
  progress.v9-qr-prog::-moz-progress-bar {
    background: var(--v9-prog-fill, var(--v9-quota-ok));
    border-radius: var(--radius-pill, 999px);
    transition: inline-size 0.3s;
  }
  progress.v9-qr-prog[data-level="ok"] { --v9-prog-fill: var(--v9-quota-ok); }
  progress.v9-qr-prog[data-level="low"] { --v9-prog-fill: var(--v9-quota-low); }
  progress.v9-qr-prog[data-level="near"] { --v9-prog-fill: var(--v9-quota-near); }
  progress.v9-qr-prog[data-level="standby"] { --v9-prog-fill: transparent; }

  @container (max-width: 215px) {
    .v9-split-hero { gap: 0.2rem; }
    .v9-split-side { gap: 0.16rem; }
    .v9-split-pct { font-size: 11.5px; }
    .v9-split-lbl { font-size: 11px; }
    .v9-tier-pfx, .v9-qr-prefix-full, .v9-qr-rst-pfx, .v9-24h-word, .v9-p-standby-full, .v9-qr-standby-word, .v9-off-pfx { display: none; }
    .v9-qr-prefix-short { display: inline; }
    .v9-qr-lbl-row, .v9-split-24h { font-size: 11px; }
    .v9-qr-pill[data-state="muted"] { font-size: 11px; padding-inline: 0.32rem; }
  }

  @media (forced-colors: active) {
    .v9-split-fill-g { forced-color-adjust: none; background: Highlight; border: 1px solid CanvasText; }
    .v9-split-fill-p { forced-color-adjust: none; background: CanvasText; border: 1px solid CanvasText; }
    .v9-split-guide { background: CanvasText; }
    .v9-split-caret { color: CanvasText; }
    progress.v9-qr-prog { forced-color-adjust: none; background: Canvas; border: 1px solid CanvasText; }
    progress.v9-qr-prog::-webkit-progress-value { background: Highlight; }
    progress.v9-qr-prog::-moz-progress-bar { background: Highlight; }
  }
}

@layer utilities {
  @media (max-width: 479px) {
    .v9-stage .v9-split-pct { font-size: 11.5px; }
    .v9-stage .v9-split-lbl { font-size: 11px; }
    .v9-stage .v9-tier-pfx, .v9-stage .v9-qr-prefix-full, .v9-stage .v9-qr-rst-pfx, .v9-stage .v9-24h-word, .v9-stage .v9-p-standby-full, .v9-stage .v9-qr-standby-word, .v9-stage .v9-off-pfx { display: none; }
    .v9-stage .v9-qr-prefix-short { display: inline; }
    .v9-stage .v9-qr-lbl-row, .v9-stage .v9-split-24h { font-size: 11px; }
    .v9-stage .v9-qr-pill[data-state="muted"] { font-size: 11px; padding-inline: 0.32rem; }
  }
}

@layer views {
  /* Card 4: Tethered Dual Carets & Pace Guide Tick on Quota & Resets Bars */
  .v9-qr-prog-wrap {
    position: relative;
    display: block;
    padding-block-start: 7px;
    min-inline-size: 0;
  }
  .v9-qr-prog-wrap.is-clean {
    padding-block-start: 0;
  }
  .v9-tether-track {
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    block-size: 6px;
    pointer-events: none;
    overflow: visible;
  }
  .v9-tether-line {
    position: absolute;
    inset-block-start: 2.5px;
    block-size: 1px;
    background: var(--text-muted);
    opacity: 0.65;
    pointer-events: none;
    z-index: 1;
  }
  .v9-tether-caret {
    position: absolute;
    inset-block-start: 0;
    inline-size: 8px;
    block-size: 6px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    line-height: 0;
    transition: inset-inline-start 0.25s ease;
  }
  .v9-tether-caret > svg { display: block; overflow: visible; }
  .v9-tether-caret[data-caret="prev"] { color: var(--text-muted); z-index: 2; }
  .v9-tether-caret[data-caret="curr"] { color: var(--text-primary); z-index: 3; }
  .v9-qr-guide {
    position: absolute;
    inset-block-end: -1px;
    inline-size: 1.5px;
    block-size: 7px;
    transform: translateX(-50%);
    background: var(--text-primary);
    opacity: 0.55;
    border-radius: 1px;
    pointer-events: none;
    z-index: 4;
  }
  .v9-qr-list.is-dimmed .v9-tether-track,
  .v9-qr-list.is-dimmed .v9-qr-guide { opacity: 0.65; }

  /* Shared #v9BurndownCard Component Styling (4 Themes & 390/860/1440 Responsive) */
  :root #v9BurndownCard,
  [data-theme="white"] #v9BurndownCard,
  [data-theme="white"] .v9-bd-card {
    --v9-bd-grid: var(--border-hairline);
    --v9-bd-axis: var(--text-muted);
  }
  [data-theme="paper"] #v9BurndownCard,
  [data-theme="paper"] .v9-bd-card {
    --v9-bd-grid: var(--border-hairline);
    --v9-bd-axis: var(--text-muted);
  }
  [data-theme="dark-paper"] #v9BurndownCard,
  [data-theme="dark-paper"] .v9-bd-card {
    --v9-bd-grid: var(--border-subtle);
    --v9-bd-axis: var(--text-muted);
  }
  [data-theme="dark"] #v9BurndownCard,
  [data-theme="dark"] .v9-bd-card {
    --v9-bd-grid: var(--border-subtle);
    --v9-bd-axis: var(--text-muted);
  }
  #v9BurndownCard,
  .v9-bd-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: var(--density-card-pad, 0.85rem);
    box-shadow: var(--v9-shadow-card);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-inline-size: 0;
    color: var(--text-primary);
    container-type: inline-size;
  }
  .v9-bd-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 0.75rem;
    min-inline-size: 0;
  }
  .v9-bd-head > * { min-inline-size: 0; }
  .v9-bd-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem 0.65rem;
    min-inline-size: 0;
    max-inline-size: 100%;
  }
  .v9-bd-controls .va-tb-group { max-inline-size: 100%; flex-wrap: wrap; }
  .v9-bd-controls button:not(.va-tb-btn),
  .v9-bd-controls select {
    min-block-size: 28px;
    padding: 0.16rem 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--ts-xs);
    font-weight: 600;
    font-variant-numeric: var(--font-nums);
    cursor: pointer;
    min-inline-size: 0;
    max-inline-size: 100%;
  }
  .v9-bd-controls button:not(.va-tb-btn):hover:not(:disabled),
  .v9-bd-controls select:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
  }
  .v9-bd-controls button:not(.va-tb-btn)[aria-pressed="true"],
  .v9-bd-controls button:not(.va-tb-btn)[data-active="true"],
  .v9-bd-controls button:not(.va-tb-btn).is-active {
    background: var(--bg-surface);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
  }
  .v9-bd-controls button:focus-visible,
  .v9-bd-controls select:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
  }
  .v9-bd-summary {
    font-family: var(--font-mono);
    font-variant-numeric: var(--font-nums);
    font-size: var(--ts-xs);
    color: var(--text-muted);
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }
  .v9-bd-summary strong { color: var(--text-primary); font-weight: 700; }
  .v9-bd-summary:empty { display: none; }
  .v9-bd-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.85rem;
    min-inline-size: 0;
    font-family: var(--font-mono);
    font-variant-numeric: var(--font-nums);
    font-size: var(--ts-xs);
    color: var(--text-secondary);
  }
  .v9-bd-leg-item {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    min-inline-size: 0;
    white-space: nowrap;
    color: var(--text-secondary);
  }
  .v9-bd-leg-item strong { color: var(--text-primary); font-weight: 700; }
  .v9-bd-swatch {
    display: inline-block;
    inline-size: 10px;
    block-size: 10px;
    border-radius: var(--radius-xs, 2px);
    background: var(--v9-bd-color, var(--accent-primary));
    flex-shrink: 0;
  }
  .v9-bd-swatch[data-kind="line"],
  .v9-bd-swatch.is-line {
    inline-size: 14px;
    block-size: 2px;
    border-radius: 1px;
  }
  .v9-bd-swatch[data-kind="dashed"],
  .v9-bd-swatch.is-dashed {
    inline-size: 14px;
    block-size: 0;
    border-radius: 0;
    background: transparent;
    border-block-start: 2px dashed var(--v9-bd-color, var(--text-muted));
  }
  .v9-bd-chart {
    position: relative;
    inline-size: 100%;
    block-size: clamp(190px, 24vw, 240px);
    min-block-size: 185px;
    min-inline-size: 0;
    overflow: hidden;
  }
  .v9-bd-chart > svg { display: block; inline-size: 100%; block-size: 100%; }

  @media (max-width: 1099px) {
    .v9-bd-legend { gap: 0.3rem 0.65rem; }
    .v9-bd-chart { block-size: clamp(185px, 25vw, 215px); }
  }

  @media (max-width: 639px) {
    #v9BurndownCard,
    .v9-bd-card { padding: 0.65rem; gap: 0.45rem; }
    .v9-bd-head { align-items: flex-start; gap: 0.35rem; }
    .v9-bd-controls { justify-content: flex-start; inline-size: 100%; gap: 0.3rem 0.5rem; }
    .v9-bd-summary { font-size: 11px; }
    .v9-bd-legend { gap: 0.25rem 0.55rem; font-size: 11px; }
    .v9-bd-chart { block-size: 176px; min-block-size: 170px; }
  }

  @container (max-width: 440px) {
    .v9-bd-controls { justify-content: flex-start; inline-size: 100%; }
  }

  @media (forced-colors: active) {
    .v9-tether-line { background: GrayText; opacity: 1; }
    .v9-tether-caret[data-caret="prev"] { color: GrayText; }
    .v9-tether-caret[data-caret="curr"] { color: CanvasText; }
    .v9-tether-track[data-window="wk"] .v9-tether-caret polygon { fill: Canvas; }
    .v9-qr-guide { background: CanvasText; opacity: 1; }
    .v9-bd-swatch { forced-color-adjust: none; border: 1px solid CanvasText; }
  }
}
