/**
 * Poisson Distribution Calculator
 * Moved from the template's inline <style> block (#35, #26). The calculator
 * follows the theme: its dark #0f172a card, white-alpha panels and literal
 * ink moved to the surface ramp and text tokens together.
 */

/* Poisson Calculator Specific Styles */
.poisson-calculator .bb-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.bac-header-subtitle {
    color: var(--text-muted);
    font-size: 1.0625rem;
    margin-top: 0.5rem;
    line-height: 1.6;
}

/* Team Input Grid */
.teams-input-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .teams-input-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .vs-divider { display: none; }
}

.team-input-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.team-input-card.home { border-color: rgba(var(--pf-primary-rgb), 0.35); }
.team-input-card.away { border-color: rgba(239, 68, 68, 0.35); }

.team-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.team-input-card.home .team-label { color: var(--up-text); }
.team-input-card.away .team-label { color: var(--down-text); }

.team-name-input,
.xg-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
}

.team-name-input { margin-bottom: 0.75rem; }

.xg-input {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    padding: 0.75rem 1rem;
}

.team-name-input:focus,
.xg-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.xg-input-group label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dim);
    padding-bottom: 1rem;
}

/* Helper Text */
.bb-helper-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* Auto-Calculate Indicator */
.bac-auto-calc-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.auto-calc-dot {
    width: 8px;
    height: 8px;
    background: var(--up);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Button Group */
.bac-button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.bb-btn {
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
}

.bb-btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
}

.bb-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--accent-line);
}

.bb-btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--tools-field-border);
}

.bb-btn-secondary:hover {
    border-color: var(--text-dim);
    color: var(--text);
    background: rgba(100, 116, 139, 0.1);
}

.bb-btn-copy {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--tools-field-border);
}

/* The shared kit's enabled state (.bb-btn-copy:not(:disabled), #e2e8f0)
   outranks the rule above; scoped here it keeps the theme ink. */
.poisson-calculator .bb-btn-copy:not(:disabled) {
    color: var(--text);
    border-color: var(--tools-field-border);
}

.poisson-calculator .bb-btn-copy:hover:not(:disabled),
.bb-btn-copy:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.bb-btn-copy:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results Section */
.poisson-results {
    display: none;
    margin-top: 1.5rem;
}

.poisson-results.visible { display: block; }

.results-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.results-header h3 {
    color: var(--text);
    margin-bottom: 0.25rem;
}

.match-title {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Main Probabilities - 3 column grid */
.main-probabilities {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .main-probabilities {
        grid-template-columns: 1fr;
    }
}

.prob-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
}

.prob-card.home {
    border-color: rgba(var(--pf-primary-rgb), 0.3);
    background: rgba(var(--pf-primary-rgb), 0.05);
}

.prob-card.draw {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.05);
}

