/* ==========================================================================
   hcontreras.com — design system
   Rule of the house: sans = language, mono = data. Never mix the two roles.
   ========================================================================== */

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
  /* Surface */
  --bg:              #0f172a;              /* slate-900 — the whole canvas    */
  --border:          rgba(226, 232, 240, .1);
  --border-strong:   rgba(226, 232, 240, .2);
  --surface:         rgba(30, 41, 59, .5); /* slate-800/50 — the only surface */

  /* Text — contrast against --bg is noted where it matters */
  --text:            #94a3b8;              /* slate-400 — body, 7.0:1         */
  --text-strong:     #e2e8f0;              /* slate-200 — headings            */
  --text-muted:      #7c8ba1;              /* 5.2:1 — smallest usable text    */
  --text-ghost:      #475569;              /* slate-600 — decorative rules    */

  /* Accent — one color, one job: links, the live nav line, the metrics */
  --accent:          #5eead4;              /* teal-300                        */
  --accent-dim:      rgba(94, 234, 212, .12);
  --sel-bg:          #5eead4;
  --sel-fg:          #134e4a;

  /* Type */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI',
               Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas,
               'Liberation Mono', monospace;

  /* Measure — one value for every block of running text */
  --measure: 34rem;

  /* Spacing — one rhythm, nothing invented */
  --s1: .25rem;   /*  4 */
  --s2: .5rem;    /*  8 */
  --s3: .75rem;   /* 12 */
  --s4: 1rem;     /* 16 */
  --s6: 1.5rem;   /* 24 */
  --s8: 2rem;     /* 32 */
  --s12: 3rem;    /* 48 */
  --s16: 4rem;    /* 64 */
  --s24: 6rem;    /* 96 */

  /* Shape — restrained; pills are reserved, chips are squared */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  /* Motion */
  --dur-fast: 150ms;
  --dur:      300ms;
  --ease:     cubic-bezier(.4, 0, .2, 1);

  --topbar-h: 4rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.625;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, dl, dd, dt, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, picture, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

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

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

/* One icon language: 1.5 stroke, round caps, no fill */
svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: var(--s3) var(--s4);
  background: var(--accent);
  color: var(--sel-fg);
  font-weight: 600;
}
.skip-link:focus { left: var(--s4); top: var(--s4); }

/* ── Mobile top bar (only ever exists below 1024px) ───────────────────── */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  height: var(--topbar-h);
  padding-inline: var(--s6);
  background: rgba(15, 23, 42, .78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.js .topbar { display: flex; }

.topbar__name {
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-strong);
}
.topbar__actions { display: flex; align-items: center; gap: var(--s3); }

.burger {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: -.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  transition: color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.burger:hover { color: var(--accent); background: var(--surface); }
.burger svg { width: 1.375rem; height: 1.375rem; }

/* ── Mobile overlay menu ──────────────────────────────────────────────── */
.menu {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: var(--s4) var(--s6) var(--s8);
  background: var(--bg);
  /* The panel falls out of the bar it was triggered from */
  animation: menu-in 200ms var(--ease) both;
}
.menu[hidden] { display: none; }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px); }
}

.menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--topbar-h) - var(--s4));
}
.menu__title { font-weight: 700; color: var(--text-strong); }

.menu__nav { margin-top: var(--s12); }
.menu__nav a {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  padding-block: var(--s3);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
  transition: color var(--dur-fast) var(--ease);
}
.menu__nav a:hover,
.menu__nav a:focus-visible { color: var(--accent); }
.menu__num {
  font-family: var(--font-mono);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-ghost);
}

.menu__foot {
  margin-top: auto;
  padding-top: var(--s8);
  border-top: 1px solid var(--border);
}
.menu__mail {
  font-family: var(--font-mono);
  font-size: .875rem;
  color: var(--text-strong);
  word-break: break-all;
}
.menu__mail:hover { color: var(--accent); }
.menu__loc {
  margin-top: var(--s1);
  font-size: .875rem;
  color: var(--text-muted);
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.layout {
  max-width: 1280px;
  margin-inline: auto;
  padding: var(--s12) var(--s6);
}

/* Below 1024 the sidebar and content are stacked siblings; without this the
   language control sits flush against the first section heading. */
.content { padding-top: var(--s16); }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--s12);
}

