/* ============================================
   TOKENS — paleta inspirada en syntax highlighting
   ============================================ */
:root {
  --bg: #F7F7F4;
  --bg-elevated: #FFFFFF;
  --bg-code: #14161A;
  --fg: #1A1D1F;
  --fg-muted: #5B6168;
  --border: #E2E2DD;
  --shadow: rgba(20, 20, 18, 0.07);

  --primary:        #D93B3B; /* color principal */
  --primary-hover:  #B32E2E; /* principal más oscuro para hovers */
  --accent-keyword: var(--primary); /* rojo - palabras clave */
  --accent-string:  #1A8F77; /* verde-teal - strings */
  --accent-fn:      #5B5BD6; /* violeta - funciones, booleanos */
  --accent-comment: #79835F; /* verde apagado - comentarios */

  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --nav-h: 64px;
  --status-h: 30px;
  --radius: 8px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  --bg: #11151C;
  --bg-elevated: #161B23;
  --bg-code: #0D1016;
  --fg: #E7E6E1;
  --fg-muted: #8B9099;
  --border: #262C36;
  --shadow: rgba(0, 0, 0, 0.4);

  --primary:        #F06262; /* principal aclarado para contraste en fondo oscuro */
  --primary-hover:  #F58C8C;
  --accent-keyword: var(--primary);
  --accent-string:  #45C7A8;
  --accent-fn:      #9292F0;
  --accent-comment: #97A187;
}

/* ============================================
   BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
  padding-bottom: var(--status-h);
}

h1, h2, h3 { font-family: var(--font-mono); margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; background: none; border: none; cursor: pointer; color: inherit; }

a, button, input, textarea {
  outline-offset: 3px;
}
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent-keyword);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

section { scroll-margin-top: var(--nav-h); }

.accent-keyword { color: var(--accent-keyword); }
.accent-string  { color: var(--accent-string); }
.accent-fn      { color: var(--accent-fn); }

.eyebrow, .section-label {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--accent-comment);
  letter-spacing: .02em;
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  margin: .5rem 0 1.75rem;
}

/* ============================================
   NAVBAR
   ============================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__logo {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1.05rem;
}
.nav__logo-muted { color: var(--fg-muted); font-weight: 500; }

.nav__links {
  display: flex;
  gap: 1.75rem;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--fg-muted);
  padding: .4rem 0;
  border-bottom: 2px solid transparent;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.nav__link:hover { color: var(--fg); }
.nav__link.is-active { color: var(--fg); border-bottom-color: var(--accent-keyword); }

.nav__dot {
  width: 7px; height: 7px; border-radius: 2px; flex: none;
}
.nav__dot--keyword { background: var(--accent-keyword); }
.nav__dot--string  { background: var(--accent-string); }
.nav__dot--fn      { background: var(--accent-fn); }
.nav__dot--comment { background: var(--accent-comment); }

.nav__burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
}
.nav__burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--fg);
  border-radius: 2px;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.nav__burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__burger.is-open span:nth-child(2) { opacity: 0; }
.nav__burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================
   HERO
   ============================================ */
