/* =============================================
   base.css  (Foundations: tokens, reset, base elements)
   ============================================= */

/* Design Tokens */
:root {
  --bg: #000000;
  --bg-alt: #0d1117;
  --card: #0f131a;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --brand: #00ffd1;
  --brand-700: #00c7a7;
  --accent: #00e7ff;
  --border: #1b2230;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-soft: 0 0 0 1px rgba(0, 231, 255, 0.08),
    0 0 24px rgba(0, 231, 255, 0.06) inset;
  --font-stack: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Reset */
* {
  box-sizing: border-box;
}
*::before,
*::after {
  box-sizing: inherit;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}
button {
  font-family: inherit;
  cursor: pointer;
}

/* Typography */
h1,
h2,
h3,
h4,
p,
ul,
ol {
  margin: 0 0 12px;
}
h1 {
  font-size: 48px;
  line-height: 1.1;
}
h2 {
  font-size: 30px;
  letter-spacing: 0.02em;
}
h3 {
  font-size: 18px;
  letter-spacing: 0.01em;
}
p {
  line-height: 1.7;
}
ul,
ol {
  padding-left: 18px;
}

/* Container */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
}

/* Sections */
.section {
  padding: 5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  margin: 0 0 1rem;
  scroll-margin-top: 80px;
}
.section.alt {
  background: rgba(0, 0, 0, 0.2);
}
.section h2 {
  position: relative;
  margin-bottom: 2rem;
  font-size: 28px;
}
.section h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 50px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--brand));
  border-radius: 1px;
  box-shadow: 0 0 15px rgba(0, 231, 255, 0.4);
}

/* Utility Lists */
.tick {
  list-style: none;
  padding-left: 0;
  margin: 1rem 0;
}
.tick li {
  position: relative;
  margin: 8px 0;
  padding-left: 22px;
  line-height: 1.6;
}
.tick li::before {
  content: "■";
  position: absolute;
  left: 0;
  top: 2px;
  font-size: 10px;
  color: var(--accent);
}

/* Animations (global) */
@keyframes pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}
@keyframes neonTitleGlow {
  0% {
    filter: drop-shadow(0 0 4px var(--accent));
  }
  100% {
    filter: drop-shadow(0 0 10px var(--brand));
  }
}
@keyframes titlePulseGlow {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

/* Background canvas */
.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
}

/* Footer */
.site-footer {
  padding: 22px 0;
}
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}
.to-top {
  color: var(--accent);
  text-decoration: none;
}
.to-top:hover {
  text-decoration: underline;
}

/* Helpers */
.hidden {
  display: none !important;
}
body.no-scroll {
  overflow: hidden;
}

/* EQUAL HEIGHT CARD SYSTEM - COMPREHENSIVE FIX */
/* Force all grid containers to stretch their children */
.cards,
.kpis,
.grid-2,
.grid-3,
.portfolio-summary,
.strategy-grid,
.metrics-container,
.investment-content,
.eco-cols {
  display: grid !important;
  align-items: stretch !important;
  gap: 1.5rem;
}

/* All card-like elements must fill their container */
.card,
.kpi,
.note,
.chart-wrap,
.sim-panel,
.scenario-chart,
.financial-metrics,
.investment-input,
.accordion .item,
.inputs,
.portfolio-stat,
.strategy-item,
.site-card,
.metric-group,
.metric,
.box-common,
.kpi-item,
.revenue-item,
.breakdown-item,
.eco-cols .col {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start;
  align-items: stretch;
  box-sizing: border-box;
}

/* Specific content alignment for different card types */
.kpi,
.kpi-item,
.metric,
.portfolio-stat {
  justify-content: center !important;
  align-items: center !important;
  text-align: center;
}

/* Ensure card content expands properly */
.card > *:last-child,
.note > *:last-child,
.chart-wrap > *:last-child,
.financial-metrics > *:last-child,
.metric-group > *:last-child {
  margin-bottom: 0;
}

/* List items within cards should not affect card height */
.card ul,
.note ul,
.strategy-item ul,
.metric-group ul {
  flex: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Grid column fixes for left/right alignment */
.grid-2 > div,
.investment-content > div,
.eco-cols .col,
.metrics-container > div {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
  gap: 1.5rem;
}

/* Specific fixes for nested elements that should maintain full height */
/* Previously forced every child to flex:1 which caused oversized boxes and clipped/hidden content.
   Relax this so children size to their content. */
.grid-2 > div > *,
.investment-content > div > *,
.eco-cols .col > *,
.metrics-container > div > * {
  flex: initial;
  min-height: auto;
}

/* Finance/Economics overrides: allow cards to size to content to avoid huge whitespace */
#economics .box-common,
#finance .financial-metrics,
#finance .investment-input,
#finance .investment-content,
#finance .financial-metrics .kpi-list {
  height: auto !important;
  flex: initial;
}

