/* ==========================================================================
   karheda.com
   ========================================================================== */

/* Fuentes (alojadas en local, ver assets/fonts/LICENSE.md)
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/instrument-serif-italic-latin.woff2") format("woff2");
}

/* Tokens
   ========================================================================== */

:root {
  --bg: #0a0b10;
  --surface: rgb(255 255 255 / 0.03);
  --surface-hover: rgb(255 255 255 / 0.055);
  --border: rgb(255 255 255 / 0.08);
  --border-strong: rgb(255 255 255 / 0.14);

  --text: #e9eaf4;
  --muted: #9a9fb4;
  --dim: #5f6579;
  --ok: #4fe3a2;
  --ok-rgb: 79 227 162;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;

  --container: 1140px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 72px;
  --radius: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

/* Paletas de acento. La activa se elige con data-theme en <html> (ámbar).
   --accent-rgb / --glow-rgb son los mismos colores en formato "R G B" para
   poder usarlos con transparencia: rgb(var(--accent-rgb) / 0.2). */

:root,
[data-theme="violet"] {
  --accent-soft: #b4b6ff;
  --accent: #8f91ff;
  --accent-strong: #6e63ff;
  --accent-rgb: 143 145 255;
  --glow-rgb: 110 99 255;
  --code-var: #c3a6ff;
}

[data-theme="ocean"] {
  --accent-soft: #bae6fd;
  --accent: #38bdf8;
  --accent-strong: #2563eb;
  --accent-rgb: 56 189 248;
  --glow-rgb: 37 99 235;
  --code-var: #93c5fd;
}

[data-theme="emerald"] {
  --accent-soft: #a7f3d0;
  --accent: #34d399;
  --accent-strong: #059669;
  --accent-rgb: 52 211 153;
  --glow-rgb: 5 150 105;
  --code-var: #6ee7b7;
}

[data-theme="amber"] {
  --accent-soft: #fde68a;
  --accent: #fbbf24;
  --accent-strong: #ea580c;
  --accent-rgb: 251 191 36;
  --glow-rgb: 234 88 12;
  --code-var: #fdba74;
}

[data-theme="rose"] {
  --accent-soft: #fbcfe8;
  --accent: #f472b6;
  --accent-strong: #db2777;
  --accent-rgb: 244 114 182;
  --glow-rgb: 219 39 119;
  --code-var: #f9a8d4;
}

[data-theme="mono"] {
  --accent-soft: #ffffff;
  --accent: #c9ccd8;
  --accent-strong: #7d8299;
  --accent-rgb: 201 204 216;
  --glow-rgb: 125 130 153;
  --code-var: #e9eaf4;
}

/* Base
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

p {
  text-wrap: pretty;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgb(var(--accent-rgb) / 0.35);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

/* Fondo animado
   ========================================================================== */

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 90% 75% at 50% 35%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 90% 75% at 50% 35%, #000 30%, transparent 100%);
}

.bg-glow {
  position: absolute;
  inset: 0 0 auto;
  height: 110vh;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 45% at 78% 28%, rgb(var(--glow-rgb) / 0.2), transparent 70%),
    radial-gradient(35% 35% at 8% 8%, rgb(var(--ok-rgb) / 0.06), transparent 70%);
}

.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

/* Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid transparent;
  transition: background-color 0.3s, border-color 0.3s;
}

.site-header.is-scrolled {
  background: rgb(10 11 16 / 0.72);
  border-bottom-color: var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 36px;
  height: 36px;
}

.brand-stop-1 {
  stop-color: var(--accent-soft);
}

.brand-stop-2 {
  stop-color: var(--accent-strong);
}

.brand__name {
  font: 500 1.05rem/1 var(--font-mono);
  letter-spacing: -0.01em;
}

.brand__cursor {
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  font-size: 0.9rem;
  color: var(--muted);
}

.site-nav > a:not(.btn) {
  transition: color 0.2s;
}

.site-nav > a:not(.btn):hover {
  color: var(--text);
}

@media (max-width: 640px) {
  .site-nav > a:not(.btn) {
    display: none;
  }
}

@media (max-width: 420px) {
  .site-nav__cta {
    display: none;
  }
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.lang-switch button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--dim);
  font: 500 0.75rem/1 var(--font-mono);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.lang-switch button:hover {
  color: var(--text);
}

.lang-switch button[aria-pressed="true"] {
  background: rgb(var(--accent-rgb) / 0.16);
  color: var(--accent-soft);
}

/* Trazo animado del logo */
.draw {
  stroke-dasharray: 1 2;
  animation: draw 1.4s var(--ease) 0.15s both;
}

