/**
 * Overrides for the IDP React menu (@idealista/menu).
 *
 * This file is manually maintained. Do NOT merge it with idp-menu.css —
 * that file is auto-generated by the Vite build and would overwrite these rules.
 *
 * Organization: rules are grouped by component. Inside each block the base
 * rules go first and the @media after, because several tie in specificity and
 * the order decides which one wins.
 *
 *   1. Base and accessibility (root and reserved height, skip link)
 *   2. Header — main bar (burger button, White variant, logo slot)
 *   3. Language selector (IdpLanguageSelector: header and drawer)
 *   4. Mobile drawer — remaining pieces
 *   5. Submenu (IdpSubmenuMega)
 */

/* ============================================================
 * 1. Base and accessibility
 * ============================================================ */

/* Menu root: reserve space before React paints
 *
 * The root arrives empty in the HTML and the library renders nothing until its
 * initial fetch ends, which shifts the content below (CLS). The header is
 * 48px tall on mobile and 64px from 768px (--menu-height of the library).
 * There is no L1/L2 bar here (unlike news), so the header height is all that
 * needs reserving. No background is painted: it depends on the variant
 * (white for luxury, brand colour otherwise), which CSS cannot know yet. */
/* @idealista/menu 3.5.0 paints the header background with
 * var(--color-comp-background-branded), a token that no published version of
 * @idealista/kiwi-tokens nor the library CSS defines: without it the header is
 * transparent. It is aliased to the previous token (brand lime). Remove the
 * alias when the library or the tokens define it. */
#idp-menu-root {
  --color-comp-background-branded: var(--color-semantic-background-brand, #e1f56e);
  width: 100%;
  min-height: 3rem;
}

@media screen and (min-width: 48rem) {
  #idp-menu-root {
    min-height: 4rem;
  }
}

/* Home variant (white header): tall header from 64rem
 *
 * The library styles the Home variant for the 6rem header idealista.com sets
 * in the home <head> (home.jspf): it pushes the user controls down with
 * --padding-top (1.75rem, against .75rem in Default), which only looks right
 * in that height. The library does not ship the 6rem, so it is replicated here
 * for any project using the variant. The class comes from idp-menu.html.twig. */
@media screen and (min-width: 64rem) {
  #idp-menu-root.idp-menu-root--home {
    min-height: 6rem;
  }

  #idp-menu-root.idp-menu-root--home .menu-wrapper {
    --menu-height: 6rem;
  }
}

/* In the app there is no header (only the IdpSubmenuMega submenu), so nothing is
 * reserved: the root takes the height of the bar. */
#idp-menu-root.idp-menu-root--app {
  min-height: 0;
}

/* Skip link ("Saltar al contenido principal")
 *
 * Same format as idealista.com: full-width black bar above the header, white
 * underlined text. The link lives in html.html.twig of the themes with the
 * core classes `visually-hidden focusable`; core makes it static on
 * :focus/:active, here we only style it. The translated text comes from
 * the theme template. */
.skip-link.visually-hidden.focusable:focus,
.skip-link.visually-hidden.focusable:active {
  /* The themes force .visually-hidden with !important and no :focus
   * exception, so it has to be reverted with !important too. */
  position: static !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  margin: 0 !important;
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  height: auto !important;
  padding: 0.5rem 1rem !important;
  background-color: #141414; /* --color-core-content-primary */
  color: #fff; /* --color-core-content-inverse */
  font-size: 0.875rem; /* 14px — body-s */
  font-weight: 600;
  line-height: 1.5rem;
  text-decoration: underline;
}

/* ============================================================
 * 2. Header — main bar
 * ============================================================ */

/* Burger / user menu button
 *
 * 32px like idealista.com. The library button uses `all: unset` (content-box),
 * so height 2rem + 0.125rem border per side gave 36px; with border-box the
 * border counts inside the 32px. */
#idp-menu-root .burger-button-container {
  box-sizing: border-box;
  height: 2rem;
}

