/* Curious Lab common header, language switch, and shared page helpers */
* { box-sizing: border-box; }

:root {
  --cl-blue: #1E3A8A;
  --cl-blue-2: #4a90e2;
  --cl-border: #e0e3ef;
  --cl-bg: #f5f7fb;
  --cl-text: #333;
}

body.has-site-header {
  margin-top: 0;
}

.site-header {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: 1000;
  width: 100%;
  padding: 10px 16px !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--cl-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
  display: block !important;
  color: var(--cl-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

.site-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.site-header__logo {
  height: 42px !important;
  width: auto;
  display: block;
  flex: 0 0 auto;
}

.site-header__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: var(--cl-blue);
  font-weight: 700;
  line-height: 1.25;
}

.site-header__title-main {
  font-size: 1.08rem;
  white-space: nowrap;
}

.site-header__title-sub {
  font-size: 0.8rem;
  opacity: 0.9;
  white-space: nowrap;
}

.site-header__menu-button {
  display: none;
  border: 1px solid #c8d2e6;
  background: #f4f7ff;
  color: var(--cl-blue);
  font-weight: 700;
  border-radius: 999px;
  padding: 7px 12px;
  font-family: inherit;
  cursor: pointer;
}

.site-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-header__nav a,
.site-header__nav button.site-header__nav-button {
  color: var(--cl-blue) !important;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 6px 8px;
  border-radius: 8px;
  font-family: inherit;
  line-height: 1.25;
}

.site-header__nav a:hover,
.site-header__nav button.site-header__nav-button:hover {
  background: #edf3ff;
  text-decoration: none !important;
}

.site-header__nav a[aria-current="page"] {
  background: #e6f0ff;
}

.site-header__nav-button {
  border: none;
  background: transparent;
  cursor: pointer;
}

.site-header__dropdown {
  position: relative;
}

.site-header__dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: #fff;
  border: 1px solid var(--cl-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
  padding: 8px;
  z-index: 1002;
}

.site-header__dropdown.open .site-header__dropdown-menu,
.site-header__dropdown:focus-within .site-header__dropdown-menu,
.site-header__dropdown:hover .site-header__dropdown-menu {
  display: block;
}

.site-header__dropdown-menu a {
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
  white-space: normal;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  background: #e6ebf5;
  padding: 2px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.lang-switch button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  color: var(--cl-blue);
  font-family: inherit;
  line-height: 1.2;
}

.lang-switch button.active {
  background: var(--cl-blue);
  color: #ffffff;
}

.lang-switch button:focus-visible,
.site-header__menu-button:focus-visible,
.site-header__nav-button:focus-visible {
  outline: 2px solid var(--cl-blue-2);
  outline-offset: 2px;
}

[data-lang-panel] { display: none; }
body.lang-ja [data-lang-panel="ja"] { display: block; }
body.lang-en [data-lang-panel="en"] { display: block; }

body.has-site-header .content {
  padding-top: 24px !important;
}

@media (max-width: 760px) {
  .site-header__inner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .site-header__brand {
    flex: 1 1 auto;
  }

  .site-header__logo {
    height: 34px !important;
  }

  .site-header__title-main {
    font-size: 1rem;
  }

  .site-header__title-sub {
    display: none;
  }

  .site-header__menu-button {
    display: inline-block;
  }

  .site-header__right {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 8px;
  }

  .site-header.is-open .site-header__right {
    display: flex;
  }

  .site-header__nav {
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .site-header__nav a,
  .site-header__nav button.site-header__nav-button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
  }

  .site-header__dropdown-menu {
    display: block;
    position: static;
    min-width: 0;
    border: none;
    box-shadow: none;
    padding: 0 0 0 14px;
    background: transparent;
  }

  .site-header__dropdown-menu a {
    padding: 7px 10px;
    font-size: 0.86rem;
  }

  .lang-switch {
    align-self: flex-start;
  }
}
