/* ----- Site header (Figma "Header": Theme = Transparent / Solid, Breakpoint = Desktop / Mobile) ----- */
header {
  z-index: 9999;
  top: 0;
  box-shadow: var(--sf-shadow-header);

  ol,
  ul,
  li {
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--sf-brand-deep);
    font-size: 16px;
  }
}

.site-header {
  min-height: var(--sf-header-h);
  padding: 6px var(--sf-gutter);
}

.site-header .navbar {
  width: 100%;
  flex-wrap: nowrap;
  gap: var(--sf-gap-md);
}

.site-logo {
  flex-shrink: 0;
  gap: clamp(10px, 0.35vw + 7.3px, 14px);
  width: max-content;
  max-width: none;
  height: auto;
  text-decoration: none;
  /* Above the desktop dropdown panel */
  position: relative;
  z-index: 3;

  img {
    width: clamp(48px, 1.4vw + 37px, 64px);
    height: clamp(48px, 1.4vw + 37px, 64px);
    object-fit: contain;
    transition: width 0.3s ease, height 0.3s ease;
  }
}

/* "ΔΗΜΟΣ ΣΦΑΚΙΩΝ" next to the logo, on one line */
.site-logo-text {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.3em;
  color: var(--sf-navy);
  font-size: clamp(15px, 0.43vw + 11.7px, 20px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: var(--sf-ls-label);
  white-space: nowrap;
  transition: color var(--sf-transition);
}

/* After scrolling the header shrinks to 70px (style.css) */
.site-header.scrolled {
  min-height: 70px;
}

.scrolled .site-logo img {
  width: 48px;
  height: 48px;
}

/* ----- Home page: transparent header over the hero ----- */
header.home-header {
  position: fixed;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  transition:
    background var(--sf-transition),
    box-shadow var(--sf-transition);
}

/* The blur sits on a layer behind the content: backdrop-filter on the header itself would make it the
   containing block of the fixed burger menu, which then gets the header's 80px height instead of the screen's */
header.home-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

/* Turns solid (white) on scroll and (desktop) on hovering the menu */
header.home-header.scrolled {
  background: var(--sf-surface);
  box-shadow: var(--sf-shadow-header);
}

@media screen and (min-width: 1400px) {
  header.home-header:hover {
    background: var(--sf-surface);
    box-shadow: var(--sf-shadow-header);
  }
}

/* White texts and icons only while the header is transparent */
header.home-header:not(.scrolled) {
  .site-logo-text,
  .header-lang,
  .header-search {
    color: var(--sf-on-dark);
  }

  .site-logo-text {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  }

  .burger-icon-line {
    background: var(--sf-on-dark);
  }
}

@media screen and (min-width: 1400px) {
  header.home-header:not(.scrolled):not(:hover) .navbar-nav > .nav-item,
  header.home-header:not(.scrolled):not(:hover) #language-switcher a {
    color: var(--sf-on-dark);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  }

  header.home-header:not(.scrolled):hover .site-logo-text {
    color: var(--sf-navy);
    text-shadow: none;
  }
}

/* ----- Nav items (Figma "Nav Item") ----- */
.nav-item {
  font-size: var(--sf-fs-label);
  font-weight: 700;
  letter-spacing: var(--sf-ls-label);
  text-transform: uppercase;

  &:first-child {
    margin-left: 0;
  }
}

.menu-item-arrow {
  font-size: 0.9em;
}

#language-switcher a {
  font-size: var(--sf-fs-label);
  font-weight: 700;
  letter-spacing: var(--sf-ls-label);
}

/* ----- Dropdown panel ----- */
.dropdownPanel {
  display: none;
  position: absolute;
  top: 90px;
  background-color: var(--sf-surface);
  overflow: hidden;
  transition: all 500ms ease-in-out;
  border-radius: 0 0 var(--sf-radius-sm) var(--sf-radius-sm);
  box-shadow: var(--sf-shadow-card);

  a {
    color: var(--sf-brand-dark);
    font-size: var(--sf-fs-md);
    line-height: 2rem;
    transition: background-color var(--sf-transition), color var(--sf-transition);
  }

  /* Hover / keyboard focus on a submenu link: light blue row, dark blue text */
  a:hover,
  a:focus-visible {
    color: var(--sf-brand-ink);
    background-color: var(--sf-brand-light);
    text-decoration: none;
    outline: none;
  }

  .submenu {
    height: 0;
    overflow: hidden;
    transition: all 500ms ease;
    background-color: var(--sf-surface-alt);
  }
}

.dropdownPanelAnimation {
  animation: dropDown 500ms ease-in-out forwards;
  transform-origin: top center;
}

@keyframes dropDown {
  0% {
    transform: scaleY(0);
  }

  80% {
    transform: scaleY(1.1);
  }

  100% {
    transform: scaleY(1);
  }
}

.menu-items-container {
  width: 100%;
}

.back-button .fa {
  transform: rotate(270deg);
}

