/* CAISO leaderboard page styles. Shared chrome (palette, header, agents menu,
   fab) is in ../chrome.css. This holds the feed, cards, table, stats, the
   chart controls, the deck.gl map legend, the rank form, and the footer. */

/* Card attribution */
.card-by { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.card-by .mention { font-size: 11.5px; }

/* Feed of cards */
.feed { max-width: 940px; margin: 26px auto; padding: 0 18px; display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 24px 22px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
/* The page h1 sits in the first card and matches the h2 look, the page
   title in the chrome header is decoration, this is the SEO heading */
.card-head h1 { margin: 0; font-size: 18px; font-weight: 700; }
.card .sub { margin: 12px 0 16px; font-size: 13px; color: var(--muted); }
/* The answer block, the lead sentence an answer engine quotes, the
   supporting facts as bullets per Indresh's review */
.card .answer { margin: 16px 0 8px; font-size: 14px; color: var(--ink); line-height: 1.55; }
.card .answer-points { margin: 0 0 8px; padding-left: 20px; font-size: 14px; color: var(--ink); line-height: 1.55; }
.card .answer-points li { margin: 4px 0; }
.card .downloads { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.card .xlink { margin: 14px 0 0; padding: 9px 14px; font-size: 12.5px; line-height: 1.4; color: var(--ink); background: rgba(20,148,138,0.07); border: 1px solid rgba(20,148,138,0.22); border-left: 3px solid #14948a; border-radius: 10px; }
.card .xlink a { color: #0f7268; font-weight: 700; text-decoration: none; border-bottom: 1px solid rgba(15,114,104,0.4); }
.card .xlink a:hover { border-bottom-color: #0f7268; }
/* Full ranking stays compact on screen, crawlers read all rows regardless */
.lb-table-scroll { max-height: 480px; overflow-y: auto; }
.card .qa { margin: 14px 0 4px; font-size: 14px; font-weight: 700; color: var(--ink); }

/* Leaderboard table */
.lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
.lb-table td { padding: 9px 10px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.lb-table tr:first-child td { font-weight: 700; }
.lb-table td.masked { color: var(--muted); font-size: 12px; }

.date-range { font-size: 15px; color: var(--ink); margin: 2px 0 16px; }
.date-range strong { color: var(--coral-dark); }
/* Metric cards in an aligned grid, lead card accented, the how lives behind an i */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { position: relative; padding: 14px 15px; background: rgba(232,131,74,0.04); border: 1px solid var(--line); border-radius: 13px; }
.stat .t { display: flex; align-items: flex-start; gap: 5px; min-height: 30px; line-height: 1.3; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; color: var(--muted); }
.stat .n { font-size: 38px; font-weight: 800; color: var(--coral-dark); line-height: 1.05; margin: 6px 0 3px; letter-spacing: -0.01em; }
.stat .n .u { font-size: 0.46em; font-weight: 700; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.stat .s { font-size: 12px; color: var(--muted); line-height: 1.35; }
.info { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; flex: none; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font: italic 700 10px/1 Georgia, serif; cursor: help; }
.info:hover, .info:focus { background: var(--coral); border-color: var(--coral); color: #fff; outline: none; }
.info .pop { display: none; position: absolute; top: 22px; left: -6px; width: min(232px, 76vw); background: #2a2018; color: #fff; padding: 10px 12px; border-radius: 9px; font-size: 12px; font-weight: 400; font-style: normal; line-height: 1.45; text-transform: none; letter-spacing: 0; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }
.info:hover .pop, .info:focus .pop { display: block; }

/* Caveat box, scopes the headline number so merchant is not read as total revenue */
.caveat { margin: 18px 0 4px; padding: 12px 16px; background: rgba(0,0,0,0.025); border: 1px solid var(--line); border-left: 3px solid var(--coral); border-radius: 10px; }
.caveat-tag { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; color: var(--coral-dark); margin-bottom: 6px; }
.caveat ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink); line-height: 1.5; }
.caveat li { margin: 4px 0; }

/* Uniform radio controls above the table and treemap */
.radio-row { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0 0 12px; }
.radios { display: inline-flex; align-items: center; gap: 16px; margin: 0 0 12px; }
.radio-row .radios { margin: 0; }
.radios label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.radios input { width: 15px; height: 15px; accent-color: var(--coral); cursor: pointer; }

/* Contact line under the rank form */
.contact { margin: 16px 0 0; font-size: 13px; color: var(--muted); }

/* deck.gl map colorbar, no native legend so this overlays the canvas */
.map-legend { position: absolute; top: 14px; right: 14px; z-index: 5; background: rgba(255,255,255,0.92); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.10); }
.map-legend-title { font-size: 11px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.map-legend-row { display: flex; gap: 7px; }
.map-legend-bar { width: 13px; height: 96px; border-radius: 3px; }
.map-legend-ticks { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); }
.map-size-row { display: flex; gap: 12px; align-items: flex-end; margin-top: 6px; }
.map-size-item { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--muted); }
/* BESS-fleet visibility toggle, hides the 3D columns to read nearby assets */
.map-bess-toggle { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11px; color: var(--ink); cursor: pointer; }
.map-bess-toggle input { width: 13px; height: 13px; accent-color: var(--coral); cursor: pointer; }
.map-rail { position: absolute; left: 14px; bottom: 14px; z-index: 5; background: rgba(255,255,255,0.92); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; box-shadow: 0 2px 8px rgba(0,0,0,0.10); color: var(--ink); }
.map-rail-cov { font-size: 10px; color: var(--muted); }

/* Legend collapse toggle, top-right chevron shrinks the legend to a pill */
.map-legend { padding-right: 26px; }
.map-legend-toggle { position: absolute; top: 6px; right: 6px; border: 0; background: none; cursor: pointer; font-size: 17px; line-height: 1; color: var(--muted); padding: 0 2px; white-space: nowrap; }
.map-legend-toggle:hover { color: var(--ink); }
.map-legend.collapsed { padding: 5px 9px; }
.map-legend.collapsed .map-legend-body { display: none; }
.map-legend.collapsed .map-legend-toggle { position: static; font-size: 12px; font-weight: 700; color: var(--ink); }

/* Map fullscreen button, bottom-right so it clears legend and rail */
.map-fs-btn { position: absolute; bottom: 14px; right: 14px; z-index: 6; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,0.92); color: var(--ink); font-size: 15px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.10); }
.map-fs-btn:hover { background: #fff; }
#map-card:fullscreen { width: 100vw; height: 100vh; background: #fff; }
#map-card:fullscreen #deck-zone-map { border-radius: 0; }
#map-card:-webkit-full-screen { width: 100vw; height: 100vh; background: #fff; }

/* Drop-pin nearest-sites panel, top-left so it clears the legend and rail */
.map-nearest { position: absolute; top: 14px; left: 14px; z-index: 6; width: 230px; max-height: calc(100% - 28px); overflow-y: auto; background: rgba(255,255,255,0.82); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 3px 12px rgba(0,0,0,0.14); }
.map-nearest-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink); }
.map-nearest-x { border: 0; background: none; font-size: 17px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px; }
.map-nearest-x:hover { color: var(--ink); }
.map-nearest-empty { padding: 11px; font-size: 12px; color: var(--muted); }
/* Section labels inside the drop-pin panel */
.mn-bins-h, .mn-top5-h { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 9px 11px 4px; }
/* Count-per-yield-bin rows */
.mn-bins { padding: 0 0 4px; }
.mn-bin { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 4px 11px; }
.mn-bin-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.mn-bin-unit { font-size: 11px; font-weight: 400; color: var(--muted); }
.mn-bin-dark .mn-bin-label { font-weight: 500; color: var(--muted); }
.mn-bin-n { font-size: 13px; font-weight: 800; color: var(--coral-dark); flex: none; font-variant-numeric: tabular-nums; }
.mn-bin-dark .mn-bin-n { color: var(--muted); }
/* Top-ranked-nearby list */
.mn-top5 { list-style: none; margin: 0; padding: 0 0 6px; border-top: 1px solid var(--line); }
.mn-top5 li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 4px 11px; }
.mn-name { font-size: 12px; font-weight: 600; color: var(--ink); }
.mn-rank { font-weight: 800; color: var(--coral-dark); }
.mn-km { font-size: 11px; color: var(--muted); flex: none; }
/* Nearby generators and data centers, the per-click server slice */
.mn-assets { border-top: 1px solid var(--line); }
.mn-assets-h { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 9px 11px 4px; }
.mn-assets-note { padding: 2px 11px 8px; font-size: 11px; color: var(--muted); }
.mn-assets-err { color: var(--coral-dark); }
.mn-planned { display: flex; align-items: center; gap: 6px; padding: 2px 11px 7px; font-size: 11.5px; color: var(--ink); cursor: pointer; }
.mn-planned input { width: 13px; height: 13px; accent-color: var(--coral); cursor: pointer; }
.mn-assets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; padding: 0 9px 9px; }
.mn-asset { display: flex; align-items: center; gap: 5px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,0.6); cursor: pointer; font: inherit; text-align: left; }
.mn-asset:hover { background: #fff; }
.mn-asset-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mn-asset-label { font-size: 11px; color: var(--ink); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mn-asset-n { font-size: 11px; font-weight: 800; color: var(--coral-dark); flex: none; font-variant-numeric: tabular-nums; }
.mn-asset-off { opacity: 0.4; }

/* Rank lookup form */
.rank-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.rank-form input, .rank-form select { flex: 1; min-width: 180px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; color: var(--ink); }
input[list]::-webkit-calendar-picker-indicator { display: none; }
.rank-form button { background: var(--coral); color: #fff; border: none; border-radius: 9px; padding: 11px 20px; font: inherit; font-weight: 700; cursor: pointer; }
.rank-form button:hover { background: var(--coral-dark); }
.rank-result { margin-top: 14px; font-size: 15px; }
.hp { position: absolute; left: -9999px; }

.foot { max-width: 940px; margin: 30px auto 50px; padding: 0 18px; font-size: 12px; color: var(--muted); }
.foot .method { margin: 8px 0; font-size: 11px; line-height: 1.5; }

/* Wrapper gives height:100% a real value so responsive Plotly renders on mobile */
.chart-wrap { height: 400px; width: 100%; }
.chart-wrap.tall { height: 640px; }
.chart-wrap.xtall { height: 780px; }
.chart-wrap [id^="chart-"] { height: 100%; width: 100%; }

/* Table horizontal scroll on mobile instead of bleed-out */
.lb-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 600px) {
  /* Tighten feed */
  .feed { padding: 0 10px; gap: 14px; margin: 14px auto; }
  .card { padding: 14px 14px 16px; }
  .card-head h2 { font-size: 16px; }
  .card-head h1 { font-size: 16px; }
  /* Stats: tighter grid, smaller numbers on narrow screens */
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat .n { font-size: 30px; }
  /* Form: stack inputs vertically */
  .rank-form { flex-direction: column; }
  .rank-form input, .rank-form select, .rank-form button { width: 100%; min-width: unset; }
  /* Table: smaller font so it fits, scroll if still too wide */
  .lb-table { font-size: 12px; }
  .lb-table th, .lb-table td { padding: 6px 6px; }
}
