/*
 * The shell's header (M1-SHELL): the top strip, the header row and the menu row with its panels, the mobile
 * menu and the search form. Colours, sizes and weights come from tokens.css.
 *
 * Breakpoints: the menu row shows from 1024 px; under it the 'Meniu' button opens the menu. Under 768 px the
 * strip's three links are at the end of that menu and the register button takes a row of its own.
 */

.site-header {
  position: relative;
  z-index: 20;
  background: var(--color-surface);
}

.site-header [hidden] {
  display: none;
}

.site-header .icon {
  flex: none;
}

/* ---------- Top strip: dark green ---------- */

.top-strip {
  background: var(--color-background-strip);
  color: var(--color-text-on-strip);
  font-size: var(--font-size-12);
  line-height: var(--line-height-16);
}

.top-strip__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-8) var(--spacing-24);
  min-height: var(--size-2rem);
}

.top-strip__identity {
  display: flex;
  align-items: center;
  gap: var(--spacing-8);
  min-width: 0;
  margin: 0;
}

.top-strip__identity span {
  font-weight: var(--font-weight-medium);
}

/* The emblem is dark blue: a white plate keeps it visible on the green */
.top-strip__identity img {
  flex: none;
  padding: var(--spacing-2);
  border-radius: var(--border-radius-4);
  background: var(--color-background-base-default);
  box-sizing: content-box;
}

.top-strip a {
  color: var(--color-text-on-strip);
}

.top-strip__links ul {
  display: flex;
  gap: var(--spacing-16);
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-strip__links a {
  display: inline-block;
  padding-block: var(--spacing-8);
  text-decoration: none;
}

.top-strip a:is(:hover, :focus-visible) {
  color: var(--color-text-on-strip);
  text-decoration: underline;
}

/* The tools and the language switch are one group at the strip's right end: where the strip wraps, the group
   moves as one and stays right-aligned (LT-7). Under 768 px it dissolves (see the narrow block). */
.top-strip__end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-8) var(--spacing-24);
  margin-left: auto;
}

.top-strip__tools {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
}

/* The text-size and read-aloud controls (UI-38, de confirmat): text buttons on the green, a white outline on hover */
.strip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-4);
  min-width: var(--size-2rem);
  min-height: var(--size-2rem);
  padding: var(--spacing-4) var(--spacing-8);
  border: var(--border-width-1) solid transparent;
  border-radius: var(--border-radius-4);
  background: transparent;
  color: var(--color-text-on-strip);
  font: var(--font-weight-medium) var(--font-size-12) / var(--line-height-16) var(--font-family-stack);
  cursor: pointer;
}

.strip-button[hidden] {
  display: none;
}

.strip-button:hover {
  border-color: var(--color-text-on-strip);
  text-decoration: underline;
}

.strip-button[aria-pressed="true"] {
  border-color: var(--color-text-on-strip);
  background: var(--color-text-on-strip);
  color: var(--color-background-strip);
}

.strip-button[aria-disabled="true"],
.strip-button[aria-disabled="true"]:hover {
  border-color: var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-text-disabled);
  cursor: not-allowed;
  text-decoration: none;
}

.top-strip .language-switch {
  margin-left: var(--spacing-8);
}

.top-strip .language-switch__link {
  min-width: var(--size-2-25rem);
  color: var(--color-text-on-strip-muted);
  font-size: var(--font-size-12);
  line-height: var(--line-height-16);
}

.top-strip .language-switch__link[aria-current="true"] {
  color: var(--color-text-on-strip);
  font-weight: var(--font-weight-semibold);
}

.top-strip .language-switch__link:is(:hover, :focus-visible) {
  color: var(--color-text-on-strip);
  text-decoration: underline;
}

/* ---------- Header row: logo and tagline, search, register ---------- */

.header-row__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-8) var(--spacing-12);
  padding-block: var(--spacing-12);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-16);
  margin-right: auto;
  min-width: 0;
}

.brand__logo {
  display: block;
  line-height: 0;
}

.brand__logo img {
  display: block;
  width: var(--size-7-5rem);
  height: auto;
}