.menu-items {
  padding: 1rem 0;
  font-weight: 500;
  border-top: solid 3px var(--sf-accent);
  background-color: var(--sf-surface);
  width: 100%;
  text-align: center;

  &:first-child {
    padding: 0;
  }

  a {
    display: grid;
    padding: 0.25rem 1rem;
    width: 100%;
  }
}

.submenu-item > a {
  display: inline-block;
  color: var(--sf-brand-dark);
}

/* ----- Actions below 1400px: language, search, menu (Figma Header Breakpoint=Mobile) ----- */
.header-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 16px;
  /* Like the logo; the open drawer (.mobile-nav, z-index 11) still covers it */
  position: relative;
  z-index: 3;
}

.header-lang {
  color: var(--sf-brand-dark);
  font-size: var(--sf-fs-label);
  font-weight: 700;
  line-height: 1;
  letter-spacing: var(--sf-ls-label);
}

.header-search {
  display: inline-flex;
  color: var(--sf-text);
  line-height: 0;
}

.header-lang:hover,
.header-search:hover {
  color: var(--sf-brand-deep);
}

.header-lang:focus-visible,
.header-search:focus-visible,
.burger-icon:focus-visible {
  outline: var(--sf-focus-ring);
  outline-offset: 3px;
  border-radius: var(--sf-radius-xs);
}

.burger-icon {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 28px;
  height: 28px;
  padding: 0 3px;
  background: none;
  border: 0;
  cursor: pointer;
}

/* Bigger tap area on touch screens without moving the icon */
.burger-icon::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.burger-icon-line {
  display: block;
  width: 100%;
  height: 2.5px;
  margin: 0;
  background: var(--sf-brand);
  border-radius: 2px;
  transition: transform 0.4s ease-out, opacity 0.4s ease-out, background var(--sf-transition);
}

.close .burger-icon-line:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.close .burger-icon-line:nth-child(2) {
  opacity: 0;
}

.close .burger-icon-line:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* ----- Desktop: full menu bar ----- */
@media screen and (min-width: 1400px) {
  .header-actions {
    display: none;
  }

  /* Brand left, menu in the middle of the free space, language far right (Figma space-between) */
  .navbar-nav {
    justify-content: flex-start;
    gap: clamp(20px, 2.5vw - 12px, 36px);
  }

  .navbar-nav::before {
    content: '';
    flex: 1 1 0;
  }

  #language-switcher {
    flex: 1 1 0;
    justify-content: flex-end;
  }

  .navbar-nav > .nav-item {
    position: relative;
    padding: 8px 6px;
    color: var(--sf-text);
    white-space: nowrap;
    transition: color var(--sf-transition);
  }

  /* Hover / active indicator under the item */
  .navbar-nav > .nav-item::after {
    content: '';
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 2px;
    height: 3px;
    background: var(--sf-accent);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform var(--sf-transition);
  }

  .navbar-nav > .nav-item:hover,
  .navbar-nav > .nav-item.active,
  .navbar-nav > .nav-item:focus-visible {
    color: var(--sf-brand-dark);
  }

  .navbar-nav > .nav-item:hover::after,
  .navbar-nav > .nav-item.active::after {
    transform: scaleX(1);
  }

  .navbar-nav > .nav-item:focus-visible {
    outline: var(--sf-focus-ring);
    outline-offset: 0;
    border-radius: var(--sf-radius-xs);
  }

  #language-switcher a {
    color: var(--sf-brand-dark);
  }

  .grand-link {
    color: var(--sf-brand-dark);
  }

  .back-button {
    display: none;
  }

  .logged-in .dropdownPanel {
    padding-top: 0rem;
    margin-top: 2rem;
  }
}

/* ----- Below 1400px: burger menu = drawer from the right (template-parts/header/header-menu.php, main.js) ----- */
/* The menu bar is hidden; the burger opens .mobile-nav over a blurred, darker page.
   Sfakia texts, colours and arrow; Moschato's layout (full-width rows, left aligned). */
.mobile-nav,
.mobile-nav-overlay {
  display: none;
}

