/* Module: lighting-tools
 * Scope: module-specific selectors use [data-module="lighting-tools"].
 * Colors: CSS custom properties only (both themes inherit from platform tokens).
 * Layout: full-bleed module that supplies its own gutter + centered wrap, then
 *         leans on platform components (strata-view-header, strata-card-grid,
 *         strata-mgmt-card, badge, input-field, btn-*) so it reads as native
 *         Strata. A landing card grid is the front door; each tool opens in a
 *         detail view. Tool-body widgets (DIP paddles, beam viz, tunable meter)
 *         stay module-specific but sit on platform surfaces.
 */

/* ---- Full-bleed frame (module supplies its own padding + max width) ---- */
.lt-root[data-module="lighting-tools"] {
  color: var(--text-primary);
  /* Reflow on the module's OWN width, not the viewport: the sidebar makes the
     content area narrower than the screen. */
  container-type: inline-size;
  container-name: lt;
}

.lt-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

[data-module="lighting-tools"] *,
[data-module="lighting-tools"] *::before,
[data-module="lighting-tools"] *::after {
  box-sizing: border-box;
}

/* ---- Landing: header + search ---- */
[data-module="lighting-tools"] .lt-header {
  align-items: flex-end;
}

[data-module="lighting-tools"] .lt-search {
  flex: 0 0 auto;
}

[data-module="lighting-tools"] .lt-search .input-field {
  width: 240px;
  max-width: 100%;
}

/* ---- Landing: group sections ---- */
[data-module="lighting-tools"] .lt-group-section {
  margin-top: 28px;
}

[data-module="lighting-tools"] .lt-group-section:first-child {
  margin-top: 0;
}

[data-module="lighting-tools"] .lt-group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

[data-module="lighting-tools"] .lt-group-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

[data-module="lighting-tools"] .lt-group-head span {
  color: var(--text-tertiary);
  font-size: 12px;
}

[data-module="lighting-tools"] .lt-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ---- Landing: tool card (clickable button styled as a panel card) ---- */
[data-module="lighting-tools"] .lt-tool-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 16px;
  text-align: left;
  font: inherit;
  color: var(--text-primary);
  cursor: pointer;
}

[data-module="lighting-tools"] .lt-card-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
}

[data-module="lighting-tools"] .lt-card-icon svg {
  width: 20px;
  height: 20px;
}

[data-module="lighting-tools"] .lt-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

[data-module="lighting-tools"] .lt-card-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

[data-module="lighting-tools"] .lt-card-desc {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.45;
}

[data-module="lighting-tools"] .lt-card-badge {
  flex: 0 0 auto;
  align-self: flex-start;
}

[data-module="lighting-tools"] .lt-no-results {
  margin-top: 24px;
}

/* ---- Detail: back bar ---- */
[data-module="lighting-tools"] .lt-detail-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

[data-module="lighting-tools"] .lt-detail-bar .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---- Tool panel ---- */
[data-module="lighting-tools"] .lt-tool-panel {
  animation: lt-panel-in var(--transition-speed) var(--transition-fn);
}

[data-module="lighting-tools"] .lt-tool-title {
  margin-bottom: 16px;
}

[data-module="lighting-tools"] .lt-tool-title h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

[data-module="lighting-tools"] .lt-tool-title p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

[data-module="lighting-tools"] .lt-grid {
  display: grid;
  gap: 12px;
}

[data-module="lighting-tools"] .lt-grid-two {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.78fr);
  /* size each column to its own content so a short result panel doesn't
     stretch into a tall hollow card next to a taller form. */
  align-items: start;
}

/* ---- Cards + result surfaces (platform panel language) ---- */
[data-module="lighting-tools"] .lt-card,
[data-module="lighting-tools"] .lt-result,
[data-module="lighting-tools"] .lt-ref-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--panel-radius);
  padding: 16px;
}

[data-module="lighting-tools"] .lt-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  align-content: start;
}

[data-module="lighting-tools"] .lt-field-wide {
  grid-column: 1 / -1;
}

[data-module="lighting-tools"] .lt-field + .lt-field {
  margin-top: 14px;
}

