/* Golfer Card - shared popup styles.
 * Inherits the active tournament theme via --t-* variables already set by
 * index.html / pool-standings-public.html / picks-distribution.html / etc.
 * Falls back to sensible dark defaults if no theme is loaded.
 */
:root {
    --gc-bg:          #f4ecd8;                   /* eggshell card background */
    --gc-panel:       #e2dccb;                   /* warm gray-eggshell tile */
    --gc-panel-2:     #d6d1c1;                   /* deeper warm gray for round/SG tiles */
    --gc-border:      rgba(60, 55, 40, 0.18);    /* warm gray border */
    --gc-accent:      #15432f;                   /* dark green accent (titles/labels) */
    --gc-text:        #1a1a1a;                   /* near-black body text */
    --gc-text-dim:    #5b6770;                   /* slate gray for muted labels */
    --gc-rule:        #c9c2af;                   /* warm gray hairline */
}

.gc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 16px;
    backdrop-filter: blur(4px);
    animation: gc-fade-in 0.18s ease-out;
}

.gc-overlay.gc-hidden {
    display: none;
}

@keyframes gc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.gc-card {
    width: 100%;
    max-width: 640px;
    background: var(--gc-bg);
    border: 1px solid var(--gc-border);
    border-radius: 12px;
    color: var(--gc-text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
    animation: gc-card-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes gc-card-in {
    from { transform: translateY(12px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* Loading state */
.gc-card.gc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px;
    gap: 14px;
    color: var(--gc-text-dim);
}
.gc-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gc-border);
    border-top-color: var(--gc-accent);
    border-radius: 50%;
    animation: gc-spin 0.8s linear infinite;
}
@keyframes gc-spin { to { transform: rotate(360deg); } }

/* Header */
.gc-header {
    position: relative;
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #ebe2c9 0%, #f4ecd8 100%);
    border-bottom: 1px solid var(--gc-border);
}
.gc-headshot {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--gc-panel);
    border: 2px solid var(--gc-accent);
    flex-shrink: 0;
}
.gc-header-text {
    flex: 1;
    min-width: 0;
}
.gc-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--gc-text);
    line-height: 1.2;
    margin-bottom: 4px;
}
.gc-subline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gc-text-dim);
}
/* Second subline: inline personal facts (Born • DOB • Turned Pro • College) */
.gc-subline-meta {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
    letter-spacing: 0.1px;
    display: block;
}
.gc-flag {
    width: 22px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}
.gc-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--gc-text-dim);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.gc-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--gc-text);
}

/* Stats row (below header) */
.gc-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--gc-border);
}
/* Main rank row carries 6 tiles
   (World / SG Rank / Wins / Earnings / Majors / Cuts). */
.gc-stats-row.gc-rank-row {
    grid-template-columns: repeat(6, 1fr);
}
.gc-stat {
    padding: 14px 8px;
    text-align: center;
    background: var(--gc-bg);
}
.gc-stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--gc-accent);
}
/* Career Earnings can run long ("$87.4M" fits, but longer strings shouldn't
 * push the tile wider). Allow the earnings tile to shrink its font slightly. */
.gc-rank-row .gc-stat-val {
    font-size: 18px;
}
.gc-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gc-text-dim);
    margin-top: 4px;
}
/* Optional third line under the label. Used by Career Wins / Career Earnings
   to surface a per-tour breakdown ("5 PGA Tour · 3 LIV"). Kept small + dim so
   it complements the headline without competing with it; long lines are
   clipped to prevent the tile from widening, since the rank row is on a
   fixed 6-column grid. The full breakdown lives in the tile's `title`
   tooltip on hover. */
.gc-stat-sub {
    font-size: 10px;
    color: var(--gc-text-dim);
    margin-top: 2px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Sections */
.gc-section {
    padding: 16px 20px;
    border-top: 1px solid var(--gc-border);
}
.gc-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gc-accent);
    margin-bottom: 10px;
}

