/* ═══════════════════════════════════════════════════════════════════════════
   鏡 Kagami Gallery — EFE-Optimized Design System
   
   Principles:
   - Minimize visual entropy while maximizing information clarity
   - Every pixel intentional, every interaction rewarding
   - Dark void canvas with luminous focal points
   - Fibonacci-based rhythm in all temporal elements
   
   h(x) ≥ 0. Always.
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'IBM Plex Sans';
  font-display: swap;
  src: local('IBM Plex Sans');
}

:root {
  /* ═══ Void Canvas ═══ */
  --void-absolute: #030305;
  --void: #050508;
  --void-soft: #08080c;
  --surface: #0c0c12;
  --surface-elevated: #101018;
  --card: #14141e;
  --card-hover: #18182a;
  
  /* ═══ Colony Spectrum ═══ */
  --spark: #ff6b6b;
  --spark-glow: rgba(255, 107, 107, 0.15);
  --forge: #ff9f43;
  --forge-glow: rgba(255, 159, 67, 0.15);
  --flow: #feca57;
  --flow-glow: rgba(254, 202, 87, 0.15);
  --nexus: #1dd1a1;
  --nexus-glow: rgba(29, 209, 161, 0.12);
  --beacon: #54a0ff;
  --beacon-glow: rgba(84, 160, 255, 0.15);
  --grove: #5f27cd;
  --grove-glow: rgba(95, 39, 205, 0.15);
  --crystal: #a55eea;
  --crystal-glow: rgba(165, 94, 234, 0.15);
  
  /* ═══ Gold Accent ═══ */
  --gold: #d4a84b;
  --gold-bright: #f0d78c;
  --gold-dim: #9a7832;
  --gold-subtle: rgba(212, 168, 75, 0.08);
  --gold-glow: rgba(212, 168, 75, 0.2);
  
  /* ═══ Text Luminance ═══ */
  --text-luminous: rgba(255, 255, 255, 0.97);
  --text-bright: rgba(255, 255, 255, 0.88);
  --text-primary: rgba(255, 255, 255, 0.76);
  --text-secondary: rgba(255, 255, 255, 0.52);
  --text-tertiary: rgba(255, 255, 255, 0.32);
  --text-hint: rgba(255, 255, 255, 0.18);
  
  /* ═══ Typography ═══ */
  --font-display: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
  
  /* ═══ Spacing (8px base) ═══ */
  --s1: 0.25rem;  /* 4px */
  --s2: 0.5rem;   /* 8px */
  --s3: 0.75rem;  /* 12px */
  --s4: 1rem;     /* 16px */
  --s5: 1.5rem;   /* 24px */
  --s6: 2rem;     /* 32px */
  --s8: 3rem;     /* 48px */
  --s10: 4rem;    /* 64px */
  --s12: 5rem;    /* 80px */
  --s16: 8rem;    /* 128px */
  
  /* ═══ Fibonacci Motion ═══ */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-micro: 55ms;
  --t-fast: 89ms;
  --t-normal: 144ms;
  --t-slow: 233ms;
  --t-slower: 377ms;
  --t-slowest: 610ms;
  
  /* ═══ Surfaces ═══ */
  --border-invisible: rgba(255, 255, 255, 0.02);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-default: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.1);
  --border-active: rgba(212, 168, 75, 0.4);
  
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--void);
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--gold);
  color: var(--void);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Focus & Accessibility
   ═══════════════════════════════════════════════════════════════════════════ */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--void);
  padding: var(--s3) var(--s5);
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  z-index: 10000;
  transition: top var(--t-normal) var(--ease-out-expo);
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   Hero
   ═══════════════════════════════════════════════════════════════════════════ */

.hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s16) var(--s5);
  overflow: hidden;
}

/* Ambient glow */
.hero::before {
  content: '';
  position: absolute;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 150vw);
  height: min(900px, 150vw);
  background: radial-gradient(
    ellipse at center,
    var(--gold-glow) 0%,
    rgba(212, 168, 75, 0.06) 30%,
    transparent 60%
  );
  pointer-events: none;
  animation: hero-breathe 12s ease-in-out infinite;
}

@keyframes hero-breathe {
  0%, 100% { 
    opacity: 0.7; 
    transform: translateX(-50%) scale(1);
  }
  50% { 
    opacity: 1; 
    transform: translateX(-50%) scale(1.08);
  }
}

/* Kanji mark */
.hero-mark {
  position: relative;
  margin-bottom: var(--s6);
}

.hero-kanji {
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: 0.15em;
  background: linear-gradient(
    165deg,
    var(--gold-bright) 0%,
    var(--gold) 40%,
    var(--gold-dim) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 60px var(--gold-glow));
  animation: kanji-glow 6s ease-in-out infinite;
}

@keyframes kanji-glow {
  0%, 100% { filter: drop-shadow(0 0 60px var(--gold-glow)) brightness(1); }
  50% { filter: drop-shadow(0 0 80px var(--gold-glow)) brightness(1.1); }
}

.hero-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-luminous);
  margin-bottom: var(--s3);
}

.hero-subtitle {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
  max-width: 32ch;
  text-align: center;
  line-height: 1.7;
}

/* Stats */
.stats {
  display: flex;
  gap: var(--s6);
  margin-top: var(--s10);
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  text-align: center;
  padding: var(--s4) var(--s5);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  min-width: 100px;
  transition: all var(--t-slow) var(--ease-out-expo);
  cursor: default;
}

.stat:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.02)
  );
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: var(--s1);
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
}