.brand__tagline {
  margin: 0;
  padding-left: var(--spacing-16);
  border-left: var(--border-width-1) solid var(--color-border);
  color: var(--color-text-secondary);
  font-family: var(--font-family-serif);
  font-style: italic;
  font-size: var(--font-size-18);
  line-height: var(--line-height-26);
}

.header-search,
.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-8);
  min-width: var(--size-2-75rem);
  min-height: var(--size-2-75rem);
  padding: var(--spacing-8) var(--spacing-16);
  border: var(--border-width-1) solid var(--color-border-field);
  border-radius: var(--border-radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--font-weight-medium) var(--font-size-16) / var(--line-height-24) var(--font-family-stack);
  cursor: pointer;
  transition:
    color var(--motion-duration-fast) var(--motion-easing-standard),
    background-color var(--motion-duration-fast) var(--motion-easing-standard),
    border-color var(--motion-duration-fast) var(--motion-easing-standard),
    box-shadow var(--motion-duration-fast) var(--motion-easing-standard);
}

.header-search:hover,
.menu-button:hover {
  background: var(--color-background-action-hover);
}

/* Expanded (FS-5): the one selected look of components.css (--color-background-action-active, a 1 px --color-action border),
   stronger than the hover tint and kept under the pointer; it changes over --motion-duration-fast with the transition above */
.header-search[aria-expanded="true"],
.menu-button[aria-expanded="true"] {
  border-color: var(--color-action);
  background: var(--color-background-action-active);
  color: var(--color-text);
}

.header-register {
  min-height: var(--size-2-75rem);
  padding: var(--spacing-8) var(--spacing-20);
  border-radius: var(--border-radius-full);
}

/* From 768 px the pills are the 40 px pills of design 01 with 14/20 text, weight 500, and a 20 px magnifier (LT-5).
   Under 768 px they stay as milestone 3 has them (LT-8). At 14 px the register label fits one line at 1024 px in RU and EN. */
@media (min-width: 768px) {
  .header-search,
  .menu-button,
  .header-register {
    min-height: var(--control-height-small);
    padding-block: var(--spacing-8);
    font-size: var(--font-size-14);
    line-height: var(--line-height-20);
  }

  .header-search .icon {
    width: var(--size-1-25rem);
    height: var(--size-1-25rem);
  }
}

/* The menu button is for the narrow layouts */
.menu-button {
  display: none;
}

/* While the menu is open the button shows × (and the script writes 'Închide', MO-3); closed, the three bars */
.menu-button .menu-button__close,
[data-menu-toggle][aria-expanded="true"] > .menu-button__open {
  display: none;
}

[data-menu-toggle][aria-expanded="true"] > .menu-button__close {
  display: block;
}

/* ---------- Search panel (OWN-2) ---------- */

/* An overlay: out of the flow, so opening it does not move #main. It starts at the header's bottom edge (top: 100% of the positioned
   .site-header, 164 px at 1440 px), under the menu row and not over it, so the .nav-group buttons stay clickable with the panel open
   (brief-m4-9). It spans the header and passes pointer events through everywhere but its panel, which is at container width on white
   with --shadow-100, above the page. It enters over --motion-duration-base from opacity 0 and 8 px up, and leaves over
   --motion-duration-fast: the script sets and clears hidden, and display is transitioned discretely so the leaving panel stays rendered
   until it has faded; where @starting-style or allow-discrete is missing it shows and hides at once. Under reduced motion it has no
   transform and the durations are within 0.01 ms (base.css). Without script the noscript style shows it in the flow. */
.site-search {
  position: absolute;
  inset-block-start: 100%;
  inset-inline: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity var(--motion-duration-base) var(--motion-easing-standard),
    transform var(--motion-duration-base) var(--motion-easing-standard),
    display var(--motion-duration-base) var(--motion-easing-standard) allow-discrete;
}

@starting-style {
  .site-search {
    opacity: 0;
    transform: translateY(calc(var(--spacing-8) * -1));
  }
}

.js .site-search[hidden] {
  display: none;
  opacity: 0;
  transform: translateY(calc(var(--spacing-8) * -1));
  transition:
    opacity var(--motion-duration-fast) var(--motion-easing-standard),
    transform var(--motion-duration-fast) var(--motion-easing-standard),
    display var(--motion-duration-fast) var(--motion-easing-standard) allow-discrete;
}

