/* Shur is laid out like a printed score: paper, ink, a five-line staff,
   and two thread colours borrowed from nakshi kantha: sindoor red for heat, nil indigo for rain. */
:root {
  --paper: #f3ecdf;
  --paper2: #eae1cf;
  --ink: #1d1a15;
  --ink2: #4d463b;
  --rule: rgba(29, 26, 21, 0.22);
  --red: #b42318;
  --red-wash: rgba(180, 35, 24, 0.08);
  --indigo: #2c3e8f;
  --indigo-wash: rgba(44, 62, 143, 0.08);
  --stitch: repeating-linear-gradient(90deg, var(--red) 0 12px, transparent 12px 21px);
  --serif: "Instrument Serif", Georgia, serif;
  --bn-serif: "Noto Serif Bengali", "Hind Siliguri", serif;
  --body: "IBM Plex Sans", "Hind Siliguri", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16140f; --paper2: #1f1c16; --ink: #efe7d6; --ink2: #bcb3a2;
    --rule: rgba(239, 231, 214, 0.2);
    --red: #ff8a75; --red-wash: rgba(255, 138, 117, 0.1);
    --indigo: #a3b4ff; --indigo-wash: rgba(163, 180, 255, 0.1);
  }
}
:lang(bn) { --body: "Hind Siliguri", "IBM Plex Sans", system-ui, sans-serif; }

* { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); color: var(--ink); background: var(--paper); line-height: 1.55; min-height: 100dvh; -webkit-tap-highlight-color: var(--red-wash); }
a { color: var(--indigo); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--red); }
button, a, summary, input { touch-action: manipulation; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -80px; background: var(--ink); color: var(--paper); padding: 10px 16px; z-index: 5; font-weight: 600; }
.skip:focus { top: 12px; }
:where(a, button, input, summary, [tabindex]):focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
main:focus { outline: none; }

/* ---------- masthead, like the title block of a score ---------- */
.mast { padding: 0 var(--gutter); max-width: 1480px; margin: 0 auto; }
.mast-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--ink);
}
.folio { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.folio [lang="bn"] { font-family: "Hind Siliguri", sans-serif; letter-spacing: 0; font-size: 14px; color: var(--red); text-transform: none; }
:lang(bn) .folio { text-transform: none; letter-spacing: 0.02em; font-family: var(--body); font-size: 13px; }
.sep { color: var(--rule); }
.lang, .sat-mode { display: inline-flex; gap: 2px; }
.lang button, .sat-mode button {
  font: inherit; font-size: 14px; color: var(--ink2); background: none; border: 0; cursor: pointer;
  padding: 6px 10px; min-height: 40px; border-bottom: 2px solid transparent;
}
.lang button:hover, .sat-mode button:hover { color: var(--ink); }
.lang button[aria-pressed="true"], .sat-mode button[aria-pressed="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--red); }

.mast-title { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(20px, 4vw, 64px); align-items: end; padding: clamp(28px, 5vw, 64px) 0 clamp(18px, 3vw, 30px); }
.glyph { margin: 0; font-family: var(--bn-serif); font-weight: 800; color: var(--red); font-size: clamp(110px, 19vw, 280px); line-height: 0.82; letter-spacing: -0.02em; }
.mast h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 5.4vw, 84px); line-height: 1; letter-spacing: -0.015em; max-width: 15ch; }
:lang(bn) .mast h1 { font-family: var(--bn-serif); font-weight: 500; line-height: 1.2; letter-spacing: 0; max-width: 18ch; font-size: clamp(34px, 4.4vw, 66px); }
.mast-sub { margin: 18px 0 0; max-width: 58ch; font-size: clamp(16px, 1.4vw, 18px); color: var(--ink2); }
.mast-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 26px; margin: 26px 0 0; }
.cta {
  display: inline-flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 24px 0 18px;
  background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 600; font-size: 17px; border-radius: 999px;
}
.cta svg { fill: currentColor; }
.cta:hover { background: var(--red); color: var(--paper); }
.cta-text { color: var(--ink); font-weight: 600; padding: 10px 0; text-decoration: none; background: repeating-linear-gradient(90deg, var(--red) 0 8px, transparent 8px 13px) left bottom / 100% 2px no-repeat; }
.cta-text:hover { color: var(--red); }
.staff-sig { display: block; width: 100%; height: 56px; }
.staff-sig line { stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0.55; }

