/**
 * トップ ヒーロー：独立 100vh 全幅 ＋ 行ごとの筆跡背景 ＋ スナップスクロール
 * 詳細度を .tbt-hero から始めるセレクタで統一し、他CSSに負けないようにする
 */

.tbt-hero {
  position: relative;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background-color: var(--tbt-namakabe);
  box-sizing: border-box;
}

.tbt-hero .tbt-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: var(--tbt-namakabe);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  will-change: transform;
}

/* パララックスモード：上に50%分バッファを確保して translateY でもギャップが出ないようにする */
.tbt-hero--parallax .tbt-hero-bg {
  inset: unset;
  top: -50%;
  left: 0;
  right: 0;
  height: 200%;
}

.tbt-hero .tbt-hero-video-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.tbt-hero .tbt-hero-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tbt-hero .tbt-hero-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, rgba(63, 63, 63, 0.35) 0%, transparent 50%);
  pointer-events: none;
  opacity: var(--tbt-hero-overlay, 1);
}

/* キャッチエリア：縦書き強制（黄金比の起点）。句読点は PHP で縦書き互換字形へ。mixed は欧文混在用 */
.tbt-hero .tbt-hero-catch-wrap {
  position: absolute;
  left: var(--tbt-hero-pos-x, 10%);
  top: var(--tbt-hero-pos-y, 50%);
  transform: translate(-50%, -50%);
  z-index: 3;
  max-width: var(--tbt-hero-text-max-width, none);
  padding: 1.25em 1.5em;
  pointer-events: none;
  writing-mode: vertical-rl !important;
  -webkit-writing-mode: vertical-rl !important;
  text-orientation: mixed;
  line-break: normal;
  word-break: normal;
}

