/* ===========================================================================
   WadisPro — interface theme
   One visual system for the header and the left panel: a single accent
   (verdigris) on a dark drafting ground, monospace for every number, quiet
   ghost buttons, colour reserved for meaning (active mode, destructive, alerts).

   Scoping: every rule is prefixed with #main-content so it wins over Tailwind
   utility classes (id > class) INCLUDING their hover/focus variants, without a
   single !important. State classes that JS toggles at runtime (bg-green-600 on
   an active connect button, border-blue-500 on the active tab…) are re-styled
   EXPLICITLY below — never removed, so the JS state machine keeps working.
   =========================================================================== */

:root {
  --wp-ground:  #0d1520;
  --wp-chrome:  #0f1723;
  --wp-well:    #0b131d;
  --wp-card:    #131e2b;
  --wp-line:    #24344a;
  --wp-line-2:  #31465f;
  --wp-ink:     #dce6f2;
  --wp-dim:     #8ba0b8;
  --wp-faint:   #5f7590;
  --wp-accent:  #4fd1b0;
  --wp-accent-deep: #1f6b5a;
  --wp-accent-edge: #2b8571;
  --wp-ochre:   #d9a24b;
  --wp-red:     #e0684f;
  --wp-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------------------------------------------------------------------------
   Chrome surfaces — header, sidebar, bottom panel share one ground
--------------------------------------------------------------------------- */
#main-content > header {
  height: 48px;
  background: var(--wp-chrome);
  border-color: var(--wp-line);
  box-shadow: none;
  padding: 0 12px;
}
#main-content > header .gap-3 { gap: 8px; }
#main-content aside.w-80 {
  background: var(--wp-chrome);
  border-color: var(--wp-line);
  box-shadow: none;
}
#main-content #bottom-panel {
  background: var(--wp-chrome);
  border-color: var(--wp-line);
}
#main-content #panel-toggle { background: var(--wp-chrome); border-color: var(--wp-line); }
#main-content #panel-toggle:hover { background: var(--wp-card); }

/* thin scrollbars in the six tab panes */
#main-content aside [id^="content-"] {
  scrollbar-width: thin;
  scrollbar-color: var(--wp-line-2) transparent;
  padding: 10px 12px;
}
#main-content aside [id^="content-"]::-webkit-scrollbar { width: 8px; }
#main-content aside [id^="content-"]::-webkit-scrollbar-thumb { background: var(--wp-line-2); border-radius: 4px; }

/* ---------------------------------------------------------------------------
   Header — brand block, buttons on one line, workspace chip
--------------------------------------------------------------------------- */
#main-content > header h1 { font-size: 13.5px; letter-spacing: -0.01em; }
#main-content > header h1 .text-\[10px\] { color: var(--wp-faint); }
#main-content > header h1 .text-\[9px\]  { color: #47596e; }
#main-content > header div.bg-blue-600 {
  background: var(--wp-accent-deep);
  padding: 6px;
  border-radius: 6px;
  box-shadow: none;
}
#main-content > header .text-xs { font-size: 10px; }
#main-content > header #connection-status {
  font-family: var(--wp-mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  padding: 1px 6px;
}
#main-content > header .w-px { background: var(--wp-line-2); }

#main-content > header button[class] {
  white-space: nowrap;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 5px;
}
#main-content > header button[class] svg { width: 14px; height: 14px; }

/* injected workspace chip — full name on hover via title, ellipsis in place */
#main-content #workspace-name-display {
  font-family: var(--wp-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--wp-accent);
  background: rgba(79, 209, 176, 0.07);
  border-color: rgba(79, 209, 176, 0.28);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------------
   Buttons — one quiet system.
   Excluded: fold headers, icon-only p-1.5 buttons (header cluster, name row),
   and the buttons INSIDE element-list rows (eye / delete keep their colours).
--------------------------------------------------------------------------- */
/* NB: the list ids are written as [id="…"] attributes, not #ids — an id inside
   :not() would inflate this rule's specificity above the explicit active-state
   rules further down, and the accent on an active tool would never show. */
