/* RENOVIA v4.8 — 全下層ページの共通ヘッダー／メニュー
 * トップページ #rv3-top は既存の完成済みVer.4.7を優先し、ここでは変更しない。
 * header.phpから wp_head() の後に読み込み。
 */

/* Homepage remains on the known-good header implementation. */
body:not(:has(#rv3-top)) {
  --rv48-head-height: 76px;
  --rv48-accent: #a73236;
}

/* Occupy the exact amount of normal document space reserved for the fixed header.
   This removes the old overlap with titles/contact forms on subpages. */
body:not(:has(#rv3-top)) .body-inner {
  padding-top: var(--rv48-head-height);
}
body:not(:has(#rv3-top)) #header.c-header {
  position: fixed !important;
  box-sizing: border-box;
  inset: auto 0 auto 0;
  top: var(--rv48-header-top, 0px) !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100% !important;
  height: var(--rv48-head-height) !important;
  padding: 0 clamp(14px, 2.1vw, 32px) !important;
  background: rgba(255, 255, 255, .985);
  border-bottom: 1px solid #efe7e6;
  box-shadow: 0 5px 18px rgba(38, 24, 31, .055);
  isolation: isolate;
}
/* v4.6.2 contact page drew a large ::before mobile overlay. The new opaque
   fixed header replaces it, so suppress that obsolete layer. */
body:not(:has(#rv3-top)) #header.c-header::before {
  content: none !important;
}

/* Current main.js hides the separate floating logo/buttons while scrolling.
   Inside this unified fixed bar, both must stay visible. */
body:not(:has(#rv3-top)) #header .c-header__logo,
body:not(:has(#rv3-top)) #header .c-header__right {
  position: relative !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  margin: 0;
  translate: none !important;
  transform: none !important;
  flex: none;
  transition: none;
}
body:not(:has(#rv3-top)) #header .c-header__logo { z-index: 3; }
body:not(:has(#rv3-top)) #header .c-header__logo a {
  display: inline-flex;
  align-items: center;
  padding: 0;
}
body:not(:has(#rv3-top)) #header .c-header__logo a img {
  display: block;
  width: clamp(115px, 9vw, 150px);
  max-width: 100%;
  height: auto;
}
body:not(:has(#rv3-top)) #header .c-header__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 50px;
  min-width: 0;
  max-width: calc(100% - 170px);
  gap: 9px;
  z-index: 4;
}
body:not(:has(#rv3-top)) #header .c-header__right__nav,
body:not(:has(#rv3-top)) #header .c-header__right__contact {
  height: 100%;
  translate: none !important;
  transform: none !important;
}
body:not(:has(#rv3-top)) #header .c-header__right__nav {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.45vw, 23px);
  padding: 0 clamp(15px, 1.7vw, 28px);
  border-radius: 13px;
  background: #fff;
}
body:not(:has(#rv3-top)) #header .c-header__right__nav a span {
  font-size: clamp(11px, .92vw, 14px);
  font-weight: 700;
  white-space: nowrap;
}
body:not(:has(#rv3-top)) #header .c-header__right__contact a {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 clamp(13px, 1.9vw, 27px);
  border-radius: 12px;
  background-color: var(--rv48-accent);
  white-space: nowrap;
}
body:not(:has(#rv3-top)) #header .c-header__right__contact a > span > span {
  font-size: clamp(12px, 1vw, 14px);
  color: #fff;
}
body:not(:has(#rv3-top)) #header .c-header__right__hamburger {
  box-sizing: border-box;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  aspect-ratio: auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eee7e7;
}
/* When the navigation panel is open, put it above other content and hide
   redundant top navigation/contact controls (close icon remains visible). */
/* Baseline menu state for special pages (e.g. recruitment) that may not
   enqueue the standard theme stylesheet. */
body:not(:has(#rv3-top)) #header .c-header__right__hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav {
  visibility: hidden;
  opacity: 0;
  z-index: 2;
  transition: opacity .2s ease, visibility .2s ease;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav.is-active {
  visibility: visible;
  opacity: 1;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #faf7f5;
  overscroll-behavior: contain;
}
body.rv48-nav-open:not(:has(#rv3-top)) { overflow: hidden; }
body.rv48-nav-open:not(:has(#rv3-top)) #header .c-header__right__nav,
body.rv48-nav-open:not(:has(#rv3-top)) #header .c-header__right__contact {
  visibility: hidden;
}
body:not(:has(#rv3-top)) #header .c-header__right__hamburger:focus-visible,
body:not(:has(#rv3-top)) #header a:focus-visible {
  outline: 3px solid #bc5362;
  outline-offset: 3px;
}

/* The full menu is kept consistent with Ver.4.7 even on special pages
   that do not load the regular theme's style.css. */
body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li {
  border: 1px solid #eadfe0;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 3px 14px rgba(93, 37, 46, .035);
}
body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 12px 30px 12px 0;
  font-size: clamp(16px, 1.35vw, 19px);
  font-weight: 700;
  line-height: 1.5;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > a::after {
  content: '›';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font: 400 26px/1 Arial, sans-serif;
  color: #a42a40;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > ul {
  border-top: 1px solid #f0e8e8;
  padding-top: 8px;
  margin-bottom: 10px;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > ul > li > a {
  display: flex;
  align-items: center;
  padding: 7px 8px 7px 12px;
  min-height: 34px;
  font-size: clamp(13px, 1vw, 15px);
  line-height: 1.5;
  color: #645960;
}
body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > ul > li > a::before {
  content: '•';
  margin-right: 9px;
  color: #a42a40;
}

/* The first content heading no longer sits behind the fixed header. */
body:not(:has(#rv3-top)) .c-sub-page-heading-1,
body:not(:has(#rv3-top)) .c-sub-page-heading-2 {
  padding-top: clamp(34px, 5vw, 72px);
}
body:not(:has(#rv3-top)) .c-sub-page-heading-1__main,
body:not(:has(#rv3-top)) .c-sub-page-heading-2__main {
  padding-top: clamp(42px, 7vw, 86px);
}
body:not(:has(#rv3-top)) [id] { scroll-margin-top: 96px; }

@media (min-width: 1220px) {
  body:not(:has(#rv3-top)) #header .c-header__open-nav {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    column-gap: clamp(26px, 5vw, 84px);
    padding: 110px clamp(24px, 5vw, 84px) 40px;
    overflow-y: auto;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__left,
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right {
    min-width: 0;
    height: auto;
    max-width: 680px;
    padding: 0;
    overflow: visible;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li {
    padding: 0 20px;
  }
}
@media (min-width: 769px) and (max-width: 1219px) {
  body:not(:has(#rv3-top)) #header .c-header__right__nav { display: none; }
  body:not(:has(#rv3-top)) #header .c-header__open-nav {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 95px clamp(18px, 4vw, 44px) 34px;
    overflow-y: auto;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right {
    order: 0;
    flex: none;
    width: 100%;
    max-width: 700px;
    margin-inline: auto;
    padding: 0;
    overflow: visible;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__left {
    order: 1;
    flex: none;
    width: 100%;
    max-width: 700px;
    height: auto;
    margin-inline: auto;
    padding: 0 0 25px;
    justify-content: flex-start;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li {
    padding: 0 16px;
  }
}
@media (max-width: 768px) {
  body:not(:has(#rv3-top)) { --rv48-head-height: 66px; }
  body:not(:has(#rv3-top)) #header.c-header { padding: 0 11px !important; gap: 7px; }
  body:not(:has(#rv3-top)) #header .c-header__logo a img {
    width: clamp(90px, 27vw, 115px);
  }
  body:not(:has(#rv3-top)) #header .c-header__right {
    height: 44px;
    gap: 6px;
    max-width: calc(100% - 105px);
  }
  body:not(:has(#rv3-top)) #header .c-header__right__nav { display: none; }
  body:not(:has(#rv3-top)) #header .c-header__right__contact a {
    padding: 0 clamp(9px, 2.4vw, 13px);
    border-radius: 10px;
  }
  body:not(:has(#rv3-top)) #header .c-header__right__contact a > span > span { font-size: clamp(11px, 3.1vw, 13px); }
  body:not(:has(#rv3-top)) #header .c-header__right__hamburger {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav {
    display: flex;
    flex-direction: column;
    padding: 0 16px 22px;
    overflow-y: auto;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right {
    order: 0;
    flex: none;
    width: 100%;
    max-width: 560px;
    margin-inline: auto;
    padding: 84px 0 25px;
    overflow: visible;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul { gap: 9px; }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li { padding: 0 16px; }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__left {
    order: 1;
    flex: none;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin-inline: auto;
    padding: 8px 0 26px;
    justify-content: flex-start;
  }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > a { font-size: clamp(17px, 4.5vw, 20px); }
  body:not(:has(#rv3-top)) #header .c-header__open-nav__right__list > ul > li > ul > li > a { font-size: clamp(13px, 3.5vw, 15px); }
  body:not(:has(#rv3-top)) .c-sub-page-heading-1,
  body:not(:has(#rv3-top)) .c-sub-page-heading-2 { padding-top: 27px; }
  body:not(:has(#rv3-top)) .c-sub-page-heading-1__main,
  body:not(:has(#rv3-top)) .c-sub-page-heading-2__main { padding-top: 35px; }
  body:not(:has(#rv3-top)) .c-sub-page-heading-1__main__en,
  body:not(:has(#rv3-top)) .c-sub-page-heading-2__main__en {
    font-size: clamp(42px, 12vw, 64px);
    line-height: 1.05;
    overflow-wrap: anywhere;
  }
  body:not(:has(#rv3-top)) [id] { scroll-margin-top: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  body:not(:has(#rv3-top)) #header.c-header { transition: none !important; }
}

/* RENOVIA v4.8.1 — open-menu logo overlap fix.
   v4.8 puts the logo at z-index:3 and the open navigation at z-index:2;
   hide ONLY the original header logo when the full-screen navigation is open.
   The original right-side close control remains usable above the panel. */
body:not(:has(#rv3-top)).rv48-nav-open #header .c-header__logo,
body:not(:has(#rv3-top)) #header:has(.c-header__open-nav.is-active) .c-header__logo {
  visibility: hidden !important;
  pointer-events: none !important;
}