@media (prefers-reduced-motion: reduce) {
  .site-search,
  .js .site-search[hidden] {
    transform: none;
  }

  @starting-style {
    .site-search {
      transform: none;
    }
  }
}

.site-search__panel {
  padding: var(--spacing-16) var(--spacing-24) var(--spacing-24);
  border-radius: 0 0 var(--border-radius-8) var(--border-radius-8);
  background: var(--color-surface);
  box-shadow: var(--shadow-100);
  pointer-events: auto;
}

.site-search__form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--spacing-12) var(--spacing-8);
}

.site-search__field {
  flex: 1 1 var(--size-16rem);
}

/* The field as #hero-q: 48 px, a 20 px magnifier 16 px from its start */
.site-search__control {
  position: relative;
}

.site-search__control input {
  padding-inline-start: var(--spacing-48);
}

.site-search__icon {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--spacing-16);
  margin-block: auto;
  color: var(--color-icon-base-default);
  pointer-events: none;
}

.site-search__submit {
  flex: 0 0 auto;
  min-width: var(--size-8rem);
}

.site-search__close {
  flex: 0 0 auto;
  width: var(--control-height);
  padding-inline: 0;
}

@media (max-width: 767.98px) {
  .site-search__panel {
    padding-inline: var(--spacing-16);
  }

  .site-search__submit {
    min-width: 0;
  }
}

/* ---------- Menu row ---------- */

.main-nav {
  border-top: var(--border-width-1) solid var(--color-border);
  border-bottom: var(--border-width-1) solid var(--color-border);
}

.main-nav__inner {
  position: relative;
}

.main-nav__groups {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  position: relative;
}

.nav-item--wide {
  position: static;
}

.nav-group {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-8);
  min-height: var(--size-3-25rem);
  padding: 0 var(--spacing-16);
  border: 0;
  border-bottom: var(--border-width-3) solid transparent;
  background: transparent;
  color: var(--color-text);
  font: var(--font-weight-medium) var(--font-size-16) / var(--line-height-24) var(--font-family-stack);
  text-align: left;
  cursor: pointer;
}

/* The desktop row only (LT-6): under 1024 px the five group labels start at the same x */
@media (min-width: 1024px) {
  .nav-item:first-child .nav-group {
    padding-left: var(--spacing-12);
  }
}

.nav-group:is(:hover, [aria-expanded="true"]) {
  background: var(--color-background-action-hover);
}

/* The group the page is under: a 3 px burgundy underline (the home page has none) */
.nav-group.is-active {
  border-bottom-color: var(--color-action);
  color: var(--color-action); /* FS-2: the label and, by currentColor, the chevron */
}

.nav-group__chevron {
  transition: transform var(--motion-duration-fast) var(--motion-easing-standard);
}

.nav-group[aria-expanded="true"] .nav-group__chevron {
  transform: rotate(180deg);
}

/* ---------- Panels ---------- */

.nav-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  min-width: var(--size-16rem);
  max-width: var(--size-24rem);
  border: var(--border-width-1) solid var(--color-border);
  border-radius: 0 0 var(--border-radius-8) var(--border-radius-8);
  background: var(--color-surface);
  box-shadow: var(--shadow-100);
}

.nav-panel--wide {
  right: var(--gutter);
  left: var(--gutter);
  max-width: none;
}

.nav-panel__columns {
  display: grid;
  grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr));
  gap: var(--spacing-16) var(--spacing-32);
  padding: var(--spacing-24);
}

.nav-panel:not(.nav-panel--wide) .nav-panel__columns {
  padding: var(--spacing-16);
}

.nav-col__title {
  margin: 0 0 var(--spacing-8);
  /* The links carry a 3 px transparent left border, so the title's text starts at the same x as theirs (LT-6) */
  padding-inline: calc(var(--spacing-12) + var(--border-width-3)) var(--spacing-12);
  color: var(--color-text-secondary);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-20);
}

.nav-col__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-col__list a {
  display: block;
  padding: var(--spacing-8) var(--spacing-12);
  border-left: var(--border-width-3) solid transparent;
  border-radius: var(--border-radius-4);
  color: var(--color-text);
  font-size: var(--font-size-16);
  line-height: var(--line-height-24);
  text-decoration: none;
}