.identity__name {
  font-size: 2.25rem;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text-strong);
}
.identity__role {
  margin-top: var(--s3);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -.015em;
  color: var(--text-strong);
}
.identity__tagline {
  margin-top: var(--s4);
  max-width: 34ch;
  color: var(--text);
}

.resume {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s6);
  font-weight: 600;
  color: var(--accent);
}
.resume svg {
  width: .875rem;
  height: .875rem;
  transition: transform var(--dur) var(--ease);
}
.resume:hover span { text-decoration: underline; text-underline-offset: 4px; }
.resume:hover svg { transform: translate(2px, -2px); }

/* Nav — the line is the affordance; it grows toward the label */
.nav { display: none; margin-top: var(--s12); }
html:not(.js) .nav { display: block; }

.nav__link {
  display: flex;
  align-items: center;
  padding-block: var(--s3);
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease);
}
.nav__line {
  width: 2rem;
  height: 1px;
  margin-right: var(--s4);
  background: var(--text-ghost);
  transition: width var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}
.nav__text {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
}
.nav__link:hover,
.nav__link:focus-visible { color: var(--text-strong); }
.nav__link:hover .nav__line,
.nav__link:focus-visible .nav__line {
  width: 4rem;
  background: var(--text-strong);
}

/* Scroll-spy active: the teal line is the one signal hover never produces,
   so "where am I" can never be confused with "what am I pointing at". */
.nav__link.is-active { color: var(--text-strong); }
.nav__link.is-active .nav__line {
  width: 4rem;
  background: var(--accent);
}

/* Reach + language */
.sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}
.reach { display: flex; flex-direction: column; gap: var(--s3); }

.reach__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-family: var(--font-mono);   /* an address is data, not language */
  font-size: .8125rem;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease);
}
.reach__link:hover { color: var(--accent); }

.reach__item {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-size: .875rem;              /* a place name is language */
  color: var(--text-muted);
  cursor: default;
}
.reach svg { width: 1rem; height: 1rem; flex: none; }

.lang {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-family: var(--font-mono);
  font-size: .75rem;
}
.lang__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;             /* a real touch target */
  padding: var(--s1) var(--s2);
  color: var(--text-muted);
  letter-spacing: .08em;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.lang__btn:hover { color: var(--text-strong); }
.lang__btn[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  font-weight: 600;
}
.lang__sep { color: var(--text-ghost); }

.lang-toggle { cursor: pointer; }
.lang-toggle--bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .08em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.lang-toggle--bar:hover { color: var(--accent); border-color: var(--border-strong); }

/* ── Cursor spotlight ─────────────────────────────────────────────────────
   An absolutely positioned wash inside `.page`, so its coordinates are page
   coordinates and stay correct while scrolling. The gradient is driven by two
   custom properties that main.js springs toward the pointer. The blue is
   deliberately almost imperceptible: blue-700 at 15% over slate-900 lifts the
   backdrop from rgb(15,23,42) to roughly rgb(17,31,68) at the centre. */
.page { position: relative; }

.spotlight {
  position: absolute;
  inset: 0;
  z-index: 25;                 /* above the page, below the top bar (30) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms var(--ease);
  background: radial-gradient(
    600px circle at var(--spot-x, 50%) var(--spot-y, 50%),
    rgba(29, 78, 216, .15),
    transparent 80%
  );
}
.spotlight.is-on { opacity: 1; }

/* Desktop-only decoration. Below 1024 there is no cursor to follow; on a coarse
   pointer there is no cursor at all; and under reduced-motion a large moving
   gradient is exactly the kind of thing the preference exists to stop. */
@media (max-width: 1023px) {
  .spotlight { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spotlight { display: none; }
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.section {
  margin-bottom: var(--s16);
  scroll-margin-top: calc(var(--topbar-h) + var(--s4));
}
.section:last-of-type { margin-bottom: var(--s12); }

.section__head {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s6);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--text);
}
.section__num {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-muted);
}

