/* ═══════════════════════════════════════════════════════════════════════════
   CYFEN.CO  —  Carbon G100 Design System
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens (dark theme) ─────────────────────────────────────────── */
:root {
  --cds-background:           #161616;
  --cds-background-secondary: #262626;
  --cds-interactive:          #0f62fe;
  --cds-interactive-hover:    #0353e9;
  --cds-text-primary:         #f4f4f4;
  --cds-text-secondary:       #c6c6c6;
  --cds-link-primary:         #78a9ff;
  --cds-border-subtle:        #393939;
  --cds-support-success:      #42be65;

  --font-sans: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --spacing-sm: 1rem;
  --spacing-md: 2rem;
  --spacing-lg: 4rem;
  --spacing-xl: 8rem;
}

/* ── Light theme overrides ──────────────────────────────────────────────── */
[data-theme="light"] {
  --cds-background:           #ffffff;
  --cds-background-secondary: #f4f4f4;
  --cds-text-primary:         #161616;
  --cds-text-secondary:       #525252;
  --cds-link-primary:         #0f62fe;
  --cds-border-subtle:        #e0e0e0;
  --cds-interactive:          #0f62fe;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* NOTE: overflow-x on html (not body) — setting it on body breaks
   IntersectionObserver in Safari/Firefox by changing the scroll container */
html { overflow-x: clip; }

body {
  background-color: var(--cds-background);
  color: var(--cds-text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; transition: color 0.2s; }
ul { list-style: none; }

/* ── Layout utilities ───────────────────────────────────────────────────── */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.grid            { display: grid; gap: var(--spacing-md); }
.grid-2          { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3          { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.text-center     { text-align: center; }
.text-secondary  { color: var(--cds-text-secondary); }
.bg-alt          { background: var(--cds-background-secondary); }

/* ── Incubation banner ──────────────────────────────────────────────────── */
.incubation-banner {
  background: linear-gradient(90deg, #0f62fe 0%, #78a9ff 50%, #0f62fe 100%);
  background-size: 200% 100%;
  animation: banner-shimmer 3s linear infinite;
  padding: 0.6rem 0;
  text-align: center;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1001;
}

.incubation-banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #fff;
  font-size: 0.875rem;
}

.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--cds-support-success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes banner-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.2); }
}

/* ── Scroll offset for fixed header (prevents section title hiding) ──────── */
section[id] {
  scroll-margin-top: 115px; /* banner ~38px + header 72px + 5px buffer */
}

@media (max-width: 768px) {
  section[id] { scroll-margin-top: 1rem; } /* header is in-flow on mobile */
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  position: fixed;
  top: 38px; /* height of banner */
  width: 100%;
  height: 72px;
  background: rgba(22, 22, 22, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--cds-border-subtle);
  display: flex;
  align-items: center;
  z-index: 1000;
}

[data-theme="light"] header { background: rgba(255, 255, 255, 0.95); }

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.logo-area { display: flex; align-items: center; gap: 0.75rem; }

.logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

/* Show black-bg logo in dark mode (default); hide it in light mode */
.logo-light { display: none; }

[data-theme="light"] .logo-dark  { display: none; }
[data-theme="light"] .logo-light { display: block; }

nav { display: flex; align-items: center; gap: var(--spacing-md); }

nav ul {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
}

nav a {
  font-size: 0.875rem;
  position: relative;
  padding: 0.25rem 0;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--cds-interactive);
  transition: width 0.25s;
}

nav a:not(.btn):hover::after { width: 100%; }

/* ── Theme toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--cds-border-subtle);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cds-text-primary);
  transition: background 0.2s;
}

.theme-toggle:hover { background: var(--cds-background-secondary); }

/* Show moon (dark mode icon) by default; show sun in light mode */
.theme-toggle .sun  { display: none; }

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

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cds-interactive);
  color: #fff;
  padding: 0.625rem 1.25rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--cds-interactive-hover); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--cds-text-primary);
  color: var(--cds-text-primary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--cds-text-primary);
  transform: translateY(-1px);
}

