/*
 * .c-header: site header. White by default (the logo's dark wordmark needs a light ground and the logo is
 * never recolored). --brand puts the header on deep green and seats the logo on a white plate.
 * The mobile menu works without JavaScript: a visually hidden checkbox toggles the panel.
 *
 *   <header class="c-header vt-header">
 *     <div class="c-header__inner c-container">
 *       <a class="c-header__brand" href="/"><img class="c-logo" src="/assets/img/brand/logo-256.webp" width="256" height="122" alt="Medallo.pro"></a>
 *       <input class="c-header__toggle u-visually-hidden" type="checkbox" id="nav-toggle" aria-label="Abrir el menú">
 *       <label class="c-header__burger" for="nav-toggle" aria-hidden="true"><span class="c-icon c-icon--menu"></span></label>
 *       <nav class="c-header__nav" aria-label="Principal">
 *         <ul class="c-header__list">
 *           <li><a class="c-header__link" href="/vitrina/" aria-current="page">Vitrina</a></li>
 *           <li><a class="c-header__link" href="/negocios/">Para negocios</a></li>
 *         </ul>
 *       </nav>
 *       <a class="c-button c-button--primary c-header__cta" href="/negocios/">Registra tu negocio</a>
 *     </div>
 *   </header>
 *
 * Mobile (< 48em): brand + CTA + menu button in one row; the nav opens as a floating panel below.
 * Desktop: brand, nav, CTA in one row. The active link takes the yellow dot, not a color change alone.
 */
.c-logo {
  inline-size: 7.5rem; /* the 120 px minimum width of the logo (D-004) */
  min-inline-size: 7.5rem;
  block-size: auto;
}

.c-header {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--md-z-header);
  background: var(--md-color-surface);
  color: var(--md-color-ink);
}

.c-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--md-space-3);
  min-block-size: 4.5rem;
}

.c-header__brand {
  display: inline-flex;
  flex: none; /* never shrinks below the logo's 120 px minimum */
  align-items: center;
  min-block-size: var(--md-target);
  margin-inline-end: auto;
}

/* Visually hidden checkbox, then its label as the menu button (a 48 px target). */
.c-header__toggle {
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0;
}

.c-header__burger {
  display: inline-flex;
  flex: none; /* always a full 48 px target */
  align-items: center;
  justify-content: center;
  inline-size: var(--md-target);
  block-size: var(--md-target);
  border-radius: var(--md-radius-full);
  background: var(--md-color-surface-alt);
  color: var(--md-color-primary);
  cursor: pointer;
}

.c-header__toggle:focus-visible + .c-header__burger {
  outline: var(--md-focus-width) solid var(--md-color-primary);
  outline-offset: var(--md-focus-offset);
}

.c-header__toggle:checked + .c-header__burger .c-icon {
  --_icon: url('../../img/icons/close.svg');
}

.c-header__nav {
  display: none;
  position: absolute;
  inset-inline: 0;
  inset-block-start: 100%;
  padding: var(--md-space-3) var(--md-gutter) var(--md-space-5);
  background: var(--md-color-surface);
  box-shadow: var(--md-shadow-float);
}

.c-header__toggle:checked ~ .c-header__nav {
  display: block;
}

.c-header__list {
  display: flex;
  flex-direction: column;
}

.c-header__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--md-space-2);
  min-block-size: var(--md-target);
  padding: 0 var(--md-space-2);
  color: var(--md-color-ink);
  font-weight: var(--md-weight-bold);
  text-decoration: none;
}

@media (hover: hover) {
  .c-header__link:hover {
    color: var(--md-color-primary);
    text-decoration: underline;
    text-decoration-thickness: 0.1em;
    text-underline-offset: 0.3em;
  }
}

/* Active: an underline (not color alone) plus the yellow dot before the label. */
.c-header__link[aria-current='page'] {
  text-decoration: underline;
  text-decoration-thickness: 0.18em;
  text-underline-offset: 0.3em;
}

.c-header__link[aria-current='page']::before {
  content: '';
  inline-size: 0.625rem;
  block-size: 0.625rem;
  border-radius: var(--md-radius-full);
  background: var(--md-color-action);
}

/* The CTA stays on the phone row (before the menu button), so it keeps a short label there. */
.c-header__cta {
  order: 2;
  /* The CTA is the part that gives way on a 360 px phone: it may shrink and wrap to two lines
     (still 48 px tall) instead of squeezing the logo or the menu button. */
  flex: 0 1 auto;
  min-inline-size: 0;
  padding-inline: var(--md-space-4);
  font-size: var(--md-font-size-sm);
  line-height: 1.15;
}

.c-header__burger {
  order: 3;
}

/* Desktop layout. .c-header--collapsed keeps the phone layout at any width (styleguide, tests). */
@media (min-width: 48em) {
  .c-header:not(.c-header--collapsed) .c-header__inner {
    gap: var(--md-space-5);
    min-block-size: 5rem;
  }

  .c-header:not(.c-header--collapsed) .c-header__burger,
  .c-header:not(.c-header--collapsed) .c-header__toggle {
    /* display: none also removes the hidden checkbox from the tab order and the a11y tree. */
    display: none;
  }

  .c-header:not(.c-header--collapsed) .c-header__nav {
    display: block;
    position: static;
    order: 1;
    margin-inline-start: auto;
    padding: 0;
    background: none;
    box-shadow: none;
  }

  .c-header:not(.c-header--collapsed) .c-header__list {
    flex-direction: row;
    gap: var(--md-space-2);
  }

  .c-header:not(.c-header--collapsed) .c-header__link {
    padding: 0 var(--md-space-3);
  }

  .c-header:not(.c-header--collapsed) .c-header__brand {
    margin-inline-end: 0;
  }

  .c-header:not(.c-header--collapsed) .c-header__cta {
    font-size: var(--md-font-size-base);
    padding-inline: var(--md-space-5);
  }
}

/* Brand variant: deep green header, logo on a white plate. */
.c-header--brand {
  background: var(--md-color-primary);
  color: var(--md-color-on-primary);
}

.c-header--brand .c-header__brand {
  padding: var(--md-space-1) var(--md-space-3);
  border-radius: var(--md-radius-full);
  background: var(--md-color-surface);
}

.c-header--brand .c-header__burger {
  background: var(--md-color-surface);
}

.c-header--brand .c-header__nav {
  background: var(--md-color-primary);
}

.c-header--brand .c-header__link {
  color: var(--md-color-on-primary);
}

@media (hover: hover) {
  .c-header--brand .c-header__link:hover {
    color: var(--md-color-action);
  }
}

.c-header--brand .c-header__toggle:focus-visible + .c-header__burger {
  outline-color: var(--md-color-action);
}

.c-header--brand :focus-visible {
  outline-color: var(--md-color-action);
}