/* White variant padding-bottom reset
 *
 * @idealista/menu injects variant styles as inline CSS custom properties on
 * .menu-wrapper (--padding-bottom, --menu-bg-color, etc.) — no class or
 * data-attribute is added for the variant, so CSS cannot target White alone.
 *
 * In practice this rule is White-only: Default and Home already set
 * --padding-bottom to "0" via inline style, so overriding padding-bottom
 * here has no visible effect on them. Only White sets it to
 * var(--dimension-x300), which this rule cancels.
 *
 * If the library ever exposes a data-variant attribute, scope this to
 * #idp-menu-root .menu-wrapper[data-variant="white"] instead. */
#idp-menu-root .menu-wrapper {
  padding-bottom: 0;
}

/* Custom logo slot (IdpLogo)
 *
 * Aligns the custom logo anchor and constrains the image height to match
 * @idealista/menu's default logo height (24px), letting width scale
 * proportionally. Works for both single-image and responsive <picture>. */
#idp-menu-root .idp-menu-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

#idp-menu-root .idp-menu-logo__img {
  height: 24px;
  width: auto;
  display: block;
}

/* Optical alignment with the links and controls
 *
 * From 1024px the library pushes the nav links and the user controls down with
 * --padding-top (inline on .menu-wrapper; .75rem in Default), because its own
 * wordmark has ascenders and most of its mass sits low. A logo with a uniform
 * height (the luxury one, all caps) stays centred and looks too high next to
 * them, so it gets the same offset. Centred, padding-top moves it down by half. */
@media (min-width: 64rem) {
  #idp-menu-root .idp-menu-logo {
    padding-top: var(--padding-top);
  }
}

/* ============================================================
 * 3. Language selector (IdpLanguageSelector)
 * ============================================================ */

/* Language selector — custom path-based selector (IdpLanguageSelector)
 *
 * @idealista/menu ships its own LanguageSelector, but it switches language
 * by code — not by URL — which breaks path-based translation (e.g.
 * /sala-de-prensa/ ↔ /press-room/). We replace it with IdpLanguageSelector,
 * which reads drupalSettings.idpMenu.languages (built by PHP via
 * LanguageManager::getLanguageSwitchLinks()) and navigates to the actual
 * translated path.
 *
 * Integration: IdpLanguageSelector is mounted as the `Shortcuts` slot of
 * <Menu> — the library renders Shortcuts OR the native LanguageSelector, so
 * providing the slot removes the native one from the header automatically.
 * `allowedLanguages={[]}` is passed to <Menu> to also suppress the native
 * selector in the drawer (empty list → renders nothing).
 *
 * CSS strategy:
 *   1. Hide ALL .language-selector__select globally (belt-and-suspenders for
 *      any remaining native instance — e.g. if allowedLanguages is later
 *      removed or the library's render logic changes).
 *   2. Re-show ONLY inside .shortcuts__slot (our IdpLanguageSelector lives
 *      there) — this is the custom selector, not the native one.
 *
 * Visual styles (trigger, options, flags, hover, check) come entirely from
 * @idealista/menu/bundled-css via the language-selector__* classes. Only
 * layout/visibility overrides are needed here. */

/* 1. Suppress the native selector everywhere — including inside the drawer,
 *    which @idealista/menu renders via a React Portal OUTSIDE #idp-menu-root.
 *    Scoping this rule to #idp-menu-root would miss the portaled drawer. */
.language-selector__select {
  display: none !important;
}

/* 2. Re-enable our custom selector inside the Shortcuts slot (header).
 *    The Shortcuts slot IS inside #idp-menu-root — scope it to avoid
 *    accidentally re-enabling the native selector anywhere else. */
#idp-menu-root .shortcuts__slot .language-selector__select {
  display: grid !important;
}

/* Reset the Drupal theme's button styles for the language trigger in the
 * header (Shortcuts slot — inside #idp-menu-root, protected by the theme's
 * :not(:where(#idp-menu-root *)) guard, but reset defensively). */