.nav-col__list a:hover {
  background: var(--color-background-action-hover);
  color: var(--color-action);
}

.nav-col__list a[aria-current="page"] {
  border-left-color: var(--color-action);
  background: var(--color-background-action-hover);
  color: var(--color-action);
  font-weight: var(--font-weight-medium);
}

/* The strip's three links at the end of the menu: under 768 px only */
.main-nav__utility {
  display: none;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Desktop panels (MO-2): from 1024 px a panel opens from opacity 0 and 4 px up to rest over --motion-duration-base and
   closes back over --motion-duration-fast. The script sets and clears the hidden attribute; display is transitioned
   discretely, so the closing panel stays rendered until its fade ends. The destination state's transition applies,
   hence the two durations. A panel that another group's opening closes carries data-instant and hides at once.
   Under reduced motion the durations are 0 ms (tokens.css). Without script nothing here applies (no .js class). */
@media (min-width: 1024px) {
  .nav-panel {
    opacity: 1;
    transform: translateY(0);
    transition:
      opacity var(--motion-duration-base) var(--motion-easing-standard),
      transform var(--motion-duration-base) var(--motion-easing-standard),
      display var(--motion-duration-base) var(--motion-easing-standard) allow-discrete;
  }

  @starting-style {
    .nav-panel {
      opacity: 0;
      transform: translateY(calc(var(--spacing-4) * -1));
    }
  }

  .js .nav-panel[hidden] {
    display: none;
    opacity: 0;
    transform: translateY(calc(var(--spacing-4) * -1));
    transition:
      opacity var(--motion-duration-fast) var(--motion-easing-standard),
      transform var(--motion-duration-fast) var(--motion-easing-standard),
      display var(--motion-duration-fast) var(--motion-easing-standard) allow-discrete;
  }

  .js .nav-panel[hidden][data-instant] {
    transition: none;
  }
}

/* ---------- Under 1024 px: the 'Meniu' button and the menu under the header row ---------- */

@media (max-width: 1023.98px) {
  .menu-button {
    display: inline-flex;
  }

  /* The brand gives way to the buttons: its tagline wraps, so the search and 'Meniu' buttons stay in the row */
  .brand {
    flex: 1 1 var(--size-6rem);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-2);
  }

  .brand__logo img {
    width: var(--size-6rem);
  }

  .brand__tagline {
    padding-left: 0;
    border-left: 0;
    font-size: var(--font-size-12);
    line-height: var(--line-height-16);
  }

  /* With script the menu is closed until 'Meniu' opens it; without script it is a list in the page.
     It reveals over --motion-duration-slow (opacity and an 8 px move down into place) and hides over --motion-duration-base:
     the transition that runs is the one of the state the menu goes to. display is animated as a discrete property, so the menu
     is removed from the page only when it has faded out; where that is not supported the menu simply appears and disappears.
     Under reduced motion the durations are 0 and all is instant. */
  .js .main-nav {
    opacity: 1;
    transform: none;
    transition:
      opacity var(--motion-duration-slow) var(--motion-easing-standard),
      transform var(--motion-duration-slow) var(--motion-easing-standard),
      display var(--motion-duration-slow) var(--motion-easing-standard) allow-discrete;
  }

  .js .main-nav:not(.is-open) {
    display: none;
    opacity: 0;
    transform: translateY(calc(var(--spacing-8) * -1));
    transition:
      opacity var(--motion-duration-base) var(--motion-easing-standard),
      transform var(--motion-duration-base) var(--motion-easing-standard),
      display var(--motion-duration-base) var(--motion-easing-standard) allow-discrete;
  }

  @starting-style {
    .js .main-nav.is-open {
      opacity: 0;
      transform: translateY(calc(var(--spacing-8) * -1));
    }
  }

  .main-nav__groups {
    flex-direction: column;
    padding-block: var(--spacing-8);
  }

  .nav-item,
  .nav-item--wide {
    position: static;
  }

  .nav-group {
    width: 100%;
    justify-content: space-between;
    padding-inline: var(--spacing-16);
  }

  .nav-panel,
  .nav-panel--wide {
    position: static;
    min-width: 0;
    max-width: none;
    border: 0;
    border-radius: var(--border-radius-8);
    background: var(--color-surface-muted);
    box-shadow: none;
  }

  /* An open group's header and its panel are one surface (--color-surface-muted) */
  .nav-group[aria-expanded="true"] {
    background: var(--color-surface-muted);
  }

  /* A group expands over --motion-duration-base (the 904 px 'Vinării și vinuri' group included): with script its panel is a
     one-cell grid whose row goes from 0fr to 1fr, and display is transitioned discretely, so a collapsing panel stays rendered
     until the row is closed. The panel's own padding sits on the columns' children, so the closed row is 0 high. */
  .js .nav-panel,
  .js .nav-panel--wide {
    display: grid;
    grid-template-rows: 1fr;
    transition:
      grid-template-rows var(--motion-duration-base) var(--motion-easing-standard),
      display var(--motion-duration-base) var(--motion-easing-standard) allow-discrete;
  }

  @starting-style {
    .js .nav-panel {
      grid-template-rows: 0fr;
    }
  }

  .js .nav-panel[hidden] {
    display: none;
    grid-template-rows: 0fr;
  }

  .nav-panel__columns,
  .nav-panel:not(.nav-panel--wide) .nav-panel__columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  .nav-col {
    padding-inline: var(--spacing-12);
  }

  .nav-col:first-child {
    padding-top: var(--spacing-8);
  }

  .nav-col:last-child {
    padding-bottom: var(--spacing-12);
  }

  .nav-col + .nav-col {
    padding-top: var(--spacing-16);
  }

  .nav-col__list a {
    min-height: var(--size-2-75rem);
    padding-block: var(--spacing-12);
  }
}