.draw--frame {
  animation-duration: 1.8s;
}

.draw--late {
  animation-delay: 0.6s;
}

@keyframes draw {
  from {
    stroke-dashoffset: 1;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* Botones
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: 600 0.95rem/1 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: translate 0.25s var(--ease), background-color 0.2s, border-color 0.2s, box-shadow 0.25s;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn:hover {
  translate: 0 -2px;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
  color: var(--bg);
  box-shadow: 0 10px 30px -12px rgb(var(--glow-rgb) / 0.75);
}

.btn--primary:hover {
  box-shadow: 0 16px 40px -12px rgb(var(--glow-rgb) / 0.95);
}

.btn--primary svg {
  transition: translate 0.25s var(--ease);
}

.btn--primary:hover svg {
  translate: 3px 0;
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--surface-hover);
  border-color: rgb(255 255 255 / 0.24);
}

.btn--sm {
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.875rem;
}

/* Hero
   ========================================================================== */

.hero {
  display: grid;
  align-items: center;
  gap: clamp(48px, 6vw, 72px);
  min-height: calc(100svh - var(--header-h));
  padding-block: clamp(40px, 8vh, 96px);
}

@media (min-width: 960px) {
  .hero {
    grid-template-columns: 1.08fr 0.92fr;
  }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 28px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: 500 0.78rem/1.2 var(--font-mono);
}

.eyebrow a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgb(var(--accent-rgb) / 0.5);
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.eyebrow a:hover {
  color: var(--accent-soft);
}

.eyebrow__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 2.4s infinite;
}

.hero__title {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 3.6rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

/* El apellido salta de línea como bloque cuando no cabe junto al nombre */
.hero__surname {
  display: inline-block;
}

.hero__tagline {
  margin: 18px 0 0;
  color: var(--text);
  font-size: clamp(1.3rem, 2.4vw, 1.75rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero__tagline em,
.contact__title em {
  padding-right: 0.06em;
  background: linear-gradient(120deg, var(--accent-soft) 10%, var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: var(--font-serif);
  font-size: 1.15em;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.hero__code {
  margin: 24px 0 0;
  color: var(--muted);
  font: 400 clamp(0.85rem, 1.6vw, 1.02rem)/1.5 var(--font-mono);
}

.c-var {
  color: var(--code-var);
}

.c-op {
  color: var(--dim);
}

.c-str {
  color: var(--ok);
}

.caret {
  display: inline-block;
  width: 0.55em;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.22em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

.hero__lead {
  max-width: 54ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.3vw, 1.075rem);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

/* Terminal */
.terminal {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgb(20 22 32 / 0.92), rgb(12 13 20 / 0.94));
  box-shadow:
    0 40px 80px -30px rgb(0 0 0 / 0.85),
    0 0 90px -25px rgb(var(--glow-rgb) / 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.terminal__bar {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 0.02);
}

.terminal__dots {
  display: flex;
  gap: 7px;
}

.terminal__dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff5f57;
  opacity: 0.85;
}

.terminal__dots i:nth-child(2) {
  background: #febc2e;
}

.terminal__dots i:nth-child(3) {
  background: #28c840;
}

.terminal__title {
  flex: 1;
  margin-right: 47px;
  color: var(--dim);
  font: 500 0.75rem/1 var(--font-mono);
  text-align: center;
}

.terminal__body {
  margin: 0;
  padding: 20px clamp(14px, 3vw, 24px) 24px;
  overflow-x: auto;
  color: var(--muted);
  font: 400 clamp(11px, 3vw, 13.5px)/1.7 var(--font-mono);
}

.terminal__body code {
  font: inherit;
}

.t-line {
  display: block;
  min-height: 1.7em;
}

.t-line.is-pending,
.t-rest {
  visibility: hidden;
}

.t-prompt,
.t-ok {
  color: var(--ok);
}

.t-cmd,
.t-value {
  color: var(--text);
}

.t-dim {
  color: var(--dim);
}

.t-label {
  color: var(--accent);
}

.t-success {
  padding: 2px 0;
  background: var(--ok);
  color: var(--bg);
  font-weight: 500;
}

.t-caret {
  display: inline-block;
  width: 0.6em;
  height: 1.2em;
  vertical-align: -0.25em;
  background: var(--text);
  animation: blink 1s steps(1) infinite;
}

/* Secciones
   ========================================================================== */

.section {
  padding-block: clamp(72px, 11vw, 136px);
}

.section__head {
  max-width: 640px;
  margin-bottom: clamp(36px, 5vw, 56px);
}

.kicker {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent);
  font: 500 0.8rem/1 var(--font-mono);
  letter-spacing: 0.02em;
}

.section h2 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

/* Tarjetas */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
  gap: 16px;
}

.card {
  position: relative;
  padding: 28px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: translate 0.35s var(--ease), border-color 0.3s;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), rgb(var(--accent-rgb) / 0.13), transparent 65%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.card:hover {
  translate: 0 -4px;
  border-color: var(--border-strong);
}

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

.card > * {
  position: relative;
}

.card__file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.04);
  color: var(--muted);
  font: 500 0.78rem/1 var(--font-mono);
}

.card__file::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}

