@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap');

:root {
  /* --- PALETTE: BIOSPHERE --- */
  --bio-deep-moss: #0c1915;
  --bio-abyss: #020617;
  --bio-void: #000000;

  --bio-glass-light: rgba(255, 255, 255, 0.7);
  --bio-glass-dark: rgba(12, 25, 21, 0.7);
  --bio-surface-light: #ffffff;
  --bio-surface-dark: #0f1c19;

  --energy-algae: #10b981;
  --energy-algae-dim: #059669;
  --energy-algae-glow: rgba(16, 185, 129, 0.4);

  --energy-solar: #fbbf24;
  --energy-solar-glow: rgba(251, 191, 36, 0.4);

  --energy-alert: #ef4444;

  /* TEXTURE */
  --mesh-doc: radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(251, 191, 36, 0.1) 0px, transparent 50%);

  /* SEMANTIC MAPPING (Default to Light Bio-Tech) */
  --bg-app: #f1f5f9;
  /* Darkened from f8fafc for better contrast */
  --bg-app-texture: var(--mesh-doc);
  --bg-surface: var(--bio-surface-light);
  --bg-glass: rgba(255, 255, 255, 0.85);
  /* Increased opacity */

  --border-subtle: rgba(16, 185, 129, 0.25);
  /* Increased contrast */
  --border-highlight: var(--energy-algae);

  --text-primary: #022c22;
  --text-secondary: #1e293b;
  /* Darkened for readability */
  --text-tertiary: #64748b;

  --accent-primary: var(--bio-deep-moss);
  --text-on-accent: #ffffff;

  /* SHAPE & PHYSICS */
  --radius-pane: 24px;
  --radius-node: 16px;
  --radius-pill: 999px;

  --max-content-width: 1400px;
  /* Default to Boxed */
  --ease-organic: cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* CINEMATIC / BIO-MODE */
body.bio-mode {
  --bg-app: var(--bio-deep-moss);
  --bg-app-texture: radial-gradient(circle at 50% 50%, #132a24 0%, #0c1915 100%);
  --bg-surface: #11241f;
  --bg-glass: rgba(17, 36, 31, 0.8);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --text-primary: #ecfdf5;
  --text-secondary: #a7f3d0;
  --text-tertiary: #6ee7b7;
  --accent-primary: var(--energy-algae);
  --text-on-accent: #022c22;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-app);
  background-image: var(--bg-app-texture);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s var(--ease-organic), color 0.5s var(--ease-organic);
}

body.wide-view {
  --max-content-width: 100vw;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem 1.5rem;
  gap: 1.5rem;
  transition: max-width 0.4s var(--ease-organic);
}

/* TOP HEADER */
#top-nav {
  height: 64px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius-pane) var(--radius-pane);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--energy-algae);
  border-radius: 4px;
  box-shadow: 0 0 10px var(--energy-algae-glow);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

#nav-wrapper {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

@media (min-width: 1025px) {
  .nav-links {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s var(--ease-organic);
}

.nav-item:hover {
  background: rgba(16, 185, 129, 0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--energy-algae);
  color: white;
  box-shadow: 0 5px 15px var(--energy-algae-glow);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.btn-login {
  background: var(--accent-primary);
  color: white;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  transition: transform 0.2s;
}

.btn-login:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* SIDEBAR REMOVAL - REPLACED BY TOP NAV */
#sidebar {
  display: none;
}

/* MAIN CONTENT */
#main-viewport {
  flex: 1;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-pane);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
  overflow: visible;
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
}

.view-section {
  flex: 1;
  padding: 4rem;
  display: none;
  animation: slideUp 0.6s var(--ease-organic);
}

.view-section.active {
  display: block;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* TYPOGRAPHY */
h2 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

.subtitle {
  display: none;
  /* Removed as per user request */
}

.outcome-heading {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  text-transform: none;
  /* Corporate level, not uppercase unless specified */
}

.interpretive-note {
  border-left: 6px solid var(--energy-algae);
  background: rgba(16, 185, 129, 0.05);
  padding: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border-radius: 0 var(--radius-node) var(--radius-node) 0;
}

.interpretive-note strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
}

p {
  font-family: 'Inter', sans-serif;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* CARDS */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

/* Ensure grid children don't overflow their containers */
.grid>* {
  min-width: 0;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-node);
  padding: 2rem;
  transition: all 0.4s var(--ease-organic);
  position: relative;
  overflow: hidden;
  /* Prevent inner content overflow */
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--energy-algae);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
}

.card h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  /* Increased emphasis */
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  font-weight: 700;
}

/* SCENARIO BUTTONS */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-preset {
  padding: 0.75rem;
  border-radius: var(--radius-node);
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn-preset:hover {
  border-color: var(--energy-algae);
  background: rgba(16, 185, 129, 0.05);
}

.btn-preset.active {
  background: var(--energy-algae);
  color: white;
  border-color: var(--energy-algae);
}

/* FOOTER / TOGGLES */
.sidebar-footer {
  display: none;
  /* Moved to top nav or footer */
}

#global-footer {
  padding: 2rem 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--energy-algae);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

/* MOBILE / TABLET OPTIMIZATION */
@media (max-width: 1024px) {
  #top-nav {
    padding: 0 1.5rem;
  }

  /* Desktop Grid Specifics */
  @media (min-width: 1025px) {
    #clients #map {
      grid-row: span 2;
    }

    #clients #logistics-controls {
      grid-column: 2;
    }

    #clients #logistics-note {
      grid-column: 2;
    }
  }

  .mobile-toggle {
    display: block;
    z-index: 1001;
  }

  #nav-wrapper {
    position: fixed;
    top: 64px;
    left: 0;
    width: 100%;
    height: 0;
    background: var(--bg-surface);
    flex-direction: column;
    justify-content: flex-start;
    padding: 0;
    overflow: hidden;
    transition: all 0.5s var(--ease-organic);
    z-index: 1000;
    border-bottom: 0px solid var(--border-subtle);
    opacity: 0;
    pointer-events: none;
  }

  #nav-wrapper.open {
    height: calc(100vh - 64px);
    padding: 3rem 2rem;
    opacity: 1;
    pointer-events: auto;
    border-bottom: 1px solid var(--border-subtle);
  }

  .nav-links {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
    margin-bottom: 2.5rem;
  }

  .nav-links .nav-item {
    width: 100%;
    justify-content: center;
    padding: 1.25rem;
    font-size: 1.1rem;
    border-radius: var(--radius-node);
  }

  .nav-controls {
    flex-direction: column;
    width: 100%;
    gap: 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
  }

  .nav-controls .theme-toggle {
    width: 100%;
    padding: 0 1rem;
  }

  .nav-controls .btn-login {
    width: 100%;
    justify-content: center;
    padding: 1.25rem;
    margin-top: 1rem;
  }

  #app-container {
    padding: 0.5rem;
    gap: 1rem;
  }

  #sidebar {
    width: 80px;
    padding: 2rem 0.5rem;
    align-items: center;
  }


  #main-viewport {
    border-radius: 16px;
  }

  .view-section {
    padding: 2rem 1.5rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  /* Section-Specific Stacking */
  #clients .grid,
  #investors .grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }

  #clients #map {
    height: 450px !important;
    order: 2;
    grid-row: auto !important;
    grid-column: auto !important;
  }

  #clients #logistics-controls {
    order: 1;
    grid-row: auto !important;
    grid-column: auto !important;
  }

  #clients #logistics-note {
    order: 3;
    margin-top: 0;
    grid-row: auto !important;
    grid-column: auto !important;
  }

  #investors .card {
    height: auto !important;
  }
}