/* ---------- the score ---------- */
main {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  grid-template-areas: "controls stage side" "how how how";
  max-width: 1480px; margin: 8px auto 0; padding: 0 var(--gutter);
  background: var(--stitch) left top / 100% 2px no-repeat;
  background-origin: content-box;
}
.controls { grid-area: controls; }
.stage { grid-area: stage; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
.side { grid-area: side; }
.how { grid-area: how; }
main > section { min-width: 0; }
.core { padding: 28px clamp(16px, 2vw, 28px) 32px; height: 100%; }
.controls .core { padding-left: 0; }
.side .core { padding-right: 0; }
@media (max-width: 1180px) {
  main { grid-template-columns: 280px minmax(0, 1fr); grid-template-areas: "controls stage" "side side" "how how"; }
  .stage { border-right: 0; }
  .side { border-top: 1px solid var(--rule); }
  .side .core { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; padding-left: 0; }
  .side h2:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .side .sat { grid-column: 2; grid-row: 2; }
}
@media (max-width: 760px) {
  .mast-title { grid-template-columns: 1fr; gap: 6px; }
  .glyph { font-size: 120px; margin-bottom: 18px; }
  main { grid-template-columns: 1fr; grid-template-areas: "stage" "controls" "side" "how"; }
  .stage { border: 0; }
  .controls, .side { border-top: 1px solid var(--rule); }
  .core, .controls .core, .side .core { padding: 24px 0; }
  .side .core { display: block; }
  .chart .axis text { font-size: 30px; }
}

h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.1; margin: 0 0 16px; }
:lang(bn) h2 { font-family: var(--bn-serif); font-weight: 500; font-size: 24px; }
h3, legend { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink2); margin: 18px 0 10px; padding: 0; }
:lang(bn) h3, :lang(bn) legend { font-family: var(--body); letter-spacing: 0.02em; font-size: 14px; text-transform: none; font-weight: 600; }

