/* =============================================
   EVGENY MIKHAYLENKO — Personal Site
   Inspired by pi.website: monospaced, minimal,
   warm cream palette, academic/research feel
   ============================================= */

/* === DESIGN TOKENS === */
:root {
  /* Type scale */
  --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.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Fonts */
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;
  --font-display: 'JetBrains Mono', monospace;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

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

  /* Content widths */
  --content-default: 720px;
  --content-wide: 960px;
}

/* === LIGHT MODE (default, pi.website-inspired) === */
:root,
[data-theme='light'] {
  --color-bg: #f5f3ee;
  --color-surface: #eeece6;
  --color-surface-2: #e8e5de;
  --color-text: #1a1a18;
  --color-text-muted: #6b6a65;
  --color-text-faint: #a8a7a2;
  --color-border: #d5d3cc;
  --color-divider: #dfddd7;
  --color-accent: #1a1a18;
  --color-accent-hover: #3a3a36;
  --color-tag-bg: rgba(26, 26, 24, 0.06);
  --color-tag-border: rgba(26, 26, 24, 0.12);
  --color-marker: #1a1a18;
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 26, 24, 0.06);
}

/* === DARK MODE === */
[data-theme='dark'] {
  --color-bg: #141413;
  --color-surface: #1c1c1a;
  --color-surface-2: #242422;
  --color-text: #d4d3ce;
  --color-text-muted: #8a8985;
  --color-text-faint: #5a5955;
  --color-border: #2e2e2b;
  --color-divider: #252523;
  --color-accent: #d4d3ce;
  --color-accent-hover: #a8a7a2;
  --color-tag-bg: rgba(212, 211, 206, 0.06);
  --color-tag-border: rgba(212, 211, 206, 0.12);
  --color-marker: #d4d3ce;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #141413;
    --color-surface: #1c1c1a;
    --color-surface-2: #242422;
    --color-text: #d4d3ce;
    --color-text-muted: #8a8985;
    --color-text-faint: #5a5955;
    --color-border: #2e2e2b;
    --color-divider: #252523;
    --color-accent: #d4d3ce;
    --color-accent-hover: #a8a7a2;
    --color-tag-bg: rgba(212, 211, 206, 0.06);
    --color-tag-border: rgba(212, 211, 206, 0.12);
    --color-marker: #d4d3ce;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

/* === BASE RESET === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  min-height: 100dvh;
  line-height: 1.7;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color 0.3s ease, color 0.3s ease;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

ul[role='list'], ol[role='list'] {
  list-style: none;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
  line-height: 1.2;
}

p, li, figcaption {
  text-wrap: pretty;
  max-width: 72ch;
}

::selection {
  background: rgba(26, 26, 24, 0.15);
  color: var(--color-text);
}

[data-theme='dark'] ::selection {
  background: rgba(212, 211, 206, 0.2);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

a, button, [role='button'], [role='link'] {
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    opacity var(--transition-interactive);
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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

@media (max-width: 640px) {
  .container {
    padding-inline: var(--space-4);
  }
}

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: oklch(from var(--color-bg) l c h / 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-divider);
  transition: box-shadow 0.3s ease;
}

.header--scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

@media (max-width: 640px) {
  .header-inner {
    padding: var(--space-3) var(--space-4);
  }
}

.logo {
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo:hover {
  opacity: 0.7;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

@media (max-width: 640px) {
  .nav {
    gap: var(--space-3);
  }
}

.nav-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  text-decoration: none;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding: var(--space-1) 0;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-text);
  transition: width 0.3s var(--ease-out);
}

.nav-link:hover {
  color: var(--color-text);
}

.nav-link:hover::after {
  width: 100%;
}

.theme-toggle {
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-tag-bg);
}

/* === HERO === */
.hero {
  padding: clamp(var(--space-16), 8vw, var(--space-32)) 0 clamp(var(--space-12), 6vw, var(--space-24));
  border-bottom: 1px solid var(--color-divider);
}

.hero-content {
  max-width: var(--content-default);
}

.hero-name {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.hero-tagline {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.hero-description {
  margin-bottom: var(--space-8);
}

.hero-description p {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.8;
  max-width: 62ch;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-tag-border);
  border-radius: var(--radius-sm);
  background: var(--color-tag-bg);
  white-space: nowrap;
}

/* === SECTIONS === */
.section {
  padding: clamp(var(--space-12), 6vw, var(--space-24)) 0;
  border-bottom: 1px solid var(--color-divider);
}

.section--alt {
  background: var(--color-surface);
}

.section--contact {
  border-bottom: none;
}

.section-title {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: clamp(var(--space-8), 4vw, var(--space-16));
  letter-spacing: -0.01em;
}

/* === TIMELINE === */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 0;
  width: 1px;
  background: var(--color-divider);
}

.timeline-item {
  position: relative;
  padding-bottom: clamp(var(--space-8), 4vw, var(--space-12));
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: calc(-1 * var(--space-8) + 1px);
  top: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-marker);
  z-index: 1;
}

.timeline-item:first-child .timeline-marker {
  box-shadow: 0 0 0 3px var(--color-bg), 0 0 0 5px var(--color-marker);
}

.timeline-content {
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}

.timeline-content:hover {
  border-color: var(--color-text-faint);
  box-shadow: var(--shadow-sm);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.role-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.company {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.role-highlight {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-tag-bg);
  border-left: 2px solid var(--color-text-faint);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.achievements {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.achievements li {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.7;
  padding-left: var(--space-4);
  position: relative;
}

.achievements li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--color-text-faint);
}

/* === EDUCATION === */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-10);
}

.edu-card {
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.edu-period {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-faint);
  margin-bottom: var(--space-3);
}

.edu-school {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.edu-full {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.6;
}

.edu-degree {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text);
}

.subsection-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.lang-list {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.lang-item {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text);
}

.lang-level {
  color: var(--color-text-faint);
}

/* === CONTACT === */
.section--contact {
  padding-bottom: clamp(var(--space-16), 8vw, var(--space-32));
}

.contact-text {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
  max-width: 50ch;
  line-height: 1.8;
}

.contact-links {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.contact-link:hover {
  border-color: var(--color-text);
  background: var(--color-surface-2);
}

.contact-link:active {
  transform: translateY(1px);
}

.contact-link svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* === FOOTER === */
.footer {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-divider);
}

.footer-text {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-faint);
}

/* === SCROLL ANIMATIONS === */
.fade-in {
  opacity: 1;
}

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

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

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .hero-name {
    font-size: clamp(1.75rem, 1rem + 3vw, 2.5rem);
  }

  .hero-tagline {
    font-size: var(--text-base);
  }

  .timeline {
    padding-left: var(--space-6);
  }

  .timeline-marker {
    left: calc(-1 * var(--space-6) + 1px);
  }

  .timeline-header {
    flex-direction: column;
    gap: var(--space-1);
  }

  .timeline-content {
    padding: var(--space-4);
  }

  .nav {
    gap: var(--space-2);
  }

  .nav-link {
    font-size: 0.7rem;
  }

  .contact-links {
    flex-direction: column;
  }

  .contact-link {
    justify-content: center;
  }
}

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