/* Rocberg components: the board, cards, charts and the layout editor.
 *
 * The colour, type and shape tokens all live in theme.css, which is the single
 * source of truth for the palette and is loaded before this file. Nothing here
 * defines a colour of its own; everything reads a --rb-* token.
 */

/* --- Page shell ------------------------------------------------------- */

/* The whole shell is dark now: the theme is global, not scoped to one page.
   These rules restyle the app chrome (sidebar, top bar, nav) that styles.css
   lays out, using the same tokens as everything else. */
.layout { background: var(--rb-bg); }
.content { background: var(--rb-bg); }
.sidebar { background: var(--rb-bg-alt); border-right: 1px solid var(--rb-border); }
.topbar { background: var(--rb-bg-alt); border-bottom: 1px solid var(--rb-border); }
.topbar-title { color: var(--rb-heading); font-family: var(--rb-font-ui); }
.wordmark { color: var(--rb-heading); font-family: var(--rb-font-display); letter-spacing: 0.3px; }
.nav-item { color: var(--rb-muted); border-radius: 8px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--rb-heading); }
.nav-item.is-active { background: var(--rb-accent-soft); color: var(--rb-accent); }

.rb {
  background: var(--rb-bg);
  color: var(--rb-text);
  font-family: var(--rb-font-ui);
  /* .content carries 22px padding; cancel it so the dark board runs to the
     edges of the main area rather than floating on the light chrome. */
  margin: -22px;
  padding: 26px 24px 40px;
  min-height: 100%;
}

.rb-masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rb-border);
  padding-bottom: 18px;
  margin-bottom: 26px;
}

.rb-title {
  font-family: var(--rb-font-display);
  color: var(--rb-heading);
  font-size: var(--fs-stat-lg);
  line-height: 1.06;
  margin: 6px 0 0;
  letter-spacing: 0.1px;
}

.rb-subtitle { color: var(--rb-muted); font-size: var(--fs-base); margin-top: 8px; }

/* The small uppercase amber "SECTION X" label. */
.rb-eyebrow {
  color: var(--rb-accent);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rb-section {
  margin: 34px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.rb-section h2 {
  font-family: var(--rb-font-display);
  color: var(--rb-heading);
  font-size: var(--fs-2xl);
  font-weight: 400;
  margin: 0;
}
.rb-section .rb-rule {
  flex: 1;
  height: 1px;
  background: var(--rb-border);
}

/* --- The board grid --------------------------------------------------- */
/*
 * A 12-column grid. Size tokens map to spans in dashboard_layout.SPANS
 * (small 4, medium 6, large 12) and arrive as a class on each slot. A later
 * free-resize step would set grid-column directly from a stored integer; the
 * markup already carries the slot, so only the class/style would change.
 */

.rb-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.rb-span-small  { grid-column: span 4; }
.rb-span-medium { grid-column: span 6; }
.rb-span-large  { grid-column: span 12; }

@media (max-width: 1200px) {
  .rb-span-small  { grid-column: span 6; }
  .rb-span-medium { grid-column: span 12; }
}
@media (max-width: 820px) {
  .rb-span-small, .rb-span-medium, .rb-span-large { grid-column: span 12; }
}

/* A hidden panel is simply not rendered when not editing. */
.rb-slot.is-hidden { display: none; }

/* --- Edit mode -------------------------------------------------------- */

.rb-masthead-actions { display: flex; align-items: center; gap: 10px; }

.rb-editbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--rb-accent-soft);
  border: 1px solid rgba(232, 134, 62, 0.35);
  border-radius: var(--rb-radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  color: var(--rb-text);
}
/* A class rule with display:flex would otherwise beat the hidden attribute. */
.rb-editbar[hidden] { display: none; }
.rb-editbar strong { color: var(--rb-heading); }
.rb-editbar-actions { display: flex; align-items: center; gap: 8px; }

/* The per-panel control bar only exists while editing. */
.rb-slot-bar { display: none; }

.rb-editing .rb-slot-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--rb-panel-2);
  border: 1px solid var(--rb-border);
  border-bottom: 0;
  border-radius: var(--rb-radius) var(--rb-radius) 0 0;
  padding: 8px 10px;
}
.rb-editing .rb-slot { outline: 1px dashed rgba(255, 255, 255, 0.14); border-radius: var(--rb-radius); }
/* Hidden panels stay on screen while editing, dimmed, so they can be restored. */
.rb-editing .rb-slot.is-hidden { display: block; opacity: 0.42; }
.rb-editing .rb-slot.is-hidden .rb-slot-body { filter: grayscale(1); }