[data-module="lighting-tools"] .lt-form-grid .lt-field + .lt-field {
  margin-top: 0;
}

[data-module="lighting-tools"] .lt-label,
[data-module="lighting-tools"] .lt-stat-label {
  display: block;
  margin: 0 0 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

[data-module="lighting-tools"] .lt-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Inputs (aligned to platform .input-field) ---- */
[data-module="lighting-tools"] .lt-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--button-radius);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition-speed) var(--transition-fn),
              box-shadow var(--transition-speed) var(--transition-fn);
}

[data-module="lighting-tools"] .lt-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The "solved for" field in Ohm's Law reads as a derived result, not an input. */
[data-module="lighting-tools"] .lt-input[readonly] {
  color: var(--accent);
  font-family: var(--font-mono);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

/* Full-width slider with a min/mid/max scale, used below the number field. */
[data-module="lighting-tools"] .lt-slider-field {
  margin-top: 12px;
}

[data-module="lighting-tools"] .lt-range {
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

[data-module="lighting-tools"] .lt-slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3px;
}

/* ---- Segments / pills / chips (single-select tokens) ---- */
[data-module="lighting-tools"] .lt-segment,
[data-module="lighting-tools"] .lt-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

[data-module="lighting-tools"] .lt-segment {
  margin-bottom: 12px;
}

[data-module="lighting-tools"] .lt-pill,
[data-module="lighting-tools"] .lt-chip {
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-speed) var(--transition-fn),
              color var(--transition-speed) var(--transition-fn),
              border-color var(--transition-speed) var(--transition-fn);
}

[data-module="lighting-tools"] .lt-pill:hover,
[data-module="lighting-tools"] .lt-chip:hover {
  background: var(--row-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

[data-module="lighting-tools"] .lt-pill-active,
[data-module="lighting-tools"] .lt-pill-active:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}

/* ---- Result panel ---- */
[data-module="lighting-tools"] .lt-result {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--panel-2);
}

/* lone empty-state prompt centers; real results top-align to match the form */
[data-module="lighting-tools"] .lt-result .lt-empty { margin: auto; }

/* a headline stat sitting directly in the result panel is not a nested card */
[data-module="lighting-tools"] .lt-result > .lt-stat {
  border: none;
  background: transparent;
  padding: 0;
}

[data-module="lighting-tools"] .lt-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

[data-module="lighting-tools"] .lt-stat {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--button-radius);
}

[data-module="lighting-tools"] .lt-stat-value {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

[data-module="lighting-tools"] .lt-stat-sub {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
}

/* status-banded stat values */
[data-module="lighting-tools"] .lt-stat-good .lt-stat-value { color: var(--success); }
[data-module="lighting-tools"] .lt-stat-warn .lt-stat-value { color: var(--warning); }
[data-module="lighting-tools"] .lt-stat-bad .lt-stat-value { color: var(--error); }
[data-module="lighting-tools"] .lt-stat-good { background: var(--success-soft); border-color: var(--success); }
[data-module="lighting-tools"] .lt-stat-warn { background: var(--warning-soft); border-color: var(--warning); }
[data-module="lighting-tools"] .lt-stat-bad  { background: var(--error-soft);   border-color: var(--error); }

/* ---- Formula reveal ---- */
[data-module="lighting-tools"] .lt-formula {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--button-radius);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

[data-module="lighting-tools"] .lt-empty {
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  padding: 8px 4px;
}

/* ---- Focus rings ---- */
[data-module="lighting-tools"] .lt-tool-card:focus-visible,
[data-module="lighting-tools"] .lt-pill:focus-visible,
[data-module="lighting-tools"] .lt-chip:focus-visible,
[data-module="lighting-tools"] .lt-switch:focus-visible,
[data-module="lighting-tools"] .lt-input:focus-visible,
[data-module="lighting-tools"] .lt-range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Action buttons (aligned to platform btn-primary / btn-secondary) ---- */
[data-module="lighting-tools"] .lt-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;   /* keep buttons their natural height, not stretched */
  gap: 8px;
}

