/* ==========================================================================
   Kleyson Prado — The Terminal Chronicle
   A developer's journey told through code
   ========================================================================== */

/* --------------------------------------------------------------------------
   Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Dark void palette */
  --void: #0a0a0c;
  --surface: #111114;
  --surface-raised: #18181c;
  --surface-overlay: #1f1f24;

  /* Text hierarchy */
  --text-primary: #f0f0f2;
  --text-secondary: #a0a0a8;
  --text-tertiary: #606068;
  --text-muted: #404048;

  /* Accent - Electric cyan/teal */
  --accent: #4aeadc;
  --accent-dim: #2eb8ac;
  --accent-glow: rgba(74, 234, 220, 0.15);
  --accent-subtle: rgba(74, 234, 220, 0.08);

  /* Branch colors for git-style */
  --branch-main: #4aeadc;
  --branch-feature: #a78bfa;
  --branch-enterprise: #f59e0b;
  --branch-origin: #f472b6;

  /* Typography */
  --font-serif: 'Crimson Pro', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;

  /* Spacing */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 5rem;
  --space-4xl: 8rem;

  /* Layout */
  --timeline-width: 60px;
  --content-max: 900px;

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Canadian theme */
:root[data-theme="ca"] {
  --accent: #f87171;
  --accent-dim: #dc2626;
  --accent-glow: rgba(248, 113, 113, 0.15);
  --accent-subtle: rgba(248, 113, 113, 0.08);
  --branch-main: #f87171;
}

