/**
 * IEEE Smart Village — shared theme tokens & chrome
 * Default: light. Toggle via js/isv-theme.js → html[data-theme="light"|"dark"]
 */

/* ── Light (default) ── */
:root,
html[data-theme="light"] {
  color-scheme: light;

  /* ISV brand */
  --isv-green: #3B6D11;
  --isv-green-dark: #2d520d;
  --isv-green-50: #EAF3DE;
  --isv-green-200: #97C459;
  --ieee-blue: #00629B;
  --ieee-blue-50: #E8F4FA;

  /* Semantic (alias for existing pages) */
  --green: var(--isv-green);
  --green-50: var(--isv-green-50);
  --green-200: var(--isv-green-200);
  --amber: #BA7517;
  --amber-50: #FAEEDA;
  --teal: #0F6E56;
  --teal-50: #E1F5EE;
  --purple: #534AB7;
  --purple-50: #EEEDFE;
  --red: #B42318;
  --red-50: #FEE4E2;
  --blue: #175CD3;
  --blue-50: #EFF8FF;

  --bg: #ffffff;
  --bg-2: #f7f6f3;
  --bg-3: #f0efe9;
  --text: #1c1c1a;
  --text-2: #5a5a55;
  --text-3: #9a9990;
  --border: rgba(0, 0, 0, 0.08);
  --border-2: rgba(0, 0, 0, 0.14);
  --shadow: 0 1px 3px rgba(28, 28, 26, 0.06);
  --accent-bar: linear-gradient(90deg, var(--isv-green) 0%, var(--isv-green-200) 55%, var(--ieee-blue) 100%);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
}

/* ── Dark (user-selected) ── */
html[data-theme="dark"] {
  color-scheme: dark;

  --isv-green: #6fa832;
  --isv-green-dark: #3B6D11;
  --isv-green-50: #1a2e0a;
  --isv-green-200: #4a7a1a;
  --ieee-blue: #4da3d9;
  --ieee-blue-50: #0a1f2e;

  --green: var(--isv-green);
  --green-50: var(--isv-green-50);
  --green-200: var(--isv-green-200);
  --amber: #d4923a;
  --amber-50: #2a1e08;
  --teal: #3d9e84;
  --teal-50: #082018;
  --purple: #8b83e8;
  --purple-50: #16143a;
  --red: #f04438;
  --red-50: #2a0a08;
  --blue: #53b1fd;
  --blue-50: #081828;

  --bg: #141416;
  --bg-2: #1c1c1f;
  --bg-3: #262629;
  --text: #ecebe6;
  --text-2: #a8a7a0;
  --text-3: #6b6a64;
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --accent-bar: linear-gradient(90deg, var(--isv-green) 0%, var(--isv-green-200) 50%, var(--ieee-blue) 100%);
}

/* ── Theme toggle button ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.theme-toggle:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--green);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.theme-toggle--icon {
  width: auto;
  padding: 8px;
}

.theme-toggle--icon .theme-toggle-label { display: none; }

/* ── ISV sidebar chrome (index shell) ── */
#sidebar.isv-sidebar {
  border-top: 3px solid transparent;
  border-image: var(--accent-bar) 1;
}

.sidebar-logo .sidebar-logo-img {
  width: 100%;
  height: auto;
  display: block;
}

html[data-theme="light"] .sidebar-logo {
  background: var(--bg);
}

html[data-theme="light"] .sidebar-logo:hover {
  background: var(--bg-3);
}

.section-header.isv-section-header {
  padding-left: 0.85rem;
  border-left: 3px solid var(--green);
}

/* ── Standalone page top bar ── */
.isv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 50;
}

.isv-topbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-bar);
}

.isv-topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.isv-topbar-logo {
  display: block;
  flex-shrink: 0;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: background 0.1s;
}

html[data-theme="light"] .isv-topbar-logo {
  background: var(--bg);
}

.isv-topbar-logo:hover {
  background: var(--bg-3);
}

.isv-topbar-logo:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.isv-topbar-logo-img {
  display: block;
  height: 44px;
  width: auto;
  max-width: min(220px, 46vw);
}

.isv-topbar-back {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.35rem 0;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.isv-topbar-back:hover {
  color: var(--green);
}

.isv-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.isv-topbar-actions .theme-toggle {
  margin-bottom: 0;
}

/* Legacy text mark (older standalone pages) */
.isv-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.isv-topbar-brand:hover { color: var(--green); }

.isv-topbar-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

html.embed .isv-topbar { display: none; }

@media (max-width: 520px) {
  .isv-topbar-back {
    display: none;
  }

  .isv-topbar .theme-toggle-label {
    display: none;
  }
}

/* Mobile: fixed theme control when sidebar hidden */
.mobile-theme-btn {
  display: none;
}

@media (max-width: 600px) {
  .mobile-theme-btn {
    display: inline-flex;
    position: fixed;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 400;
    width: 40px;
    height: 40px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
  }
}

/* Callout boxes — only the title line (first direct strong) breaks to its own row */
.callout > strong:first-child {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.callout p strong,
.callout em strong {
  display: inline;
  font-weight: 600;
}
.callout p {
  margin: 0 0 0.5rem;
  line-height: 1.55;
}
.callout p:last-child {
  margin-bottom: 0;
}