/* 縦書き強制 ＋ 行ごとの筆跡背景（フォントは .tbt-hero-brand / .tbt-hero-tagline で個別指定） */
.tbt-hero .tbt-hero-vertical-logo {
  position: relative;
  z-index: 1;
  writing-mode: vertical-rl !important;
  -webkit-writing-mode: vertical-rl !important;
  color: var(--tbt-hero-text-color, #FAF9F7);
  /* 影は各文字要素（.tbt-hero-brand / .tagline）にのみ。コンテナに矩形シャドウを付けない */
  text-shadow: none;
  opacity: 0;
  /* 右側からスッと入る（画面座標で +X ＝右） */
  transform: translateX(1.35rem);
  transition:
    opacity 1.9s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.9s cubic-bezier(0.22, 1, 0.36, 1);
  text-orientation: mixed;
  line-break: normal;
}

/* 各グリフに沿う多重 text-shadow（フォールバックは functions.php の tbt_hero_default_glyph_text_shadow と同値） */
.tbt-hero .tbt-hero-brand,
.tbt-hero .tbt-hero-tagline,
.tbt-hero .tbt-hero-line .tbt-hero-brand,
.tbt-hero .tbt-hero-line .tbt-hero-tagline {
  text-shadow: var(
    --tbt-hero-shadow,
    0 1px 0 rgba(0, 0, 0, 0.92),
    0 2px 4px rgba(0, 0, 0, 0.65),
    0 4px 14px rgba(0, 0, 0, 0.45),
    0 0 2px rgba(0, 0, 0, 0.9),
    0 0 1px rgba(0, 0, 0, 0.5),
    1px 1px 2px rgba(0, 0, 0, 0.55),
    -1px -1px 2px rgba(0, 0, 0, 0.45),
    1px -1px 2px rgba(0, 0, 0, 0.4),
    -1px 1px 2px rgba(0, 0, 0, 0.4),
    0 1px 8px rgba(0, 0, 0, 0.35)
  ) !important;
  -webkit-text-stroke: 0.45px rgba(0, 0, 0, 0.35);
  paint-order: stroke fill;
}

/* コンテンツ配置：カスタマイザーの「配置」設定を flex / text-align に反映 */
.tbt-hero .tbt-hero-brand,
.tbt-hero .tbt-hero-tagline {
  text-align: var(--tbt-hero-text-align, left);
}

/* 黄金比：左＝キャッチ（下ずらし）、右＝タイトル。.tbt-hero-has-lines で :has() 非対応でも適用 */
.tbt-hero .tbt-hero-vertical-logo.tbt-hero-has-lines,
.tbt-hero .tbt-hero-vertical-logo:has(.tbt-hero-line) {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start;
  justify-content: var(--tbt-hero-justify, flex-start);
  gap: 0.6em;
  writing-mode: vertical-rl !important;
  -webkit-writing-mode: vertical-rl !important;
  direction: ltr;
}

.tbt-hero .tbt-hero-vertical-logo.tbt-hero-has-lines .tbt-hero-line:not(.tbt-hero-line--title),
.tbt-hero .tbt-hero-vertical-logo:has(.tbt-hero-line) .tbt-hero-line:not(.tbt-hero-line--title) {
  margin-top: 40px !important;
}

.tbt-hero .tbt-hero-catch-wrap.is-visible .tbt-hero-vertical-logo {
  opacity: 1;
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .tbt-hero .tbt-hero-vertical-logo {
    transform: none;
    transition-duration: 0.01ms;
  }

  .tbt-hero .tbt-hero-catch-wrap.is-visible .tbt-hero-vertical-logo {
    transform: none;
  }
}

/* 縦書きで「行」＝1列ずつ。各行が独立したブロック */
.tbt-hero .tbt-hero-line {
  position: relative;
  display: inline-block !important;
  writing-mode: vertical-rl !important;
  -webkit-writing-mode: vertical-rl !important;
  flex-shrink: 0;
  text-orientation: mixed;
}

/* 各行ごとの筆跡背景（和紙・刷毛目） */
.tbt-hero .tbt-hero-line-bg {
  position: absolute;
  inset: -14px -8px;
  z-index: 0;
  pointer-events: none;
  opacity: var(--tbt-hero-zabuton-opacity, 0.9);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: cover;
  mask-size: cover;
}

/* 座布団ありのとき行背景を確実に表示（霞・和紙・刷毛目） */
.tbt-hero.has-zabuton .tbt-hero-line-bg {
  min-height: 1px;
  visibility: visible;
}
.tbt-hero .tbt-hero-catch-wrap--zabuton-kasumi .tbt-hero-line-bg {
  background: radial-gradient(
    ellipse 100% 120% at 50% 50%,
    var(--tbt-hero-zabuton-color, #7F2629) 0%,
    var(--tbt-hero-zabuton-color, #7F2629) 28%,
    transparent 68%
  );
  -webkit-mask-image: none;
  mask-image: none;
}

.tbt-hero .tbt-hero-catch-wrap--zabuton-washi .tbt-hero-line-bg {
  background: radial-gradient(
    ellipse 110% 110% at 50% 50%,
    var(--tbt-hero-zabuton-color, #7F2629) 0%,
    transparent 62%
  );
  -webkit-mask-image: none;
  mask-image: none;
}

.tbt-hero .tbt-hero-catch-wrap--zabuton-hakeme .tbt-hero-line-bg {
  background: radial-gradient(
    ellipse 100% 115% at 50% 50%,
    var(--tbt-hero-zabuton-color, #7F2629) 0%,
    transparent 60%
  );
  -webkit-mask-image: var(--tbt-hero-zabuton-line-mask);
  mask-image: var(--tbt-hero-zabuton-line-mask);
}

.tbt-hero .tbt-hero-brand,
.tbt-hero .tbt-hero-tagline {
  position: relative;
  z-index: 1;
  display: block !important;
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: keep-all !important;
}

.tbt-hero .tbt-hero-brand {
  font-family: var(--tbt-font-title, var(--tbt-font-serif));
  font-size: max(2.25rem, var(--tbt-hero-font-size, 48px));
  font-weight: var(--tbt-font-title-weight, 600);
  letter-spacing: 0.2em;
}

.tbt-hero .tbt-hero-tagline {
  font-family: var(--tbt-font-catch, var(--tbt-font-serif));
  font-size: max(1.35rem, var(--tbt-hero-tagline-font-size, 30px));
  font-weight: var(--tbt-font-catch-weight, 400);
  letter-spacing: 0.15em;
  opacity: 0.95;
}

.tbt-hero .tbt-hero-line + .tbt-hero-line .tbt-hero-tagline {
  margin-top: 0;
}

.tbt-hero .tbt-hero-line--title .tbt-hero-brand {
  margin-top: 0;
}

.tbt-hero .tbt-hero-vertical-logo > .tbt-hero-brand {
  margin-top: 0;
}

.tbt-hero .tbt-hero-vertical-logo > .tbt-hero-tagline {
  margin-top: 1.5em;
}

.tbt-hero-reveal {
  position: relative;
  z-index: 2;
  background-color: var(--tbt-washi-cream);
}

/* Full-to-Next：CSS Scroll Snap */
body.tbt-hero-scroll-full-to-next {
  scroll-snap-type: y mandatory;
  overflow-x: hidden;
}
body.tbt-hero-scroll-full-to-next .tbt-hero,
body.tbt-hero-scroll-full-to-next .tbt-hero-reveal {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

@media (max-width: 781px) {
  .tbt-hero {
    min-height: 70vh;
    height: 70vh;
  }
  .tbt-hero .tbt-hero-line-bg {
    inset: -10px -6px;
  }
  .tbt-hero .tbt-hero-vertical-logo.tbt-hero-has-lines .tbt-hero-line:not(.tbt-hero-line--title),
  .tbt-hero .tbt-hero-vertical-logo:has(.tbt-hero-line) .tbt-hero-line:not(.tbt-hero-line--title) {
    margin-top: 30px !important;
  }
  .tbt-hero .tbt-hero-brand {
    font-size: clamp(26px, 7.2vw, max(2.25rem, var(--tbt-hero-font-size, 48px)));
  }
  .tbt-hero .tbt-hero-tagline {
    font-size: clamp(18px, 5.2vw, max(1.35rem, var(--tbt-hero-tagline-font-size, 30px)));
  }
}
