/* CampusBuddyn header ja mobiilivalikko. */

body > .site-header {
  --cb-header-ink: #192e4b;
  --cb-header-accent: #436fa6;
  --cb-header-logo-width: 200px;
  --cb-header-height: 80px;
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  height: var(--cb-header-height);
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #e4eaf2;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 3px 18px rgba(24, 46, 75, .025);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Kirjautuneen käyttäjän WordPress-työkalupalkkia ei peitetä. */
body.admin-bar > .site-header { top: 32px; }
@media (max-width: 782px) {
  body.admin-bar > .site-header { top: 46px; }
}
@media (max-width: 600px) {
  /* Puhelimessa WP:n työkalupalkki vierittyy pois näkyvistä. */
  body.admin-bar > .site-header { top: 0; }
}

body > .site-header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  width: min(calc(100% - 48px), 1240px);
  max-width: 1240px;
  height: 100%;
  margin: 0 auto;
  padding: 0;
}
body > .site-header .site-branding {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  margin: 0;
}
body > .site-header .custom-logo-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 100%;
  line-height: 1;
}
body > .site-header .custom-logo {
  display: block;
  width: var(--cb-header-logo-width);
  max-width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}
body > .site-header .site-logo {
  color: var(--cb-header-ink);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -1px;
}

/* Työpöydän navigaatio. */
body > .site-header .primary-navigation {
  position: static;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: auto;
  min-width: 0;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body > .site-header .nav-menu {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 26px;
  margin: 0 18px 0 0;
  padding: 0;
  list-style: none;
}
body > .site-header .nav-menu > li { margin: 0; padding: 0; border: 0; }
body > .site-header .nav-menu > li { position: relative; }
body > .site-header .nav-menu > li > a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  border: 0;
  color: #42536c;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  transition: color .16s ease;
}
body > .site-header .nav-menu > li > a:hover { color: var(--cb-header-accent); }
body > .site-header .nav-menu > :is(.current-menu-item, .current_page_item) > a,
body > .site-header .nav-menu > li > a[aria-current="page"] {
  color: #244e81;
  border: 0;
}
body > .site-header .nav-menu > :is(.current-menu-item, .current_page_item) > a::after,
body > .site-header .nav-menu > li > a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 1px;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: #4b73a6;
}

/* Kirjaudu / Oma tili / Kirjaudu ulos: nykyiset linkit säilyvät. */
body > .site-header .primary-navigation > .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 42px;
  margin: 0;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
body > .site-header .primary-navigation > .button-navy {
  color: #fff;
  border-color: #203b5f;
  background: #203b5f;
  box-shadow: 0 2px 5px #1e365610;
}
body > .site-header .primary-navigation > .button-navy:hover {
  color: #fff;
  border-color: #30547e;
  background: #30547e;
}
body > .site-header .primary-navigation > .button-outline {
  color: #29476b;
  border-color: #cfdae8;
  background: #fff;
}
body > .site-header .primary-navigation > .button-outline:hover {
  color: #203b5f;
  border-color: #aebfd4;
  background: #f2f6fc;
}
body > .site-header :is(a, button):focus-visible {
  outline: 3px solid #8badd9;
  outline-offset: 4px;
}
body > .site-header .menu-toggle { display: none; }

/* Nykyisen WordPress-valikon Ruoka-, Ajanhallinta- ja Hyvinvointi-linkit.
   Numerot ovat VALIKKOKOHTIEN tunnisteita, eivät sivujen tunnisteita.
   Jos luot valikon myöhemmin uudelleen, tarkista nämä kolme tunnistetta. */
body > .site-header .nav-menu > .cb-menu-coming::after {
  content: "Tulossa";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  z-index: 2;
  padding: 4px 9px;
  border: 1px solid #dce5ef;
  border-radius: 5px;
  color: #536d8b;
  background: #f4f7fc;
  font: 500 10px/1.4 Inter, Arial, sans-serif;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -3px);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