#main-content > header button[class]:where(:not([class*="p-1.5"])),
#main-content aside button[class]:where(:not(.wp-fold-hd):not([class*="p-1.5"]):not(:is([id="channel-list"], [id="dam-list"], [id="dyke-list"], [id="culvert-list"], [id="flood-list"]) *)) {
  background: var(--wp-card);
  border: 1px solid var(--wp-line-2);
  color: var(--wp-ink);
  transition: background .12s, border-color .12s, color .12s;
}
#main-content > header button[class]:where(:not([class*="p-1.5"])):hover,
#main-content aside button[class]:where(:not(.wp-fold-hd):not([class*="p-1.5"]):not(:is([id="channel-list"], [id="dam-list"], [id="dyke-list"], [id="culvert-list"], [id="flood-list"]) *)):hover {
  background: #1c2a3a;
  border-color: #40587a;
  color: #ffffff;
}
#main-content aside button[class]:not(.wp-fold-hd):not([class*="p-1.5"]) { border-radius: 4px; }

/* keyboard focus, everywhere in the chrome */
#main-content aside :is(button, input, select, textarea):focus-visible,
#main-content > header button:focus-visible {
  outline: 2px solid var(--wp-accent);
  outline-offset: 1px;
}

/* Primary actions — the few that DO something, filled with the accent */
#main-content button[class][onclick="App.saveSession()"],
#main-content button[class][onclick^="App.autoSize"],
#main-content button[class][onclick="App.applySmoothing()"],
#main-content button[class][onclick^="App.addComment"],
#main-content button[class][onclick^="App.start"][onclick$="Draw()"],
#main-content #btn-compute-storage,
#main-content #flood-run-btn {
  background: var(--wp-accent-deep);
  border: 1px solid var(--wp-accent-edge);
  color: #eafff8;
  font-weight: 600;
}
#main-content button[class][onclick="App.saveSession()"]:hover,
#main-content button[class][onclick^="App.autoSize"]:hover,
#main-content button[class][onclick="App.applySmoothing()"]:hover,
#main-content button[class][onclick^="App.addComment"]:hover,
#main-content button[class][onclick^="App.start"][onclick$="Draw()"]:hover,
#main-content #btn-compute-storage:hover,
#main-content #flood-run-btn:hover {
  background: #268067;
  border-color: #35997d;
}

/* Active tool modes — the exact classes the JS toggles, re-coloured */
#main-content #btn-side-connect.bg-green-600,
#main-content #btn-end-connect.bg-cyan-600,
#main-content #btn-daylight.bg-green-700,
#main-content #btn-set-seed.bg-amber-600 {
  background: var(--wp-accent-deep);
  border-color: var(--wp-accent);
  color: #eafff8;
  box-shadow: inset 0 0 0 1px rgba(79, 209, 176, .35);
}
#main-content #btn-set-main.bg-green-900 {
  background: rgba(79, 209, 176, .12);
  border-color: var(--wp-accent);
  color: var(--wp-accent);
  font-weight: 700;
}

/* Flood source mode cards — active card keyed on the border class JS adds */
#main-content [id^="flood-src-"][class] { background: var(--wp-card); border-color: var(--wp-line-2); }
#main-content [id^="flood-src-"]:is(.border-blue-500, .border-cyan-500, .border-green-500, .border-orange-500),
#main-content #flood-boundary-btn.border-teal-500 {
  border-color: var(--wp-accent);
  background: rgba(79, 209, 176, .08);
}

/* ---------------------------------------------------------------------------
   Tabs — quiet, mono, accent underline on the active one
--------------------------------------------------------------------------- */
#main-content aside [id^="tab-"][class] {
  font-family: var(--wp-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--wp-faint);
  background: transparent;
  padding-top: 10px;
  padding-bottom: 9px;
  /* the generic button skin gives every aside button a 1px frame — a tab is
     an underline, not a box */
  border-width: 0 0 2px 0;
  border-style: solid;
  border-color: transparent;
  border-radius: 0;
}
#main-content aside [id^="tab-"][class]:hover { color: var(--wp-dim); }
#main-content aside [id^="tab-"].border-blue-500 {
  color: var(--wp-ink);
  border-color: var(--wp-accent);
  background: transparent;
}

/* ---------------------------------------------------------------------------
   Fields — recessed wells, mono numerals, accent focus
--------------------------------------------------------------------------- */
#main-content aside input[type="text"][class],
#main-content aside input[type="number"][class],
#main-content aside select[class],
#main-content aside textarea[class] {
  background: var(--wp-well);
  border-color: var(--wp-line-2);
  border-radius: 4px;
  color: var(--wp-ink);
}
#main-content aside input[type="number"][class],
#main-content aside select[class] {
  font-family: var(--wp-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
#main-content aside :is(input, select, textarea)[class]:focus {
  border-color: var(--wp-accent);
  box-shadow: 0 0 0 2px rgba(79, 209, 176, .15);
}
#main-content aside ::placeholder { color: #4a5f77; }
#main-content aside input[type="checkbox"],
#main-content aside input[type="range"] { accent-color: var(--wp-accent); }