.card h3 {
  margin: 26px 0 10px;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Stack: sin JS o con movimiento reducido se muestra como lista estática */
.marquee + .marquee {
  margin-top: 12px;
}

.marquee__track {
  padding-inline: var(--gutter);
}

.marquee__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: 500 0.9rem/1 var(--font-mono);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.75;
}

.marquee--reverse .chip::before {
  background: var(--ok);
}

@media (prefers-reduced-motion: no-preference) {
  .js .marquee {
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  }

  .js .marquee__track {
    display: flex;
    width: max-content;
    padding-inline: 0;
    animation: marquee var(--duration, 40s) linear infinite;
  }

  .js .marquee--reverse .marquee__track {
    animation-direction: reverse;
  }

  .js .marquee:hover .marquee__track {
    animation-play-state: paused;
  }

  .js .marquee__list {
    flex-wrap: nowrap;
    padding-right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marquee__list[aria-hidden="true"] {
    display: none;
  }
}

/* Contacto */
.contact__card {
  position: relative;
  padding: clamp(44px, 7vw, 88px) clamp(20px, 5vw, 64px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    radial-gradient(70% 110% at 50% 0%, rgb(var(--glow-rgb) / 0.16), transparent 60%),
    var(--surface);
  text-align: center;
}

.section .contact__title {
  font-size: clamp(2.1rem, 5.5vw, 3.6rem);
  line-height: 1.05;
}

.contact__lead {
  max-width: 50ch;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.1rem);
}

.contact__email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-top: 36px;
  padding: 7px 7px 7px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: rgb(10 11 16 / 0.6);
  font: 500 clamp(0.95rem, 2.4vw, 1.15rem)/1 var(--font-mono);
}

.contact__email a {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.contact__email a:hover {
  color: var(--accent-soft);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-hover);
  color: var(--muted);
  font: 500 0.8rem/1 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.copy-btn svg {
  width: 15px;
  height: 15px;
}

.copy-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.copy-btn.is-done {
  border-color: rgb(var(--ok-rgb) / 0.4);
  color: var(--ok);
}

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.social {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  transition: translate 0.25s var(--ease), color 0.2s, border-color 0.2s;
}

.social svg {
  width: 18px;
  height: 18px;
}

.social:hover {
  translate: 0 -2px;
  border-color: var(--border-strong);
  color: var(--text);
}

/* Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: 28px;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.site-footer code {
  font: 400 0.8rem/1.4 var(--font-mono);
}

/* Aparición al hacer scroll
   ========================================================================== */

.js .reveal {
  opacity: 0;
}

.js .reveal.is-visible {
  animation: reveal 0.9s var(--ease) both;
  animation-delay: calc(var(--d, 0) * 90ms);
}

/* Keyframes
   ========================================================================== */

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgb(var(--ok-rgb) / 0.55);
  }
  70%,
  100% {
    box-shadow: 0 0 0 10px rgb(var(--ok-rgb) / 0);
  }
}

@keyframes marquee {
  to {
    transform: translateX(calc(-1 * var(--shift, 50%)));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
