/* ============================================================
   Cricket Manager — Main Stylesheet
   Visual refresh: cricket-themed greens, polished cards,
   better typography, enhanced tables, section styling.
   Built on Pico CSS v2.
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
    /* Cricket greens */
    --cm-green-900: #0d2818;
    --cm-green-800: #1a472a;
    --cm-green-700: #1b4332;
    --cm-green-600: #2d6a4f;
    --cm-green-500: #40916c;
    --cm-green-400: #52b788;
    --cm-green-100: #d8f3dc;
    --cm-green-50: #f0fdf4;

    /* Accent / warm tones */
    --cm-gold: #f59e0b;
    --cm-gold-light: #fef3c7;
    --cm-amber: #e65100;

    /* Neutrals */
    --cm-gray-50: #f9fafb;
    --cm-gray-100: #f3f4f6;
    --cm-gray-200: #e5e7eb;
    --cm-gray-300: #d1d5db;
    --cm-gray-400: #9ca3af;
    --cm-gray-500: #6b7280;
    --cm-gray-600: #4b5563;
    --cm-gray-700: #374151;
    --cm-gray-800: #1f2937;
    --cm-gray-900: #111827;

    /* Results */
    --cm-win: #16a34a;
    --cm-win-bg: rgba(22, 163, 74, 0.08);
    --cm-loss: #dc2626;
    --cm-loss-bg: rgba(220, 38, 38, 0.06);
    --cm-draw-bg: rgba(128, 128, 128, 0.06);

    /* Functional */
    --cm-radius: 8px;
    --cm-radius-sm: 4px;
    --cm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --cm-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --cm-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* ── Pico Overrides ── */
:root {
    --pico-primary: #1a472a;
    --pico-primary-hover: #2d6a4f;
    --pico-border-radius: 8px;
}

/* ── Base Typography ── */
body {
    background-color: var(--cm-gray-50);
}

h1 {
    color: var(--cm-green-800);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

h2 {
    color: var(--cm-green-800);
    font-weight: 700;
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--cm-green-100);
}

h3 {
    color: var(--cm-green-700);
    font-weight: 600;
    font-size: 1.15rem;
}

/* Navigation styles are in nav.css */

/* ── Stat Cards (article elements in .grid) ── */
.stat-big {
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    margin: 0;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.grid > article {
    border-radius: var(--cm-radius);
    border: 1px solid var(--cm-gray-200);
    box-shadow: var(--cm-shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    position: relative;
}

.grid > article::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--cm-green-600), var(--cm-green-400));
}

.grid > article:hover {
    box-shadow: var(--cm-shadow-md);
    transform: translateY(-1px);
}

.grid > article header {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cm-gray-500);
    padding: 0.7rem 1rem 0.2rem;
}

.grid > article footer {
    font-size: 0.8rem;
    color: var(--cm-gray-400);
    padding: 0.2rem 1rem 0.6rem;
    text-align: center;
}

/* Result colours */
.win { color: var(--cm-win); }
.loss { color: var(--cm-loss); }

/* Match list row colouring */
tr.win { background-color: var(--cm-win-bg); }
tr.loss { background-color: var(--cm-loss-bg); }
tr.draw { background-color: var(--cm-draw-bg); }

/* Not out batters */
tr.not-out td { font-style: italic; }

/* Dismissal text */
.dismissal { font-size: 0.85em; color: var(--cm-gray-400); }

/* ── Tables ── */
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
}

table td, table th {
    padding: 0.6rem 0.9rem;
}

table thead th {
    background: var(--cm-green-50);
    color: var(--cm-green-800);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--cm-green-100);
    position: sticky;
    top: 0;
}

table tbody tr {
    border-bottom: 1px solid var(--cm-gray-100);
    transition: background 0.1s;
}

table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.015);
}

table tbody tr:hover {
    background-color: rgba(45, 106, 79, 0.06);
}

table tfoot td {
    font-weight: 600;
    border-top: 2px solid var(--cm-green-100);
    background: var(--cm-green-50);
}

figure {
    overflow-x: auto;
    border-radius: var(--cm-radius);
    border: 1px solid var(--cm-gray-200);
    box-shadow: var(--cm-shadow-sm);
    margin-bottom: 1.5rem;
}

figure > table {
    margin: 0;
}

/* ── Section Styling ── */
section {
    margin-bottom: 2.5rem;
}

section > p:first-of-type {
    color: var(--cm-gray-500);
    font-size: 0.92rem;
}