/* field labels → drafting-plan micro caps */
#main-content aside label[class*="text-"] {
  font-family: var(--wp-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--wp-faint);
}
/* …but checkbox row labels keep their inline size */
#main-content aside label[class*="cursor-pointer"] { letter-spacing: .04em; }

/* section headings in the non-folded panels (dams, dykes, culverts, flood, settings)
   and the culvert sub-headings — a title with a hairline that runs to the edge */
#main-content aside :is(h3, label, div)[class*="uppercase"][class*="font-bold"] {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--wp-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--wp-faint);
}
#main-content aside :is(h3, label, div)[class*="uppercase"][class*="font-bold"]::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--wp-line);
}

/* small informational notes lose the alarm red */
#main-content aside #prop-manning-source { color: var(--wp-ochre); }

/* ---------------------------------------------------------------------------
   Collapsible sections (built by panel-folds.js)
--------------------------------------------------------------------------- */
.wp-fold { border-top: 1px solid var(--wp-line); }
.wp-fold-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 2px;
  background: none;
  border: 0;
  color: var(--wp-dim);
  font: inherit;
  cursor: pointer;
}
.wp-fold-hd:hover { color: var(--wp-ink); }
.wp-fold-hd:focus-visible { outline: 2px solid var(--wp-accent); outline-offset: -2px; border-radius: 2px; }
/* the chevron is DRAWN, not a glyph — Windows turns "▶" into a blue emoji */
.wp-fold-chev {
  flex: none;
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
.wp-fold.is-open .wp-fold-chev { transform: rotate(45deg); }
.wp-fold-name {
  flex: none;
  font-family: var(--wp-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.wp-fold.is-open .wp-fold-name { color: var(--wp-ink); }
.wp-fold-sum {
  margin-left: auto;
  font-family: var(--wp-mono);
  font-size: 10px;
  color: var(--wp-faint);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 62%;
  transition: opacity .12s;
}
.wp-fold.is-open .wp-fold-sum { opacity: 0; }
.wp-fold-body { padding: 2px 0 10px; }
.wp-fold:not(.is-open) > .wp-fold-body { display: none; }

/* folds sit flush like a table of contents */
#main-content #selected-props > .wp-fold + .wp-fold { margin-top: 0; }
/* the channel-list fold keeps its toolbar but drops the duplicated title */
.wp-fold[data-fold="channel-list"] .wp-fold-body h3 { display: none; }

/* ---------------------------------------------------------------------------
   Element list rows — same card language as the region cards
--------------------------------------------------------------------------- */
#main-content aside :is(.channel-item, .dam-item, .dyke-item, .culvert-item)[class] {
  background: var(--wp-card);
  border-color: var(--wp-line);
  border-left-width: 3px;
  border-left-color: transparent;
  border-radius: 4px;
}
#main-content aside :is(.channel-item, .dam-item, .dyke-item, .culvert-item)[class]:hover {
  background: #182534;
}
#main-content aside .channel-item.border-blue-500,
#main-content aside .dam-item.border-amber-500,
#main-content aside .dyke-item.border-emerald-500,
#main-content aside .culvert-item.border-cyan-500 {
  background: #12251f;
  border-color: var(--wp-accent-deep);
  border-left-color: var(--wp-accent);
}
#main-content aside #flood-list > div[class] { border-radius: 4px; }
#main-content aside #flood-list > div.border-blue-500 {
  background: #12251f;
  border-color: var(--wp-accent);
}

/* search box — a PILL, so it can never be mistaken for the name field */
#main-content aside #element-search-input[class] {
  background: var(--wp-well);
  border-color: var(--wp-line-2);
  border-radius: 999px;
}
#main-content aside #element-search-results[class] {
  background: var(--wp-card);
  border-color: var(--wp-line-2);
}