#idp-menu-root .shortcuts__slot .language-selector__trigger {
  appearance: none;
  background-color: transparent;
  border: var(--dimension-x050, 1px) solid transparent;
  border-radius: var(--dimension-x100, 0.25rem);
  box-shadow: none;
  color: inherit;
  font: inherit;
  padding: 2px;
}

#idp-menu-root .shortcuts__slot .language-selector__trigger:hover {
  background-color: transparent;
  box-shadow: none;
  cursor: pointer;
}

/* Reset for the drawer trigger — portaled OUTSIDE #idp-menu-root, so the
 * theme's :not(:where(#idp-menu-root *)) guard does NOT protect it.
 * Mirrors .idn-drawer-language .language-selector__trigger in news. */
.idp-drawer-language .language-selector__trigger {
  width: 100%;
  appearance: none;
  min-height: unset;
  padding: 0;
  padding-left: 2px;
  background-color: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-align: unset;
  border: var(--dimension-x050, 1px) solid transparent;
  border-radius: var(--dimension-x100, 0.25rem);
  box-shadow: none;
  display: flex;
  align-items: center;
}

.idp-drawer-language .language-selector__trigger:hover {
  background-color: transparent;
  box-shadow: none;
  cursor: pointer;
}

/* Open state (aria-expanded=true): library hover background + border. */
.idp-drawer-language .language-selector__trigger[aria-expanded="true"] {
  background: var(--color-state-background-hover, #f4f5f2);
  border-color: var(--color-core-border-secondary, #6f6f6d);
  box-shadow: none;
}

/* option text colour — prevent the Drupal theme link colour from overriding
 * the library's default (dark text on light background). */
#idp-menu-root .shortcuts__slot .language-selector__option {
  color: #141414; /* --color-core-content-primary */
  text-decoration: none;
}

#idp-menu-root .shortcuts__slot .language-selector__option:hover {
  color: #141414;
  text-decoration: none;
}

/* Selected option background. The library marks it with [aria-selected];
 * the selector is a link list, so the active one carries aria-current. */
.language-selector__option[aria-current="true"] {
  background-color: var(--color-core-background-secondary);
}

/* Trigger focus. The library rule uses variables that do not resolve here and
 * the outline was not painted; the colour is fixed. */
.language-selector__trigger:focus,
.idp-drawer-language .language-selector__trigger:focus {
  outline: 2px solid #0a58ca;
  outline-offset: 1px;
}

/* Option focus. The container has hidden overflow, so the outline goes
 * inwards (negative offset). */
.language-selector__option:focus {
  outline: 2px solid #0a58ca;
  outline-offset: -2px;
}

/* check icon alignment — same as news idn-menu-overrides.css. */
#idp-menu-root .shortcuts__slot .language-selector__option-check {
  display: inline-flex;
  align-items: center;
  margin-inline-start: auto;
}

/* ============================================================
 * 4. Mobile drawer — remaining pieces
 * ============================================================ */

/* Drawer language selector (IdpDrawerContent)
 *
 * Re-enable our IdpLanguageSelector inside the drawer. The drawer is rendered
 * via a React Portal OUTSIDE #idp-menu-root, so this rule must NOT be scoped
 * to that root — same approach as idn-menu-overrides.css in the news project. */
.idp-drawer-language .language-selector__select {
  display: grid !important;
  width: 100%;
}

/* Hide the library's native DrawerLanguageSelector wrapper
 *
 * @idealista/menu always renders a DrawerContent + native LanguageSelector
 * between the two <hr> dividers in the non-logged drawer — it cannot be
 * replaced via slots. With allowedLanguages=[] it renders empty.
 *
 * We suppress the whole DrawerContent wrapper with :has() so the two
 * consecutive <hr> collapse. The first <hr> (before this block) is then
 * hidden with the adjacent sibling combinator to avoid a double divider.
 *
 * data-value is an attribute only present on the native selector, not on
 * our custom IdpLanguageSelector — this targets it precisely. */