/* Bio-first paint: results skeleton shown while the career-stats fan-out is
   still loading. Replaced by the real tables on the repaint. */
.gc-skel-rows { display: flex; flex-direction: column; gap: 8px; }
.gc-skel-row {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg,
        var(--gc-border) 0%,
        rgba(255, 255, 255, 0.10) 50%,
        var(--gc-border) 100%);
    background-size: 200% 100%;
    animation: gc-skel-shimmer 1.2s ease-in-out infinite;
    opacity: 0.6;
}
.gc-skel-row:nth-child(2) { width: 92%; }
.gc-skel-row:nth-child(3) { width: 96%; }
.gc-skel-row:nth-child(4) { width: 88%; }
@keyframes gc-skel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Live panel */
.gc-live-panel {
    background: rgba(var(--t-secondary-r, 230), var(--t-secondary-g, 199), var(--t-secondary-b, 87), 0.04);
}
.gc-live-panel .gc-stats-row {
    grid-template-columns: repeat(2, 1fr);
    background: transparent;
    gap: 8px;
}
.gc-live-panel .gc-stat { background: var(--gc-panel); border-radius: 6px; }

.gc-rounds {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.gc-round-box {
    background: var(--gc-panel);
    border-radius: 6px;
    padding: 10px 4px;
    text-align: center;
}
.gc-round-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gc-text-dim);
    margin-bottom: 4px;
}
.gc-round-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--gc-text);
    font-family: "Courier New", monospace;
}

/* Clickable round boxes + Total tile - open the Scorecard overlay on that
 * specific round (Total = last round played). Applied only when the
 * Scorecard module is loaded on the host page AND the round has scores. */
.gc-sc-trigger {
    cursor: pointer;
    transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.gc-sc-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.gc-live-panel .gc-stat.gc-sc-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* SG grid */
.gc-sg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}
/* Forced 4-up variant (used by the SG - Last 12 Months row so OTT/APP/ATG/PUTT
 * always sit in one row, not 3+1 on narrower viewports). */
.gc-sg-grid.gc-sg-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.gc-sg-item {
    background: var(--gc-panel);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}
