:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --ink: #1a1a1a;
    --muted: #4b5563;
    --accent: #1f6feb;
    --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    background: #111827;
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.site-header .brand { color: white; font-weight: 600; font-size: 18px; display: flex; align-items: center; }
.site-header .brand-logo { height: 52px; width: auto; }
.site-header nav { display: flex; gap: 16px; margin-left: auto; }
.site-header nav a { color: #cbd5e1; }
.site-header nav a:hover { color: white; text-decoration: none; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.site-footer { text-align: center; color: var(--muted); padding: 24px; }

.muted { color: var(--muted); }
.back { display: inline-block; margin-bottom: 8px; }

.stats { display: flex; gap: 16px; margin: 16px 0 24px; flex-wrap: wrap; }
.stat {
    background: var(--card);
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    min-width: 120px;
}
.stat strong { font-size: 28px; display: block; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.card-list { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.card a { display: block; }
.card strong { display: block; margin-bottom: 4px; }

.team-grid { list-style: none; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.team-grid li { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data th { background: #111827; color: white; font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.data tr:last-child td { border-bottom: none; }

.filters {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.filters fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.filters legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.filters .checkbox { display: inline-flex; gap: 6px; align-items: center; margin-right: 12px; }
.filters button { background: var(--accent); color: white; border: none; border-radius: 6px; padding: 8px 16px; cursor: pointer; }
.filters button:hover { background: #155bcc; }

.ics-link { display: inline-block; margin: 8px 0; padding: 6px 12px; border: 1px solid var(--accent); border-radius: 6px; }

.affiliate-link { margin: 8px 0; }
.affiliate-link a { display: inline-block; padding: 6px 12px; border: 1px solid #10b981; border-radius: 6px; color: #10b981; text-decoration: none; font-size: 14px; }
.affiliate-link a:hover { background: #10b981; color: white; }

/* This Week's Bobbleheads widget */
.this-week { margin: 24px 0; }
.this-week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.this-week-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; transition: transform 0.1s, box-shadow 0.1s; }
.this-week-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); text-decoration: none; }
.this-week-card img { width: 100%; height: 120px; object-fit: contain; background: var(--bg); border-radius: 4px; }
.this-week-placeholder { width: 100%; height: 120px; background: var(--bg); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 48px; }
.this-week-info { padding: 8px 4px 4px; display: flex; flex-direction: column; gap: 2px; }
.this-week-info strong { font-size: 0.9em; line-height: 1.2; }
.this-week-info span { font-size: 0.8em; }
.this-week-date { color: var(--accent); font-weight: 600; font-size: 0.85em; }

/* Next Bobblehead countdown card (team page) */
.next-bobble-card { display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, #1f6feb 0%, #1e3a5f 100%); color: white; padding: 16px; border-radius: 12px; margin: 16px 0; }
.next-bobble-img { width: 100px; height: 100px; object-fit: contain; background: rgba(255,255,255,0.1); border-radius: 8px; flex-shrink: 0; }
.next-bobble-placeholder { display: flex; align-items: center; justify-content: center; font-size: 56px; }
.next-bobble-info { display: flex; flex-direction: column; gap: 4px; }
.next-bobble-label { font-size: 0.75em; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.next-bobble-name { font-size: 1.2em; line-height: 1.2; }
.next-bobble-meta { font-size: 0.9em; opacity: 0.9; }
.next-bobble-countdown { font-size: 1em; font-weight: 600; color: #fbbf24; margin-top: 4px; }

#map { background: #ddd; }

.muted { color: var(--muted); }
.back { display: inline-block; margin-bottom: 8px; }

.stats { display: flex; gap: 16px; margin: 16px 0 24px; flex-wrap: wrap; }
.stat { background: var(--card); padding: 16px 20px; border-radius: 8px; border: 1px solid var(--border); min-width: 120px; }
.stat strong { font-size: 28px; display: block; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.card-list { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.card a { display: block; }
.card strong { display: block; margin-bottom: 4px; }

.team-grid { list-style: none; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.team-grid li { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); margin-top: 12px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data th { background: #111827; color: white; font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.data tr:last-child td { border-bottom: none; }

.filters { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.filters fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.filters legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.filters .checkbox { display: inline-flex; gap: 6px; align-items: center; margin-right: 12px; }
.filters button { background: var(--accent); color: white; border: none; border-radius: 6px; padding: 8px 16px; cursor: pointer; }
.filters button:hover { background: #155bcc; }

.ics-link { display: inline-block; margin: 8px 0; padding: 6px 12px; border: 1px solid var(--accent); border-radius: 6px; }

/* Hero */
.hero {
    background: linear-gradient(135deg, #1e3a5f 0%, #111827 100%);
    color: white;
    padding: 48px 32px;
    border-radius: 12px;
    margin-bottom: 32px;
    text-align: center;
}
.hero h1 { font-size: 2.5rem; margin: 0 0 12px; font-weight: 700; }
.hero-subtitle { font-size: 1.1rem; color: #94a3b8; margin: 0 0 24px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; margin-bottom: 32px; }
.hero .stats { justify-content: center; }
.hero .stat { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.hero .stat strong { color: white; }
.hero .stat span { color: #94a3b8; }

/* Buttons */
.btn { display: inline-block; padding: 12px 24px; border-radius: 8px; font-weight: 600; text-decoration: none; transition: transform 0.1s; }
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #155bcc; color: white; }
.btn-secondary { background: transparent; color: white; border: 2px solid rgba(255,255,255,0.4); }
.btn-secondary:hover { border-color: white; color: white; }

/* Badge */
.badge { display: inline-block; background: #fbbf24; color: #1a1a1a; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; }

/* Share links */
.share-links { display: flex; gap: 12px; align-items: center; margin: 12px 0; }
.share-links a { background: var(--card); border: 1px solid var(--border); padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.share-links a:hover { background: var(--accent); color: white; border-color: var(--accent); text-decoration: none; }

/* Mobile bottom nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #111827;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    justify-content: space-around;
    z-index: 1000;
    border-top: 1px solid #374151;
}
.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #94a3b8;
    font-size: 10px;
    text-decoration: none;
    gap: 2px;
}
.mobile-nav a span { font-size: 10px; }
.mobile-nav a:hover, .mobile-nav a:active { color: white; }

@media (max-width: 720px) {
    .container { padding: 0 12px; }
    .site-header { padding: 10px 12px; gap: 12px; flex-wrap: wrap; }
    .site-header nav { margin-left: 0; gap: 12px; flex-wrap: wrap; }
    table.data { display: block; overflow-x: auto; }
    .filters { flex-direction: column; align-items: stretch; }
    .stats { flex-direction: column; }
    .mobile-nav { display: flex; }
    .site-header nav { display: none; }
    body { padding-bottom: 70px; }
    .site-footer { padding-bottom: 80px; }
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Level groups (MiLB expandable sections) */
details.level-group { margin-bottom: 12px; }
details.level-group summary { cursor: pointer; padding: 8px 0; font-size: 1.1em; }
details.level-group summary:hover { color: var(--accent); }

/* Blog article body images */
.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
    display: block;
}
.article-body img.img-small  { max-width: 240px; }
.article-body img.img-medium { max-width: 480px; }
.article-body img.img-large  { max-width: 800px; }
.article-body img.img-full   { max-width: 100%; }
.article-body img.img-left   { float: left;  margin: 8px 16px 8px 0; }
.article-body img.img-right  { float: right; margin: 8px 0 8px 16px; }
.article-body img.img-center { margin-left: auto; margin-right: auto; }

/* New section headings clear any floated image from the previous section */
.article-body h2, .article-body h3, .article-body h4 { clear: both; }

/* Exception: when an image (or an image-only paragraph) is the IMMEDIATE
   predecessor of a heading, that heading does NOT clear. This lets you
   place a floated image right before a heading so the heading and image
   align at the top, with body text wrapping below. */
.article-body img.img-left + h2,
.article-body img.img-right + h2,
.article-body img.img-left + h3,
.article-body img.img-right + h3,
.article-body img.img-left + h4,
.article-body img.img-right + h4,
.article-body p:has(> img.img-left:only-child) + h2,
.article-body p:has(> img.img-right:only-child) + h2,
.article-body p:has(> img.img-left:only-child) + h3,
.article-body p:has(> img.img-right:only-child) + h3,
.article-body p:has(> img.img-left:only-child) + h4,
.article-body p:has(> img.img-right:only-child) + h4 {
    clear: none;
}

/* Use a horizontal rule (--- in Markdown) to force-clear a float when needed */
.article-body hr { clear: both; }

/* Image row — wrap multiple images in <div class="img-row">...</div> for a
   side-by-side layout that wraps on narrow screens. Each child img sizes
   itself within the available space. */
.article-body .img-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    align-items: flex-start;
}
.article-body .img-row img {
    flex: 1 1 0;
    margin: 0;
    min-width: 0;
}
.article-body .img-row .img-caption {
    flex: 1 1 0;
    text-align: center;
    font-size: 0.85em;
    color: var(--muted);
}

@media (max-width: 720px) {
    .article-body img.img-left, .article-body img.img-right { float: none; margin: 16px 0; }
    .article-body .img-row { flex-direction: column; }
    .article-body .img-row img { flex: 1 1 auto; }
}
