/* ════════════════════════════════════════════════════════════════
   David Arellano — Portfolio
   style.css
   ════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2128;
  --accent:    #00ff88;
  --accent-dim:#00cc6a;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --border:    #30363d;
  --danger:    #f85149;
  --success:   #3fb950;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --nav-h:     64px;
  --radius:    6px;
  --max-w:     1100px;
  --section-pad: 6rem 1.5rem;

  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-mono); line-height: 1.2; }
p { color: var(--muted); }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Utilities ────────────────────────────────────────────────── */
.accent { color: var(--accent); }

.section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--section-pad);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: lowercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.section-heading {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--text);
  margin-bottom: 3rem;
  font-weight: 600;
}

/* ── Scroll Fade-in ───────────────────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-ghost:hover {
  background: rgba(0, 255, 136, 0.08);
  transform: translateY(-2px);
}

.btn-whatsapp {
  background: transparent;
  color: #25d366;
  border: 1px solid #25d366;
  margin-top: 1rem;
  width: 100%;
  justify-content: center;
}
.btn-whatsapp:hover {
  background: rgba(37, 211, 102, 0.08);
  transform: translateY(-2px);
}

/* ── Nav ──────────────────────────────────────────────────────── */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}

#navbar.scrolled {
  border-bottom-color: var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 2rem;
}

.nav-logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  transition: color var(--transition);
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--transition);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text);
}

.nav-links a:hover::after { transform: scaleX(1); }

.nav-resume {
  color: var(--accent) !important;
}

.lang-toggle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius);
  transition: var(--transition);
  flex-shrink: 0;
}

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

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: var(--transition);
  transform-origin: center;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ── Hero ─────────────────────────────────────────────────────── */
#hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Subtle grid background */
#hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.15;
  pointer-events: none;
}

/* Radial glow */
#hero::after {
  content: '';
  position: absolute;
  top: 30%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(0, 255, 136, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 3rem) 1.5rem 3rem;
  position: relative;
  z-index: 1;
}

.hero-greeting {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 1rem;
  animation: fadeSlideUp 0.6s ease both;
}

.hero-name {
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.05;
  margin-bottom: 0.75rem;
  animation: fadeSlideUp 0.6s ease 0.1s both;
}

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

.hero-title {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: var(--muted);
  margin-bottom: 1.5rem;
  animation: fadeSlideUp 0.6s ease 0.2s both;
}

.hero-bio {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 550px;
  margin-bottom: 2.5rem;
  animation: fadeSlideUp 0.6s ease 0.3s both;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  animation: fadeSlideUp 0.6s ease 0.4s both;
}

.hero-scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 1.5rem;
  display: flex;
  align-items: center;
}

.scroll-line {
  width: 1px;
  height: 60px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  animation: scrollLine 2s ease-in-out infinite;
}

/* ── About ────────────────────────────────────────────────────── */
#about {
  background: var(--surface);
}

.about-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4rem;
  align-items: start;
}

.avatar-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}

.avatar-img {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 1;
  border: 2px solid var(--border);
}

.avatar-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.4;
  animation: ringPulse 3s ease-in-out infinite;
}

.about-content p {
  margin-bottom: 1rem;
  color: var(--muted);
}

.about-meta {
  margin: 1.5rem 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.about-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  transition: color var(--transition);
  border-bottom: 1px solid transparent;
}

.social-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.social-icon {
  color: var(--accent);
}

/* ── Experience / Timeline ────────────────────────────────────── */
#experience {
  background: var(--bg);
}

.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, var(--accent), var(--border) 80%, transparent);
}

.timeline-item {
  position: relative;
  margin-bottom: 2.5rem;
}

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

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 18px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  transform: translateX(-4px);
  transition: border-color var(--transition), background var(--transition);
}

.timeline-item:hover .timeline-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.timeline-card:hover {
  border-color: rgba(0, 255, 136, 0.3);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.05);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.timeline-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.company-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px;
  flex-shrink: 0;
}

a:has(.company-logo) {
  display: inline-flex;
  flex-shrink: 0;
  border-radius: 8px;
  transition: opacity 0.2s, box-shadow 0.2s;
}

a:has(.company-logo):hover {
  opacity: 0.8;
  box-shadow: 0 0 0 2px var(--accent);
}

.company-logo-fallback {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.timeline-role {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.timeline-company {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.timeline-dates {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.timeline-desc {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.65;
}

.timeline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 100px;
  padding: 0.15rem 0.65rem;
}

.blink-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: blink 1.2s step-end infinite;
}

/* ── Skills ───────────────────────────────────────────────────── */
#skills {
  background: var(--surface);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.skill-group-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  font-weight: 500;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.skill-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  transition: var(--transition);
}

.skill-tag:hover {
  color: var(--text);
  border-color: var(--muted);
}

.skill-tag.featured {
  color: var(--accent);
  border-color: rgba(0, 255, 136, 0.3);
  background: rgba(0, 255, 136, 0.05);
}

.skill-tag.featured:hover {
  background: rgba(0, 255, 136, 0.1);
}

/* ── Education ────────────────────────────────────────────────── */
#education {
  background: var(--bg);
}

.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.edu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  gap: 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.edu-card:hover {
  border-color: rgba(0, 255, 136, 0.3);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.05);
}

.edu-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.edu-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.35rem;
}

.edu-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.edu-org {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.edu-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Contact ──────────────────────────────────────────────────── */
#contact {
  background: var(--surface);
}

.contact-subheading {
  color: var(--muted);
  font-size: 1rem;
  margin-top: -2rem;
  margin-bottom: 3rem;
  max-width: 480px;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 3rem;
  align-items: start;
}

/* Form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: lowercase;
}

.form-group input,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0.65rem 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: vertical;
  outline: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--border);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.08);
}

.form-status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  min-height: 1.5rem;
}

.form-status.success { color: var(--success); }
.form-status.error { color: var(--danger); }

/* Direct contact */
.contact-or {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.contact-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1rem;
  transition: color var(--transition);
}

.contact-option:hover { color: var(--accent); }

.contact-option-icon {
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Footer ───────────────────────────────────────────────────── */
footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.footer-copy { color: var(--border); }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

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

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50%       { transform: scale(1.05); opacity: 0.7; }
}

@keyframes scrollLine {
  0%   { opacity: 0; transform: scaleY(0); transform-origin: top; }
  40%  { opacity: 1; transform: scaleY(1); transform-origin: top; }
  60%  { opacity: 1; transform: scaleY(1); transform-origin: bottom; }
  100% { opacity: 0; transform: scaleY(0); transform-origin: bottom; }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .avatar-wrapper {
    margin: 0 auto;
  }

  .about-content { text-align: center; }
  .about-links { justify-content: center; }
  .about-meta { text-align: center; }
}

@media (max-width: 700px) {
  :root {
    --section-pad: 4rem 1.25rem;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    font-size: 1rem;
    color: var(--text);
  }

  .nav-toggle { display: flex; }

  .lang-toggle { margin-left: 0; }

  .timeline {
    padding-left: 1.25rem;
  }

  .timeline-dot {
    left: -1.25rem;
  }

  .timeline-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .timeline-dates { white-space: normal; }

  .skills-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hero-ctas {
    flex-direction: column;
  }

  .hero-ctas .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Focus Styles (Accessibility) ────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Reduce 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; }
  .fade-in { opacity: 1; transform: none; }
}