/* Ensure KPI items don't over-reserve width; prevent values from wrapping badly */
#finance .financial-metrics .kpi-list .value {
  min-width: 120px; /* was 160px globally */
  white-space: nowrap;
}

/* GDPR & Legal Footer Styles - Main Website Style */
.legal-footer {
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 0;
  margin-top: 2rem;
  color: var(--muted);
  font-family: var(--font-stack);
  font-size: 0.8rem;
  backdrop-filter: blur(10px);
}

.legal-footer .container {
  max-width: 1120px;
}

/* Compact collapsed state */
.legal-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.5rem 0;
}

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

.legal-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s ease;
}

.legal-link:hover {
  color: var(--brand);
}

.expand-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--muted);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.expand-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.simulation-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  color: #22c55e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Expandable content - hidden by default */
.legal-expanded {
  display: none;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideDown 0.3s ease;
}

.legal-expanded.show {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.legal-section {
  margin-bottom: 1.5rem;
}

.legal-section h4 {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.legal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.legal-item {
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  transition: background 0.2s ease;
}

.legal-item:hover {
  background: rgba(0, 0, 0, 0.4);
}

.legal-item h5 {
  margin: 0 0 0.3rem 0;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
}

.legal-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.disclaimer-content {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.disclaimer-content p {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

.disclaimer-content ul {
  margin: 0.5rem 0 0.5rem 1rem;
  padding: 0;
}

.disclaimer-content li {
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
  line-height: 1.4;
}

.risk-warning {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  padding: 0.75rem;
  margin-top: 0.75rem;
  color: #fecaca;
  font-size: 0.8rem;
  font-weight: 500;
}

.contact-link {
  color: var(--accent);
  text-decoration: none;
}

.contact-link:hover {
  color: var(--brand);
}

/* Modal - simplified */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.modal-body h4 {
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-body ul {
  margin-left: 1rem;
}

.modal-body li {
  margin-bottom: 0.3rem;
}

.modal-body a {
  color: var(--accent);
  text-decoration: none;
}

.modal-body a:hover {
  color: var(--brand);
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
}

.btn {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.btn:hover {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.4);
}

/* Mobile */
@media (max-width: 768px) {
  .legal-compact {
    flex-direction: column;
    align-items: flex-start;
  }

  .legal-links {
    order: 2;
  }

  .expand-toggle {
    order: 1;
    align-self: flex-end;
  }

  .simulation-badge {
    order: 3;
    align-self: center;
  }

  .legal-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .legal-footer {
    padding: 2rem 0 1.5rem;
  }

  .gdpr-section,
  .disclaimer-section {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .legal-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .gdpr-links {
    flex-direction: column;
    gap: 0.75rem;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
    max-height: 90vh;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }

  .simulation-badge {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }
}

/* =============================================
   Page Load Animations (Smooth Entrance)
   ============================================= */

/* Keyframes */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animation Classes - GPU composited for better performance */
.animate-on-load {
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.fade-in {
  animation: fadeIn 0.6s ease-out forwards;
  will-change: opacity;
}

.fade-in-up {
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.fade-in-scale {
  animation: fadeInScale 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.slide-in-left {
  animation: slideInLeft 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.slide-in-right {
  animation: slideInRight 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

/* Stagger delays for sequential animations */
.animate-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.3s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.4s; opacity: 0; }
.animate-delay-5 { animation-delay: 0.5s; opacity: 0; }
.animate-delay-6 { animation-delay: 0.6s; opacity: 0; }

/* Apply to common elements - SMOOTH ENTRANCE (like ebattery.energy) */

/* NO opacity:0 on critical elements - animations handle fade-in */

.cyber-header {
  animation: fadeIn 0.8s ease-out;
}

.hero {
  animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1);
}

section {
  animation: fadeIn 0.8s ease-out;
}

.card,
.cyber-card {
  animation: fadeInScale 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .cyber-header,
  .animate-on-load,
  .fade-in,
  .fade-in-up,
  .fade-in-scale,
  .slide-in-left,
  .slide-in-right,
  .hero,
  section,
  .card,
  .cyber-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
