/* ═══════════════════════════════════════════════════════════════
   Terrain Carver — Theme Bridge
   Maps local CSS variables to shared --t-* tokens so that
   styles.css continues to work under all themes without changes.
   ═══════════════════════════════════════════════════════════════ */

/* ── Remap local vars to theme tokens ── */
[class*="theme-"] {
  --bg:           var(--t-bg-primary);
  --bg2:          var(--t-bg-secondary);
  --text:         var(--t-text);
  --text2:        var(--t-text-dim);
  --accent:       var(--t-accent);
  --accent2:      var(--t-accent);
  --border:       var(--t-border);
  --input-bg:     var(--t-input-bg);
  --input-border: var(--t-input-border);
  --section-bg:   var(--t-bg-secondary);
  --btn-bg:       var(--t-bg-tertiary);
  --btn-hover:    var(--t-hover-bg);
}

/* ── Layout: push the flex row below the fixed theme bar ── */
body { padding-top: var(--sb-topbar-h); box-sizing: border-box; }

/* ── Sidebar header: top flex item, naturally stays put while sidebar-body scrolls ── */
.sb-header { flex-shrink: 0; }

/* ── Section: add background on top of sb-section border/padding ── */
[class*="theme-"] .section {
  background: var(--t-bg-secondary);
  border-radius: var(--t-radius);
}

/* ── Field rows (label + input + unit, not sb-input-row) ── */
[class*="theme-"] .field label {
  font-size: var(--t-fs-label);
  color: var(--t-text-dim);
  font-weight: var(--t-label-weight, 400);
  text-shadow: var(--t-text-glow, none);
}
[class*="theme-"] .field input[type="number"],
[class*="theme-"] .field input[type="text"] {
  background: var(--t-input-bg);
  border: var(--t-border-width) solid var(--t-input-border);
  color: var(--t-text);
  font-size: var(--t-fs-input);
  border-radius: var(--t-radius);
  text-shadow: var(--t-text-glow, none);
}
[class*="theme-"] .field input[type="number"]:focus,
[class*="theme-"] .field input[type="text"]:focus {
  outline: none;
  border-color: var(--t-accent);
  box-shadow: var(--t-shadow-halo, none);
}
[class*="theme-"] .field input[type="checkbox"] {
  accent-color: var(--t-accent);
}
[class*="theme-"] .field .unit {
  font-size: var(--t-fs-unit);
  color: var(--t-text-dim);
  text-shadow: var(--t-text-glow, none);
}
[class*="theme-"] .field input[type="range"] {
  accent-color: var(--t-accent);
}

/* ── Generate button (outside any section, needs full width) ── */
[class*="theme-"] button.primary.sb-btn-action {
  width: 100%;
  margin-top: 4px;
}
[class*="theme-"] button.primary.sb-btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

/* ── Export row ── */
[class*="theme-"] .export-row {
  display: flex;
  gap: 6px;
}
[class*="theme-"] .export-row .sb-btn-output {
  flex: 1;
}

/* ── Map container ── */
[class*="theme-"] #mapContainer {
  border: var(--t-border-width) solid var(--t-border);
  border-radius: var(--t-radius);
}

/* ── Status bar ── */
[class*="theme-"] #statusBar {
  background: rgba(0,0,0,0.5);
  color: var(--t-text-dim);
}

/* ── Loading overlay ── */
[class*="theme-"] #loadingOverlay {
  color: var(--t-accent);
}

/* ── Per-theme section title overrides (h3 targets) ── */
.theme-shopbot1 .section h3.sb-section-title {
  color: #f09040;
  text-shadow: 0 0 6px rgba(240,144,64,0.35);
}
.theme-shopbot1 .section h3.sb-section-title::before {
  content: '// ';
  color: #a05818;
}

.theme-devdark .section h3.sb-section-title::before {
  content: '// ';
  color: #6a9955;
}
.theme-devdark .section:nth-child(1) h3 { color: #c586c0; }
.theme-devdark .section:nth-child(2) h3 { color: #4ec9b0; }
.theme-devdark .section:nth-child(3) h3 { color: #dcdcaa; }
.theme-devdark .section:nth-child(4) h3 { color: #ce9178; }
.theme-devdark .section:nth-child(5) h3 { color: #569cd6; }
.theme-devdark .section:nth-child(6) h3 { color: #4fc1ff; }
.theme-devdark .section:nth-child(7) h3 { color: #c586c0; }
.theme-devdark .section:nth-child(8) h3 { color: #dcdcaa; }

/* ── ShopBot3: legal-pad sidebar + teal viewport ── */

.theme-shopbot3 .sidebar-body {
  background-color: #fef9c3;
  background-image:
    linear-gradient(to right, transparent 44px, #e06060 44px, #e06060 46px, transparent 46px),
    repeating-linear-gradient(to bottom, transparent 0px, transparent 29px, #aecfea 29px, #aecfea 30px);
  background-attachment: local;
  padding: 0 !important;
  gap: 0 !important;
}

.theme-shopbot3 .section {
  background: transparent !important;
  border-radius: 0 !important;
  border: none !important;
  padding: 0 1rem 0 56px !important;
  margin: 0 !important;
}

.theme-shopbot3 .section h3.sb-section-title {
  height: 30px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  color: #5a2800;
  font-size: 16px;
}

/* Map: snap to 7 ruled lines; kill the default margin-bottom */
.theme-shopbot3 #mapContainer {
  height: 210px !important;
  margin-bottom: 0 !important;
  background: #66bdb3 !important;
  border-color: rgba(255,255,255,0.3) !important;
  border-radius: 0 !important;
}

/* coord-grid: kill gap and margin so rows snap cleanly */
.theme-shopbot3 .coord-grid {
  gap: 0 !important;
  margin-bottom: 0 !important;
}

/* info-note: one ruled line, block so text-overflow works */
.theme-shopbot3 .info-note {
  display: block;
  height: 30px;
  line-height: 30px;
  margin: 0 !important;
  padding: 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-shopbot3 .field {
  height: 30px;
  margin: 0 !important;
  gap: 6px;
  align-items: center;
}

.theme-shopbot3 .field label {
  height: 30px;
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 16px;
}

.theme-shopbot3 .field input[type="number"],
.theme-shopbot3 .field input[type="text"] {
  height: 30px;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-radius: 0 !important;
  font-size: 16px;
}

.theme-shopbot3 .field select {
  height: 30px;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 0;
  font-size: 16px;
}

.theme-shopbot3 .field input[type="range"] {
  height: 20px;
  margin: 0;
}

.theme-shopbot3 .field .unit {
  font-size: 16px;
}

/* primary button: one ruled line, kill margin-top */
.theme-shopbot3 button.primary {
  height: 30px;
  padding: 0 !important;
  margin-top: 0 !important;
  border-radius: 0 !important;
  font-size: 15px;
}

/* export row buttons: one ruled line */
.theme-shopbot3 .export-row {
  margin: 0 !important;
  gap: 2px;
}
.theme-shopbot3 .export-row button {
  height: 30px;
  padding: 0 !important;
  border-radius: 0 !important;
  font-size: 14px;
}

/* stats: each line on a ruled row */
.theme-shopbot3 .stats {
  font-size: 14px;
  line-height: 30px;
  margin: 0;
}

/* sb-header stays on its own row above the ruled area */
.theme-shopbot3 .sb-header {
  background: var(--t-bg-header);
}
