/* Tab 3D (views/terrain3d.js). The terrain is the one bold element; the chrome around it is small, solid
   panel-colour cards in the corners. Cyan only marks the user's selection (picked box, focus). */
.t3 {
  position: absolute; inset: 0; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 62%, #12304f 0%, #0a1b31 48%, var(--bg, #071426) 100%);
  font-family: var(--font); color: var(--text);
}
.t3-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.t3-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.t3-head, .t3-tools, .t3-legend, .t3-tip, .t3-status, .t3-side {
  position: absolute; z-index: 2;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.t3-head { top: 12px; left: 12px; max-width: min(420px, calc(100% - 24px)); padding: 10px 14px; }
.t3-title { margin: 0; font-size: var(--fs-18); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.t3-layer { margin: 2px 0 0; font-size: var(--fs-12); color: var(--text-2); line-height: 1.4; }

.t3-tools { top: 12px; right: 12px; display: flex; align-items: center; gap: 8px; padding: 6px; }
.t3-reset { font-size: var(--fs-14); padding: 8px 14px; min-height: 38px; background: #1c4a70; border-color: var(--accent); }
.t3-reset:hover { background: #245a86; }
.t3-side-btn[hidden] { display: none; }
.t3-exag { display: flex; align-items: center; gap: 8px; font-size: var(--fs-12); color: var(--text-2); }
.t3-exag input { flex: 1; min-width: 90px; accent-color: var(--accent); }
.t3-exag-v { min-width: 3ch; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.t3-btn {
  font: inherit; font-size: var(--fs-12); font-weight: 600; color: var(--text);
  background: var(--panel-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; min-height: 32px; cursor: pointer;
}
.t3-btn:hover { background: #21426a; }
.t3-btn:focus-visible, .t3-exag input:focus-visible, .t3-tip-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.t3-btn-primary { width: 100%; margin-top: 10px; background: #1c4a70; }

.t3-legend { left: 12px; bottom: 12px; padding: 10px 14px; max-width: min(320px, calc(100% - 24px)); font-size: var(--fs-12); }
.t3-legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.t3-legend li { display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.t3-sw { flex: none; width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px #0004; }
.t3-legend-foot { margin: 8px 0 0; color: var(--muted); font-size: var(--fs-11); line-height: 1.4; }
.t3-ramp { height: 10px; border-radius: 3px; width: 200px; }
/* elevation legend (real DEM min/max, log scale) */
.t3-elev { width: 240px; max-width: 100%; }
.t3-elev-h { margin: 0 0 6px; color: var(--text-2); font-size: var(--fs-12); font-weight: 600; }
.t3-elev-ramp { width: 100%; height: 12px; box-shadow: inset 0 0 0 1px #0005; }
.t3-ticks { position: relative; height: 16px; margin-top: 3px; color: var(--text-2); font-size: var(--fs-11); font-variant-numeric: tabular-nums; }
.t3-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.t3-ticks span::before { content: ""; position: absolute; left: 50%; top: -4px; width: 1px; height: 3px; background: var(--muted); }
.t3-ticks span.is-first { transform: none; } .t3-ticks span.is-first::before { left: 0; }
.t3-ticks span.is-last { transform: translateX(-100%); } .t3-ticks span.is-last::before { left: auto; right: 0; }
.t3-elev.is-compact { width: 100%; }
.t3-ovkey { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.t3-ovkey .t3-pinkey-h { margin-bottom: 6px; }

/* panel content (rendered into the host's shared right panel, or into .t3-side when there is none) */
.t3-side { top: 64px; right: 12px; width: 280px; max-height: calc(100% - 140px); overflow: auto; padding: 12px 14px; }
.t3-side[hidden] { display: none; }
.t3p { display: grid; gap: 12px; font-size: var(--fs-12); color: var(--text-2); line-height: 1.45; }
.t3p-h { margin: 0; }
.t3p p { margin: 0; }
.t3p-src { color: var(--muted); font-size: var(--fs-11); }
.t3p-k { margin: 0 0 6px !important; color: var(--text); font-weight: 600; }
.t3p-sec { display: grid; gap: 6px; }
.t3p-note { color: var(--muted); font-size: var(--fs-11); }
.t3p-reset { justify-self: start; }
.t3p-ov { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; }
.t3p-ov > summary { cursor: pointer; color: var(--text); font-weight: 600; padding: 2px 0; }
.t3p-ov > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.t3p-ov[open] { display: grid; gap: 8px; padding-bottom: 10px; }
.t3p-ovtitle { color: var(--muted); font-size: var(--fs-11); padding-left: 20px; }
.t3-tip-cls { display: flex; align-items: center; gap: 6px; margin-top: 4px !important; }
.t3-ramp-l { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-11); margin-top: 3px; }

.t3-hint {
  position: absolute; z-index: 1; left: 50%; top: 84px; transform: translateX(-50%);
  margin: 0; padding: 6px 12px; border-radius: 999px; background: #071426cc; color: var(--text-2);
  font-size: var(--fs-12); white-space: nowrap; pointer-events: none; transition: opacity .4s ease;
}
.t3-hint.t3-gone { opacity: 0; }

.t3-status { top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: min(440px, calc(100% - 32px)); padding: 14px 18px; font-size: var(--fs-14); line-height: 1.5; text-align: center; }
.t3-status[hidden] { display: none; }
.t3-status[data-kind="warn"] { top: auto; bottom: 64px; transform: translateX(-50%); border-color: var(--warn); }
.t3-status[data-kind="error"] { border-color: var(--border-strong); }
.t3.t3-off .t3-tools, .t3.t3-off .t3-legend, .t3.t3-off .t3-hint, .t3.t3-off .t3-side { display: none; }

.t3-tip { width: 270px; padding: 12px 14px; border-color: var(--accent); }
.t3-tip[hidden] { display: none; }
.t3-tip-main { margin: 0 24px 4px 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-14); font-weight: 600; line-height: 1.35; }
.t3-tip-sub { margin: 0; font-size: var(--fs-12); color: var(--text-2); }
.t3-tip-x {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.t3-tip-x:hover { color: var(--text); background: var(--panel-3); }
.t3-tip-sheet { left: 8px !important; right: 8px; bottom: 8px; top: auto !important; width: auto; }

/* ---- hotspot pins: a numbered dot on top of a thin 3D stem; colour = storm attribution */
.t3 { --pin-pre: var(--cls-5, var(--cls-seasonal)); --pin-storm: var(--cls-2, var(--cls-new)); --pin-unk: var(--muted); }
.t3-pins { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.t3-pins[hidden] { display: none; }
.t3-pin {
  position: absolute; left: 0; top: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; padding: 0;
  display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.t3-pin[hidden] { display: none; }
.t3-pin-head {
  width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pin); color: var(--bg); border: 2px solid var(--panel);
  font: 700 10px/1 var(--font); font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgb(0 0 0 / .45); transition: transform .15s ease;
}
.t3-pin.is-pre { --pin: var(--pin-pre); }
.t3-pin.is-storm { --pin: var(--pin-storm); }
.t3-pin.is-unk { --pin: var(--pin-unk); }
.t3-pin:hover .t3-pin-head, .t3-pin:focus-visible .t3-pin-head { transform: scale(1.25); }
.t3-pin:focus-visible { outline: none; }
.t3-pin:focus-visible .t3-pin-head { border-color: var(--accent); }
.t3-pin-dot { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--pin-unk); }
.t3-pin-dot.is-pre { background: var(--pin-pre); }
.t3-pin-dot.is-storm { background: var(--pin-storm); }

.t3-pin-label {
  position: absolute; left: 0; top: 0; z-index: 3; width: max-content; max-width: 240px; pointer-events: none;
  padding: 8px 11px; font-size: var(--fs-12); line-height: 1.4; color: var(--text-2);
  background: color-mix(in srgb, var(--panel) 96%, transparent); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.t3-pin-label[hidden] { display: none; }
.t3-pin-label p { margin: 0; }
.t3-pin-label-h { display: flex; align-items: center; gap: 6px; color: var(--text); font-weight: 600; font-size: var(--fs-14); margin-bottom: 2px !important; }
.t3-pin-label-f { margin-top: 4px !important; color: var(--muted); font-size: var(--fs-11); }

.t3-pins-tg { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.t3-pins-tg[hidden] { display: none; }
.t3-pins-tg input { margin: 0; width: 14px; height: 14px; accent-color: var(--muted); }
.t3-pins-tg input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.t3-pinkey { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.t3-legend > .t3-pinkey:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.t3-pinkey-h { margin: 0; color: var(--muted); font-size: var(--fs-11); }
.t3-pinkey-row { display: flex; align-items: center; gap: 8px; line-height: 1.3; }

@media (prefers-reduced-motion: reduce) { .t3-pin-head { transition: none; } .t3-pin:hover .t3-pin-head, .t3-pin:focus-visible .t3-pin-head { transform: none; } }

@media (max-width: 640px) {
  .t3-head { top: 8px; left: 8px; right: 8px; max-width: none; padding: 8px 12px; }
  .t3-title { font-size: var(--fs-14); }
  .t3-tools { top: auto; bottom: 8px; right: 8px; left: auto; padding: 4px; flex-direction: column; align-items: stretch; gap: 4px; max-width: 130px; }
  .t3-reset { font-size: var(--fs-12); padding: 7px 10px; }
  .t3-legend { left: 8px; bottom: 8px; max-width: calc(100% - 154px); padding: 8px 10px; font-size: var(--fs-11); }
  .t3-elev { width: 100%; min-width: 170px; }
  .t3-side { top: 72px; bottom: auto; left: 8px; right: 8px; width: auto; max-height: 55%; z-index: 4; }
  .t3-legend-foot, .t3-pinkey { display: none; }
  .t3-pin-label { max-width: min(240px, calc(100% - 16px)); }
  .t3-hint { top: 74px; bottom: auto; white-space: normal; width: calc(100% - 32px); text-align: center; border-radius: var(--radius); }
}
@media (prefers-reduced-motion: reduce) { .t3-hint { transition: none; } }