/* The action row + result list/empty live inside the 2-col .lt-form-grid.
   Pin the buttons to the bottom of their cell (lined up with the adjacent
   input) and let the list/tokens/empty span the full width below. */
[data-module="lighting-tools"] .lt-form-grid > .lt-action-row {
  align-self: end;
}

[data-module="lighting-tools"] .lt-form-grid > .lt-list,
[data-module="lighting-tools"] .lt-form-grid > .lt-token-row,
[data-module="lighting-tools"] .lt-form-grid > .lt-empty {
  grid-column: 1 / -1;
}

[data-module="lighting-tools"] .lt-primary-btn,
[data-module="lighting-tools"] .lt-mini-btn {
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--button-radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition-speed) var(--transition-fn),
              border-color var(--transition-speed) var(--transition-fn);
}

[data-module="lighting-tools"] .lt-primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

[data-module="lighting-tools"] .lt-primary-btn:hover { box-shadow: var(--shadow-sm); }

[data-module="lighting-tools"] .lt-mini-btn {
  background: var(--panel-2);
  color: var(--text-secondary);
  font-size: 12px;
}

[data-module="lighting-tools"] .lt-mini-btn:hover {
  background: var(--row-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ---- Lists / tokens (circuit + cable) ---- */
[data-module="lighting-tools"] .lt-list,
[data-module="lighting-tools"] .lt-token-row {
  display: grid;
  gap: 8px;
}

[data-module="lighting-tools"] .lt-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--button-radius);
  background: var(--panel-2);
}

[data-module="lighting-tools"] .lt-list-row strong {
  font-family: var(--font-mono);
  color: var(--accent);
}

[data-module="lighting-tools"] .lt-list-row span,
[data-module="lighting-tools"] .lt-list-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

[data-module="lighting-tools"] .lt-token-row {
  display: flex;
  flex-wrap: wrap;
}

[data-module="lighting-tools"] .lt-token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

[data-module="lighting-tools"] .lt-token button {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0 2px;
  font-weight: 700;
}

/* ---- Tables (planner + reference) ---- */
[data-module="lighting-tools"] .lt-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--button-radius);
}

[data-module="lighting-tools"] .lt-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 360px;
}

/* Reference tables hold wrappable prose; let them shrink + wrap, not scroll. */
[data-module="lighting-tools"] .lt-ref-card .lt-table { min-width: 0; }

/* Result tables (addressing / network / cable plan) hold short numeric cells.
   Hug their content instead of stretching the full module width, so a 4-column
   table doesn't leave a wide empty gap on the right. */
[data-module="lighting-tools"] .lt-table-region .lt-table-wrap {
  width: max-content;
  max-width: 100%;
}

[data-module="lighting-tools"] .lt-table th,
[data-module="lighting-tools"] .lt-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 12.5px;
  line-height: 1.4;
}

[data-module="lighting-tools"] .lt-table td {
  color: var(--text-secondary);
}

[data-module="lighting-tools"] .lt-table tbody tr:last-child td { border-bottom: none; }
[data-module="lighting-tools"] .lt-table tbody tr:nth-child(even) td { background: var(--row-alt); }

[data-module="lighting-tools"] .lt-table th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--text-tertiary);
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 11px;
}

[data-module="lighting-tools"] .lt-table td:first-child {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Reference sections ---- */
[data-module="lighting-tools"] .lt-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

[data-module="lighting-tools"] .lt-ref-card h4,
[data-module="lighting-tools"] .lt-result h4 {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
}

[data-module="lighting-tools"] .lt-result h4 { margin: 18px 0 6px; }
[data-module="lighting-tools"] .lt-result h4:first-child { margin-top: 0; }

/* ---- DIP switch paddles (signature widget) ---- */
[data-module="lighting-tools"] .lt-switch-row {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

[data-module="lighting-tools"] .lt-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--button-radius);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color var(--transition-speed) var(--transition-fn),
              background var(--transition-speed) var(--transition-fn);
}

[data-module="lighting-tools"] .lt-switch-num {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-tertiary);
}

/* the fixed-size track; the paddle is positioned INSIDE it */
[data-module="lighting-tools"] .lt-switch-track {
  position: relative;
  width: 24px;
  height: 42px;
  border-radius: 6px;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  transition: background var(--transition-speed) var(--transition-fn),
              border-color var(--transition-speed) var(--transition-fn);
}

