/* style.css — Ciral Fusion Design Tokens & Component Styles */

/* ============================================
   TYPOGRAPHY: Sora (display) + DM Sans (body)
   Sora: geometric, technical, distinctive - perfect for hard-tech
   DM Sans: clean, readable, premium - optical sizing helps at all scales
   ============================================ */

/* ============================================
   TYPE SCALE — fluid clamp()
   ============================================ */
:root {
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.9rem  + 0.5vw,  1.125rem);
  --text-lg:   clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1rem    + 1.5vw,  2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);
  --text-hero: clamp(3rem,     0.5rem  + 7vw,    8rem);
}

/* ============================================
   4PX SPACING SYSTEM
   ============================================ */
:root {
  --space-1:  0.25rem;  /*  4px */
  --space-2:  0.5rem;   /*  8px */
  --space-3:  0.75rem;  /* 12px */
  --space-4:  1rem;     /* 16px */
  --space-5:  1.25rem;  /* 20px */
  --space-6:  1.5rem;   /* 24px */
  --space-8:  2rem;     /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */
  --space-32: 8rem;     /* 128px */
}

/* ============================================
   CIRAL FUSION PALETTE — LIGHT MODE
   Deep navy/charcoal surfaces, Ciral blue accent
   ============================================ */
:root, [data-theme="light"] {
  /* --- Surfaces (cool slate-white) --- */
  --color-bg:               #f4f5f7;
  --color-surface:          #f8f9fb;
  --color-surface-2:        #ffffff;
  --color-surface-offset:   #eef0f4;
  --color-surface-offset-2: #e8eaef;
  --color-surface-dynamic:  #dde0e8;
  --color-divider:          #d5d8e0;
  --color-border:           #c8ccd6;

  /* --- Text (cool slate) --- */
  --color-text:             #1a1e2a;
  --color-text-muted:       #5a6278;
  --color-text-faint:       #9ba3b8;
  --color-text-inverse:     #f4f5f7;

  /* --- Primary Accent (Ciral Blue) --- */
  --color-primary:          #2C7BE5;
  --color-primary-hover:    #1a65cc;
  --color-primary-active:   #1050a8;
  --color-primary-highlight: #daeafc;

  /* --- Secondary (ice blue - for subtle tints) --- */
  --color-secondary:        #5bc8f5;
  --color-secondary-hover:  #3ab5e8;
  --color-secondary-highlight: #daf4ff;

  /* --- Status colors --- */
  --color-success:          #1a8a5e;
  --color-warning:          #c47a1a;
  --color-error:            #c0392b;

  /* --- Radius --- */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* --- Transitions --- */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-enter: 320ms cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Shadows (cool-tinted for slate surfaces) --- */
  --shadow-sm: 0 1px 2px oklch(0.2 0.02 240 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.02 240 / 0.10);
  --shadow-lg: 0 12px 32px oklch(0.2 0.02 240 / 0.14);

  /* --- Content widths --- */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
  --content-full: 100%;

  /* --- Font families --- */
  --font-display: 'Sora', 'Helvetica Neue', sans-serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ============================================
   DARK MODE — Primary aesthetic for Ciral
   Deep charcoal/navy, dramatic, energy-focused
   ============================================ */
[data-theme="dark"] {
  /* --- Surfaces (deep navy-charcoal, NOT pure black) --- */
  --color-bg:               #0d1117;
  --color-surface:          #131920;
  --color-surface-2:        #161e28;
  --color-surface-offset:   #1c2430;
  --color-surface-offset-2: #1c2430;
  --color-surface-dynamic:  #243040;
  --color-divider:          #1e2a38;
  --color-border:           #263448;

  /* --- Text --- */
  --color-text:             #e2e8f0;
  --color-text-muted:       #8b9bb4;
  --color-text-faint:       #6b7f96;
  --color-text-inverse:     #0d1117;

  /* --- Primary Accent (Ciral Blue — brightened for dark bg) --- */
  --color-primary:          #4a9eff;
  --color-primary-hover:    #2C7BE5;
  --color-primary-active:   #1a65cc;
  --color-primary-highlight: #0f2240;

  /* --- Secondary (ice cyan) --- */
  --color-secondary:        #7dd3fc;
  --color-secondary-hover:  #5bc8f5;
  --color-secondary-highlight: #0a2535;

  /* --- Status colors --- */
  --color-success:          #34d399;
  --color-warning:          #fbbf24;
  --color-error:            #f87171;

  /* --- Shadows (deep for dark mode) --- */
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 16px 48px oklch(0 0 0 / 0.5);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:               #0d1117;
    --color-surface:          #131920;
    --color-surface-2:        #192029;
    --color-surface-offset:   #151c24;
    --color-surface-offset-2: #1c2430;
    --color-surface-dynamic:  #243040;
    --color-divider:          #1e2a38;
    --color-border:           #263448;
    --color-text:             #e2e8f0;
    --color-text-muted:       #7c8fa8;
    --color-text-faint:       #3d4f62;
    --color-text-inverse:     #0d1117;
    --color-primary:          #4a9eff;
    --color-primary-hover:    #2C7BE5;
    --color-primary-active:   #1a65cc;
    --color-primary-highlight: #0f2240;
    --color-secondary:        #7dd3fc;
    --color-secondary-hover:  #5bc8f5;
    --color-secondary-highlight: #0a2535;
    --color-success:          #34d399;
    --color-warning:          #fbbf24;
    --color-error:            #f87171;
    --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.3);
    --shadow-md: 0 4px 16px oklch(0 0 0 / 0.4);
    --shadow-lg: 0 16px 48px oklch(0 0 0 / 0.5);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.container {
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--wide {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--narrow {
  max-width: var(--content-narrow);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* ============================================
   TYPOGRAPHY SYSTEM
   ============================================ */

.font-display {
  font-family: var(--font-display);
}

.text-hero {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.text-display {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.text-heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.text-subheading {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 500;
  line-height: 1.3;
}

.text-body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.65;
}

.text-small {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.6;
}

.text-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============================================
   SCROLL REVEAL ANIMATIONS (CSS-native, no CLS)
   ============================================ */

.fade-in {
  opacity: 1;
}

@supports (animation-timeline: scroll()) {
  .fade-in {
    opacity: 0;
    animation: reveal-fade linear forwards;
    animation-timeline: view();
    animation-range: entry 10% entry 70%;
  }
}

@keyframes reveal-fade {
  to { opacity: 1; }
}

.reveal-clip {
  opacity: 1;
}

@supports (animation-timeline: scroll()) {
  .reveal-clip {
    clip-path: inset(30% 0 0 0 round 4px);
    opacity: 0;
    animation: reveal-clip-anim linear forwards;
    animation-timeline: view();
    animation-range: entry 10% entry 70%;
  }
}

@keyframes reveal-clip-anim {
  to {
    clip-path: inset(0% 0 0 0 round 4px);
    opacity: 1;
  }
}

/* Stagger for child elements */
.stagger-children > * {
  opacity: 1;
}

@supports (animation-timeline: scroll()) {
  .stagger-children > *:nth-child(1) { animation-delay: 0ms; }
  .stagger-children > *:nth-child(2) { animation-delay: 60ms; }
  .stagger-children > *:nth-child(3) { animation-delay: 120ms; }
  .stagger-children > *:nth-child(4) { animation-delay: 180ms; }
  .stagger-children > *:nth-child(5) { animation-delay: 240ms; }
  .stagger-children > * {
    opacity: 0;
    animation: reveal-fade linear forwards;
    animation-timeline: view();
    animation-range: entry 10% entry 70%;
  }
}

/* ============================================
   BUTTON SYSTEM
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background var(--transition-interactive),
    color var(--transition-interactive),
    box-shadow var(--transition-interactive),
    border-color var(--transition-interactive),
    transform var(--transition-interactive);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border: 1px solid transparent;
}
.btn--primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px color-mix(in oklch, var(--color-primary) 40%, transparent);
}
.btn--primary:active {
  transform: translateY(0);
  box-shadow: none;
  background: var(--color-primary-active);
}

.btn--secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn--secondary:hover {
  background: var(--color-primary-highlight);
  transform: translateY(-1px);
}
.btn--secondary:active {
  transform: translateY(0);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
  border-color: var(--color-text-faint);
}

/* ============================================
   CARD SYSTEM
   ============================================ */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow var(--transition-interactive),
    border-color var(--transition-interactive);
}

.card--hover:hover {
  box-shadow: var(--shadow-md);
  border-color: color-mix(in oklch, var(--color-primary) 30%, var(--color-border));
}

/* ============================================
   BADGE / CHIP
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge--primary {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
}

.badge--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* ============================================
   DIVIDER
   ============================================ */

.divider {
  height: 1px;
  background: var(--color-divider);
  border: none;
  margin-block: var(--space-8);
}

/* ============================================
   THEME TOGGLE
   ============================================ */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive);
}
.theme-toggle:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

/* ============================================
   TECH SECTION — MATLAB / Simulink attribution
   ============================================ */

.tech__credibility {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: stretch;
  margin-top: var(--space-12);
}

.tech__credibility .tech__trl,
.tech__credibility .tech__tools {
  margin: 0;
  padding: var(--space-8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-offset, transparent);
}

.tech__credibility .tech__tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-5);
}

@media (max-width: 820px) {
  .tech__credibility {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
}


.tech__tools-logo {
  flex: 0 0 auto;
  width: auto;
  height: 56px;
  max-width: 64px;
  object-fit: contain;
}

.tech__tools-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.tech__tools-primary {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  letter-spacing: 0.01em;
}

.tech__tools-secondary {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 520px) {
  .tech__tools {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .tech__tools-logo {
    height: 44px;
    max-width: 48px;
  }
}
