/* ========================================
   HYPER MODERN CSS - 2025 Edition
   ======================================== */

/* Modern CSS Layers for cascade control */
@layer reset, tokens, base, components, utilities;

/* ========================================
   Design Tokens (CSS Custom Properties)
   ======================================== */
@layer tokens {
  :root {
    /* Modern color palette using oklch for perceptual uniformity */
    --hue-primary: 195;
    --hue-accent: 280;

    /* Primary colors */
    --primary-50: oklch(97% 0.02 var(--hue-primary));
    --primary-100: oklch(93% 0.04 var(--hue-primary));
    --primary-200: oklch(85% 0.08 var(--hue-primary));
    --primary-300: oklch(75% 0.12 var(--hue-primary));
    --primary-400: oklch(65% 0.15 var(--hue-primary));
    --primary-500: oklch(55% 0.18 var(--hue-primary));
    --primary-600: oklch(45% 0.15 var(--hue-primary));
    --primary-700: oklch(35% 0.12 var(--hue-primary));

    /* Accent gradient */
    --accent-start: oklch(70% 0.25 var(--hue-primary));
    --accent-end: oklch(60% 0.3 var(--hue-accent));

    /* Surface colors - dark theme */
    --bg-base: oklch(12% 0.02 var(--hue-primary));
    --bg-surface: oklch(16% 0.02 var(--hue-primary));
    --bg-elevated: oklch(20% 0.02 var(--hue-primary));
    --bg-overlay: oklch(24% 0.02 var(--hue-primary));

    /* Glass effect colors */
    --glass-bg: oklch(20% 0.02 var(--hue-primary) / 0.6);
    --glass-border: oklch(50% 0.05 var(--hue-primary) / 0.15);
    --glass-highlight: oklch(100% 0 0 / 0.05);

    /* Text colors */
    --text-primary: oklch(95% 0.01 var(--hue-primary));
    --text-secondary: oklch(75% 0.02 var(--hue-primary));
    --text-muted: oklch(55% 0.02 var(--hue-primary));

    /* Semantic colors */
    --success: oklch(70% 0.2 145);
    --warning: oklch(75% 0.2 85);
    --error: oklch(65% 0.25 25);

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 3rem;
    --space-10: 4rem;
    --space-12: 6rem;

    /* Typography 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.9rem + 0.5vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.25rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
    --text-3xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
    --text-4xl: clamp(2.5rem, 2rem + 3vw, 4rem);

    /* Font stacks */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, 'Courier New', monospace;

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

    /* Shadows - layered for depth */
    --shadow-sm:
      0 1px 2px oklch(0% 0 0 / 0.1),
      0 1px 3px oklch(0% 0 0 / 0.08);
    --shadow-md:
      0 4px 6px oklch(0% 0 0 / 0.1),
      0 2px 4px oklch(0% 0 0 / 0.06),
      0 10px 20px oklch(0% 0 0 / 0.1);
    --shadow-lg:
      0 10px 25px oklch(0% 0 0 / 0.15),
      0 5px 10px oklch(0% 0 0 / 0.08),
      0 20px 40px oklch(0% 0 0 / 0.2);
    --shadow-glow:
      0 0 20px oklch(70% 0.2 var(--hue-primary) / 0.3),
      0 0 40px oklch(60% 0.15 var(--hue-primary) / 0.2);

    /* Transitions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Container */
    --container-max: 72rem;
    --container-padding: clamp(1rem, 5vw, 2rem);
  }
}

/* ========================================
   Reset Layer
   ======================================== */
@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    hanging-punctuation: first last;
  }

  body {
    min-height: 100dvh;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

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

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

  p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
    text-wrap: balance;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  ul, ol {
    list-style: none;
  }
}

/* ========================================
   Base Styles
   ======================================== */
@layer base {
  body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-base);

    /* Animated gradient background */
    background-image:
      radial-gradient(ellipse 80% 50% at 50% -20%, oklch(30% 0.1 var(--hue-primary) / 0.3), transparent),
      radial-gradient(ellipse 60% 40% at 100% 100%, oklch(25% 0.15 var(--hue-accent) / 0.2), transparent),
      radial-gradient(ellipse 50% 30% at 0% 80%, oklch(30% 0.1 var(--hue-primary) / 0.15), transparent);
    background-attachment: fixed;
  }

  ::selection {
    background: oklch(60% 0.2 var(--hue-primary) / 0.4);
    color: var(--text-primary);
  }

  /* Focus styles */
  :focus-visible {
    outline: 2px solid var(--accent-start);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
  }

  /* Typography */
  h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
  }

  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }

  a {
    color: var(--accent-start);
    transition: color var(--duration-fast) var(--ease-out-expo);

    &:hover {
      color: var(--accent-end);
      text-decoration: underline;
      text-decoration-thickness: 2px;
      text-underline-offset: 4px;
    }
  }

  .muted {
    color: var(--text-secondary);
  }
}