/* Colony colors */
.c-gold { color: var(--gold); }
.c-spark { color: var(--spark); }
.c-forge { color: var(--forge); }
.c-flow { color: var(--flow); }
.c-nexus { color: var(--nexus); }
.c-beacon { color: var(--beacon); }
.c-grove { color: var(--grove); }
.c-crystal { color: var(--crystal); }

/* ═══════════════════════════════════════════════════════════════════════════
   Navigation
   ═══════════════════════════════════════════════════════════════════════════ */

nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(5, 5, 8, 0.88);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s3) var(--s4);
  gap: var(--s1);
  flex-wrap: wrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  font-size: 0.8125rem;
  font-weight: 450;
  color: var(--text-tertiary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease-out-expo);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
  color: var(--gold);
  background: var(--gold-subtle);
  border-color: rgba(212, 168, 75, 0.15);
}

.nav-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Main Layout
   ═══════════════════════════════════════════════════════════════════════════ */

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--s10) var(--s5) var(--s16);
}

section {
  margin-bottom: var(--s12);
  scroll-margin-top: 100px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Section Header
   ═══════════════════════════════════════════════════════════════════════════ */

.section-header {
  display: flex;
  align-items: flex-start;
  gap: var(--s4);
  margin-bottom: var(--s5);
}

.section-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.section-text h2 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: var(--s1);
  letter-spacing: -0.01em;
}

.section-text p {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.section-text code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  margin-right: var(--s2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   App Card
   ═══════════════════════════════════════════════════════════════════════════ */

.app-card {
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--t-slow) var(--ease-out-expo);
}

.app-card:hover {
  border-color: var(--border-hover);
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.3),
    0 0 0 1px var(--border-hover);
}

.app-header {
  padding: var(--s5) var(--s6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s5);
  flex-wrap: wrap;
}

.app-header h3 {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-luminous);
  margin-bottom: var(--s2);
  letter-spacing: -0.01em;
}

.app-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 52ch;
}

/* Tech badges */
.tech-stack {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.badge {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  font-weight: 500;
  padding: var(--s1) var(--s3);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.badge-swift { background: var(--spark-glow); color: var(--spark); border-color: rgba(255, 107, 107, 0.2); }
.badge-kotlin { background: var(--crystal-glow); color: var(--crystal); border-color: rgba(165, 94, 234, 0.2); }
.badge-rust { background: var(--forge-glow); color: var(--forge); border-color: rgba(255, 159, 67, 0.2); }
.badge-ts { background: var(--beacon-glow); color: var(--beacon); border-color: rgba(84, 160, 255, 0.2); }
.badge-js { background: var(--flow-glow); color: var(--flow); border-color: rgba(254, 202, 87, 0.2); }
.badge-py { background: var(--nexus-glow); color: var(--nexus); border-color: rgba(29, 209, 161, 0.2); }

/* ═══════════════════════════════════════════════════════════════════════════
   App Content
   ═══════════════════════════════════════════════════════════════════════════ */

.app-content {
  padding: var(--s5) var(--s6);
}

/* Function blocks */
.fn-section {
  margin-bottom: var(--s6);
}

.fn-section:last-child {
  margin-bottom: 0;
}

.fn-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.fn-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-subtle), transparent);
}

.fn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s3);
}

.fn-item {
  padding: var(--s3) var(--s4);
  background: var(--surface-elevated);
  border: 1px solid var(--border-invisible);
  border-radius: var(--radius-md);
  transition: all var(--t-fast) var(--ease-out-expo);
  cursor: default;
}

.fn-item:hover {
  background: var(--card);
  border-color: var(--border-subtle);
  transform: translateY(-1px);
}

.fn-name {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: var(--s1);
}

.fn-desc {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Status Indicators
   ═══════════════════════════════════════════════════════════════════════════ */

.status-grid {
  margin-top: var(--s5);
  padding-top: var(--s5);
  border-top: 1px solid var(--border-subtle);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s2) 0;
  font-size: 0.8125rem;
}

.status-row:not(:last-child) {
  border-bottom: 1px solid var(--border-invisible);
}

.status-label {
  color: var(--text-secondary);
  font-weight: 450;
}

.status-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: var(--s1) var(--s3);
  border-radius: var(--radius-xs);
}

.status-ok {
  color: var(--nexus);
  background: var(--nexus-glow);
}

.status-partial {
  color: var(--flow);
  background: var(--flow-glow);
}

.status-adapter {
  color: var(--spark);
  background: var(--spark-glow);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════════════════════════ */

footer {
  text-align: center;
  padding: var(--s12) var(--s5);
  border-top: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, transparent, rgba(212, 168, 75, 0.02));
}

.footer-kanji {
  font-size: 4rem;
  font-weight: 200;
  color: var(--gold-dim);
  line-height: 1;
  margin-bottom: var(--s4);
  opacity: 0.6;
}

footer p {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-bottom: var(--s2);
}

footer .safety {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--nexus);
  opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════════════════════ */

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

.animate {
  animation: fade-up var(--t-slower) var(--ease-out-expo) both;
}

.delay-1 { animation-delay: 55ms; }
.delay-2 { animation-delay: 89ms; }
.delay-3 { animation-delay: 144ms; }
.delay-4 { animation-delay: 233ms; }
.delay-5 { animation-delay: 377ms; }

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hero {
    min-height: 60vh;
    padding: var(--s10) var(--s4);
  }
  
  .stats {
    gap: var(--s3);
  }
  
  .stat {
    min-width: 80px;
    padding: var(--s3) var(--s4);
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .section-header {
    flex-direction: column;
    gap: var(--s3);
  }
  
  .app-header {
    padding: var(--s4);
    flex-direction: column;
  }
  
  .app-content {
    padding: var(--s4);
  }
  
  .fn-grid {
    grid-template-columns: 1fr;
  }
}
