/* Longer rationale for the comments in this file: architecture/tokens-css-rationale.md */
/* RYEWIRED - Shared Design Tokens + Base Rules Loaded by both app (css/app.css) and admin
   (admin/renderer/css/admin.css). */

@import url('../vendor/fonts/fonts.css');

:root {
  /* ── Source palette ── */
  --rw-brown:           #5C4033;
  --rw-white:           #FDFDFD;
  --rw-red:             #B0202E;
  --rw-blue:            #2B579A;

  /* ── UI surfaces ── */
  --bg-base:            #0D0A08;
  --bg-panel:           #1E1612;
  --bg-raised:          #2D201A;
  --bg-elevated:        #3C2A22;
  --bg-input:           #1A120E;
  --bg-overlay:         rgba(10, 6, 4, 0.82);

  /* ── Elevation ── */
  --shadow-modal:       0 16px 48px rgba(0, 0, 0, 0.7);
  --shadow-popover:     0 8px 32px rgba(0, 0, 0, 0.6);

  /* ── Borders ── */
  --border:             #4D3224;
  --border-light:       #6B4634;
  --border-focus:       var(--rw-blue);

  /* ── Text ── */
  --text-primary:       #F5F0ED;
  --text-secondary:     #C9B0A0;
  --text-dim:           #A58471;
  --text-placeholder:   #9D765B;
  --text-on-accent:     #FFFFFF;
  --text-on-alert:      #FFFFFF;

  /* ── Accent / functional ── */
  --accent:             var(--rw-blue);
  --accent-text:        #6D97D6; /* accent-colored TEXT on dark panels, 4.5:1; --accent stays for fills and borders */
  --accent-hover:       #3568B8;
  --accent-dim:         #1A3A6A;
  --accent-subtle:      rgba(43, 87, 154, 0.15);
  --alert:              var(--rw-red);
  --alert-text:         #E6737E; /* alert-colored TEXT on dark panels, 4.5:1; --alert stays for fills and borders */
  --alert-hover:        #D02838;
  --alert-dim:          #6A1018;
  --alert-subtle:       rgba(176, 32, 46, 0.15);
  --warning:            #C87820;
  --warning-subtle:     rgba(200, 120, 32, 0.15);
  --success:            #2A7A4A;
  --success-text:       #3AA967; /* success-colored TEXT on dark panels, 4.5:1; --success stays for fills and borders */
  --success-subtle:     rgba(42, 122, 74, 0.15);
  /* Board-canvas selection outline - a dedicated token, deliberately separate from --warning even
     though selection used to reuse it: --warning is real warning UI. */
  --selection:          #ffffff;

  /* ── Board surface ── */
  --board-bg:           #EAE5E0;
  --board-hole:         #4A3E34;
  --board-hole-shadow:  #251E16;
  --board-stripe:       #F0EDE5;
  --board-ext-panel-bg: #1C1512; /* External Switches panel: slightly lighter than --bg-base (#0D0A08, the dark canvas), NOT the tan board — a separate off-board surface, not more board */
  --board-bus-r:        var(--rw-red);
  --board-bus-b:        var(--rw-blue);
  --board-bus-r-bg:     rgba(176, 32, 46, 0.07);
  --board-bus-b-bg:     rgba(43, 87, 154, 0.07);
  --board-label:        #716457;
  --board-hover:        rgba(43, 87, 154, 0.25);
  --board-selected:     rgba(200, 120, 32, 0.45);
  --board-wire-start:   rgba(200, 120, 32, 0.55);

  /* ── Instruments ── */
  --scope-bg:           #080C08;
  --scope-grid:         #101810;
  --scope-grid-center:  #1A2A1A;
  --scope-trace:        #4AE880;
  --scope-trace-glow:   rgba(74, 232, 128, 0.4);
  --spectrum-bar:       var(--rw-blue);

  /* ── Sim states ── */
  --sim-stopped:        var(--text-dim);
  --sim-running:        var(--success-text);
  --sim-running-pulse:  rgba(42, 122, 74, 0.3);

  /* ── Hover/emphasis variants ── */
  --success-hover:      #35904E; /* brighter than --success, for .tb-run's hover state */
  --alert-bright:       #ff5555; /* brighter than --alert, for a hover-only accent (admin's .row-del) */
  --code-text:          #b8d7a3; /* soft green used for JSON/code-like readouts (admin's editor + test-preview) */

  /* ── Typography ── */
  --font-ui:            'Inter', system-ui, sans-serif;
  --font-mono:          'IBM Plex Mono', 'Consolas', monospace;

  /* ── Sizing ── */
  --titlebar-h:         36px;
  --toolbar-h:          44px;
  --palette-w:          210px;
  --props-w:            250px;
  --statusbar-h:        26px;
  --radius-sm:          4px;
  --radius:             6px;
  --radius-lg:          10px;

  /* ── Transitions ── */
  --t-fast:             0.08s ease;
  --t-med:              0.15s ease;
}

/* Shared base rules Byte-identical (or identical apart from one value) in both app.css and
   admin.css before this consolidation. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font-family: var(--font-ui); cursor: pointer; }
input, select, textarea { font-family: var(--font-ui); }

/* Global scrollbar shape - each consumer may still override its own fixed track width/thumb radius
   for its own density, but the color/ track treatment is shared. */
::-webkit-scrollbar       { background: transparent; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  background-clip: padding-box;
  /* border-style/border-color set here so every consumer's own rule only ever needs to set
     border-width. */
  border-style: solid;
  border-color: transparent;
  transition: border-width 0.15s;
}

/* Shared field/input shape - the surface/border/radius/color/outline/ transition treatment every
   text input in both apps uses (search boxes, property fields, admin's .field). */
#palette-search, #comp-search, .prop-input, .field, .custom-select .cs-trigger {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  outline: none; transition: border-color var(--t-fast);
}

/* Shared panel-header bar shape. */
.panel-titlebar, .panel-header {
  display: flex; align-items: center;
  padding: 0 12px; height: 36px;
  border-bottom: 1px solid var(--border);
}
