/*
====================================================================
TT-OS UNIFIED DARK THEME v002
Purpose:
- Match Observatory visual language across selected TT-OS intelligence pages.
- Apply to whole page, including lower sections, footer and boundary blocks.
- Preserve existing content.
====================================================================
*/

:root {
  --color-bg-green: #2e5a44;
  --color-bg-deep: #171B14;
  --color-surface-dark: #234533;
  --color-surface-mid: #2f6048;
  --color-accent-lime: #a3e635;
  --color-accent-gold: #C9A35C;
  --color-text-white: #ffffff;
  --color-text-muted: rgba(255,255,255,0.85);

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;

  --line-height-text: 1.65;
  --line-height-heading: 1.25;

  --container-width: 800px;
  --wide-width: 1120px;
  --line-soft: rgba(255,255,255,0.14);
}

* {
  box-sizing: border-box;
}

html,
body.ttos-theme {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--color-bg-deep) 0%, var(--color-bg-green) 100%) !important;
  color: var(--color-text-white) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: var(--line-height-text);
  overflow-x: hidden;
}

/* Whole-page coverage */
body.ttos-theme main,
body.ttos-theme .container,
body.ttos-theme .page-shell,
body.ttos-theme .main-content,
body.ttos-theme .content,
body.ttos-theme .site-content,
body.ttos-theme section,
body.ttos-theme footer {
  background: transparent !important;
  color: var(--color-text-white) !important;
}

/* Main container discipline */
body.ttos-theme main,
body.ttos-theme .container,
body.ttos-theme .page-shell,
body.ttos-theme .main-content {
  width: min(var(--wide-width), calc(100% - 32px));
  max-width: var(--wide-width);
  margin-left: auto;
  margin-right: auto;
}

/* Header */
body.ttos-theme header,
body.ttos-theme .site-header,
body.ttos-theme nav.site-nav,
body.ttos-theme .top-nav {
  background: rgba(23,27,20,0.72) !important;
  border: 1px solid var(--line-soft) !important;
  border-radius: 18px;
  color: var(--color-text-white) !important;
}

body.ttos-theme nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

body.ttos-theme nav a,
body.ttos-theme header a {
  color: var(--color-text-white) !important;
  text-decoration: none;
}

body.ttos-theme nav a:hover,
body.ttos-theme header a:hover {
  color: var(--color-accent-lime) !important;
}

/* Typography */
body.ttos-theme h1,
body.ttos-theme h2,
body.ttos-theme h3,
body.ttos-theme h4,
body.ttos-theme h5,
body.ttos-theme h6 {
  color: var(--color-text-white) !important;
  line-height: var(--line-height-heading);
}

body.ttos-theme h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7vw, 6.8rem);
  line-height: 0.94;
  letter-spacing: -0.05em;
  margin-top: 0;
  margin-bottom: var(--space-md);
}

body.ttos-theme h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 4vw, 2.45rem);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--line-soft) !important;
}

body.ttos-theme h3,
body.ttos-theme h4 {
  color: var(--color-accent-lime) !important;
}

body.ttos-theme p,
body.ttos-theme li,
body.ttos-theme td,
body.ttos-theme th,
body.ttos-theme small,
body.ttos-theme span {
  color: var(--color-text-muted) !important;
  line-height: var(--line-height-text);
}

body.ttos-theme p,
body.ttos-theme ul,
body.ttos-theme ol,
body.ttos-theme table,
body.ttos-theme pre {
  margin-top: 0;
  margin-bottom: var(--space-md);
}

body.ttos-theme a {
  color: var(--color-accent-lime) !important;
  font-weight: 700;
}

/* Cards and boxes */
body.ttos-theme .card,
body.ttos-theme .ttos-card,
body.ttos-theme .anchor-card,
body.ttos-theme .theme-box,
body.ttos-theme .framework-card,
body.ttos-theme .logic-node,
body.ttos-theme .agent-box,
body.ttos-theme .telemetry-card,
body.ttos-theme .method-box,
body.ttos-theme .protocol-box,
body.ttos-theme .alert-box,
body.ttos-theme article {
  background: var(--color-surface-dark) !important;
  color: var(--color-text-white) !important;
  border: 1px solid var(--line-soft) !important;
  border-left: 4px solid var(--color-accent-lime) !important;
  border-radius: 16px !important;
  padding: var(--space-md) !important;
  box-shadow: none !important;
}