/* paddle parked at the bottom of the track (OFF) */
[data-module="lighting-tools"] .lt-switch-paddle {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 4px;
  background: var(--text-tertiary);
  transition: top var(--transition-speed) var(--transition-fn),
              bottom var(--transition-speed) var(--transition-fn),
              background var(--transition-speed) var(--transition-fn);
}

[data-module="lighting-tools"] .lt-switch-val {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

[data-module="lighting-tools"] .lt-switch:hover { border-color: var(--border-strong); }

[data-module="lighting-tools"] .lt-switch-on {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

[data-module="lighting-tools"] .lt-switch-on .lt-switch-track {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* paddle slides to the top of the track (ON) and turns accent */
[data-module="lighting-tools"] .lt-switch-on .lt-switch-paddle {
  top: 4px;
  bottom: auto;
  background: var(--accent);
}

[data-module="lighting-tools"] .lt-switch-on .lt-switch-num,
[data-module="lighting-tools"] .lt-switch-on .lt-switch-val { color: var(--accent); }

/* ---- Tunable-white meter (warm -> cool) ---- */
[data-module="lighting-tools"] .lt-meter {
  position: relative;
  height: 14px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: visible;
  /* vivid warm (amber) -> cool (blue) so the blend reads at a glance */
  background: linear-gradient(90deg, var(--warning), var(--accent));
}

[data-module="lighting-tools"] .lt-meter span {
  position: absolute;
  top: -4px;
  width: 6px;
  height: 22px;
  border-radius: 3px;
  background: var(--text-primary);
  border: 2px solid var(--panel);
  box-shadow: var(--shadow);
  transform: translateX(-3px);
}

/* ---- Beam-spread visualizer ---- */
[data-module="lighting-tools"] .lt-beam-viz {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

[data-module="lighting-tools"] .lt-beam-viz svg {
  width: 100%;
  max-width: 300px;
  height: auto;
}

[data-module="lighting-tools"] .lt-beam-pool {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.5;
}

[data-module="lighting-tools"] .lt-beam-axis { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
[data-module="lighting-tools"] .lt-beam-src { fill: var(--accent); }
[data-module="lighting-tools"] .lt-beam-cap { fill: var(--text-tertiary); font-family: var(--font-mono); font-size: 9px; }

/* ---- Motion ---- */
@keyframes lt-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  [data-module="lighting-tools"] .lt-tool-panel { animation: none; }
  [data-module="lighting-tools"] * { transition: none !important; }
}

/* ---- Responsive (container-based: reflows on the module's OWN width) ---- */
@container lt (max-width: 720px) {
  [data-module="lighting-tools"] .lt-grid-two {
    grid-template-columns: 1fr;
  }

  [data-module="lighting-tools"] .lt-header {
    align-items: flex-start;
  }

  [data-module="lighting-tools"] .lt-search .input-field {
    width: 100%;
  }
}

@container lt (max-width: 560px) {
  [data-module="lighting-tools"] .lt-wrap {
    padding: 16px 16px 40px;
  }

  [data-module="lighting-tools"] .lt-form-grid {
    grid-template-columns: 1fr;
  }

  [data-module="lighting-tools"] .lt-stat-grid { grid-template-columns: 1fr; }
  [data-module="lighting-tools"] .lt-stat-value { font-size: 19px; }
}

/* iOS Safari zooms inputs under 16px on focus; bump at phone width. */
@media (max-width: 640px) {
  [data-module="lighting-tools"] .lt-input,
  [data-module="lighting-tools"] .lt-search .input-field {
    font-size: 16px;
  }

  [data-module="lighting-tools"] .lt-tool-card,
  [data-module="lighting-tools"] .lt-pill,
  [data-module="lighting-tools"] .lt-chip,
  [data-module="lighting-tools"] .lt-switch,
  [data-module="lighting-tools"] .lt-primary-btn,
  [data-module="lighting-tools"] .lt-mini-btn {
    touch-action: manipulation;
  }
}