.rb-slot-title { color: var(--rb-heading); font-size: var(--fs-sm); font-weight: 600; }
.rb-slot-spacer { flex: 1; }

.rb-drag-handle {
  cursor: grab;
  color: var(--rb-muted);
  font-size: var(--fs-lg);
  line-height: 1;
  padding: 2px 4px;
  user-select: none;
}
.rb-drag-handle:active { cursor: grabbing; }

.rb-slot.is-dragging { opacity: 0.45; }
.rb-slot.is-drop-target { outline: 2px solid var(--rb-accent); }

.rb-size-group { display: inline-flex; gap: 3px; }
.rb-size-btn, .rb-vis-btn {
  background: transparent;
  color: var(--rb-muted);
  border: 1px solid var(--rb-border);
  border-radius: 6px;
  font-family: var(--rb-font-ui);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 3px 8px;
  cursor: pointer;
}
.rb-size-btn.is-on {
  background: var(--rb-accent);
  border-color: var(--rb-accent);
  color: #17120c;
}
.rb-size-btn:hover, .rb-vis-btn:hover { color: var(--rb-heading); }

.rb-pill-new { background: rgba(63, 182, 139, 0.16); color: var(--rb-green); }

/* --- Cards ------------------------------------------------------------ */

.rb-card {
  background: var(--rb-panel);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  box-shadow: var(--rb-shadow);
  padding: 18px 18px 16px;
}
.rb-card h3 {
  font-family: var(--rb-font-ui);
  color: var(--rb-heading);
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0 0 2px;
}
.rb-card .rb-note { color: var(--rb-muted); font-size: var(--fs-sm); margin: 0 0 12px; }

.rb-grid { display: grid; gap: 16px; }
.rb-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.rb-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rb-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1200px) {
  .rb-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rb-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .rb-grid-6, .rb-grid-3, .rb-grid-2 { grid-template-columns: 1fr; }
}

/* --- Headline (stat) cards -------------------------------------------- */

.rb-stat {
  position: relative;
  background: linear-gradient(180deg, var(--rb-panel-2), var(--rb-panel));
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  box-shadow: var(--rb-shadow);
  padding: 16px 16px 14px;
  overflow: hidden;
}
.rb-stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--rb-tint, var(--rb-accent));
}
.rb-stat .rb-stat-label {
  color: var(--rb-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.rb-stat .rb-stat-value {
  font-family: var(--rb-font-display);
  color: var(--rb-heading);
  font-size: var(--fs-stat-lg);
  line-height: 1.1;
  margin-top: 8px;
}
/* The amber underline beneath a headline number. */
.rb-stat .rb-stat-underline {
  width: 34px;
  height: 3px;
  border-radius: 2px;
  background: var(--rb-tint, var(--rb-accent));
  margin-top: 10px;
}
.rb-stat .rb-stat-sub { color: var(--rb-muted); font-size: var(--fs-sm); margin-top: 9px; }

/* --- Charts ----------------------------------------------------------- */

.rb-chart { position: relative; width: 100%; }
.rb-chart-sm { height: 210px; }
.rb-chart-md { height: 260px; }
.rb-chart-lg { height: 300px; }

/* --- Lists ------------------------------------------------------------ */

.rb-list { list-style: none; margin: 0; padding: 0; }
.rb-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rb-border);
  font-size: var(--fs-base);
}
.rb-list li:last-child { border-bottom: 0; }
.rb-list .rb-list-meta { color: var(--rb-muted); font-size: var(--fs-sm); white-space: nowrap; }
.rb-list a { color: var(--rb-text); text-decoration: none; }
.rb-list a:hover { color: var(--rb-accent); }

/* --- Traffic-light style chips (used by status counts) ----------------- */

