/* Main styles for Emiliano Ruiz - Portfolio */
:root {
    --bg: #0f172a;
    --surface: #111827;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #60a5fa;
    --primary-600: #3b82f6;
    --accent: #22d3ee;
    --border: #1f2937;
    --chip-bg: #0b1220;
    --success: #10b981;
    --danger: #f97316;
    /* Motion & depth */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --dur-1: 150ms;
    --dur-2: 300ms;
    --dur-3: 600ms;
    --shadow-1: 0 10px 30px rgba(0,0,0,.15);
    --radius: 12px;
  }
  
  /* Small phones */
  @media (max-width: 480px) {
    .btn { width: 100%; justify-content: center; }
    .hero .cta .btn { flex: 1 1 auto; }
    .cards { gap: 12px; }
  }
  
  html[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #334155;
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --accent: #0891b2;
    --border: #e2e8f0;
    --chip-bg: #f1f5f9;
  }
  
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--text);
    background: radial-gradient(1200px 800px at 100% -10%, rgba(34,211,238,0.08), transparent 50%),
                radial-gradient(900px 700px at -20% 0%, rgba(96,165,250,0.08), transparent 50%),
                var(--bg);
    line-height: 1.6;
    overflow-x: hidden; /* avoid accidental horizontal scroll due to transforms */
  }
  html { overflow-x: hidden; }
  /* Subtle noise overlay to reduce banding (sits below content) */
  body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .02; background-image:
    radial-gradient(rgba(255,255,255,.7) 0.5px, transparent 0.5px);
    background-size: 4px 4px; }
  main, .site-header, .site-footer { position: relative; z-index: 2; }
  
  img { max-width: 100%; display: block; }
  p { hyphens: auto; }
  
  .container { width: min(1100px, 92%); margin: 0 auto; }
  .section { padding: 56px 0; content-visibility: auto; contain-intrinsic-size: 1px 600px; }
  /* Ensure anchor targets are not hidden under sticky header */
  :where(#home, #stack, #projects, #offers, #faq, #contact) { scroll-margin-top: calc(80px + env(safe-area-inset-top)); }
  .section-title { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); margin: 0 0 16px; letter-spacing: .2px; }
  .subtitle { color: var(--muted); margin-top: -6px; }
  
  /* Header */
  .site-header { position: sticky; top: 0; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 10; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 92%, transparent); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-top: env(safe-area-inset-top); }
  .nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
  .brand { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; text-decoration: none; font-weight: 700; letter-spacing: .5px; }
  .nav-links { list-style: none; display: flex; gap: 18px; margin: 0; padding: 0; }
  .nav a { position: relative; color: var(--text); text-decoration: none; font-weight: 500; opacity: .9; transition: color var(--dur-1) var(--ease-out); }
  .nav a::after { content: ""; position: absolute; left: 0; bottom: -6px; width: 0; height: 2px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width var(--dur-2) var(--ease-out); border-radius: 2px; }
  .nav a:hover { opacity: 1; color: var(--primary); }
  .nav a:hover::after, .nav a.active::after, .nav a[aria-current="true"]::after { width: 100%; }
  .nav a.active, .nav a[aria-current="true"] { color: var(--primary); }
  /* Ensure nav links align vertically with controls */
  .nav-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 2px; }
  .scroll-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 20; pointer-events: none; top: env(safe-area-inset-top); }
  .scroll-progress span { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); transform-origin: left; }
  /* Starfield background canvas (disabled) */
  .starfield { display: none !important; }
  .back-to-top { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 44px; height: 44px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text); cursor: pointer; transform: translateY(12px); opacity: 0; visibility: hidden; transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), border-color var(--dur-1) var(--ease-out); z-index: 30; }
  .back-to-top.show { opacity: 1; transform: none; visibility: visible; }
  .back-to-top:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); color: var(--primary); }
  .back-to-top:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
  
  /* Header shrink on scroll */
  body.scrolled .nav { height: 56px; }
  body.scrolled .site-header { background: color-mix(in srgb, var(--bg) 96%, transparent); border-bottom-color: color-mix(in srgb, var(--primary) 12%, var(--border)); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
  .theme-toggle { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; height: 44px; width: 44px; display: grid; place-items: center; cursor: pointer; }
  .theme-toggle:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
  /* Mobile menu toggle */
  .menu-toggle { display: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; height: 44px; width: 44px; place-items: center; cursor: pointer; }
  .menu-toggle:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
  /* Language switch */
  .lang-switch { margin-right: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; height: 44px; }
  .lang-switch:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); color: var(--primary); }
  /* Nav hire-me button override */
  .nav .hire-me { margin-left: 6px; }
  .nav .hire-me::after { content: none; }
  
  /* Overlay for mobile nav */
  .nav-overlay { position: fixed; inset: 0; background: color-mix(in srgb, rgba(0,0,0,0.55) 70%, var(--bg)); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--dur-2) var(--ease-out), visibility var(--dur-2) var(--ease-out); z-index: 9; }
  .nav-overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }
  
  /* Hero */
  .hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 28px; padding: 64px 0 24px; align-items: center; }
  .hero h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.1; margin: 0 0 8px; }
  .hero .summary { color: var(--muted); max-width: 60ch; }
  .hero .cta { margin: 16px 0 8px; display: flex; gap: 12px; flex-wrap: wrap; }
  .avatar { width: 260px; height: 260px; border-radius: 52px; border: 1px solid var(--border); background: var(--surface); padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
  .avatar.photo { padding: 0; border: 0; object-fit: cover; object-position: 36% 40%; transform: scale(1.46); transform-origin: 36% 40%; user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; pointer-events: none; }
  .avatar-frame { width: 260px; height: 260px; border-radius: 52px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.15); overflow: hidden; display: grid; place-items: center; }
  .hero-media { display: grid; place-items: center; align-self: start; }
  
  .btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; text-decoration: none; font-weight: 600; border: 1px solid var(--border); color: var(--text); transition: all .2s ease; min-height: 44px; }
  .btn.primary { background: linear-gradient(135deg, var(--primary), var(--accent)); border: none; color: white; }
  .btn.primary:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: var(--shadow-1); }
  .btn.ghost { background: transparent; }
  .btn.ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
  
  .quick-stats { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; color: var(--muted); }
  .quick-stats li { position: relative; padding-left: 16px; }
  .quick-stats li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }
  /* Highlights list (recruiter-focused) */
  .highlights { list-style: none; padding: 0; margin: 8px 0 18px; display: grid; gap: 10px; color: var(--muted); }
  .highlights li { position: relative; padding-left: 20px; line-height: 1.65; }
  .highlights li::before { content: "★"; position: absolute; left: 0; top: 2px; color: color-mix(in srgb, var(--accent) 72%, var(--primary)); font-size: .85rem; }
  #stack .highlights { max-width: 78ch; }
  .highlights strong { color: var(--text); }
  /* Better wrapping for long tokens */
  .summary, .quick-stats, .card p { overflow-wrap: anywhere; word-break: break-word; }

  /* Hero metrics (counters) */
  .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 14px; }
  .metric { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; text-align: center; transition: transform var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
  .metric:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
  .metric .number { font-size: clamp(1.4rem, 1.2rem + 1.6vw, 2.2rem); font-weight: 800; line-height: 1; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .metric .label { color: var(--muted); font-size: .95rem; margin-top: 6px; }
  /* Inline About under hero metrics */
  .about-inline { margin-top: 14px; color: var(--muted); }
  .about-inline h3 { margin: 8px 0 6px; font-size: 1.1rem; color: var(--text); }
  /* Inline Contact under hero */
  .contact-inline { margin-top: 16px; }
  .contact-inline h3 { margin: 10px 0 8px; font-size: 1.05rem; color: var(--text); }

  /* Skill level badges */
  .lvl { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: .74rem; margin-left: 6px; border: 1px solid var(--border); background: var(--chip-bg); color: var(--text); vertical-align: middle; }
  .lvl.adv { background: color-mix(in srgb, var(--accent) 18%, var(--chip-bg)); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
  .lvl.int { background: color-mix(in srgb, var(--primary) 14%, var(--chip-bg)); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
  .lvl.bas { background: color-mix(in srgb, var(--muted) 16%, var(--chip-bg)); border-color: color-mix(in srgb, var(--muted) 30%, var(--border)); }

  /* Cards */
  .cards { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: stretch; }
  .card { grid-column: span 6; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); height: 100%; display: flex; flex-direction: column; }
  .card h3 { margin: 0 0 8px; }
  .card p { color: var(--muted); margin: 0 0 10px; }
  .card .meta { list-style: none; padding: 0; margin: 0 0 8px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: .9rem; }
  .card .meta li { white-space: normal; overflow-wrap: anywhere; }
  .card .tags { display: flex; gap: 8px; flex-wrap: wrap; }
  .card .tags span { background: var(--chip-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--border)); padding: 6px 10px; border-radius: 999px; font-size: .85rem; }
  #stack .cards { gap: 14px; }
  #stack .card { padding: 16px; border-radius: 14px; }
  #stack.section { padding-top: 56px; }
  .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-1); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
  .card.hidden { display: none; }

  /* 3 columns on wide screens for Stack */
  @media (min-width: 1100px) {
    #stack .card { grid-column: span 4; }
    #offers .card { grid-column: span 4; }
    #projects .card { grid-column: span 4; }
  }

  /* Services spacing */
  #offers .cards { gap: 14px; }
  #offers.section { padding-top: 56px; }

  /* Add simple icons to Services (first cards group only) */
  #offers .cards:first-of-type .card h3 { display: flex; align-items: center; gap: 8px; }
  #offers .cards:first-of-type .card:nth-child(1) h3::before { content: "⏱️"; }
  #offers .cards:first-of-type .card:nth-child(2) h3::before { content: "📦"; }
  #offers .cards:first-of-type .card:nth-child(3) h3::before { content: "🛠️"; }

  /* Icons for Process cards (second group under #offers) */
  #offers h3.section-title + .cards .card h3 { display: flex; align-items: center; gap: 8px; }
  #offers h3.section-title + .cards .card:nth-child(1) h3::before { content: "🧭"; }
  #offers h3.section-title + .cards .card:nth-child(2) h3::before { content: "📆"; }
  #offers h3.section-title + .cards .card:nth-child(3) h3::before { content: "✅"; }
  #offers h3.section-title + .cards .card:nth-child(4) h3::before { content: "🚀"; }

  /* Projects spacing */
  #projects .cards { gap: 14px; }

  /* Project filters (no-image alternative to organize projects) */
  .filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
  .filter { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 700; }
  .filter:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); color: var(--primary); }
  .filter.active { background: linear-gradient(135deg, var(--primary), var(--accent)); border-color: color-mix(in srgb, var(--primary) 60%, var(--border)); color: #fff; }
  .filters .search { flex: 1 1 220px; min-width: 200px; height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: var(--surface); color: var(--text); font-weight: 500; }
  .filters .search:focus { outline: 2px solid color-mix(in srgb, var(--primary) 50%, var(--border)); outline-offset: 2px; }
  .no-results { color: var(--muted); margin: 8px 0 0; }
  /* Router views */
  .route.hidden { display: none !important; }
  /* FAQ */
  .faq { display: grid; gap: 10px; }
  .faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
  .faq summary { cursor: pointer; font-weight: 700; list-style: none; }
  .faq summary::-webkit-details-marker { display: none; }
  .faq summary::after { content: '+'; float: right; color: var(--muted); transition: transform var(--dur-2) var(--ease-out); }
  .faq details[open] summary::after { content: '−'; color: var(--primary); }
  .faq p { color: var(--muted); margin: 8px 0 0; }

  /* Work slider */
  .work-slider { position: relative; overflow: hidden; }
  .work-track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 360px); gap: 16px; overflow-x: auto; padding: 6px 6px 12px; scroll-snap-type: x mandatory; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
  .work-track::-webkit-scrollbar { height: 0; width: 0; background: transparent; }
  .work-track::-webkit-scrollbar-thumb { background: transparent; }
  .work-track:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 10px; }
  .work-track .card { grid-column: auto; min-width: 280px; scroll-snap-align: start; }
  .work-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 70%, var(--surface)); color: var(--text); display: grid; place-items: center; cursor: pointer; z-index: 3; }
  .work-btn:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
  .work-btn.prev { left: -6px; }
  .work-btn.next { right: -6px; }
  .work-btn:disabled { opacity: .4; cursor: default; }
  @media (max-width: 900px) {
    .work-track { grid-auto-columns: minmax(82%, 1fr); padding-inline: 6px; }
    .work-btn { display: none; }
  }
  
  /* Contact */
  .contact .contact-actions, .contact-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
  .social { list-style: none; display: flex; gap: 14px; padding: 0; margin: 10px 0 0; }
  .social a { color: var(--text); text-decoration: none; border-bottom: 1px dashed var(--border); }
  .social a:hover { color: var(--primary); border-bottom-color: var(--primary); }
  
  /* Footer */
  .site-footer { border-top: 1px solid var(--border); padding: 18px 0; margin-top: 40px; background: color-mix(in srgb, var(--bg) 92%, transparent); }
  .site-footer p { color: var(--muted); margin: 0; text-align: center; }
  
  /* Responsive */
  @media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; text-align: center; }
    .hero .summary { margin-inline: auto; }
    .hero-media { order: -1; align-self: center; }
    .avatar { width: 202px; height: 202px; }
    .avatar-frame { width: 202px; height: 202px; border-radius: 40px; }
    .section { padding: 48px 0; }
    .cards .card { grid-column: span 12; }
    .section-title { font-size: clamp(1.2rem, 1.2rem + 1.2vw, 1.8rem); }
    .card .meta li { white-space: normal; }
    .cta { gap: 10px; }
    /* Mobile nav panel */
    .menu-toggle { display: grid; touch-action: manipulation; }
    .nav { gap: 10px; }
    .nav-links { position: fixed; left: 0; right: 0; top: 64px; z-index: 12; background: color-mix(in srgb, var(--bg) 96%, var(--surface) 4%); border-bottom: 1px solid var(--border); padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); display: none; flex-direction: column; gap: 12px; }
    .nav.open #primaryNav { display: flex; }
    .nav-links { padding-left: calc(20px + env(safe-area-inset-left)); padding-right: calc(20px + env(safe-area-inset-right)); }
    .nav-links a { padding: 10px 6px; min-height: 44px; }
    .nav-links { top: calc(64px + env(safe-area-inset-top)); }
    body.scrolled .nav-links { top: calc(56px + env(safe-area-inset-top)); }
    /* Metrics grid on mobile */
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* Hire me full width on mobile */
    .nav-links .hire-me { width: 100%; justify-content: center; }
  }
  
  /* Very small screens */
  @media (max-width: 360px) {
    .brand { width: 36px; height: 36px; }
    .theme-toggle, .menu-toggle { width: 40px; height: 40px; }
    .lang-switch { height: 40px; padding: 6px 8px; }
    .hero h1 { font-size: 1.9rem; }
    .section-title { font-size: 1.6rem; }
  }
  
  /* Prevent body scroll when mobile nav is open */
  body.nav-open { overflow: hidden; }
  
  /* Accessibility */
  :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
  
  /* Skip link */
  .skip-link { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
  .skip-link:focus { position: fixed; left: 16px; top: 16px; width: auto; height: auto; padding: 10px 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); z-index: 50; }
  
  /* Reveal animations */
  [data-animate] { opacity: 0; transform: translateY(12px); transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); transition-delay: var(--delay, 0ms); }
  [data-animate].is-visible { opacity: 1; transform: none; }
  
  /* Reduced motion */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
  }

  /* Resume page (screen) */
  body.resume .site-header,
  body.resume .scroll-progress,
  body.resume .back-to-top,
  body.resume .starfield { display: none !important; }
  body.resume { background: var(--bg); }
  body.resume main { padding-top: 16px; }
  body.resume .container { width: min(900px, 92%); }
  body.resume .resume-header h1 { margin: 0 0 4px; }
  body.resume .resume-header .subtitle { margin: 0 0 10px; }
  body.resume .info { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); margin: 8px 0 16px; }
  body.resume .info a { color: var(--text); border-bottom: 1px dashed var(--border); text-decoration: none; }
  body.resume .info a:hover { color: var(--primary); border-bottom-color: var(--primary); }
  body.resume .grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
  body.resume .span-12 { grid-column: span 12; }
  body.resume .span-6 { grid-column: span 6; }
  body.resume .span-4 { grid-column: span 4; }
  @media (max-width: 900px) {
    body.resume .span-6, body.resume .span-4 { grid-column: span 12; }
  }

  /* Print styles for resume */
  @media print {
    html, body { background: #ffffff !important; color: #000 !important; }
    .site-header, .site-footer, .scroll-progress, .back-to-top, .starfield, .nav-overlay, .menu-toggle, .theme-toggle, .lang-switch { display: none !important; }
    .container { width: 100% !important; margin: 0 !important; }
    .section { padding: 12px 0 !important; }
    .card { background: #fff !important; color: #000 !important; border-color: #ddd !important; box-shadow: none !important; }
    .btn { display: none !important; }
    a { color: #000 !important; text-decoration: underline !important; }
    .filters { display: none !important; }
  }
  