/* Notices and governance boundaries */
body.ttos-theme .notice,
body.ttos-theme .boundary-box,
body.ttos-theme .evidence-box,
body.ttos-theme .callout {
  background: rgba(0,0,0,0.18) !important;
  color: var(--color-text-muted) !important;
  border: 1px solid var(--line-soft) !important;
  border-left: 4px solid var(--color-accent-lime) !important;
  border-radius: 14px !important;
  padding: var(--space-md) !important;
}

/* Kill accidental cream/white drift on these selected pages */
body.ttos-theme .bg-cream,
body.ttos-theme .cream,
body.ttos-theme .bg-white,
body.ttos-theme .white,
body.ttos-theme [style*="#F4EAD5"],
body.ttos-theme [style*="#f4ead5"],
body.ttos-theme [style*="#FCFCFA"],
body.ttos-theme [style*="#fcfcfa"],
body.ttos-theme [style*="#fbfaf7"],
body.ttos-theme [style*="background:#fff"],
body.ttos-theme [style*="background: #fff"],
body.ttos-theme [style*="background-color:#fff"],
body.ttos-theme [style*="background-color: #fff"] {
  background: var(--color-surface-dark) !important;
  background-color: var(--color-surface-dark) !important;
  color: var(--color-text-white) !important;
}

/* Grids */
body.ttos-theme .grid,
body.ttos-theme .theme-grid,
body.ttos-theme .logic-grid,
body.ttos-theme .agent-grid,
body.ttos-theme .telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: var(--space-md);
  margin: var(--space-md) 0 var(--space-lg);
}

/* Tables */
body.ttos-theme table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface-dark) !important;
  color: var(--color-text-white) !important;
  border: 1px solid var(--line-soft) !important;
}

body.ttos-theme th,
body.ttos-theme td {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--line-soft) !important;
  text-align: left;
}

body.ttos-theme th {
  color: var(--color-accent-lime) !important;
  background: rgba(0,0,0,0.2) !important;
}

/* Footer must not remain old style */
body.ttos-theme footer {
  margin-top: var(--space-xl) !important;
  padding: 3rem 1.5rem !important;
  border-top: 1px solid var(--line-soft) !important;
  background: rgba(0,0,0,0.18) !important;
}

body.ttos-theme footer div,
body.ttos-theme footer p,
body.ttos-theme footer small {
  max-width: var(--container-width);
  margin-left: auto;
  margin-right: auto;
  color: rgba(255,255,255,0.7) !important;
}

/* Responsive */
@media (max-width: 900px) {
  body.ttos-theme main,
  body.ttos-theme .container,
  body.ttos-theme .page-shell,
  body.ttos-theme .main-content {
    width: min(100% - 28px, var(--wide-width));
  }
}

@media (max-width: 560px) {
  body.ttos-theme main,
  body.ttos-theme .container,
  body.ttos-theme .page-shell,
  body.ttos-theme .main-content {
    width: min(100% - 22px, var(--wide-width));
  }

  body.ttos-theme h1 {
    font-size: clamp(2.45rem, 13vw, 3.6rem);
  }

  body.ttos-theme nav {
    gap: 0.6rem 0.8rem;
  }

  body.ttos-theme nav a {
    font-size: 0.78rem;
  }

  body.ttos-theme .card,
  body.ttos-theme .ttos-card,
  body.ttos-theme .anchor-card,
  body.ttos-theme .theme-box,
  body.ttos-theme .framework-card,
  body.ttos-theme .logic-node,
  body.ttos-theme .agent-box,
  body.ttos-theme .telemetry-card,
  body.ttos-theme .notice,
  body.ttos-theme .boundary-box,
  body.ttos-theme article {
    padding: 1.05rem !important;
  }
}