/* Brazilian theme */
:root[data-theme="br"] {
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --accent-glow: rgba(74, 222, 128, 0.15);
  --accent-subtle: rgba(74, 222, 128, 0.08);
  --branch-main: #4ade80;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-secondary);
  background: var(--void);
  min-height: 100vh;
  overflow-x: hidden;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

strong {
  color: var(--accent);
  font-weight: 500;
}

em {
  font-style: italic;
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Scroll Progress Bar
   -------------------------------------------------------------------------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 9999;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.header.scrolled {
  background: rgba(10, 10, 12, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--space-md) var(--space-xl);
}

.logo img {
  height: 40px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.8;
  transition: opacity 0.2s;
}

.logo:hover img {
  opacity: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.country-flag {
  font-size: 1.25rem;
  opacity: 0.8;
}

.country-flag:empty {
  display: none;
}

.nav {
  display: flex;
  gap: var(--space-sm);
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.2s;
}

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

.nav-link.social {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  background: var(--accent-subtle);
}

.nav-link.social svg {
  width: 18px;
  height: 18px;
}

.nav-link.social:hover {
  color: var(--void);
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   Main Chronicle Layout
   -------------------------------------------------------------------------- */
.chronicle {
  display: grid;
  grid-template-columns: var(--timeline-width) 1fr;
  min-height: 100vh;
  max-width: calc(var(--content-max) + var(--timeline-width) + var(--space-4xl));
  margin: 0 auto;
}

@media (max-width: 768px) {
  .chronicle {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Timeline Spine
   -------------------------------------------------------------------------- */
.timeline-spine {
  position: fixed;
  left: max(0px, calc((100vw - var(--content-max) - var(--timeline-width) - var(--space-4xl)) / 2));
  top: 0;
  bottom: 0;
  width: var(--timeline-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4xl) 0;
  z-index: 100;
}

@media (max-width: 768px) {
  .timeline-spine {
    display: none;
  }
}

.timeline-track {
  position: relative;
  width: 2px;
  height: 100%;
  background: var(--surface-raised);
  border-radius: 1px;
}

.timeline-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(to bottom, var(--accent), var(--accent-dim));
  border-radius: 1px;
  transition: height 0.1s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

.timeline-markers {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
}

.marker {
  position: fixed;
  left: calc(var(--timeline-width) / 2);
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--surface-overlay);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s var(--ease-out);
  /* Default position - will be updated by JS */
  top: 50%;
  opacity: 0;
}

.marker.positioned {
  opacity: 1;
}

.marker::before {
  content: attr(data-year);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.marker.passed {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.marker.passed::before {
  opacity: 1;
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   Content Flow
   -------------------------------------------------------------------------- */
.content-flow {
  grid-column: 2;
  padding: 0 var(--space-2xl);
  max-width: calc(var(--content-max) + var(--space-4xl));
}

@media (max-width: 768px) {
  .content-flow {
    grid-column: 1;
    padding: 0 var(--space-lg);
  }
}

/* --------------------------------------------------------------------------
   Terminal Hero
   -------------------------------------------------------------------------- */
.hero-terminal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-4xl) 0;
  position: relative;
}

.terminal-window {
  width: 100%;
  max-width: 800px;
  background: var(--surface);
  border: 1px solid var(--surface-raised);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.2),
    0 20px 40px rgba(0, 0, 0, 0.3);
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--surface-overlay);
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.terminal-dot:nth-child(1) { background: #ff5f57; }
.terminal-dot:nth-child(2) { background: #febc2e; }
.terminal-dot:nth-child(3) { background: #28c840; }

.terminal-title {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.terminal-body {
  padding: var(--space-lg);
  font-family: var(--font-mono);
}

.terminal-line {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.prompt {
  color: var(--accent);
  font-weight: 500;
}

.command {
  color: var(--text-primary);
  font-size: 0.875rem;
}

.terminal-output {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.terminal-output h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: var(--space-xs);
  letter-spacing: -0.02em;
}

.terminal-output .role {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
  margin-bottom: 0;
}

.terminal-output p {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-2xs);
  line-height: 1.6;
}

.cursor {
  display: inline-block;
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Typing animation */
.typing {
  overflow: hidden;
  white-space: nowrap;
  animation: typing 0.5s steps(6) 0.5s both;
}

.delayed {
  opacity: 0;
  animation: fadeIn 0.3s ease 1.2s forwards;
}

.delayed-more {
  opacity: 0;
  animation: fadeIn 0.3s ease 1.6s forwards;
}

.cursor-line {
  opacity: 0;
  animation: fadeIn 0.3s ease 2s forwards;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Scroll hint */
.scroll-hint {
  position: absolute;
  bottom: var(--space-2xl);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  animation: float 2s ease-in-out infinite;
}

.scroll-hint svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
}

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

/* --------------------------------------------------------------------------
   Chapters
   -------------------------------------------------------------------------- */
.chapter {
  padding: var(--space-4xl) 0;
  opacity: 0;
  transform: translateY(40px);
  transition: all 0.8s var(--ease-out);
}

.chapter.in-view {
  opacity: 1;
  transform: translateY(0);
}

.chapter-intro {
  margin-bottom: var(--space-3xl);
}

.chapter-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: var(--space-md);
}

.chapter h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: var(--space-lg);
  letter-spacing: -0.02em;
}

.chapter-lead {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 800px;
}

/* --------------------------------------------------------------------------
   Commit Log (Job Entries)
   -------------------------------------------------------------------------- */
.commit-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.commit {
  position: relative;
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--surface-raised);
  border-radius: 8px;
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.6s var(--ease-out);
}

.commit.in-view {
  opacity: 1;
  transform: translateX(0);
}

.commit:nth-child(1) { transition-delay: 0ms; }
.commit:nth-child(2) { transition-delay: 80ms; }
.commit:nth-child(3) { transition-delay: 160ms; }
.commit:nth-child(4) { transition-delay: 240ms; }
.commit:nth-child(5) { transition-delay: 320ms; }

/* Branch line indicator */
.commit::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--space-lg);
  bottom: var(--space-lg);
  width: 3px;
  background: var(--branch-main);
  border-radius: 2px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.commit:hover::before {
  opacity: 1;
}

.commit[data-hash="2019-2021"]::before { background: var(--branch-feature); }
.commit[data-hash="2017-2019"]::before { background: var(--branch-feature); }
.commit[data-hash="2012-2017"]::before { background: var(--branch-enterprise); }
.commit[data-hash="2004-2012"]::before { background: var(--branch-origin); }

.commit-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.commit-hash {
  color: var(--accent);
}

.commit-branch {
  color: var(--text-tertiary);
  padding: var(--space-2xs) var(--space-xs);
  background: var(--surface-overlay);
  border-radius: 4px;
}

.commit-content {
  padding-left: var(--space-md);
}

.commit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  width: 100%;
}

.company-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.company-link:hover {
  opacity: 0.8;
}

.company-logo {
  width: 160px;
  height: 80px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.7;
}

.company-link h3 {
  display: none;
}

.commit-header h3 {
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--text-primary);
}

.commit-header-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.commit-role {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.commit-message {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  font-style: italic;
}

.commit-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s var(--ease-out), opacity 0.3s;
  opacity: 0;
}

.commit.expanded .commit-details {
  max-height: 500px;
  opacity: 1;
}

.commit-details p {
  font-size: 0.9375rem;
  margin-bottom: var(--space-sm);
}

.commit-toggle {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs) 0;
  transition: color 0.2s;
}

.commit-toggle:hover {
  color: var(--accent);
}

.toggle-hide {
  display: none;
}

.commit.expanded .toggle-show {
  display: none;
}

.commit.expanded .toggle-hide {
  display: inline;
}

/* --------------------------------------------------------------------------
   Skill Constellation
   -------------------------------------------------------------------------- */
.skill-constellation {
  position: relative;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 1;
  margin: var(--space-3xl) auto;
}

.constellation-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 0 30px var(--accent-glow);
}

.core-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.skill-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px dashed var(--surface-overlay);
}

.orbit-1 {
  width: 55%;
  height: 55%;
}

.orbit-2 {
  width: 78%;
  height: 78%;
}

.orbit-3 {
  width: 100%;
  height: 100%;
}

.skill-node {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: var(--space-2xs) var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--surface-raised);
  border-radius: 4px;
  white-space: nowrap;
  cursor: default;
  transition: all 0.3s var(--ease-out);
  transform: translate(-50%, -50%);
}

