:root {
  --font-body: "Saans", "Saans Fallback", sans-serif;
  --font-display: "Haffer", "Haffer Fallback", sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", monospace;

  /* Asymmetric corner shapes shared by content components */
  --radius-card: 0.5rem 1.25rem 0.5rem 1.25rem;  /* surfaces: cards, code blocks, accordions */
  --radius-chip: 1rem 0.5rem 1rem 0.5rem;        /* interactive chips and buttons */
  --radius-tag: 0.7em 0.25em 0.7em 0.25em;       /* small inline badges, scales with text */
}

.glass {
  background: rgba(255, 255, 255, 0.1);
  background-blend-mode: screen;
  overflow: clip;
  backdrop-filter: blur(10px) saturate(140%);
  outline: 3px solid rgba(255, 255, 255, 0.033);
  outline-offset: -1.5px;
  position: relative;
  box-shadow: 0 0 1rem 0rem var(--surface-color);
  &::before,
  &::after {
    position: absolute;
    width: 300px;
    height: 300px;
    filter: blur(40px);
    opacity: 0.2;
    pointer-events: none;
    content: "";
  }

  &::before {
    background: radial-gradient(
      circle,
      rgba(0, 255, 255, 0.35),
      transparent 70%
    );
    top: -90px;
    left: -120px;
  }
  &::after {
    background: radial-gradient(
      circle,
      rgba(255, 0, 255, 0.28),
      transparent 70%
    );
    bottom: -90px;
    right: -120px;
  }
}
.glass-intense {
  /* theme change: the glass tint and edge fade slowly */
  transition: background-color 2s ease, outline-color 2s ease;
  &::before,
  &::after {
    opacity: 0.5;
  }
}

.border-radius-full {
  border-radius: 3rem;
}

.border-radius-a {
  border-radius: 0.75rem 3rem 0.75rem 3rem;
  border-radius: clamp(0.25rem, 2.5vw, 0.75rem) clamp(1.875rem, 4vw, 2.75rem) clamp(0.25rem, 2.5vw, 0.75rem) clamp(1.875rem, 4vw, 2.75rem);
}

.border-radius-b {
  border-radius: 3rem 0.75rem 3rem 0.75rem;
  border-radius: clamp(1.875rem, 4vw, 2.75rem) clamp(0.25rem, 2.5vw, 0.75rem) clamp(1.875rem, 4vw, 2.75rem) clamp(0.25rem, 2.5vw, 0.75rem);

  
}

body {
  background-color: rgb(34, 34, 34);
  background-image: url("../img/bg.webp");
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
  height: 100dvh;
  margin: 0;
  display: flex;
  align-items: end;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background-blend-mode: screen;
  font-family: var(--font-body);
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--overlay-color);
    z-index: 0;
    pointer-events: none;
  }
  @media (max-width: 900px) {
    height: initial;
    overflow: initial;
  }
}


.social-links {
  ul {
    display: flex;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: .875rem 1.25rem;
    li {
      margin-bottom: 0;
      /* block link/button = the icon's padded box, so the focus ring wraps the
         same shape as the hover tint (an inline link was smaller: cut ring).
         The CV opener is a <button> (it opens a dialog) styled the same. */
      :is(a, button) {
        display: block;
        padding: 0;
        border-radius: var(--radius-chip);
        &:focus-visible {
          outline: 2px solid var(--focus-ring);
          outline-offset: 2px;
        }
        i {
          display: block;
          font-size: 1.75rem;
          padding: 0.5rem;
          color: var(--accent-color);
          opacity: 0.6;
          border-radius: inherit;
        }
        &:hover i,
        &:focus-visible i {
          opacity: 1;
          background: var(--surface-color);
        }
      }
    }
  }
}

/* Circular avatar crop, shared by the header button (.avatar-btn) and the
   info drawer (.info-drawer__avatar). The element sets its own size.
   The photo is larger than the circle and pushed down, so its bottom edge
   (cut torso) falls outside the circle and the face sits near its center.
   Tune here: zoom = photo width vs. the circle, y = offset from the circle's
   top (% of its height; higher = lower), x = horizontal nudge (% of its
   width; higher = to the right). Solid accent background; a hairline ring
   keeps the edge visible over the glass (mostly in dark mode). */