.btn-lg { font-size: 1rem; padding: 0.875rem 2rem; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* override section's padding; top accounts for fixed banner (38px) + header (72px) */
  padding: 110px 0 var(--spacing-xl);
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: var(--cds-background);
  background-image:
    linear-gradient(rgba(15, 98, 254, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 98, 254, 0.08) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: grid-drift 20s linear infinite;
}

[data-theme="light"] .hero-bg { background-color: #f4f4f4; }

/* ── Floating quantum symbols on hero grid ──────────────────────────────── */
.grid-sym {
  position: absolute;
  left: var(--x);
  top:  var(--y);
  font-family: var(--font-mono);
  font-size: var(--s, 1rem);
  font-weight: 300;
  color: var(--cds-interactive);
  pointer-events: none;
  user-select: none;
  animation: sym-drift var(--dur, 9s) ease-in-out var(--d, 0s) infinite;
}

@keyframes sym-drift {
  0%   { opacity: 0;    transform: translateY(0px); }
  20%  { opacity: 0.25; }
  50%  { opacity: 0.12; transform: translateY(-14px); }
  80%  { opacity: 0.25; }
  100% { opacity: 0;    transform: translateY(0px); }
}

/* Slightly more muted on light backgrounds */
[data-theme="light"] .grid-sym { filter: opacity(0.7); }

@keyframes grid-drift {
  0%   { background-position: 0 0; }
  100% { background-position: 50px 50px; }
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 820px;
  animation: fade-up 1s ease-out both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero h1 {
  font-size: clamp(2.25rem, 5vw, 4rem);
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: var(--spacing-sm);
  background: linear-gradient(90deg, var(--cds-text-primary) 40%, var(--cds-link-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.125rem;
  color: var(--cds-text-secondary);
  max-width: 580px;
  margin: 0 auto var(--spacing-md);
}

.hero-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: var(--spacing-md);
}

.tag {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--cds-border-subtle);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .tag { background: rgba(0, 0, 0, 0.04); }

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Section base ────────────────────────────────────────────────────────── */
section {
  padding: var(--spacing-xl) 0;
  border-bottom: 1px solid var(--cds-border-subtle);
}

.section-header { margin-bottom: var(--spacing-lg); }

.section-tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--cds-link-primary);
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 400;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--cds-background-secondary);
  padding: var(--spacing-md);
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: border-color 0.25s, transform 0.25s, background 0.25s;
}

.card:hover {
  border-left-color: var(--cds-interactive);
  transform: translateX(4px);
}

.card-icon {
  display: block;
  width: 32px;
  height: 32px;
  margin-bottom: var(--spacing-sm);
  /* Colorise black Carbon SVG paths → #78a9ff (brand light-blue, dark mode) */
  filter: brightness(0) saturate(100%) invert(67%) sepia(41%) saturate(700%) hue-rotate(195deg);
}

[data-theme="light"] .card-icon {
  /* Colorise black Carbon SVG paths → #0f62fe (brand blue, light mode) */
  filter: brightness(0) saturate(100%) invert(26%) sepia(99%) saturate(1800%) hue-rotate(215deg) brightness(95%);
}

.card h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.card p  { font-size: 0.9rem; color: var(--cds-text-secondary); }

/* ── About layout ────────────────────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  align-items: start;
}

.stat-box {
  border-top: 1px solid var(--cds-border-subtle);
  padding-top: var(--spacing-sm);
  margin-top: var(--spacing-md);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 600;
}

.stat-label { font-size: 0.875rem; color: var(--cds-text-secondary); }

/* ── Research: checklist ─────────────────────────────────────────────────── */
.checklist { list-style: none; margin-top: 2rem; }

.checklist li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  font-size: 0.95rem;
  color: var(--cds-text-secondary);
}

.checklist li svg,
.checklist li img {
  flex-shrink: 0;
  /* Colorise Carbon icon to #78a9ff in dark mode */
  filter: brightness(0) saturate(100%) invert(67%) sepia(41%) saturate(700%) hue-rotate(195deg);
}

[data-theme="light"] .checklist li img {
  filter: brightness(0) saturate(100%) invert(26%) sepia(99%) saturate(1800%) hue-rotate(215deg) brightness(95%);
}

/* ── Research: code block ────────────────────────────────────────────────── */
.code-card {
  background: var(--cds-background-secondary);
  border: 1px solid var(--cds-border-subtle);
  border-radius: 8px;
  padding: 2rem;
}

.code-title {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--cds-text-primary);
  margin-bottom: 1.5rem;
}

.code-block {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.85;
  color: var(--cds-text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.code-block code { font-family: inherit; }
.c-str           { color: var(--cds-link-primary); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  background: #000;
  padding: var(--spacing-lg) 0;
  font-size: 0.875rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.footer-col h4         { color: #fff; font-weight: 600; margin-bottom: var(--spacing-sm); }
.footer-col ul li      { margin-bottom: 0.4rem; }
.footer-col ul li a    { color: #c6c6c6; }
.footer-col ul li a:hover { color: var(--cds-link-primary); text-decoration: underline; }

.copyright {
  border-top: 1px solid var(--cds-border-subtle);
  padding-top: var(--spacing-sm);
  color: #a8a8a8;
  font-size: 0.8125rem;
}

/* ── Scroll reveal ───────────────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Instant visibility for users who prefer reduced motion or have JS disabled */
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.active {
    opacity: 1;
    transform: none;
    transition: none;
  }

  /* Hide drifting symbols — purely decorative, not meaningful */
  .grid-sym { display: none; }
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--cds-background-secondary);
  border: 1px solid var(--cds-border-subtle);
  border-radius: 10px;
  padding: var(--spacing-lg);
  max-width: 480px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--cds-text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

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

.modal h2 { font-size: 1.375rem; margin-bottom: var(--spacing-md); }

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  color: var(--cds-text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--cds-background);
  border: 1px solid var(--cds-border-subtle);
  border-radius: 4px;
  color: var(--cds-text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: 2px solid var(--cds-interactive);
  outline-offset: 0;
  border-color: var(--cds-interactive);
}

.form-group textarea { min-height: 110px; resize: vertical; }

.form-submit { width: 100%; margin-top: 0.5rem; }

.form-success { display: none; text-align: center; padding: var(--spacing-md); }
.form-success.active { display: block; }
.form-success h3 { margin-bottom: 0.5rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  header {
    height: auto;
    top: 0;
    position: relative;
    padding: 0.75rem 0;
  }

  .incubation-banner { position: relative; }

  .nav-container { flex-wrap: wrap; gap: 0.75rem; }

  nav ul { gap: 1rem; flex-wrap: wrap; }

  .hero {
    padding-top: var(--spacing-lg);
    min-height: 80vh;
  }

  .logo-img { height: 36px; }
}

@media (max-width: 480px) {
  :root {
    --spacing-xl: 4rem;
    --spacing-lg: 2.5rem;
  }
}