/* ========================================
   Components
   ======================================== */
@layer components {
  /* Container */
  .container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-padding);
  }

  /* Header - Hero section */
  header {
    position: relative;
    text-align: center;
    padding-block: var(--space-12);
    padding-top: calc(var(--space-12) + 60px); /* Extra space for language switcher */
    overflow: visible;

    /* Modern gradient mesh background */
    background:
      linear-gradient(135deg, var(--bg-base) 0%, transparent 50%),
      linear-gradient(225deg, oklch(25% 0.15 var(--hue-accent) / 0.5) 0%, transparent 50%),
      linear-gradient(315deg, oklch(30% 0.2 var(--hue-primary) / 0.6) 0%, transparent 50%),
      var(--bg-surface);

    /* Animated gradient border */
    &::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 2px;
      background: linear-gradient(90deg,
        transparent,
        var(--accent-start),
        var(--accent-end),
        var(--accent-start),
        transparent
      );
      background-size: 200% 100%;
      animation: shimmer 3s linear infinite;
    }

    h1 {
      font-size: var(--text-4xl);
      font-weight: 800;
      letter-spacing: -0.03em;
      margin-bottom: var(--space-3);

      /* Gradient text */
      background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-start) 50%, var(--accent-end) 100%);
      background-clip: text;
      -webkit-background-clip: text;
      color: transparent;

      /* Text glow */
      filter: drop-shadow(0 0 30px oklch(70% 0.2 var(--hue-primary) / 0.3));
    }

    p {
      font-size: var(--text-lg);
      color: var(--text-secondary);
      max-width: 50ch;
      margin-inline: auto;
    }
  }

  /* Sections - Glass cards */
  section {
    position: relative;
    margin-block: var(--space-6);
    padding: var(--space-6);

    /* Glassmorphism effect */
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);

    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);

    /* Layered shadow for depth */
    box-shadow:
      var(--shadow-md),
      inset 0 1px 0 var(--glass-highlight),
      inset 0 -1px 0 oklch(0% 0 0 / 0.1);

    /* Hover effect */
    transition:
      transform var(--duration-normal) var(--ease-out-expo),
      box-shadow var(--duration-normal) var(--ease-out-expo);

    &:hover {
      transform: translateY(-4px);
      box-shadow:
        var(--shadow-lg),
        var(--shadow-glow),
        inset 0 1px 0 var(--glass-highlight);
    }

    /* Section title styling */
    & > h2 {
      display: flex;
      align-items: center;
      gap: var(--space-3);
      padding-bottom: var(--space-4);
      margin-bottom: var(--space-5);
      border-bottom: 1px solid var(--glass-border);

      /* Gradient underline effect */
      position: relative;

      &::after {
        content: '';
        position: absolute;
        bottom: -1px;
        left: 0;
        width: 60px;
        height: 3px;
        background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
        border-radius: var(--radius-full);
      }
    }

    h3 {
      color: var(--text-primary);
      margin-top: var(--space-5);
      margin-bottom: var(--space-3);

      &:first-of-type {
        margin-top: 0;
      }
    }
  }

  /* Roast section - special styling */
  section.roast {
    background: linear-gradient(135deg,
      oklch(25% 0.15 40 / 0.6) 0%,
      oklch(20% 0.1 30 / 0.6) 100%
    );
    border-left: 4px solid var(--warning);

    &::before {
      content: '';
      position: absolute;
      inset: 0;
      background: radial-gradient(ellipse at top right, oklch(60% 0.2 40 / 0.1), transparent 70%);
      border-radius: inherit;
      pointer-events: none;
    }
  }

  /* Grid layout */
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: var(--space-6);
  }

  /* Lists */
  ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  li {
    position: relative;
    padding-left: var(--space-6);
    color: var(--text-secondary);

    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0.6em;
      width: 8px;
      height: 8px;
      background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
      border-radius: 50%;
      box-shadow: 0 0 10px oklch(70% 0.2 var(--hue-primary) / 0.4);
    }
  }

  /* Pills / Tags */
  .pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    margin: var(--space-1) var(--space-2) var(--space-1) 0;

    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);

    background: linear-gradient(135deg,
      oklch(25% 0.05 var(--hue-primary) / 0.8),
      oklch(20% 0.03 var(--hue-primary) / 0.8)
    );
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);

    backdrop-filter: blur(10px);
    transition: all var(--duration-fast) var(--ease-out-expo);

    &:hover {
      background: linear-gradient(135deg,
        oklch(30% 0.08 var(--hue-primary) / 0.9),
        oklch(25% 0.05 var(--hue-primary) / 0.9)
      );
      border-color: var(--accent-start);
      transform: translateY(-2px);
      box-shadow: 0 4px 12px oklch(0% 0 0 / 0.2);
    }
  }

  /* Buttons */
  a.button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    margin-top: var(--space-4);
    margin-right: var(--space-3);

    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--bg-base);

    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    border: none;
    border-radius: var(--radius-lg);

    box-shadow:
      0 4px 15px oklch(60% 0.2 var(--hue-primary) / 0.3),
      inset 0 1px 0 oklch(100% 0 0 / 0.2);

    transition: all var(--duration-normal) var(--ease-out-back);

    &:hover {
      transform: translateY(-3px) scale(1.02);
      box-shadow:
        0 8px 25px oklch(60% 0.2 var(--hue-primary) / 0.4),
        0 0 30px oklch(60% 0.2 var(--hue-primary) / 0.2),
        inset 0 1px 0 oklch(100% 0 0 / 0.3);
      text-decoration: none;
    }

    &:active {
      transform: translateY(-1px) scale(0.98);
    }
  }

  /* Experience items */
  .xp-item {
    position: relative;
    padding: var(--space-5);
    margin-bottom: var(--space-5);

    background: oklch(18% 0.02 var(--hue-primary) / 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);

    transition: all var(--duration-normal) var(--ease-out-expo);

    /* Timeline connector */
    &::before {
      content: '';
      position: absolute;
      left: -20px;
      top: 50%;
      width: 12px;
      height: 12px;
      background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
      border-radius: 50%;
      transform: translateY(-50%);
      box-shadow: 0 0 15px oklch(70% 0.2 var(--hue-primary) / 0.5);
    }

    &:hover {
      background: oklch(22% 0.03 var(--hue-primary) / 0.6);
      border-color: oklch(50% 0.1 var(--hue-primary) / 0.3);
      transform: translateX(8px);
    }

    h3 {
      margin: 0 0 var(--space-2) 0;
      font-size: var(--text-lg);
    }

    .xp-meta {
      font-size: var(--text-sm);
      color: var(--text-muted);
      margin-bottom: var(--space-3);
    }

    p:last-child {
      color: var(--text-secondary);
      margin: 0;
    }
  }

  /* Experience container with timeline */
  #xp-container {
    position: relative;
    padding-left: var(--space-6);

    &::before {
      content: '';
      position: absolute;
      left: 6px;
      top: 0;
      bottom: 0;
      width: 2px;
      background: linear-gradient(180deg,
        var(--accent-start),
        var(--accent-end) 50%,
        var(--glass-border)
      );
      border-radius: var(--radius-full);
    }
  }

  /* Language Switcher */
  .lang-switcher {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    display: flex;
    gap: var(--space-2);
    z-index: 1000;

    /* Glass container */
    padding: var(--space-2);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
  }

  .lang-btn {
    padding: var(--space-2) var(--space-4);

    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);

    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    cursor: pointer;

    transition: all var(--duration-fast) var(--ease-out-expo);

    &:hover {
      color: var(--text-primary);
      background: oklch(30% 0.05 var(--hue-primary) / 0.5);
    }

    &.active {
      color: var(--bg-base);
      background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
      box-shadow: 0 2px 10px oklch(60% 0.2 var(--hue-primary) / 0.4);
    }
  }
}