[data-testid="kiwi-drawer-content"]:has(.language-selector__select[data-value]) {
  display: none;
}
[data-testid="kiwi-drawer-content"]:has(.language-selector__select[data-value]) + [data-kiwi-divider] {
  display: none;
}

/* ============================================================
 * 5. Submenu (IdpSubmenuMega)
 * ============================================================ */

/* Submenu (IdpSubmenuMega), today only mounted in the native app
 *
 * Design: Figma "Landings Luxury" > Categories Navigation (7745:867). The
 * design may change, so everything adjustable is a custom property on
 * .idp-submenu. No <Menu> is mounted in the app, so there is no .menu-wrapper:
 * the side padding is defined here. The panel hangs from .idp-submenu, which
 * is the positioned box. */
.idp-submenu {
  --idp-submenu-padding: var(--padding-medium, 1rem);
  --idp-submenu-bar-height: 2rem;
  --idp-submenu-bg: var(--color-core-background-primary, #fff);
  --idp-submenu-border: var(--color-core-border-primary, #e5e6e1);
  --idp-submenu-text: var(--color-core-content-primary, #141414);
  /* Luxury gold from the design. Not the semantic accent tokens: the library
   * and kiwi-tokens define them as magenta (#b62682), which is wrong here. */
  --idp-submenu-accent: #90793c;
  --idp-submenu-accent-border: #90793c;
  --idp-submenu-columns: 2;
  --idp-submenu-shadow: 0 0 0 1px rgb(20 20 20 / 5%), 0 1px 0.5px rgb(20 20 20 / 5%), 0 2px 1px rgb(20 20 20 / 5%),
    0 4px 2px rgb(20 20 20 / 5%);
  position: relative;
  background-color: var(--idp-submenu-bg);
}

.idp-submenu__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--padding-x-small, 0.5rem);
  padding-inline: var(--idp-submenu-padding);
  border-bottom: 1px solid var(--idp-submenu-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.idp-submenu__bar::-webkit-scrollbar {
  display: none;
}

.idp-submenu__button {
  flex: none;
  box-sizing: border-box;
  height: var(--idp-submenu-bar-height);
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--idp-submenu-text);
  font: inherit;
  font-size: 0.75rem; /* label/regular */
  line-height: 1.125rem;
  cursor: pointer;
}

.idp-submenu__button--link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.idp-submenu__button--open {
  border-bottom-color: var(--idp-submenu-accent-border);
}

.idp-submenu__button:focus-visible,
.idp-submenu__link:focus-visible {
  outline: 2px solid #0a58ca;
  outline-offset: 2px;
}

.idp-submenu__panel {
  position: absolute;
  top: 100%;
  inset-inline: 0;
  z-index: 101;
  box-sizing: border-box;
  padding: var(--padding-medium, 1rem) var(--idp-submenu-padding) var(--padding-x-small, 0.5rem);
  background-color: var(--idp-submenu-bg);
  border-bottom: 1px solid var(--idp-submenu-border);
  box-shadow: var(--idp-submenu-shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 100ms ease-in-out, visibility 100ms ease-in-out;
}

.idp-submenu__panel[data-open="true"] {
  opacity: 1;
  visibility: visible;
}

.idp-submenu__group + .idp-submenu__group {
  margin-top: var(--padding-medium, 1rem);
}

.idp-submenu__group-title {
  margin: 0 0 var(--padding-x-small, 0.5rem);
  color: var(--idp-submenu-accent);
  font-size: 0.875rem; /* body-s/bold */
  font-weight: 700;
  line-height: 1.3125rem;
}

.idp-submenu__list {
  display: grid;
  grid-template-columns: repeat(var(--idp-submenu-columns), minmax(0, 1fr));
  column-gap: var(--padding-x-small, 0.5rem);
  row-gap: var(--padding-xx-small, 0.25rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.idp-submenu__link {
  display: flex;
  align-items: center;
  min-height: 2rem;
  color: var(--idp-submenu-accent);
  font-size: 0.875rem; /* body-s/semibold */
  font-weight: 600;
  line-height: 1.3125rem;
  text-decoration: none;
}