.avatar-crop {
  --avatar-zoom: 115%;
  --avatar-y: 8%;
  --avatar-x: 4%;
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--accent-color);
  box-shadow: 0 0 0 1px var(--line-color);
  img {
    position: absolute;
    top: var(--avatar-y);
    left: calc(50% + var(--avatar-x));
    /* only the width is set: height follows the photo's ratio (never stretched) */
    width: var(--avatar-zoom);
    height: auto;
    max-width: none;
    translate: -50% 0;
    /* hover zoom (.avatar-btn) grows around the face, not the image center */
    transform-origin: 50% 30%;
  }
}

header {
  .avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    flex: none;
    border-radius: 50%;
    padding: 0;
    color: inherit;
    text-align: start;
    .avatar-btn__photo {
      width: 100%;
      flex: none;
    }
    /* name + hint: only in the open mobile menu */
    .avatar-btn__text {
      display: none;
    }
    /* breathing room between the avatar and the nav items, scales with the layout
       (cqi = % of .layout's width, a size container) */
    /* shrinks to ~0 near the 900px breakpoint, where the header is tightest */
    margin-inline-end: clamp(0rem, calc(12cqi - 6.5rem), 2.5rem);
    @media (prefers-reduced-motion: no-preference) {
      img {
        transition: scale 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
      }
    }
    /* it opens a drawer: a zoom on the photo (not the circle) invites the click */
    &:hover img {
      scale: 1.14;
    }
    &:focus-visible {
      outline: 2px solid var(--focus-ring);
      outline-offset: 2px;
    }
  }
  nav {
    ul {
      display: flex;
      gap: 0.25rem;
      list-style: none;
      margin: 0;
      padding: 0;
      max-width: 100%;
      li {
        font-size: var(--fs-8);
        font-weight: 400;
        min-width: fit-content;
        a {
          /* inactive links slightly muted, so hover/current stand out by contrast */
          color: color-mix(in srgb, var(--accent-color) 75%, transparent);
          font-family: var(--font-mono);
          text-decoration: none;
          /* inline padding tightens on narrow layouts (10px at the breakpoint, 1rem from ~1100px) */
          padding: 0.75rem clamp(0.625rem, calc(4cqi - 1.75rem), 1rem);
          display: inline-block;
          border-radius: 0.75rem 0.25rem 0.75rem 0.25rem;
          transition: color 0.2s ease-out, background-color 0.2s ease-out, box-shadow 0.2s ease-out;
          /* hover: a light tint, just a hint */
          &:hover {
            color: var(--accent-color);
            background: color-mix(in srgb, var(--surface-color) 50%, transparent);
          }
          /* current section: full tint + hairline border, reads as "selected" */
          /* monospace: same advance at any weight, so no layout shift */
          &[aria-current="location"] {
            color: var(--accent-color);
            font-weight: 600;
            background: var(--surface-color);
            box-shadow: inset 0 0 0 1px var(--line-color);
          }
          &:focus-visible {
            outline: 2px solid var(--focus-ring);
            outline-offset: 2px;
          }
        }
      }
    }
  }

  /* Controls group (language + theme): hairline divider from the main nav.
     Both spacings stay tight near the breakpoint and open up on wide layouts:
     - divider → language: 1rem at the breakpoint; matches the header gap on
       the nav side (~28px at a 1136px layout, 2rem at max width)
     - language → theme: 20px → 28px (gap set in layout.css, next to the
       generic "header > *" gap it overrides)
     The divider is the border: padding-block makes it a bit taller than the
     controls (doesn't grow the header, which is sized by the nav links). */
  .header__controls {
    border-inline-start: 1px solid var(--line-color);
    padding-inline-start: clamp(1rem, calc(6cqi - 2.5rem), 2rem);
    padding-block: 0.25rem;
  }

  /* Language switch: one link, plain mono text "ES/EN", no pill. A click
     anywhere switches to the other language. The current language stands out
     by type (accent + weight + underline + size) and comes first via "order"
     (DOM order stays fixed). js/ui/lang-switch.js animates the swap.
     Label sizes are em-based on the link (--fs-8 here, larger in the mobile
     menu): current 1em, other 0.75em. Labels and "/" share the baseline. */
  .lang-switch {
    display: inline-flex;
    align-items: baseline;
    /* ~24px target (WCAG 2.5.8) for the whole control */
    padding-block: 0.25rem;
    font-family: var(--font-mono);
    font-size: var(--fs-8);
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.25rem;
    &:focus-visible {
      outline: 2px solid var(--focus-ring);
      outline-offset: 2px;
    }
    /* hovering any part lights up the language you'd switch to
       (not right after a click, until the pointer leaves: js/ui/lang-switch.js) */
    &[href]:hover:not([data-just-switched]) .lang-switch__label:not([data-current]) {
      color: var(--accent-color);
    }
    /* disabled (no href) until the English version exists: dimmed, inert;
       the tooltip ("coming soon") still shows on hover */
    &:not([href]) {
      opacity: 0.55;
      cursor: default;
    }
  }
  .lang-switch__label {
    order: 2;
    font-size: 0.75em;
    /* the swap animation scales from the bottom-left, near the baseline */
    transform-origin: left bottom;
    transition: color 0.2s ease-out;
    &[data-current] {
      order: 0;
      font-size: 1em;
      color: var(--accent-color);
      font-weight: 600;
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 0.3em;
    }
  }
  .lang-switch__sep {
    order: 1;
  }
}

