/*
 * トップページのKV(.xs-home-hero)を画面いっぱいの水槽にする。
 * KVは元から画面の左・右・上の端に接している(ヘッダーは固定で、その下に重なる)ので、
 * 高さを 100svh にして上下左右とも最大にする。訪問者が非表示にした場合(html.xs-aqw-off)は元の見た目に戻る。
 */

/* 画面いっぱいのKV */
html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero {
  align-content: center;
  background-color: #0a3042;
  color: #fff;
  display: grid;
  justify-items: center;
  min-height: 100vh;
  min-height: 100svh;
  /* 固定ヘッダーの下に文字を逃がし、下はスクロール案内の分を空ける */
  padding-block: calc(var(--xs-header-height, 0px) + 24px) 88px !important;
  text-align: center;
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero::before,
html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero::after {
  display: none;
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero :is(h1, p) {
  color: #fff;
  text-shadow: 0 2px 16px rgba(2, 18, 28, 0.55);
}

/*
 * KVの上にいる間だけ、固定ヘッダーを透過して白文字にする。
 * 戻る条件は wallpaper.js が html に付ける .xs-aqw-scrolled(KVの下端がヘッダーを越えた)。
 * スマホのメニューを開いている間(.has-modal-open)と、ドロップダウン内のリンクは、地が白いので元の色のまま。
 * .js は JSが動く環境だけに限る(JSが無いと戻す手段が無いため)。
 */
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background-color: transparent;
  border-bottom-color: transparent;
}

html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-site-title a,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-submenu__toggle,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__responsive-container-open {
  color: #fff;
  text-shadow: 0 1px 12px rgba(2, 18, 28, 0.55);
}

/*
 * ホバー・フォーカス中は、テーマが濃い背景を敷くと白文字が読めなくなる。
 * 透過中は、ごく薄い白の面に置き換え、文字は白のままにする。
 */
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content:hover,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content:focus-visible,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item:hover > .wp-block-navigation-item__content,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item:focus-within > .wp-block-navigation-item__content,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-site-title a:hover,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-site-title a:focus-visible {
  background-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item:hover > .wp-block-navigation-submenu__toggle,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__container > .wp-block-navigation-item:focus-within > .wp-block-navigation-submenu__toggle {
  background-color: transparent;
  color: #fff;
}

/*
 * 透過ヘッダーの間(KVの上)だけ、プルダウン(カテゴリ)を角丸・半透明にし、項目を線で区切る。
 * KVを越えたあと・水槽を隠したとき・他のページ・プラグインが無いときは、テーマ標準のプルダウンのまま。
 * スマホのメニュー(オーバーレイ)の中は対象外。
 */
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation:not(.has-background) .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__submenu-container {
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  background-color: color-mix(in srgb, var(--xs-color-surface, #fff) 88%, transparent);
  border: 1px solid var(--xs-color-line, #dedbd2);
  border-radius: calc(var(--xs-radius, 8px) * 1.5);
  box-shadow: var(--xs-shadow-soft, 0 20px 45px rgba(23, 24, 28, 0.08));
  color: var(--xs-color-ink, #17181c);
  overflow: hidden;
  padding: 0;
}

html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__submenu-container > .wp-block-navigation-item:not(:last-child) {
  border-bottom: 1px solid var(--xs-color-line, #dedbd2);
}

html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
  border-radius: 0;
  color: var(--xs-color-ink, #17181c);
  padding: 0.7rem 1.1rem;
  text-shadow: none;
  transition: background-color 160ms ease, color 160ms ease;
}

html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover,
html.js:not(.xs-aqw-off):not(.xs-aqw-scrolled):not(.has-modal-open) body.xs-aqw-kv .xs-site-header .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation__submenu-container .wp-block-navigation-item__content:focus-visible {
  background-color: color-mix(in srgb, var(--xs-color-accent, #0f766e) 12%, transparent);
  color: var(--xs-color-accent-strong, #115e59);
}

/*
 * KVの検索欄。入力欄とボタンを、1つの丸い検索バーとしてまとめる(水槽が表示されているときだけ)。
 * テーマ標準は、入力欄とボタンが別々の形で、スマホでは縦に積まれる。ここでは幅によらず横並びの1本にする。
 * ボタンはテーマ共通のボタン(.wp-block-search__button)をそのまま使い、位置と余白だけ整える。
 */
html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero .wp-block-search {
  max-width: 580px;
  width: min(100%, 580px);
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero .wp-block-search__inside-wrapper {
  -webkit-backdrop-filter: blur(10px);
  align-items: center;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 12px 36px rgba(2, 18, 28, 0.38);
  display: flex;
  gap: 6px;
  overflow: visible;
  padding: 6px;
  transition: box-shadow 160ms ease;
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero .wp-block-search__inside-wrapper:focus-within {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5), 0 12px 36px rgba(2, 18, 28, 0.38);
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero .wp-block-search__input {
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  color: var(--xs-color-ink, #17181c);
  flex: 1 1 auto;
  font-size: 1rem;
  min-height: 44px;
  min-width: 0;
  outline: 0;
  padding-inline: 1.1rem;
  width: auto;
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero .wp-block-search__input::placeholder {
  color: var(--xs-color-muted, #626875);
}

html:not(.xs-aqw-off) body.xs-aqw-kv .xs-home-hero .wp-block-search__button {
  align-items: center;
  border-radius: 999px;
  flex: none;
  justify-content: center;
  margin: 0;
  min-height: 44px;
  padding: 0.65rem 1.5rem;
  width: auto;
}

/* 水槽(背景+魚)。KVいっぱいに敷き、クリックは通さない */
.xs-aqw-host {
  isolation: isolate;
}

/* テーマが .xs-home-hero > * に position: relative を当てているので、それより強い指定で絶対配置にする */
.xs-aqw-host > .xs-aqw {
  background: #0a3042;
  inset: 0;
  margin: 0 !important;
  max-width: none;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  width: 100%;
  z-index: 0;
}

.xs-aqw-host > .xs-aqw[hidden] {
  display: none;
}

.xs-aqw__bg {
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: cover;
  inset: 0;
  opacity: 0;
  position: absolute;
  transition: opacity 700ms ease;
}

.xs-aqw__bg.is-ready {
  opacity: 1;
}

/* 水の演出が背景をキャンバスで描いている間は、CSS側の背景と暗さの重ねは使わない(演出を止めたときの予備) */
.xs-aqw-host > .xs-aqw.is-canvas-bg > .xs-aqw__bg {
  opacity: 0;
}

.xs-aqw-host > .xs-aqw.is-canvas-bg::after {
  display: none;
}

/* 見出しが読めるよう、上(ヘッダーと文字の部分)を少し暗くする */
.xs-aqw::after {
  background: linear-gradient(to bottom, rgba(4, 24, 36, 0.5) 0%, rgba(4, 24, 36, 0.18) 40%, rgba(4, 24, 36, 0.3) 100%);
  content: "";
  inset: 0;
  position: absolute;
}

.xs-aqw__canvas {
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
  z-index: 1;
}

/* 切り替えボタン。見た目はテーマ共通のボタン(style.css の共通ボタン定義)を使い、ここでは位置と大きさだけ決める */
.xs-aqw-host > .xs-aqw-toggle {
  bottom: clamp(12px, 2vw, 24px);
  box-shadow: 0 8px 24px rgba(2, 18, 28, 0.3);
  cursor: pointer;
  font-size: 0.85rem;
  margin: 0 !important;
  padding: 0.45rem 1rem;
  position: absolute;
  right: clamp(12px, 2vw, 24px);
  z-index: 2;
}

.xs-aqw-host > .xs-aqw-toggle[hidden],
.xs-aqw-host > .xs-aqw-scroll[hidden] {
  display: none;
}

/* 下へスクロールする案内 */
.xs-aqw-host > .xs-aqw-scroll {
  background: rgba(4, 24, 36, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  bottom: clamp(16px, 3vw, 28px);
  color: #fff;
  cursor: pointer;
  display: grid;
  height: 44px;
  left: 50%;
  margin: 0 !important;
  place-items: center;
  position: absolute;
  transform: translateX(-50%);
  transition: background-color 160ms ease;
  width: 44px;
  z-index: 2;
}

.xs-aqw-host > .xs-aqw-scroll:hover,
.xs-aqw-host > .xs-aqw-scroll:focus-visible {
  background: rgba(4, 24, 36, 0.62);
}

.xs-aqw-scroll span {
  animation: xs-aqw-nudge 1.8s ease-in-out infinite;
  border-bottom: 2px solid currentColor;
  border-right: 2px solid currentColor;
  height: 10px;
  transform: rotate(45deg) translate(-2px, -2px);
  width: 10px;
}

@keyframes xs-aqw-nudge {
  50% {
    transform: rotate(45deg) translate(1px, 1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .xs-aqw__bg {
    transition: none;
  }

  .xs-aqw-scroll span {
    animation: none;
  }
}