/* Under 768 px: the strip's links go to the end of the menu, and the register button has a row of its own */
@media (max-width: 767.98px) {
  .top-strip__links {
    display: none;
  }

  .top-strip__inner {
    flex-wrap: wrap;
    column-gap: var(--spacing-8);
    padding-block: var(--spacing-4);
  }

  .top-strip__identity {
    flex: 1 1 100%;
  }

  .top-strip__end {
    display: contents;
  }

  .top-strip .language-switch {
    margin-left: auto;
  }

  .main-nav__utility {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-4) var(--spacing-24);
    padding: var(--spacing-12) var(--spacing-16) var(--spacing-16);
    border-top: var(--border-width-1) solid var(--color-border);
  }

  .main-nav__utility a {
    display: inline-block;
    padding-block: var(--spacing-12);
  }

  /* The search button is its icon: its label stays for assistive technology */
  .header-search {
    padding-inline: var(--spacing-8);
  }

  .header-search__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: calc(var(--border-width-1) * -1);
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .header-register {
    flex: 1 0 100%;
  }
}

/* From 768 to 1023 px the strip is one row 32 px high (R-HOME-NAV, brief m4 item 11): its three links go to the end of the menu, as under
   768 px, and stay in the menu while the strip holds the name, the text tools and the language switch. The name takes the room that is
   left, so that should a row wrap the last box of each row still ends at the container's right edge. At 1024 px and wider the strip is as it was. */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .top-strip__links {
    display: none;
  }

  .top-strip__identity {
    flex: 1 1 auto;
  }

  .main-nav__utility {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-4) var(--spacing-24);
    padding: var(--spacing-12) var(--spacing-16) var(--spacing-16);
    border-top: var(--border-width-1) solid var(--color-border);
  }

  .main-nav__utility a {
    display: inline-block;
    padding-block: var(--spacing-12);
  }
}

/* Reduced motion (M4-MOTION, MO-7): the menus' small moves (4 px for a desktop panel, 8 px for the mobile menu) are dropped with the
   durations: a panel and the menu only fade, and where reduced motion is asked for they show and hide at once */
@media (prefers-reduced-motion: reduce) {
  .nav-panel,
  .js .nav-panel[hidden],
  .js .main-nav:not(.is-open),
  .js .main-nav.is-open {
    transform: none;
  }

  @starting-style {
    .nav-panel,
    .js .main-nav.is-open {
      transform: none;
    }
  }
}