.prob-card.away {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.prob-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.prob-value {
    font-size: 2rem;
    font-weight: 700;
}

.prob-card.home .prob-value { color: var(--up-text); }
.prob-card.draw .prob-value { color: var(--warn-text); }
.prob-card.away .prob-value { color: var(--down-text); }

.prob-odds {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Over/Under Section */
.bb-zones-container {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.bb-sport-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.bb-sport-icon {
    color: var(--up-text);
}

.ou-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.ou-item {
    background: var(--surface-3);
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
}

.ou-line {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.ou-values {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
}

.ou-over, .ou-under {
    font-size: 0.875rem;
    font-weight: 600;
}

.ou-over { color: var(--up-text); }
.ou-under { color: var(--accent-text); }

/* Score Matrix */
.score-matrix {
    display: grid;
    grid-template-columns: auto repeat(6, 1fr);
    gap: 2px;
    min-width: 400px;
}

/* The home/away tints carry the axis and the highlight/top-3 tints carry
   the rank; the text on them reads in the ink (#34: accent text on a tint
   of itself, 4.05:1 as red). */
.matrix-header {
    background: rgba(var(--pf-primary-rgb), 0.1);
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text);
}

.matrix-row-header {
    background: rgba(239, 68, 68, 0.1);
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text);
}

.matrix-cell {
    background: var(--surface-3);
    padding: 0.5rem 0.25rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.matrix-cell.highlight {
    background: rgba(var(--pf-primary-rgb), 0.15);
    color: var(--text);
    font-weight: 600;
}

.matrix-cell.top-3 {
    background: rgba(251, 191, 36, 0.15);
    color: var(--text);
}

.matrix-corner {
    background: var(--surface-2);
}

/* Most Likely Scores */
.likely-scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
}

.likely-score-item {
    background: var(--surface-3);
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
}

.likely-score-item.rank-1 {
    background: rgba(var(--pf-primary-rgb), 0.1);
    border: 1px solid rgba(var(--pf-primary-rgb), 0.3);
}

.score-display {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.score-prob {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.likely-score-item.rank-1 .score-prob { color: var(--text); }

/* Goal Distribution - 2 columns */
.distribution-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .distribution-grid { grid-template-columns: 1fr; }
}

.distribution-team h4 {
    margin-bottom: 0.75rem;
}

.distribution-team.home h4 { color: var(--up-text); }
.distribution-team.away h4 { color: var(--down-text); }

.distribution-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dist-label {
    width: 50px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.dist-bar-container {
    flex: 1;
    height: 20px;
    background: var(--surface-3);
    border-radius: 4px;
    overflow: hidden;
}

.dist-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.distribution-team.home .dist-bar {
    background: var(--up-text);
}

.distribution-team.away .dist-bar {
    background: var(--down);
}

.dist-value {
    width: 50px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: right;
}

/* Content Styles */
/* Prose h2 outside the bridge's containers: the headline signature (#29). */
.bac-content h2 {
    font-family: var(--headline);
    font-weight: var(--headline-weight, 500);
    font-size: var(--tools-h2-size);
    letter-spacing: var(--section-title-tracking);
    line-height: var(--section-title-leading);
    color: var(--text);
    margin: 2rem 0 1rem;
}

.bac-content h2:first-child {
    margin-top: 0;
}

.bac-content p,
.bac-content ul {
    max-width: var(--tools-measure);
}

/* The article and FAQ columns themselves read at the measure, whether or
   not the athlete-kit change (#224) caps the left column. */
.poisson-calculator > .left-column > :is(.bac-content, .bac-faq-section) {
    max-width: var(--tools-measure);
}

.bac-content p {
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 1rem;
}

.bac-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.bac-content ul li {
    color: var(--text-muted);
    padding: 0.5rem 0 0.5rem 1.5rem;
    position: relative;
    line-height: 1.6;
}

.bac-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.875rem;
    width: 6px;
    height: 6px;
    background: var(--up-text);
    border-radius: 50%;
}

.formula-box {
    background: var(--surface-3);
    padding: 1.25rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-family: var(--font-mono);
    color: var(--text);
    font-size: 0.9375rem;
    overflow-x: auto;
}

/* Related Tools Widget */
.bac-related-widget {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.bac-related-title {
    font-family: var(--font-sans);
    font-weight: var(--tools-ui-heading-weight);
    font-size: var(--tools-ui-title-size);
    color: var(--text);
    margin-bottom: 1rem;
}

.bac-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.bac-related-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.bac-related-card:hover {
    background: var(--surface-3);
    border-color: rgba(var(--pf-primary-rgb), 0.3);
    transform: translateY(-2px);
}

.bac-related-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: rgba(var(--pf-primary-rgb), 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--up-text);
}

.bac-related-content h3 {
    color: var(--text);
    margin-bottom: 0.25rem;
}

.bac-related-content p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

/* FAQ Section */
.bac-faq-section {
    margin-top: 2.5rem;
}

.bac-faq-title {
    font-family: var(--headline);
    font-weight: var(--headline-weight, 500);
    font-size: var(--tools-h2-size);
    letter-spacing: var(--section-title-tracking);
    line-height: var(--section-title-leading);
    color: var(--text);
    margin-bottom: 1rem;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile touch targets */
@media (max-width: 768px) {
    .team-name-input,
    .xg-input,
    .bb-btn {
        min-height: 48px;
        font-size: 16px;
    }
}
