/* ==========================================================================
   Layout: sticky top bar, sticky sidebar, sections, 12-column responsive grid
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-5);
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-mark { width: 28px; height: 28px; transition: transform var(--t-fast) var(--ease); }
.brand:hover .brand-mark { transform: scale(1.08); }
/* Lighter tints of --you/--claude, only for this mark -- the "eclipse" concept
   picked from the logo review, softened per direct feedback ("light colours").
   color-mix with white keeps it unmistakably blue/orange and still theme-
   adaptive (it tracks whatever --you/--claude resolve to per theme), without
   touching those tokens themselves, which still drive real chart/data color
   everywhere else in the app. */
.bm-you { fill: color-mix(in srgb, var(--you) 65%, white); }
.bm-claude { fill: color-mix(in srgb, var(--claude) 65%, white); fill-opacity: 0.85; mix-blend-mode: multiply; }
:root[data-theme="dark"] .bm-claude { mix-blend-mode: screen; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-name b { font-weight: 800; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-left: auto;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  padding: var(--s-5) var(--s-3) var(--s-5) var(--s-5);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group {
  padding: 14px 12px 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-group:first-child { padding-top: 2px; }
/* The Alerts group heading itself hints at overall status: it's the one nav label that
   can carry a live health color, so a glance at the sidebar answers "is anything wrong"
   before opening the section. */
.nav-group[data-status="bad"] { color: var(--critical-ink); }
.nav-group[data-status="warn"] { color: var(--ink); }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-ctl);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link[aria-current="true"] {
  background: var(--inverse);
  color: var(--inverse-ink);
}
.nav-link[aria-current="true"] .nav-icon { opacity: 1; }
.nav-link .nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.7;
}
.sidebar-foot {
  margin-top: auto;
  padding: var(--s-4) 12px 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

main {
  min-width: 0;
  padding: 0 var(--s-6) var(--s-7) var(--s-4);
  outline: none;
}

#view { max-width: 1320px; }

/* ---------- footer: author left, privacy right ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-2) var(--s-5);
  max-width: 1320px;
  margin-top: var(--s-7);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--you); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* sections */
.section { padding-top: var(--s-6); }
/* A bare widget starts as a genuinely empty <div> before its first render. Without
   this, IntersectionObserver can't compute an intersection ratio for a zero-area
   target and some browsers then never report it as visible — the widget stays
   unrendered forever. Required for correctness, not cosmetic — every bare widget
   (this panel included) depends on it. */
.bare { min-height: 4px; }
.section + .section { margin-top: var(--s-3); }
.section-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.section-head-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-top: 1px;
  border-radius: var(--r-ctl);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.section-head-icon .nav-icon { width: 17px; height: 17px; opacity: 1; }
.section-head-text { flex: 1 1 auto; min-width: 0; }
.section-head h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.section-head p {
  color: var(--muted);
  font-size: 14px;
  max-width: 60ch;
  margin-top: 3px;
}

/* 12-column grid; cards declare their span */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
}
.grid > [data-span="3"] { grid-column: span 3; }
.grid > [data-span="4"] { grid-column: span 4; }
.grid > [data-span="5"] { grid-column: span 5; }
.grid > [data-span="6"] { grid-column: span 6; }
.grid > [data-span="7"] { grid-column: span 7; }
.grid > [data-span="8"] { grid-column: span 8; }
.grid > [data-span="12"] { grid-column: span 12; }

/* ---------- tablet ---------- */
@media (max-width: 1180px) {
  .grid > [data-span="3"] { grid-column: span 6; }
  .grid > [data-span="4"] { grid-column: span 6; }
  .grid > [data-span="5"],
  .grid > [data-span="7"],
  .grid > [data-span="8"] { grid-column: span 12; }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: var(--topbar-h);
    z-index: 30;
    height: auto;
    padding: 8px var(--s-4);
    background: color-mix(in srgb, var(--page) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar ul { flex-direction: row; gap: 4px; }
  .nav-link { white-space: nowrap; padding: 6px 12px; }
  .nav-link .nav-count { display: none; }
  .nav-group { display: none; } /* group labels don't read well in a horizontal scroller */
  .sidebar-foot { display: none; }
  main { padding: 0 var(--s-5) var(--s-7); }
  html { scroll-padding-top: calc(var(--topbar-h) + 120px); }
}

/* ---------- phone ---------- */
@media (max-width: 720px) {
  :root { --topbar-h: 56px; --card-pad: 16px; }
  .topbar { gap: var(--s-2); padding: 0 var(--s-4); }
  .brand-name { display: none; }
  main { padding: 0 var(--s-4) var(--s-7); }
  .grid { gap: 12px; }
  .grid > [data-span] { grid-column: span 12; }
  .section-head h2 { font-size: 20px; }
  .site-footer { flex-direction: column; gap: 6px; }
}