/* ---------------------------------------------------------------------------
   Slim bottom-panel header (applied by slimBottomPanelHeader)
--------------------------------------------------------------------------- */
#panel-toggle.wp-slim { height: 26px; padding-left: 12px; padding-right: 10px; }
#panel-toggle.wp-slim #panel-title { font-size: 11px; letter-spacing: .06em; }
#panel-toggle.wp-slim #panel-context-badge { font-size: 9.5px; padding: 0 5px; }
#panel-toggle.wp-slim #panel-hint { font-size: 9.5px; padding: 0 5px; }
#panel-toggle.wp-slim .flex.items-center.gap-4 { gap: 10px; }
#panel-toggle.wp-slim svg { width: 15px; height: 15px; }
@media (max-width: 1200px) { #panel-toggle.wp-slim #panel-hint { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .wp-fold-chev, .wp-fold-sum,
  #main-content aside button[class],
  #main-content > header button[class] { transition: none; }
}

/* ---------------------------------------------------------------------------
   Bottom panel — profile legend row + cross-section header
   Trace colours (WS cyan, EGL red, Yc, Yn, Jump…) are SEMANTIC: they match the
   plot lines, so they stay. Only the chrome around them joins the system.
--------------------------------------------------------------------------- */
#main-content #profile-legend {
  height: 30px;
  gap: 10px;
  background: var(--wp-chrome);
  border-color: var(--wp-line);
  font-family: var(--wp-mono);
}
#main-content #profile-legend label[class] {
  gap: 4px;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: .03em;
}
#main-content #profile-legend label[class]:hover { background: var(--wp-card); }
#main-content #profile-legend input[type="checkbox"] { width: 11px; height: 11px; }

/* legend buttons join the system; Compute is the primary action here */
#main-content #profile-legend button[class] {
  background: var(--wp-card);
  border: 1px solid var(--wp-line-2);
  color: var(--wp-ink);
  border-radius: 3px;
  padding: 2px 8px;
  font-family: var(--wp-mono);
  font-size: 10px;
  transition: background .12s, border-color .12s;
}
#main-content #profile-legend button[class]:hover { background: #1c2a3a; border-color: #40587a; }
#main-content #profile-legend #btn-compute-hydraulics {
  background: var(--wp-accent-deep);
  border-color: var(--wp-accent-edge);
  color: #eafff8;
  font-weight: 700;
}
#main-content #profile-legend #btn-compute-hydraulics:hover { background: #268067; }
/* stale-results warning state (JS toggles bg-orange-600 + animate-pulse) */
#main-content #profile-legend #btn-compute-hydraulics.bg-orange-600 {
  background: #8a5b1e;
  border-color: var(--wp-ochre);
  color: #ffe9c4;
}
/* the regime/freeboard badge keeps its severity palette; only the shape joins */
#main-content #profile-legend #wsp-regime-warning {
  border-radius: 3px;
  font-family: var(--wp-mono);
  font-size: 9.5px;
  letter-spacing: .02em;
  padding: 2px 7px;
}

/* splitters pick up the accent on hover */
#main-content #panel-splitter:hover { background: var(--wp-accent-deep); }

/* cross-section header strip */
#main-content #xsec-panel { background: var(--wp-chrome); border-color: var(--wp-line); }
#main-content #xsec-panel .bg-gray-750 { background: var(--wp-chrome); border-color: var(--wp-line); }
#main-content #xsec-panel input[type="number"][class] {
  background: var(--wp-well);
  border-color: var(--wp-line-2);
  border-radius: 3px;
  font-family: var(--wp-mono);
}
#main-content #xsec-panel input[type="range"] { accent-color: var(--wp-accent); }
#main-content #xsec-val { color: var(--wp-accent); }

/* A <select> in a flex row refuses to shrink below its longest option
   (min-width:auto), so the region assembly selector escaped the card. */
#main-content aside select[class] { min-width: 0; max-width: 100%; }
#main-content aside .wp-reditor .flex { min-width: 0; }

/* ---------------------------------------------------------------------------
   Name vs search — the two must never look alike.
   The element name reads as a TITLE; the pencil turns it into a field.
--------------------------------------------------------------------------- */
#main-content aside input.wp-name-ro[class] {
  background: transparent;
  border-color: transparent;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .01em;
  padding-left: 2px;
  cursor: default;
  text-overflow: ellipsis;
}
#main-content aside input.wp-name-editing[class] {
  background: var(--wp-well);
  border-color: var(--wp-accent);
  font-size: 13px;
  font-weight: 600;
}

#main-content aside #element-search-input[class]::placeholder { color: var(--wp-faint); }
#main-content aside #element-search-input[class]:focus {
  border-color: var(--wp-accent);
  box-shadow: none;
}

/* "Auto width" wrapped to two lines in its half-column and pushed the row
   into the DEPTH labels below. */
#main-content button[class][onclick^="App.autoSize"] { white-space: nowrap; }