.avatar {
  position: relative;
  z-index: 1;
}

/* Compact header + fullscreen menu: same breakpoint as the stacked layout (layout.css) */
:where(.layout) > header {
  @media (max-width: 900px) {
    background-color: var(--surface-light-color);
    backdrop-filter: blur(100px);
    &.border-radius-full {
      padding: 0 !important;
      border-radius: var(--radius-chip);
    }

    :not(#menu-toggle, #menu-toggle *) {
      display: none;
    }
    /* Open menu: 3-row grid with the same 1rem inset on every side.
       - top: avatar + name (its center matches the close button: both 3rem
         high, 1rem from the top; the toggle stays absolutely positioned so it
         doesn't move between closed and open)
       - middle: nav card, centered, scrolls if the screen is short
       - bottom: language (start) and theme (end) */
    &.menu-open {
      /* item size: grows with the width, capped so the 6 items fit the height.
         Each item is ~2.9 × --nav-fs tall (line-height + paddings), ~17.5 × for
         the list; the rest of the screen takes ~15rem (top/bottom bars 2 × 3rem,
         header padding 2rem, grid gaps 2rem, card padding up to 5rem).
         The 1rem floor only kicks in on very short screens (landscape phones),
         where the card scrolls. */
      --nav-fs: clamp(1rem, min(0.6rem + 3.2vw, (100dvh - 15rem) / 18), 2.25rem);
      border-radius: 0;
      inset: 0;
      width: 100% !important;
      height: 100%;
      padding: 1rem !important;
      /* grid (display, rows, gap): layout.css, which loads later and would override it here */
      :not(#menu-toggle, #menu-toggle *) {
        display: flex;
      }
      .avatar-btn {
        justify-self: start;
        /* keeps clear of the close button (3rem + 1rem gap) */
        max-width: calc(100% - 4rem);
        width: auto;
        min-height: 3rem;
        margin: 0;
        gap: 0.75rem;
        border-radius: 1.5rem 0.75rem 1.5rem 0.75rem;
        .avatar-btn__photo {
          width: 3rem;
        }
        .avatar-btn__text {
          flex-direction: column;
          min-width: 0;
          line-height: 1.25;
          strong {
            font-size: var(--fs-5);
            font-weight: 600;
          }
          small {
            font-family: var(--font-mono);
            font-size: var(--fs-9);
            color: var(--text-muted);
          }
        }
      }
      /* language at the start, theme at the end; the group itself has no box */
      .header__controls {
        justify-content: space-between;
        min-height: 3rem;
        border: 0;
        padding: 0;
      }
      .lang-switch {
        /* ≥44px touch target */
        min-height: 3rem;
        padding-inline: 0.5rem;
        margin-inline-start: -0.5rem;
        /* base size for the em-based labels (current 1em, other 0.75em) */
        font-size: var(--fs-5);
      }
      .theme-toggle-label {
        min-height: 3rem;
        align-items: center;
        /* the switch is %-based: a real height instead of transform: scale */
        .custom-switch {
          height: 1.6rem;
        }
      }
      nav {
        justify-self: center;
        width: min(100%, clamp(300px, 65vw, 520px));
        max-height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 1.5rem 0.5rem 1.5rem 0.5rem;
        ul {
          display: flex !important;
          flex-direction: column !important;
          align-items: stretch;
          justify-content: center;
          justify-self: unset;
          gap: 0;
          background: var(--surface-light-color);
          padding: clamp(1rem, min(4vw, 4dvh), 2.5rem) clamp(1.25rem, 3vw, 2rem);
          border-radius: 1.5rem 0.5rem 1.5rem 0.5rem;
          width: 100%;
          counter-reset: nav-item;

          li {
            counter-increment: nav-item;
            font-size: var(--nav-fs);
            justify-content: start;
            width: 100%;
            padding-block: 0.18em;

            /* hairline between items; the padding keeps the active pill off the line */
            & + li {
              border-top: 1px solid var(--line-color);
            }

            /* index layout: number + label, left aligned, ≥44px touch target */
            a {
              align-items: baseline;
              gap: 0.55em;
              width: 100%;
              padding: 0.45em 0.75em;

              /* sizes derive from --nav-fs, so the number scales with the label */
              &::before {
                content: counter(nav-item, decimal-leading-zero);
                /* fixed width: the label doesn't move when the active number grows */
                min-width: calc(var(--nav-fs) * 0.8);
                font-size: calc(var(--nav-fs) * 0.55);
                font-weight: 400;
                font-variant-numeric: tabular-nums;
                color: var(--text-muted);
                transition: color 0.2s ease-out, font-size 0.2s ease-out;
              }

              /* current section: desktop look (tint + hairline) + stronger, larger number */
              &[aria-current="location"]::before {
                font-size: calc(var(--nav-fs) * 0.6);
                font-weight: 700;
                color: var(--accent-color);
              }
            }
          }
        }
      }
    }
  }
}