.hero {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 6vw, 4rem) 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.hero__inner {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.eyebrow { display: block; margin-bottom: 1rem; }

.hero__title {
  font-size: clamp(2.3rem, 5.5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.caret {
  display: inline-block;
  width: .09em;
  height: .85em;
  background: var(--primary);
  margin-left: .12em;
  vertical-align: -.05em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero__subtitle {
  margin-top: 1.25rem;
  max-width: 34rem;
  color: var(--fg-muted);
  font-size: 1.02rem;
}

.hero__actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-mono);
  font-size: .9rem;
  font-weight: 500;
  padding: .7rem 1.1rem;
  border-radius: var(--radius);
  transition: transform .15s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn__prompt { color: var(--primary); }
.btn__arrow { color: var(--fg-muted); }

.btn--primary {
  background: var(--fg);
  color: var(--bg);
}
[data-theme="dark"] .btn--primary { background: var(--primary); color: #0D1016; }
.btn--primary .btn__prompt { color: var(--primary); }
.btn--primary:hover .btn__prompt { color: #fff; opacity: .7; }
[data-theme="dark"] .btn--primary .btn__prompt { color: #0D1016; opacity: .7; }
.btn--primary:hover { background: var(--primary-hover); color: #fff; }
[data-theme="dark"] .btn--primary:hover { color: #0D1016; }
[data-theme="dark"] .btn--primary:hover .btn__prompt { color: #0D1016; }

.btn--ghost {
  border: 1px solid var(--border);
  color: var(--fg);
}
.btn--ghost:hover { border-color: var(--accent-keyword); }

/* code window (hero + about) */
.code-window {
  background: var(--bg-code);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 12px 32px var(--shadow);
  border: 1px solid var(--border);
}
.code-window__bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem .8rem;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.code-window__dot { width: 9px; height: 9px; border-radius: 50%; }
.code-window__dot--r { background: #E5635A; }
.code-window__dot--y { background: #E5B84B; }
.code-window__dot--g { background: #5FBF6E; }
.code-window__title {
  margin-left: .5rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: #8B9099;
}
.code-window__body {
  margin: 0;
  padding: 1.25rem 1.4rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.7;
  color: #C9CCD1;
  overflow-x: auto;
}
.tok-comment { color: var(--accent-comment); }
.tok-keyword { color: var(--accent-keyword); }
.tok-string  { color: var(--accent-string); }
.tok-fn      { color: var(--accent-fn); }

/* Propiedad indentada: si el texto no entra, la continuación queda alineada con la línea */
.code-line {
  display: block;
  padding-left: 2ch;
}
.tok-op      { color: var(--fg-muted); }

/* ============================================
   ABOUT
   ============================================ */
.about {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}
.about__inner {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 3rem;
  align-items: start;
}
.about__text p { color: var(--fg-muted); margin-bottom: 1rem; }
.about__text p:last-of-type { margin-bottom: 1.5rem; }

.chip-list { display: flex; flex-wrap: wrap; gap: .55rem; }
.chip {
  font-family: var(--font-mono);
  font-size: .78rem;
  padding: .35rem .65rem;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-radius: 6px;
  color: var(--primary);
}

/* ============================================
   PROJECTS
   ============================================ */
.projects {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

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

.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.project-card:hover {
  border-color: var(--accent-keyword);
  transform: translateY(-3px);
  box-shadow: 0 14px 28px var(--shadow);
}

.project-card__file {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--accent-comment);
}

.project-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: .6rem 0 .5rem;
}

.project-card__desc {
  color: var(--fg-muted);
  font-size: .92rem;
  flex: 1;
}

.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.tag {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  padding: .2rem .5rem;
  border-radius: 5px;
}

.project-card__links {
  display: flex;
  gap: 1rem;
  margin-top: .25rem;
}
.project-link {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--fg);
  border-bottom: 1px solid transparent;
}
.project-link:hover { color: var(--accent-keyword); border-bottom-color: var(--accent-keyword); }

/* ============================================
   CONTACT
   ============================================ */
.contact {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.contact__inner {
  display: grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 3rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-line {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.form-line label {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--fg-muted);
}
.form-line label .tok-keyword { font-weight: 500; }

.form-line input,
.form-line textarea {
  font-family: var(--font-mono);
  font-size: .92rem;
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .65rem .8rem;
  resize: vertical;
  transition: border-color .2s var(--ease);
}
.form-line input::placeholder,
.form-line textarea::placeholder { color: var(--fg-muted); opacity: .55; }
.form-line input:focus,
.form-line textarea:focus { border-color: var(--accent-keyword); }

.contact-form .btn { align-self: flex-start; margin-top: .3rem; }

.form-status {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--accent-string);
  min-height: 1.2em;
}

.contact-meta {
  border-left: 1px solid var(--border);
  padding-left: 2rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.contact-meta__label {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--accent-comment);
  margin-bottom: .3rem;
}
.contact-meta__link {
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--fg-muted);
  border-bottom: 1px solid transparent;
  width: fit-content;
}
.contact-meta__link:hover { color: var(--accent-keyword); border-bottom-color: var(--accent-keyword); }

/* ============================================
   STATUS BAR (footer fijo + toggle de tema)
   ============================================ */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--status-h);
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: .72rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .9rem;
  z-index: 200;
}
[data-theme="dark"] .status-bar { background: #0D1016; color: #C9CCD1; }

.status-bar__left, .status-bar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.status-bar__branch { color: var(--accent-string); }
[data-theme="light"] .status-bar__branch { color: #6FE3C4; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  color: inherit;
  transition: background-color .15s var(--ease);
}
.theme-toggle:hover { background: rgba(255,255,255,.12); }
.theme-toggle__icon--moon { display: none; }
[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
[data-theme="dark"] .theme-toggle__icon--moon { display: block; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 860px) {
  .hero__inner,
  .about__inner,
  .contact__inner {
    grid-template-columns: 1fr;
  }
  .hero__code { order: 1; }
  .contact-meta {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1.5rem;
  }
  .projects__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .nav__links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s var(--ease);
  }
  .nav__links.is-open { max-height: 320px; }
  .nav__link {
    padding: 1rem 1.5rem;
    width: 100%;
    border-bottom: 1px solid var(--border);
    border-left: 2px solid transparent;
  }
  .nav__link.is-active { border-left-color: var(--accent-keyword); border-bottom: 1px solid var(--border); }
  .nav__burger { display: flex; }
  .status-bar__item--hide-mobile { display: none; }
}

@media (max-width: 600px) {
  .projects__grid { grid-template-columns: 1fr; }
  .hero__title { font-size: clamp(2rem, 9vw, 2.6rem); }
}

/* Fix responsive sección About */
.about__inner > * {
  min-width: 0;
}

.about .code-window {
  width: 100%;
  max-width: 100%;
}

.about .code-window__body {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Ajustes extra para móviles */
@media (max-width: 860px) {
  .about {
    padding: 2rem 1rem;
  }

  .about__inner {
    gap: 2rem;
  }

  .about__text {
    width: 100%;
  }

  .chip-list {
    gap: .4rem;
  }

  .chip {
    font-size: .72rem;
  }
}