/* ========================================
   Utilities
   ======================================== */
@layer utilities {
  .hidden { display: none !important; }
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
}

/* ========================================
   Animations
   ======================================== */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px oklch(70% 0.2 var(--hue-primary) / 0.3);
  }
  50% {
    box-shadow: 0 0 40px oklch(70% 0.2 var(--hue-primary) / 0.5);
  }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
  .lang-switcher {
    position: fixed;
    top: var(--space-3);
    right: var(--space-3);
    left: auto;
    padding: var(--space-1);
    gap: var(--space-1);
  }

  .lang-btn {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
  }

  header {
    padding-block: var(--space-8);
    padding-top: calc(var(--space-8) + 50px);
  }

  section {
    padding: var(--space-5);
    margin-block: var(--space-4);
  }

  #xp-container {
    padding-left: var(--space-4);

    &::before {
      left: 2px;
    }

    .xp-item::before {
      left: -14px;
      width: 8px;
      height: 8px;
    }
  }

  .xp-item {
    padding: var(--space-4);
  }

  a.button {
    width: 100%;
    justify-content: center;
    margin-right: 0;
  }
}

/* ========================================
   Reduced Motion
   ======================================== */
@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;
  }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
  body {
    background: white;
    color: black;
  }

  section {
    background: white;
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
  }

  .lang-switcher,
  header::after {
    display: none;
  }
}