/* ---------- controls ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 24px; min-width: 0; }
legend { margin-top: 0; }
.chips { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); }
.chip, .track {
  font: inherit; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--rule);
  text-align: left; cursor: pointer; min-height: 46px; padding: 8px; display: flex; align-items: center; gap: 10px; min-width: 0;
}
.chip:nth-child(odd) { border-right: 1px solid var(--rule); }
.chip .n { font-family: var(--mono); font-size: 12px; color: var(--red); width: 14px; }
.chip:hover, .track:hover { background: var(--red-wash); }
.chip[aria-pressed="true"], .track[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip[aria-pressed="true"] .n { color: var(--paper); }
.tracks { display: grid; border-top: 1px solid var(--rule); }
.track { flex-direction: column; align-items: flex-start; gap: 0; padding: 10px; }
.track b { font-weight: 600; }
.track small { font-size: 13px; opacity: 0.8; }
.row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.row input[type="range"] { flex: 1; accent-color: var(--red); min-height: 32px; }
.row output { min-width: 34px; text-align: right; font-family: var(--mono); font-size: 14px; color: var(--ink2); }
.check { gap: 10px; cursor: pointer; min-height: 40px; }
.check input { accent-color: var(--red); width: 20px; height: 20px; margin: 0; }

/* ---------- stage ---------- */
.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl, .play { display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.ctl { width: 48px; height: 48px; background: none; color: var(--ink); border: 1px solid var(--ink); }
.ctl:hover { background: var(--ink); color: var(--paper); }
.play { width: 76px; height: 76px; background: var(--ink); color: var(--paper); border: 0; }
.play:hover, .play[data-playing="true"] { background: var(--red); }
.ctl svg, .play svg { width: 22px; height: 22px; fill: currentColor; }
.play svg { width: 30px; height: 30px; }
.play .i-pause { display: none; }
.play[data-playing="true"] .i-pause { display: block; }
.play[data-playing="true"] .i-play { display: none; }
.story-btn {
  margin-left: auto; font: inherit; font-weight: 600; color: var(--ink); background: none; border: 1px solid var(--ink);
  border-radius: 999px; padding: 10px 20px; cursor: pointer; min-height: 46px;
}
.story-btn:hover { background: var(--ink); color: var(--paper); }
.ctl:active, .play:active, .story-btn:active, .cta:active, .chip:active, .track:active { transform: scale(0.97); }

.readout { margin: 26px 0 6px; }
.when { font-family: var(--serif); font-weight: 400; font-size: clamp(52px, 7vw, 96px); line-height: 0.95; margin: 0 0 18px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
:lang(bn) .when { font-family: var(--bn-serif); font-weight: 500; letter-spacing: 0; line-height: 1.1; font-size: clamp(44px, 5.5vw, 76px); }
.vals { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.val { margin: 0; padding: 2px 0 2px 14px; display: grid; gap: 2px; min-width: 0; border-left: 3px solid; }
.val.heat { border-color: var(--red); }
.val.rain { border-color: var(--indigo); }
.val .k { font-family: var(--mono); font-size: 12px; color: var(--ink2); letter-spacing: 0.1em; text-transform: uppercase; }
:lang(bn) .val .k { font-family: var(--body); letter-spacing: 0; font-size: 14px; text-transform: none; }
.val .v { font-family: var(--mono); font-size: clamp(26px, 3vw, 34px); font-weight: 500; line-height: 1.15; overflow-wrap: anywhere; }
:lang(bn) .val .v { font-family: var(--body); font-weight: 600; }
.val.heat .v { color: var(--red); }
.val.rain .v { color: var(--indigo); }
.val .sub { font-size: 14px; color: var(--ink2); min-height: 1.4em; }
.flags { min-height: 30px; margin: 14px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.04em; padding: 3px 10px; border: 1px solid; border-radius: 2px; }
:lang(bn) .flag { font-family: var(--body); font-size: 13px; }
.flag.hot, .flag.extreme { color: var(--red); background: var(--red-wash); }
.flag.wet { color: var(--indigo); background: var(--indigo-wash); }

.chart-fig { margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--ink); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--rule); stroke-dasharray: 2 4; }
.chart .staff line { stroke: var(--ink); stroke-width: 1; opacity: 0.32; }
.chart .axis text { fill: var(--ink2); font-size: 17px; font-family: var(--mono); }
.chart .bar { fill: var(--indigo); opacity: 0.5; }
.chart .bar.wet { opacity: 1; }
.chart .tline { fill: none; stroke: var(--red); stroke-width: 2.25; stroke-linejoin: round; }
.chart .tline.slur { stroke: var(--ink); stroke-width: 1; opacity: 0.45; }
.chart .head { fill: var(--ink); transform-box: fill-box; transform-origin: center; transform: rotate(-22deg); }
.chart .head.hot { fill: var(--red); }
.chart .trend { stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 8 6; opacity: 0.8; }
.chart .cursor { stroke: var(--red); stroke-width: 1.5; }
.chart .dot { fill: var(--red); stroke: var(--paper); stroke-width: 2.5; transform-box: fill-box; transform-origin: center; transform: rotate(-22deg); }
figcaption { font-size: 14px; color: var(--ink2); margin-top: 10px; }
.status { font-size: 14px; color: var(--ink2); min-height: 1.4em; margin: 10px 0 0; }
.status.err { color: var(--red); }
.status button { font: inherit; margin-left: 8px; background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: 6px 16px; cursor: pointer; min-height: 36px; }

.story-box { margin-top: 22px; padding: 18px 0 0; background: var(--stitch) left top / 100% 2px no-repeat; }
.story-box h3 { margin: 0 0 8px; color: var(--red); }
.story-box p { margin: 0; font-size: 18px; line-height: 1.65; max-width: 68ch; }

/* ---------- side ---------- */
.facts { list-style: none; padding: 0; margin: 0 0 28px; border-top: 1px solid var(--ink); }
.facts li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.facts .big { display: block; font-family: var(--serif); font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
:lang(bn) .facts .big { font-family: var(--bn-serif); font-weight: 500; font-size: 26px; }
.facts .big.heat { color: var(--red); }
.facts .big.rain { color: var(--indigo); }
.facts .lbl { font-size: 14px; color: var(--ink2); }
.sat-frame { position: relative; overflow: hidden; background: var(--paper2); aspect-ratio: 480 / 620; border: 1px solid var(--ink); box-shadow: 0 0 0 6px var(--paper), 0 0 0 7px var(--rule); margin: 7px; }
.sat-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pin { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px #fff; }
.sat-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 22px; color: var(--ink2); margin: 0; font-size: 14px; }
.sat-mode { margin-top: 14px; }
.sat-cap { font-size: 13px; color: var(--ink2); margin: 6px 0 0; }

/* ---------- how ---------- */
.how { background: var(--stitch) left top / 100% 2px no-repeat; }
.how .core { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 40px; align-items: start; padding: 36px 0 40px; }
.how h2 { grid-column: 1 / -1; font-size: clamp(34px, 3.4vw, 46px); margin-bottom: 20px; }
.how h3 { margin-top: 0; }
.how .core > div { min-width: 0; }
@media (max-width: 760px) { .how .core { grid-template-columns: 1fr; } .how .core > div + div { margin-top: 24px; } }
.legend, .keys { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.legend li { display: flex; gap: 12px; align-items: center; }
.sw { width: 14px; height: 10px; border-radius: 50%; flex: none; transform: rotate(-22deg); }
.sw.heat { background: var(--red); }
.sw.rain { background: var(--indigo); border-radius: 1px; width: 4px; height: 16px; transform: none; }
.sw.thunder { background: var(--ink); }
.sw.bell { background: none; border: 2px solid var(--red); }
kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--ink); border-bottom-width: 2px; border-radius: 3px; padding: 1px 7px; background: var(--paper); }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸"; margin-right: 10px; color: var(--red); }
details[open] summary::before { content: "▾"; }
details table { width: 100%; border-collapse: collapse; font-size: 14px; font-family: var(--mono); }
:lang(bn) details table { font-family: var(--body); }
details th, details td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--rule); }
details thead th { position: sticky; top: 0; background: var(--paper); border-bottom-color: var(--ink); }
#table { max-height: 320px; overflow: auto; overscroll-behavior: contain; }
#csv { font: inherit; font-weight: 600; background: none; color: var(--ink); border: 1px solid var(--ink); border-radius: 999px; padding: 8px 18px; cursor: pointer; min-height: 44px; }
#csv:hover { background: var(--ink); color: var(--paper); }

.foot { max-width: 1480px; margin: 0 auto; padding: 18px var(--gutter) calc(36px + env(safe-area-inset-bottom)); color: var(--ink2); font-size: 14px; background: var(--stitch) left top / 100% 2px no-repeat; background-origin: content-box; }
.foot p { margin: 4px 0; }
.noscript { margin: 0 var(--gutter) 12px; padding: 12px 16px; border: 1px solid var(--red); color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .chip, .track, .story-btn, .lang button, .sat-mode button, .ctl, .play, .cta, .cta-text, #csv {
    transition: background-color 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
  }
  .glyph { animation: ink 1.2s var(--ease) both; }
  @keyframes ink { from { opacity: 0; transform: translateY(14px); } }
}
@media print { .transport, .lang, .sat-mode, #csv, .skip { display: none; } }