.gc-sg-label {
    font-size: 11px;
    color: var(--gc-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.gc-sg-val {
    font-size: 16px;
    font-weight: 700;
    font-family: "Courier New", monospace;
    color: var(--gc-text);
}
.gc-sg-val.gc-pos { color: #15803d; }
.gc-sg-val.gc-neg { color: #b91c1c; }
.gc-sg-sub {
    font-size: 10px;
    color: var(--gc-text-dim);
    margin-top: 2px;
    font-family: "Courier New", monospace;
}

/* Results tables */
.gc-results {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.gc-results th {
    text-align: left;
    padding: 6px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--gc-text-dim);
    border-bottom: 1px solid var(--gc-border);
    font-weight: 600;
}
.gc-results td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--gc-border);
    color: var(--gc-text);
}
.gc-results tr:last-child td {
    border-bottom: none;
}
.gc-results td.gc-win {
    color: #8a6d1f;
    font-weight: 700;
}
.gc-results tr.gc-win-row td {
    background: rgba(212, 175, 55, 0.10);
}
.gc-results tr.gc-muted td {
    color: var(--gc-text-dim);
    font-style: italic;
}

/* Position-tier coloring inside the Pos cell.
 * Wraps the position value in a span so background "boxes" hug the value
 * rather than filling the entire cell. */
.gc-pos-cell { white-space: nowrap; text-align: center; }
.gc-results th:nth-child(3) { text-align: center; }
.gc-pos-tier {
    display: inline-block;
    min-width: 28px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    line-height: 1.2;
}
.gc-pos-mc {
    color: #dc2626;
    font-weight: 700;
    font-style: normal;
}
.gc-pos-wd {
    color: #6b7280;
    font-weight: 600;
    font-style: normal;
}
.gc-pos-win {
    display: inline-block;
    min-width: 28px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.2;
    background: #d4af37;
    color: #1a1a1a;
    font-weight: 800;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}
.gc-pos-top5 {
    background: #16a34a;
    color: #ffffff;
}
.gc-pos-top10 {
    background: #86efac;
    color: #14532d;
}
.gc-pos-top25 {
    background: #d8f0dc;
    color: #166534;
}
.gc-pos-norm {
    color: #1a1a1a;
}

/* ---- Rank/position tier badge for STAT tiles (live Position, Course Fit,
 *      Course History). Same color scale as the table .gc-pos-* classes
 *      but sized for the bigger stat-value text. ---- */
.gc-rank-badge {
    display: inline-block;
    min-width: 48px;
    text-align: center;
    padding: 4px 12px;
    border-radius: 6px;
    line-height: 1.15;
    font-weight: 700;
}
.gc-rank-mc {
    color: #dc2626;
    font-weight: 800;
}
.gc-rank-win {
    display: inline-block;
    min-width: 48px;
    text-align: center;
    padding: 4px 12px;
    border-radius: 6px;
    line-height: 1.15;
    background: #d4af37;
    color: #1a1a1a;
    font-weight: 800;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}
.gc-rank-top5 {
    background: #16a34a;
    color: #ffffff;
}
.gc-rank-top10 {
    background: #86efac;
    color: #14532d;
}
.gc-rank-top25 {
    background: #d8f0dc;
    color: #166534;
}
.gc-rank-norm {
    color: #1a1a1a;
}

/* Hover overrides - defend against host-page tr:hover styles
 * (pages like index.html apply backgrounds on row hover that would
 *  wash out our card). Keep text legible in all row states. */
.gc-card .gc-results tbody tr:hover td,
.gc-card .gc-results tr:hover td {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--gc-text) !important;
}
.gc-card .gc-results tbody tr.gc-win-row:hover td,
.gc-card .gc-results tr.gc-win-row:hover td {
    background: rgba(212, 175, 55, 0.18) !important;
    color: #8a6d1f !important;
}
.gc-card .gc-results tbody tr.gc-win-row:hover td.gc-win,
.gc-card .gc-results tr.gc-win-row:hover td.gc-win {
    color: #8a6d1f !important;
}
.gc-card .gc-results tbody tr.gc-muted:hover td,
.gc-card .gc-results tr.gc-muted:hover td {
    background: rgba(0, 0, 0, 0.03) !important;
    color: var(--gc-text-dim) !important;
}

/* Personal grid */
.gc-personal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 6px 16px;
}
.gc-personal-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed var(--gc-border);
    font-size: 13px;
}
.gc-personal-key {
    color: var(--gc-text-dim);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.3px;
}
.gc-personal-val {
    color: var(--gc-text);
    font-weight: 500;
}

.gc-empty {
    padding: 28px;
    text-align: center;
    color: var(--gc-text-dim);
    font-size: 14px;
}

/* Responsive */
@media (max-width: 520px) {
    .gc-overlay { padding: 0; }
    .gc-card { border-radius: 0; min-height: 100vh; max-width: 100%; }
    .gc-name { font-size: 18px; }
    .gc-headshot { width: 56px; height: 56px; }
    .gc-stats-row { grid-template-columns: repeat(2, 1fr); }
    /* Rank row has 5 tiles - 3-across on mobile wraps cleanly to 3+2 layout */
    .gc-stats-row.gc-rank-row { grid-template-columns: repeat(3, 1fr); }
    .gc-rank-row .gc-stat-val { font-size: 16px; }
    .gc-live-panel .gc-stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* Clickable golfer names */
[data-golfer-name] {
    cursor: pointer;
    transition: color 0.12s;
}
[data-golfer-name]:hover {
    color: var(--gc-accent);
    text-decoration: underline;
}