/* Mobile menu: staggered entrance of the items (replays on every open,
   since the items go from display: none to flex) */
@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
  header.menu-open nav li {
    animation: nav-item-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    &:nth-child(2) { animation-delay: 55ms; }
    &:nth-child(3) { animation-delay: 110ms; }
    &:nth-child(4) { animation-delay: 165ms; }
    &:nth-child(5) { animation-delay: 220ms; }
    &:nth-child(6) { animation-delay: 275ms; }
  }
}

/* Open mobile menu covers the page: no scrolling behind it */
@media (max-width: 900px) {
  html:has(header.menu-open) {
    overflow: hidden;
  }
}

@keyframes nav-item-in {
  from {
    opacity: 0;
    transform: translateY(0.9rem);
  }
}

#menu-toggle {
  display: none;
  font-size: 2rem;
  color: var(--accent-color);
  opacity: 0.6;
  transition: opacity 0.25s ease-out, color 0.25s ease-out, background-color 0.25s ease-out;
  padding: 0.5rem;
  line-height: 1;
  border-radius: var(--radius-chip);
  i {
    display: block;
  }
  /* open menu: same spot as the closed button (header is fixed at
     top/right 1rem with no padding) and its own backing, like .dialog-close */
  &[aria-expanded="true"] {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--surface-light-color);
    backdrop-filter: blur(100px);
    -webkit-backdrop-filter: blur(100px);
    /* fade only the glyph, not the backing (opacity would fade both) */
    opacity: 1;
    color: color-mix(in srgb, var(--accent-color) 60%, transparent);
  }
  &:hover,
  &:focus-visible {
    opacity: 1;
    color: var(--accent-color);
    background: var(--surface-color);
  }
  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }
  @media (max-width: 900px) {
    display: block;
  }
}

/* receives focus from the back-to-top button: no ring around the whole intro */
#intro:focus {
  outline: none;
}

/* skip link target: focus lands in the scroll area, no ring around all the content */
.content-wrapper:focus {
  outline: none;
}

/* Skip link: first tab stop, off-screen until focused; then a glass pill
   in the top-left corner (same surface and corners as the menu button) */
.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000000;
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-8);
  color: var(--accent-color);
  text-decoration: none;
  background: var(--surface-light-color);
  backdrop-filter: blur(100px);
  -webkit-backdrop-filter: blur(100px);
  border-radius: var(--radius-chip);
  box-shadow: 0 0.4rem 1.25rem -0.75rem rgba(0, 0, 0, 0.3);
  translate: 0 calc(-100% - 2rem);
  &:focus-visible {
    translate: none;
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }
  @media (prefers-reduced-motion: no-preference) {
    transition: translate 0.2s ease-out;
  }
}