@media screen and (max-width: 1399.98px) {
  #navbarNavAltMarkup {
    justify-content: flex-end;
  }

  /* The menu items are in the drawer, the language link in the header actions */
  #navbarNavAltMarkup .navbar-nav {
    display: none !important;
  }

  .mobile-nav-overlay:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(28, 49, 68, 0.35);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-nav:not([hidden]) {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 11;
    width: min(92vw, 480px);
    height: 100dvh;
    padding-bottom: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--sf-surface);
    box-shadow: -1px 2px 12px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .mobile-nav-overlay.is-open {
    opacity: 1;
  }

  .mobile-nav.is-open {
    transform: translateX(0);
  }

  /* Under the WordPress admin bar when logged in */
  .admin-bar .mobile-nav:not([hidden]) {
    top: 32px;
    height: calc(100dvh - 32px);
  }

  /* The chatbot bubble stays out of the way while the menu is open */
  body.mobile-nav-open .cpwebchatHolder {
    display: none !important;
  }

  .mobile-nav-top {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 24px;
    background: var(--sf-surface);
    border-bottom: 1px solid var(--sf-border);
  }

  .mobile-nav-title {
    margin: 0;
    color: var(--sf-text);
    font-size: var(--sf-fs-lg);
    font-weight: 700;
    line-height: 1.2;
  }

  .mobile-nav-close {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--sf-radius-xs);
    cursor: pointer;
  }

  .mobile-nav-close::before,
  .mobile-nav-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    background: var(--sf-text);
    border-radius: 2px;
    transform: translate(-50%, -50%) rotate(45deg);
    transition: background-color var(--sf-transition);
  }

  .mobile-nav-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .mobile-nav-close:hover::before,
  .mobile-nav-close:hover::after {
    background: var(--sf-accent);
  }

  .mobile-nav-close:focus-visible {
    outline: var(--sf-focus-ring);
    outline-offset: 2px;
  }

  .mobile-nav-list,
  .mobile-nav-submenu-inner {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* ----- First level: Ο ΔΗΜΟΣ ΜΑΣ, ΕΝΗΜΕΡΩΣΗ... (Sfakia nav item: bold, capitals, angle arrow) ----- */
  .mobile-nav-item {
    border-bottom: 1px solid var(--sf-border);
  }

  .mobile-nav-item:last-child {
    border-bottom: 0;
  }

  .mobile-nav-item > .mobile-nav-toggle,
  .mobile-nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 18px 24px;
    color: var(--sf-brand-deep);
    background: none;
    border: 0;
    font-size: var(--sf-fs-md);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: var(--sf-ls-label);
    text-align: left;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
  }

  .mobile-nav-item > .mobile-nav-toggle > span,
  .mobile-nav-link > span {
    transition: color var(--sf-transition), transform var(--sf-transition);
  }

  .mobile-nav-arrow {
    flex-shrink: 0;
    font-size: 0.9em;
    transition: color var(--sf-transition), transform 0.3s ease;
  }

  /* Hover / open: the keyword and its arrow turn orange */
  .mobile-nav-item > .mobile-nav-toggle:hover,
  .mobile-nav-item > .mobile-nav-toggle[aria-expanded='true'],
  .mobile-nav-link:hover {
    color: var(--sf-accent);
  }

  .mobile-nav-item > .mobile-nav-toggle:hover > span,
  .mobile-nav-link:hover > span {
    transform: translateX(4px);
  }

  .mobile-nav-toggle[aria-expanded='true'] > .mobile-nav-arrow {
    transform: rotate(180deg);
  }

  .mobile-nav-item > .mobile-nav-toggle:focus-visible,
  .mobile-nav-link:focus-visible {
    color: var(--sf-accent);
    outline: var(--sf-focus-ring);
    outline-offset: -3px;
  }

  /* ----- Submenu: opens in place (0fr → 1fr animates the real height) ----- */
  .mobile-nav-submenu {
    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    transition: grid-template-rows 0.3s ease, visibility 0s linear 0.3s;
  }

  .mobile-nav-submenu.is-open {
    grid-template-rows: 1fr;
    visibility: visible;
    transition: grid-template-rows 0.3s ease, visibility 0s;
  }

  .mobile-nav-submenu > .mobile-nav-submenu-inner {
    min-height: 0;
    overflow: hidden;
  }

  .mobile-nav-item > .mobile-nav-submenu > .mobile-nav-submenu-inner {
    padding-bottom: 8px;
  }

  /* Second / third level links: like the links of the dropdown panel on desktop */
  .mobile-nav-sublink {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 24px 10px 36px;
    color: var(--sf-brand-dark);
    background: none;
    border: 0;
    font-size: var(--sf-fs-md);
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--sf-transition), color var(--sf-transition);
  }

  .mobile-nav-sublink:hover,
  .mobile-nav-sublink:focus-visible,
  .mobile-nav-sublink[aria-expanded='true'] {
    color: var(--sf-brand-ink);
    background-color: var(--sf-brand-light);
    text-decoration: none;
  }

  .mobile-nav-sublink:focus-visible {
    outline: var(--sf-focus-ring);
    outline-offset: -3px;
  }

  .mobile-nav-submenu.is-nested {
    background-color: var(--sf-surface-alt);
  }

  .mobile-nav-submenu.is-nested .mobile-nav-sublink {
    padding-left: 52px;
  }
}

@media screen and (max-width: 782.98px) {
  .admin-bar .mobile-nav:not([hidden]) {
    top: 46px;
    height: calc(100dvh - 46px);
  }
}

@media screen and (max-width: 767.98px) {
  .mobile-nav:not([hidden]) {
    width: 100vw;
  }
}

/* Very narrow phones: keep brand and actions on one row */
@media screen and (max-width: 359.98px) {
  .site-logo-text {
    font-size: 13px;
  }

  .header-actions {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .navbar-nav > .nav-item::after,
  .burger-icon-line,
  .mobile-nav:not([hidden]),
  .mobile-nav-overlay:not([hidden]),
  .mobile-nav-submenu,
  .mobile-nav-arrow,
  .mobile-nav-item > .mobile-nav-toggle > span,
  .mobile-nav-link > span {
    transition: none;
  }
}