.skill-node.primary {
  color: var(--text-primary);
  border-color: var(--accent-dim);
  background: var(--surface-raised);
  font-size: 0.75rem;
  padding: var(--space-xs) var(--space-sm);
}

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

.skill-node.tertiary {
  color: var(--text-tertiary);
  font-size: 0.625rem;
  padding: 2px 6px;
}

.skill-node:hover,
.skill-node.focused {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--surface-overlay);
  box-shadow: 0 0 12px var(--accent-glow);
  z-index: 20;
  transform: translate(-50%, -50%) scale(1.1);
}

.skill-constellation.has-focus .skill-node:not(.focused) {
  opacity: 0.4;
}

.constellation-note {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Stats Strip
   -------------------------------------------------------------------------- */
.stats-strip {
  display: flex;
  justify-content: center;
  gap: var(--space-3xl);
  padding: var(--space-3xl) 0;
  border-top: 1px solid var(--surface-raised);
  border-bottom: 1px solid var(--surface-raised);
  margin: var(--space-3xl) 0;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s var(--ease-out);
}

.stats-strip.in-view {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 600px) {
  .stats-strip {
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
  }
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 300;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-suffix {
  color: var(--accent);
}

.stat-key {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: lowercase;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
  padding: var(--space-3xl) 0 var(--space-2xl);
  text-align: center;
}

.footer-content {
  max-width: 700px;
  margin: 0 auto;
}

.footer-message {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  font-style: italic;
}

.footer-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
}

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --space-2xl: 2rem;
    --space-3xl: 3rem;
    --space-4xl: 4rem;
  }

  .header {
    padding: var(--space-md);
  }

  .hero-terminal {
    padding: var(--space-3xl) 0;
  }

  .terminal-window {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin: 0 calc(-1 * var(--space-lg));
    width: calc(100% + var(--space-lg) * 2);
  }

  .chapter h2 {
    font-size: 2rem;
  }

  .skill-constellation {
    max-width: 300px;
  }

  .skill-node {
    font-size: 0.5rem;
    padding: 2px 5px;
  }

  .skill-node.primary {
    font-size: 0.5625rem;
    padding: 3px 6px;
  }

  .skill-node.tertiary {
    display: none;
  }

  .constellation-core {
    width: 45px;
    height: 45px;
  }

  .core-label {
    font-size: 0.5rem;
  }
}

/* --------------------------------------------------------------------------
   Focus & Accessibility
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

  .skill-orbit {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   Scrollbar
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--void);
}

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

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