/* Back to top (js/ui/to-top.js toggles .is-visible). Lives outside .layout
   (see index.html), always position: fixed.
   - Wide desktop (>= 1280px): floats in the viewport corner, outside the card.
   - Narrow desktop (901-1279px): tucked into the card's bottom-right corner,
     clear of the content scrollbar. Card edges derive from .layout
     (max-width 1200px, padding 2rem + --center-pad when centered).
   - Mobile: viewport corner.
   Hidden state uses visibility so it can't be focused or clicked, delayed
   until the fade-out ends. */
.to-top {
  --to-top-size: 2.25rem;
  --to-top-inset: 0.4rem;
  position: fixed;
  right: calc(max(0px, (100vw - 1200px) / 2) + 2rem + var(--scrollbar-w, 0px) + var(--to-top-inset));
  bottom: calc(2rem + var(--center-pad, 0px) + var(--to-top-inset));
  z-index: 100;
  display: grid;
  place-items: center;
  width: var(--to-top-size);
  aspect-ratio: 1;
  /* asymmetric corners, echoing the card shapes */
  border-radius: 0.95rem 0.4rem 0.95rem 0.4rem;
  color: var(--accent-color);
  font-size: 0.8rem;
  text-decoration: none;
  background: var(--surface-light-color);
  backdrop-filter: blur(12px) saturate(140%);
  outline: 1px solid var(--line-color);
  outline-offset: -1px;
  box-shadow: 0 0.4rem 1.25rem -0.75rem rgba(0, 0, 0, 0.3);

  @media (min-width: 1280px) {
    --to-top-size: 2.5rem;
    right: 1.25rem;
    bottom: 1.25rem;
  }
  @media (max-width: 900px) {
    --to-top-size: 2.5rem;
    right: 1rem;
    bottom: 1rem;
  }

  /* hidden */
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.75rem) scale(0.85);
  transition:
    opacity 0.3s ease,
    transform 0.35s ease,
    visibility 0s linear 0.35s,
    background-color 0.2s ease,
    box-shadow 0.2s ease;

  i {
    transition: transform 0.25s ease;
  }

  &.is-visible {
    opacity: 0.6;
    visibility: visible;
    transform: none;
    transition:
      opacity 0.35s ease,
      transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
      visibility 0s,
      background-color 0.2s ease,
      box-shadow 0.2s ease;
  }

  &.is-visible:hover,
  &.is-visible:focus-visible {
    opacity: 1;
    background-color: var(--form-surface);
    box-shadow: 0 0.75rem 1.75rem -0.75rem rgba(0, 0, 0, 0.45);
    transform: translateY(-2px);
    i {
      transform: translateY(-2px);
    }
  }
  &:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
  }
  &.is-visible:active {
    transform: scale(0.94);
    transition-duration: 0.1s;
  }

  @media (prefers-reduced-motion: reduce) {
    &,
    &.is-visible,
    &.is-visible:hover,
    &.is-visible:focus-visible,
    &.is-visible:active,
    i {
      transform: none !important;
    }
  }
}

iframe{
  border: none;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  aspect-ratio: 16/10;
  background-color: transparent;
}


/* =========================
Scrollbar styling
========================= */

/* Firefox */

*{
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
}

/* WebKit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.25),
    rgba(255, 255, 255, 0.1)
  );
  border-radius: 999px;

  /* clave para efecto glass */
  border: 1px solid rgba(255, 255, 255, 0.2);
  background-clip: padding-box;

  /* progressive enhancement */
  transition: background 0.2s ease, border-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4),
    rgba(255, 255, 255, 0.2)
  );
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* esquina cuando hay scroll en ambos ejes */
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-button {
  display: none;
}


/* scrollbar base */
main .content-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

/* thumb oculto por defecto */
main .content-wrapper::-webkit-scrollbar-thumb {
  opacity: 0;
  transition: opacity 0.2s ease;

  background: rgba(255, 255, 255, 0.3);
  border-radius: 999px;
}

/* 👇 aparece cuando haces hover en TODO el contenedor */
main .content-wrapper:hover::-webkit-scrollbar-thumb {
  opacity: 1;
}