/* ==============================================================================
   SITE HEADER (templates/partials/header.html)
   ============================================================================== */

/* The header is part of the paper, not a bar laid over it: same
   background as the page and a hairline under it, so on the home page
   the photo of the showcase is the first strong thing the eye meets
   (doc/07). */
.site-header {
  background: var(--page-bg);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

/* Same width as the page's content column (page.css), so the wordmark
   lines up with the text below it and with the slideshow caption. On a
   phone the bar wraps into two rows: wordmark and tools first, the
   navigation under them (see the media query at the end). */
.site-header__bar {
  max-width: calc(var(--content-max-width) + 2 * var(--spacing-lg));
  margin: 0 auto;
  padding: var(--spacing-sm) var(--spacing-lg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--spacing-xl);
  row-gap: var(--spacing-xs);
}

/* --------------------------------------------------------------------------
   Wordmark: the logo's column and "M|C", which opens to the full surnames
   on hover or keyboard focus. Each surname's tail sits in a one-column
   inline grid whose track goes from 0fr to 1fr; that is the one way to
   animate a width to its content's own size without measuring it in
   script. The global reduced-motion guard (main.css) turns the 200 ms
   into an instant change.
   -------------------------------------------------------------------------- */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-height: 44px;
  color: var(--text-primary);
  text-decoration: none;
}

.wordmark:hover {
  text-decoration: none;
}

/* The PNG is a black silhouette at 256px; it is drawn at 2rem and
   inverted in dark mode below, so the column stays the ink colour. */
.wordmark__logo {
  width: 2rem;
  height: 2rem;
}

.wordmark__name {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-title);
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.wordmark__word {
  display: inline-flex;
}

.wordmark__rest {
  display: inline-grid;
  grid-template-columns: 0fr;
  transition: grid-template-columns 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.wordmark__rest > span {
  overflow: hidden;
}

.wordmark:hover .wordmark__rest,
.wordmark:focus-visible .wordmark__rest {
  grid-template-columns: 1fr;
}

.wordmark__bar {
  margin-inline: 0.2em;
  color: var(--text-muted);
  font-weight: 700;
}

.wordmark__tagline {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

:root[data-theme="dark"] .wordmark__logo {
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark__logo {
    filter: invert(1);
  }
}

/* --------------------------------------------------------------------------
   Navigation: three words, the current one underlined in the accent and
   set in the bold weight, so the state never rests on colour alone.
   -------------------------------------------------------------------------- */
.site-nav {
  margin-inline-start: auto;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-lg);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav__list a {
  display: inline-block;
  padding-block: var(--spacing-xs);
  border-bottom: 2px solid transparent;
  color: var(--text-primary);
  text-decoration: none;
}

.site-nav__list a:hover {
  border-bottom-color: var(--border-color);
  text-decoration: none;
}

.site-nav__list li.is-current a {
  border-bottom-color: var(--accent-blue);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Tools: the language switcher ("ES / EN") and the theme buttons, both
   set as small text separated by a slash, the way a drawing's title
   block lists its options. The slash is a ::before with an empty
   alternative text after the "/" so assistive tech reads only the
   choices themselves.
   -------------------------------------------------------------------------- */
.site-header__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-xs) var(--spacing-lg);
}

.lang-switch {
  display: flex;
  align-items: center;
}

/* 4 px on each side bring "ES", two letters wide (16 px), to the 24 px a
   target needs (WCAG 2.5.8). The slash of the next link is drawn inside
   that link, after its own 4 px, so its margin only goes on the far side
   and the slash still sits halfway between the two codes. */
.lang-switch__link {
  padding: var(--spacing-xs) 4px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  text-decoration: none;
  text-transform: uppercase;
}

.lang-switch__link + .lang-switch__link::before {
  content: "/" / "";
  margin-inline: 0 var(--spacing-sm);
  color: var(--border-color);
}

.lang-switch__link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.lang-switch__link.is-current {
  color: var(--text-primary);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Phones and narrow tablets: wordmark and tools share the first row, the
   navigation takes the whole second one. The tagline goes first when
   space runs out, the surnames are still a tap away on the wordmark.
   -------------------------------------------------------------------------- */
@media (max-width: 48em) {
  .site-header__bar {
    padding-inline: var(--spacing-md);
    column-gap: var(--spacing-md);
  }

  /* Tighter here so "ES / EN" and the three theme words still share the
     wordmark's row from 375px; at 320px they drop to a row of their own. */
  .site-header__tools {
    margin-inline-start: auto;
    column-gap: var(--spacing-md);
  }

  .site-nav {
    order: 3;
    flex-basis: 100%;
    margin-inline-start: 0;
  }
}

@media (max-width: 30em) {
  .wordmark__tagline {
    display: none;
  }
}