.rb-lights { display: flex; gap: 10px; flex-wrap: wrap; }
.rb-light {
  flex: 1 1 92px;
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius-sm);
  background: var(--rb-bg-alt);
  padding: 12px;
}
.rb-light .rb-light-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; margin-right: 7px;
}
.rb-light .rb-light-value {
  font-family: var(--rb-font-display);
  color: var(--rb-heading);
  font-size: var(--fs-3xl);
  margin-top: 6px;
}
.rb-light .rb-light-label {
  color: var(--rb-muted); font-size: var(--fs-xs);
  letter-spacing: 0.07em; text-transform: uppercase; font-weight: 600;
}

/* --- Buttons and empty states ----------------------------------------- */

.rb-btn {
  display: inline-block;
  background: var(--rb-accent);
  color: #17120c;
  border: 0;
  border-radius: var(--rb-radius-sm);
  padding: 9px 15px;
  font-family: var(--rb-font-ui);
  font-size: var(--fs-base);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.rb-btn:hover { background: var(--rb-accent-deep); }
.rb-btn-ghost {
  background: transparent;
  color: var(--rb-text);
  border: 1px solid var(--rb-border);
}
.rb-btn-ghost:hover { background: var(--rb-panel-2); color: var(--rb-heading); }

.rb-empty {
  border: 1px dashed var(--rb-border);
  border-radius: var(--rb-radius-sm);
  background: var(--rb-bg-alt);
  color: var(--rb-muted);
  padding: 22px 16px;
  text-align: center;
  font-size: var(--fs-base);
}
.rb-empty strong { display: block; color: var(--rb-text); margin-bottom: 4px; font-size: var(--fs-base); }

.rb-pill {
  display: inline-block;
  background: var(--rb-accent-soft);
  color: var(--rb-accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* --- Ranked dashboard --------------------------------------------------
   The board leads with what you act on. Two card treatments support that:
   a lead card for the primary panel, and a quiet card for demoted context. */

.rb-card-lead {
  background: linear-gradient(180deg, var(--rb-panel-2), var(--rb-panel));
  border-color: rgba(232, 134, 62, 0.35);
}
.rb-card-quiet {
  background: var(--rb-bg-alt);
  box-shadow: none;
  padding: 12px 14px;
}

/* Headline counters as a compact strip: one row, small numbers, secondary. */
.rb-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  align-items: flex-start;
}
.rb-strip-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  padding: 3px 0;
  border-bottom: 2px solid transparent;
}
.rb-strip-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.rb-strip-item:hover { border-bottom-color: var(--rb-tint, var(--rb-accent)); text-decoration: none; }
.rb-strip-value {
  font-family: var(--rb-font-ui);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--rb-heading);
  line-height: 1;
}
.rb-strip-label {
  color: var(--rb-muted);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
/* Quieter than the label above it: context, not a second heading. */
.rb-strip-sub {
  color: var(--rb-muted);
  font-size: var(--fs-xs);
  opacity: 0.8;
}

/* The lead panel's traffic lights are larger than a normal light row. */
.rb-lights-lead { margin-top: 14px; }
.rb-lights-lead .rb-light { padding: 14px 16px; }
.rb-lights-lead .rb-light-value { font-size: var(--fs-stat); }
.rb-lights-lead .rb-light:hover { border-color: var(--rb-accent); }

/* "Green and Higher value: prioritise these" as its own call to action. */
.rb-prioritise {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--rb-radius-sm);
  background: rgba(63, 182, 139, 0.12);
  border: 1px solid rgba(63, 182, 139, 0.4);
  color: var(--rb-text);
  text-decoration: none;
}
.rb-prioritise:hover { background: rgba(63, 182, 139, 0.2); text-decoration: none; }
.rb-prioritise strong { color: var(--rb-heading); flex: 1; }
.rb-prioritise-count {
  font-family: var(--rb-font-display);
  font-size: var(--fs-2xl);
  color: var(--rb-green);
  line-height: 1;
}

/* A compact page header in place of the old full-width hero. */
.rb-topline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rb-border);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.rb-topline .rb-note { margin: 0; }