/* ── Prose ────────────────────────────────────────────────────────────── */
.prose {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  max-width: var(--measure);
}

/* ── Project ──────────────────────────────────────────────────────────── */
.project__shot {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .8);
}
.project__shot img { width: 100%; height: auto; }

.project__body {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  margin-top: var(--s8);
  max-width: var(--measure);
}
.project__head { display: flex; flex-direction: column; gap: var(--s2); }
.project__title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text-strong);
}
.project__kind {
  font-size: .8125rem;
  color: var(--text-muted);
}

.points {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.points li {
  position: relative;
  padding-left: var(--s6);
}
.points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .7em;
  width: .75rem;
  height: 1px;
  background: var(--text-ghost);
}

/* ── Tags — data, so mono and squared off ─────────────────────────────── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}
.tags li {
  padding: var(--s1) var(--s3);
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.more {
  margin-top: var(--s8);
  max-width: var(--measure);
  font-size: .875rem;
  color: var(--text-muted);
}

/* ── Skill groups ─────────────────────────────────────────────────────── */
.groups {
  display: flex;
  flex-direction: column;
  gap: var(--s8);
}
.group__label {
  margin-bottom: var(--s3);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text);
}

/* ── Credentials ──────────────────────────────────────────────────────── */
.credentials {
  display: grid;
  gap: var(--s8);
  margin-top: var(--s12);
  padding-top: var(--s8);
  border-top: 1px solid var(--border);
}
.credential__label {
  margin-bottom: var(--s3);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text);
}
.credential__title { color: var(--text-strong); font-weight: 500; }
.credential__meta { font-size: .875rem; color: var(--text-muted); }

.pairs { display: flex; flex-direction: column; gap: var(--s3); }
.pairs li {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  color: var(--text-strong);
  font-weight: 500;
}
.pairs__level {
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Contact ──────────────────────────────────────────────────────────── */
.cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s8);
  padding: var(--s3) var(--s6);
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.cta svg {
  width: .875rem;
  height: .875rem;
  transition: transform var(--dur) var(--ease);
}
.cta:hover { background: var(--accent-dim); border-color: var(--accent); }
.cta:hover svg { transform: translate(2px, -2px); }

.footer {
  margin-top: var(--s12);
  padding-top: var(--s8);
  border-top: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text-muted);
  max-width: var(--measure);
}

/* ── Tablet ───────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .layout { padding: var(--s16) var(--s12); }
  .topbar { padding-inline: var(--s12); }
  .menu { padding-inline: var(--s12); }

  .identity__name { font-size: 3rem; }
  .identity__role { font-size: 1.25rem; }

  /* More air between major sections as the page gets wider */
  .section { margin-bottom: var(--s24); }
  .credentials { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Desktop: the two-column composition ──────────────────────────────── */
@media (min-width: 1024px) {
  .layout {
    display: flex;
    justify-content: space-between;
    gap: var(--s12);
    padding: 0 var(--s12);
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1 1 48%;
    min-width: 0;
    max-height: 100vh;
    padding-block: var(--s24);
    gap: 0;
  }

  .content {
    flex: 1 1 52%;
    min-width: 0;
    padding-block: var(--s24);
  }

  /* The bar and its overlay menu are a small-screen device only. This must
     out-specify `.js .topbar`, hence the repeated selector. */
  .topbar, .js .topbar { display: none; }

  .nav { display: block; }

  /* Third step of the vertical rhythm: 64 / 96 / 144 */
  .section { margin-bottom: 9rem; }
  .section:last-of-type { margin-bottom: var(--s16); }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
