/* Climate graph: header, twin-axis chart (precipitation bars, temperature line), table view, build form.
   Builds on the shared .explorer, .btn and .cx styles in styles.css. */
.climate-graph {
  --cg-rain: #2563a8; /* bars: 6.1:1 on the card */
  --cg-rain-text: #1d4f8a;
  --cg-temp: #c62828; /* line and hatch: 5.6:1 on the card */
  --cg-temp-text: #b71c1c;
  min-width: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .climate-graph {
    --cg-rain: #6cb2f5;
    --cg-rain-text: #8cc4f8;
    --cg-temp: #ff8a80;
    --cg-temp-text: #ff9e95;
  }
}
/* The same colours when the student picks the dark theme with the toggle (data-theme="dark"), also on a device that prefers light. */
:root[data-theme="dark"] .climate-graph {
  --cg-rain: #6cb2f5;
  --cg-rain-text: #8cc4f8;
  --cg-temp: #ff8a80;
  --cg-temp-text: #ff9e95;
}

/* Header. */
.cg-name { font-size: 1.15rem; overflow-wrap: anywhere; }
.cg-facts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin: 0 0 0.7rem; }
.cg-facts > div { min-width: 0; }
.cg-facts dt { overflow-wrap: anywhere; font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cg-facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* The announcement is also on screen: it is the readout of the last action (or of the problem with an entry). */
.cg-readout { margin: 0 0 0.8rem; min-height: 1.5em; padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--accent-soft); font-weight: 600; overflow-wrap: anywhere; }
.cg-readout.is-error { background: var(--bad-soft); border-left: 5px solid var(--bad); /* not colour alone: a bar and the words "Not added" */ }

.cg-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.cg-toggle { min-height: 44px; }
.cg-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Chart. */
.cg-chart-wrap { max-width: 420px; border-radius: 10px; }
.cg-grid { stroke: var(--grid); stroke-width: 1; }
.cg-zero { stroke: var(--axis); stroke-width: 1.5; }
/* The 100 mm line: above it the precipitation scale is reduced. Dashed and heavier, and the band above it is tinted: not colour alone. */
.cg-split { stroke: var(--axis); stroke-width: 1.5; stroke-dasharray: 5 3; }
.cg-band { fill: color-mix(in srgb, var(--cg-rain) 14%, var(--surface)); }
.cg-tick { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cg-tick--temp { fill: var(--cg-temp-text); }
.cg-tick--rain { fill: var(--cg-rain-text); }
.cg-month { font-size: 13px; font-weight: 700; fill: var(--muted); }
.cg-bar { fill: var(--cg-rain); }
.cg-arid { stroke: var(--cg-temp); stroke-width: 1; stroke-dasharray: 3 2; /* hatched and dashed: not colour alone */ }
.cg-hatch { stroke: var(--cg-temp); stroke-width: 1.5; }
.cg-line { fill: none; stroke: var(--cg-temp); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.cg-point { fill: var(--surface); stroke: var(--cg-temp); stroke-width: 2.5; }
@media (prefers-reduced-motion: no-preference) {
  .cg-bar.is-new, .cg-point.is-new { animation: cg-pop 0.2s ease-out; } /* only what was just entered */
}
@keyframes cg-pop { from { opacity: 0.3; } to { opacity: 1; } }

/* The key says the same as the colours: a block, a line with a ring, and a hatch. */
.cg-legend { list-style: none; margin: 0.5rem 0 0.3rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.cg-legend li[hidden] { display: none; }
.cg-legend li { display: flex; align-items: center; gap: 0.5rem; overflow-wrap: anywhere; }
.cg-legend li::before { content: ''; flex: none; box-sizing: border-box; width: 1.8rem; height: 0.9rem; }
.cg-legend .cg-legend-rain::before { width: 0.9rem; margin: 0 0.45rem; background: var(--cg-rain); }
.cg-legend .cg-legend-temp::before { height: 0; border-top: 3px solid var(--cg-temp); }
.cg-legend .cg-legend-band::before { border-top: 2px dashed var(--axis); background: color-mix(in srgb, var(--cg-rain) 14%, var(--surface)); height: 0.9rem; }
.cg-legend .cg-legend-arid::before { border: 1px dashed var(--cg-temp); background: repeating-linear-gradient(135deg, transparent 0 3px, var(--cg-temp) 3px 4px); }
.cg-scale { margin: 0 0 0.5rem; font-size: 0.88rem; }

/* Table view. */
.cg-table-box { margin-bottom: 0.6rem; overflow-x: auto; } /* a safety net for a very narrow screen or a wide font: the table scrolls here, not the page */
.cg-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.cg-table caption { text-align: left; font-weight: 700; padding-bottom: 0.3rem; overflow-wrap: anywhere; }
.cg-table th, .cg-table td { border: 1px solid var(--border); padding: 0.25rem 0.22rem; text-align: left; }
.cg-table thead th { background: var(--surface-2); font-size: 0.7rem; line-height: 1.25; vertical-align: bottom; }
.cg-table tbody th, .cg-table tfoot th { font-weight: 500; }
.cg-table .cg-num { text-align: right; }
.cg-table tr.is-arid td, .cg-table tr.is-arid th { background: color-mix(in srgb, var(--cg-temp) 12%, var(--surface)); font-weight: 700; }
.cg-table tfoot th, .cg-table tfoot td { background: var(--surface-2); font-weight: 600; }

/* Build form. */
.cg-form { margin: 0 0 0.8rem; }
.cg-fieldset { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: flex-end; margin: 0; padding: 0.6rem 0.8rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.cg-fieldset legend { padding: 0 0.3rem; font-weight: 700; }
.cg-field { display: flex; flex-direction: column; gap: 0.2rem; font-weight: 600; font-size: 0.9rem; min-width: 0; flex: 1 1 8rem; }
.cg-select, .cg-input { font: inherit; font-weight: 400; min-height: 44px; padding: 0.3rem 0.6rem; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; max-width: 100%; }
.cg-input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-soft); }
.cg-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1 1 100%; }
.cg-add, .cg-clear { min-height: 44px; }

/* Source line, under the graph or the table. */
.cg-source { margin: 0.6rem 0 0; font-size: 0.88rem; color: var(--muted); overflow-wrap: anywhere; }
.cg-source--illustrative { font-weight: 700; }