body > .site-header .nav-menu > .cb-menu-coming:is(:hover, :focus-within)::after {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* Tabletti ja puhelin: käytetään teeman nykyistä valikkopainiketta ja JS:ää. */
@media (max-width: 1000px) {
  body > .site-header {
    --cb-header-height: 72px;
    --cb-header-logo-width: 185px;
  }
  body > .site-header .header-inner { gap: 16px; }
  body > .site-header .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    gap: 10px;
    min-width: 96px;
    min-height: 44px;
    margin: 0 0 0 auto;
    padding: 10px 12px;
    border: 1px solid #dce5ef;
    border-radius: 9px;
    color: #203b5f;
    background: #f8fafd;
    font: 600 12px/1.5 Inter, Arial, sans-serif;
    cursor: pointer;
  }
  body > .site-header .menu-toggle:hover,
  body > .site-header .menu-toggle[aria-expanded="true"] { background: #edf3fb; }
  body > .site-header .menu-icon {
    position: relative;
    display: block;
    width: 20px;
    height: 16px;
  }
  body > .site-header .menu-icon i {
    position: absolute;
    left: 0;
    display: block;
    width: 20px;
    height: 2px;
    margin: 0;
    border-radius: 2px;
    background: #29476b;
    transition: transform .16s ease, opacity .16s ease;
  }
  body > .site-header .menu-icon i:nth-child(1) { top: 1px; }
  body > .site-header .menu-icon i:nth-child(2) { top: 7px; }
  body > .site-header .menu-icon i:nth-child(3) { top: 13px; }
  body > .site-header .menu-toggle[aria-expanded="true"] .menu-icon i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body > .site-header .menu-toggle[aria-expanded="true"] .menu-icon i:nth-child(2) { opacity: 0; }
  body > .site-header .menu-toggle[aria-expanded="true"] .menu-icon i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  body > .site-header .primary-navigation {
    position: absolute;
    top: calc(100% + 8px);
    right: 24px;
    left: auto;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: min(440px, calc(100% - 48px));
    max-width: none;
    max-height: calc(100dvh - 140px);
    margin: 0;
    padding: 14px;
    overflow-y: auto;
    border: 1px solid #dfe7f1;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 14px 40px rgba(25, 46, 75, .12);
    overscroll-behavior: contain;
  }
  body > .site-header .primary-navigation.is-open { display: flex; }
  body > .site-header .nav-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    margin: 0;
    padding: 0 0 10px;
    border-bottom: 1px solid #e8edf4;
  }
  body > .site-header .nav-menu > li > a {
    display: flex;
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body > .site-header .nav-menu > li > a:hover { background: #f5f8fc; }
  body > .site-header .nav-menu > :is(.current-menu-item, .current_page_item) > a,
  body > .site-header .nav-menu > li > a[aria-current="page"] { background: #eaf2fc; }
  body > .site-header .nav-menu > :is(.current-menu-item, .current_page_item) > a::after,
  body > .site-header .nav-menu > li > a[aria-current="page"]::after { display: none; }
  body > .site-header .nav-menu > .cb-menu-coming > a {
    padding-right: 90px;
  }
  body > .site-header .nav-menu > .cb-menu-coming::after {
    top: 50%;
    right: 12px;
    left: auto;
    transform: translateY(-50%);
    opacity: 1;
    visibility: visible;
  }
  body > .site-header .nav-menu > .cb-menu-coming:is(:hover, :focus-within)::after {
    transform: translateY(-50%);
  }
  body > .site-header .primary-navigation > .button {
    align-self: stretch;
    width: 100%;
    min-height: 46px;
    margin: 0;
    font-size: 13px;
  }
}

@media (max-width: 600px) {
  body > .site-header {
    --cb-header-height: 68px;
    --cb-header-logo-width: 178px;
  }
  body > .site-header .header-inner { width: calc(100% - 32px); }
  body > .site-header .primary-navigation {
    right: 12px;
    width: calc(100% - 24px);
    max-height: calc(100dvh - 120px);
  }
}
@media (max-width: 360px) {
  body > .site-header { --cb-header-logo-width: 156px; }
  body > .site-header .header-inner { gap: 10px; }
  body > .site-header .menu-toggle { min-width: 90px; padding-inline: 10px; }
}
/* Myös ison kosketusnäytön käyttäjä näkee tilan ilman hoveria. */
@media (hover: none) and (min-width: 1001px) {
  body > .site-header .nav-menu > .cb-menu-coming::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  body > .site-header *,
  body > .site-header *::before,
  body > .site-header *::after { transition: none !important; }
}