/* Details/Summary styling */
details {
    border: 1px solid var(--cm-gray-200);
    border-radius: var(--cm-radius);
    margin-bottom: 0.8rem;
    overflow: hidden;
}

details summary {
    padding: 0.8rem 1rem;
    background: var(--cm-gray-50);
    cursor: pointer;
    font-size: 0.92rem;
    transition: background 0.15s;
}

details summary:hover {
    background: var(--cm-green-50);
}

details[open] summary {
    border-bottom: 1px solid var(--cm-gray-200);
    background: var(--cm-green-50);
}

details > table,
details > figure {
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* ── Quality Tier Badges ── */
.tier {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tier-elite { background: linear-gradient(135deg, #7c3aed, #9b59b6); color: white; }
.tier-strong { background: linear-gradient(135deg, #16a34a, #22c55e); color: white; }
.tier-good { background: linear-gradient(135deg, #2563eb, #3b82f6); color: white; }
.tier-average { background: linear-gradient(135deg, #d97706, #f59e0b); color: #1a1a1a; }
.tier-developing { background: var(--cm-gray-200); color: var(--cm-gray-600); }

/* ── Award Cards ── */
.award-card {
    text-align: center;
    border-radius: var(--cm-radius);
}

.award-card header {
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cm-gray-500);
}

/* ── Rotation Fairness Badges ── */
.rotation-rating {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.rotation-good { background: linear-gradient(135deg, #16a34a, #22c55e); color: white; }
.rotation-fair { background: linear-gradient(135deg, #d97706, #f59e0b); color: #1a1a1a; }
.rotation-poor { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }

/* ── Position Matrix ── */
.position-used {
    background-color: rgba(45, 106, 79, 0.15);
    font-weight: 700;
    text-align: center;
    color: var(--cm-green-800);
}

figure table td:not(:first-child),
figure table th:not(:first-child) {
    text-align: center;
    min-width: 2rem;
}

/* ── Footer ── */
footer {
    margin-top: 2.5rem;
    padding: 1.2rem 0;
    text-align: center;
    color: var(--cm-gray-400);
    border-top: 1px solid var(--cm-gray-200);
    font-size: 0.85rem;
}

/* ── Team of the Season XI ── */
.team-sheet {
    max-width: 720px;
    margin: 0 auto;
    border: 2px solid var(--cm-green-600);
    border-radius: var(--cm-radius);
    overflow: hidden;
    box-shadow: var(--cm-shadow-md);
}

.xi-table {
    width: 100%;
    margin: 0;
}

.xi-table thead th {
    background: linear-gradient(135deg, var(--cm-green-800), var(--cm-green-600));
    color: white;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    padding: 0.7rem 0.8rem;
}

.xi-table tbody tr {
    border-bottom: 1px solid var(--cm-gray-100);
}

.xi-table tbody tr:last-child {
    border-bottom: none;
}

.xi-pos {
    width: 2.5rem;
    text-align: center;
    font-weight: 700;
    color: var(--cm-gray-400);
    font-size: 0.85rem;
}

.xi-name {
    white-space: nowrap;
}

.xi-name a {
    text-decoration: none;
    color: var(--cm-green-800);
    font-weight: 600;
}

.xi-name a:hover {
    color: var(--cm-green-600);
}

.xi-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    margin-left: 0.4rem;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.xi-badge-wk {
    background: linear-gradient(135deg, #ea580c, #f97316);
    color: white;
}

.xi-badge-ar {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: white;
}

.xi-role-label {
    font-size: 0.82rem;
    color: var(--cm-gray-400);
}

.xi-stat-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.8rem;
    font-size: 0.85em;
}

.xi-stat {
    white-space: nowrap;
}

.xi-rationale {
    font-size: 0.75em;
    color: var(--cm-gray-400);
    margin-top: 0.15rem;
}

.xi-row:nth-child(even) {
    background-color: var(--cm-green-50);
}

/* ── Competition Ladder ── */
tr.ladder-highlight {
    background-color: rgba(45, 106, 79, 0.12) !important;
    font-weight: 600;
}

tr.ladder-highlight td {
    color: var(--cm-green-800);
}

.ladder-secondary {
    color: var(--cm-gray-400);
    font-size: 0.82em;
}

/* ── Back Links ── */
section + p > a,
p:last-child > a[href*="/team/"] {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 500;
    color: var(--cm-green-600);
}

/* ── HR Dividers ── */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--cm-green-100), var(--cm-gray-200), var(--cm-green-100), transparent);
    margin: 2rem 0;
}

/* ============================================================
   ABOUT PAGE STYLES
   ============================================================ */

.about-hero {
    background: linear-gradient(135deg, var(--cm-green-800) 0%, var(--cm-green-600) 40%, #1e5f8a 100%);
    color: white;
    padding: 3rem 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.about-hero::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: 2.8rem;
    margin: 0 0 0.5rem 0;
    color: white;
    letter-spacing: -0.02em;
    font-weight: 800;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin: 0 0 0.75rem 0;
    opacity: 0.95;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.hero-tagline {
    font-size: 1rem;
    opacity: 0.8;
    margin: 0;
}

.about-section {
    margin-bottom: 3rem;
}

.section-heading {
    font-size: 1.6rem;
    color: var(--cm-green-800);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 3px solid var(--cm-green-600);
    display: inline-block;
}

.about-intro-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.about-intro-text p {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.about-intro-visual {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.philosophy-card {
    padding: 1rem 1.2rem;
    border-left: 4px solid var(--cm-green-600);
    border-radius: 0 var(--cm-radius) var(--cm-radius) 0;
    background: var(--cm-green-50);
    margin: 0;
}

.philosophy-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.philosophy-card h3 {
    font-size: 1rem;
    margin: 0 0 0.3rem 0;
    color: var(--cm-green-800);
}

.philosophy-card p {
    font-size: 0.9rem;
    margin: 0;
    color: var(--cm-gray-500);
}

/* Ball-by-ball section */
.bbb-section {
    background: linear-gradient(180deg, var(--cm-green-50) 0%, rgba(255,255,255,0) 100%);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--cm-green-100);
}

.bbb-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin: 1.5rem 0;
}

.bbb-card {
    padding: 1.2rem;
    margin: 0;
    border-radius: var(--cm-radius);
}

.bbb-card header {
    font-weight: bold;
    font-size: 0.95rem;
}

.bbb-card p {
    font-size: 0.95rem;
    line-height: 1.6;
}

.bbb-wrong {
    border-left: 4px solid var(--cm-loss);
}

.bbb-wrong .bbb-verdict {
    color: var(--cm-loss);
}

.bbb-right {
    border-left: 4px solid var(--cm-win);
}

.bbb-right .bbb-verdict {
    color: var(--cm-win);
}

.bbb-arrow {
    font-size: 2rem;
    color: var(--cm-green-600);
    text-align: center;
}

.bbb-footnote {
    text-align: center;
    font-size: 0.9rem;
    color: var(--cm-gray-400);
    margin-top: 1rem;
}

/* How it works flow */
.flow-steps {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
    margin: 2rem 0;
}

.flow-step {
    flex: 1;
    min-width: 180px;
    max-width: 240px;
    text-align: center;
    padding: 1rem;
}

.flow-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cm-green-800), var(--cm-green-600));
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 0.8rem;
    box-shadow: 0 2px 8px rgba(26, 71, 42, 0.3);
}

.flow-step h3 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    color: var(--cm-green-800);
}

.flow-step p {
    font-size: 0.88rem;
    color: var(--cm-gray-500);
    margin: 0;
    line-height: 1.5;
}

.flow-connector {
    width: 2.5rem;
    height: 2px;
    background: linear-gradient(90deg, var(--cm-green-600), var(--cm-green-400));
    margin-top: 2.4rem;
    flex-shrink: 0;
}

/* Feature grid (about page) */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
}

.feature-card {
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    border-radius: var(--cm-radius);
}

.feature-card:hover {
    box-shadow: var(--cm-shadow-md);
    transform: translateY(-2px);
}

.feature-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.2rem;
    color: white;
}

.feature-header h3 {
    margin: 0;
    font-size: 1rem;
    color: white;
}

.feature-icon {
    font-size: 1.3rem;
}

.feature-batting { background: linear-gradient(135deg, var(--cm-green-800), var(--cm-green-600)); }
.feature-bowling { background: linear-gradient(135deg, #b71c1c, #e53935); }
.feature-fielding { background: linear-gradient(135deg, #4a148c, #7b1fa2); }
.feature-compliance { background: linear-gradient(135deg, #e65100, #ff8f00); }
.feature-season { background: linear-gradient(135deg, #0d47a1, #1565c0); }
.feature-fairness { background: linear-gradient(135deg, #004d40, #00897b); }

.feature-card ul {
    padding: 0.8rem 1.2rem 0.8rem 2rem;
    margin: 0;
}

.feature-card li {
    font-size: 0.88rem;
    padding: 0.15rem 0;
    color: var(--cm-gray-500);
}

/* Compliance section */
.compliance-section {
    background: linear-gradient(180deg, rgba(230, 81, 0, 0.04) 0%, rgba(230, 81, 0, 0.02) 100%);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(230, 81, 0, 0.1);
}

.compliance-rules-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.compliance-rule-card {
    margin: 0;
    padding: 1.2rem;
    border-left: 4px solid #e65100;
    border-radius: 0 var(--cm-radius) var(--cm-radius) 0;
}

.compliance-rule-card h4 {
    margin: 0 0 0.5rem 0;
    color: #e65100;
    font-size: 1rem;
}

.compliance-rule-card p {
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.6;
    color: var(--cm-gray-500);
}

/* Data source card */
.data-source-card {
    margin: 0;
    padding: 1.5rem 2rem;
    border-left: 4px solid var(--cm-green-600);
    border-radius: 0 var(--cm-radius) var(--cm-radius) 0;
}

.data-source-content h3 {
    margin: 0 0 0.8rem 0;
    color: var(--cm-green-800);
}

.data-source-content p {
    line-height: 1.7;
}

.data-source-content code {
    font-size: 0.85em;
}

.data-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.data-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.data-stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--cm-green-600);
    line-height: 1;
    letter-spacing: -0.02em;
}

.data-stat-label {
    font-size: 0.78rem;
    color: var(--cm-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.2rem;
}

/* Tech grid */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.tech-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--cm-green-50);
    border-radius: var(--cm-radius);
    text-align: center;
    border: 1px solid var(--cm-green-100);
}

.tech-item strong {
    font-size: 0.95rem;
    color: var(--cm-green-800);
}

.tech-item span {
    font-size: 0.8rem;
    color: var(--cm-gray-400);
    margin-top: 0.2rem;
}

/* Closing section */
.about-closing {
    text-align: center;
}

.about-closing blockquote {
    border-left: 4px solid var(--cm-green-600);
    max-width: 700px;
    margin: 0 auto 1rem auto;
    font-style: italic;
    padding: 1rem 1.5rem;
    background: var(--cm-green-50);
    border-radius: 0 var(--cm-radius) var(--cm-radius) 0;
}

.about-closing blockquote p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.7;
}

.closing-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--cm-green-600);
}

/* ============================================================
   SEASON SUMMARY — Section-specific styles
   ============================================================ */

/* Season summary anchor nav */
.no-print > nav ul,
section + nav ul {
    flex-wrap: wrap;
}

/* ── Compliance Report Styling ── */
.compliance-pass {
    color: var(--cm-win);
    font-weight: 600;
}

.compliance-fail {
    color: var(--cm-loss);
    font-weight: 600;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 992px) {
    .about-intro-grid {
        grid-template-columns: 1fr;
    }
    .about-intro-visual {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .philosophy-card {
        flex: 1;
        min-width: 200px;
    }
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .bbb-container {
        grid-template-columns: 1fr;
    }
    .bbb-arrow {
        transform: rotate(90deg);
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.6rem;
    }
    h2 {
        font-size: 1.25rem;
    }
    .hero-title {
        font-size: 2rem;
    }
    .hero-subtitle {
        font-size: 1.05rem;
    }
    .feature-grid {
        grid-template-columns: 1fr;
    }
    .compliance-rules-grid {
        grid-template-columns: 1fr;
    }
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .flow-connector {
        display: none;
    }
    .flow-steps {
        flex-direction: column;
        align-items: center;
    }
    .data-stats {
        justify-content: center;
    }
    .stat-big {
        font-size: 1.6rem;
    }
    table td, table th {
        padding: 0.35rem 0.45rem;
        font-size: 0.82rem;
    }
}

/* ============================================================
   PRINT STYLES — Season Summary
   ============================================================ */
@media print {
    nav, .no-print, footer, .team-subnav {
        display: none !important;
    }
    body {
        font-size: 10pt;
        background: white;
    }
    main.container {
        max-width: 100%;
        padding: 0;
    }
    section {
        page-break-inside: avoid;
    }
    h2 {
        page-break-after: avoid;
        border-bottom-color: #ccc;
    }
    table {
        page-break-inside: auto;
    }
    tr {
        page-break-inside: avoid;
    }
    article {
        border: 1px solid #ccc;
        padding: 0.5rem;
        box-shadow: none;
    }
    .grid > article::before {
        display: none;
    }
    .stat-big {
        font-size: 1.4rem;
    }
    a {
        color: inherit;
        text-decoration: none;
    }
    hr {
        page-break-after: always;
        border: none;
        background: none;
    }
    figure {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    details {
        border: 1px solid #ccc;
    }
}
