/*
 * ASIAN BRANDS 60 の見た目。部品（src/ab60/ui/）ごとに 1 節。
 * 値はページに直に書かず、上のトークン（色・書体・文字の大きさ・余白・骨組み）から取る。
 * 幅はスマホを基準に、640px（タブレット）・1024px（PC）で足す。文字の大きさは 360〜1440px の間でなめらかに変わる
 */

/* ui-sdk が足す CSS より、このファイルを勝たせる。閉じた中身（hidden）は hydrate の前から隠す */
@layer ui-sdk;

@layer ui-sdk {
  :where([data-slot][hidden]:not([hidden='until-found'])) {
    display: none !important;
  }
}

/* ===== 色のテーマ（ui/Theme.tsx が <html data-color-scheme> に端末に合わせる / ライト / ダーク を出す） ===== */
:root,
[data-color-scheme='system'] {
  color-scheme: light dark;
}

[data-color-scheme='light'] {
  color-scheme: light;
}

[data-color-scheme='dark'] {
  color-scheme: dark;
}

/* ===== トークン ===== */
:root {
  /* 色は light-dark(ライト, ダーク)。文字の赤はどちらの地の上でも 4.5:1 以上 */
  --color-brand: light-dark(rgb(222 24 24), rgb(255 72 72));
  --color-bg: light-dark(#f5f5f5, #0f0b0b);
  --color-on-brand: light-dark(#fff, #0f0b0b);
  --color-scrim: light-dark(rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.6));
  --color-shade: rgb(0 0 0 / 0.2);
  --color-veil: light-dark(rgb(222 24 24 / 0.6), rgb(255 72 72 / 0.7));
  --color-surface: light-dark(#fff, #1c1616);

  /* 書体 */
  --font-en: 'Cormorant Garamond', serif;
  --font-ja: 'Noto Serif JP', serif;

  /* 文字の大きさ。clamp は 360px で最小・1440px で最大 */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-body: clamp(0.9375rem, 0.875rem + 0.28vw, 1.125rem);
  --text-body-ja: clamp(0.8125rem, 0.79rem + 0.09vw, 0.875rem);
  --text-nav: clamp(0.875rem, 0.25rem + 0.78vw, 1.125rem);
  --nav-gap: clamp(0.5rem, 0.94vw, 1rem);
  --text-eyebrow: clamp(1rem, 0.833rem + 0.74vw, 1.5rem);
  --text-thanks: clamp(1.5rem, 1.167rem + 1.48vw, 2.5rem);
  --text-label: clamp(2rem, 1.667rem + 1.48vw, 3rem);
  --text-display: clamp(2.5rem, 2rem + 2.22vw, 4rem);

  /* 余白（8 の倍数） */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4rem;
  --space-8: 6rem;
  --space-9: 8rem;
  --space-10: 12rem;

  /* 骨組み。左の列（rail）にロゴと縦書きの見出し、右に中身。gutter は右と左の端の余白 */
  --rail: 20vw;
  --gutter: var(--space-3);
  --page-top: var(--space-8);
  --section-space: var(--space-8);
  --header-top: var(--space-3);
  --ornament: 2rem;
  --kazari: 10rem;
}

@media (min-width: 640px) {
  :root {
    --rail: 18vw;
    --gutter: var(--space-4);
    --page-top: var(--space-9);
    --section-space: var(--space-9);
    --header-top: var(--space-4);
    --ornament: 3rem;
    --kazari: 12.5rem;
  }
}

@media (min-width: 1024px) {
  :root {
    --rail: 17vw;
    --gutter: var(--space-6);
    --section-space: var(--space-10);
    --ornament: 4rem;
  }
}

/* ===== 土台 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-brand);
  font-family: var(--font-ja);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
}

ul {
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/*
 * 現れる動き。スクロールに合わせて CSS だけで動かす（JS を待たないので、最初の画面の表示を遅らせない）。
 * 対応していないブラウザ・動きを減らす設定では、最初から見えている
 */
@keyframes appear {
  from {
    opacity: 0;
    translate: 0 var(--space-4);
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    [data-appear] {
      animation: appear linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 80%;
    }
  }
}

/* ===== 文字の部品（ui/Text.tsx） ===== */
.eyebrow {
  font: 400 var(--text-eyebrow) / 1.3 var(--font-en);
  letter-spacing: 0.05em;
}

.display {
  font: 700 var(--text-display) / 1.2 var(--font-en);
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.text-en {
  font: 400 var(--text-body) / 1.7 var(--font-en);
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}

.text-ja {
  font: 500 var(--text-body-ja) / 2.4 var(--font-ja);
  letter-spacing: 0.2em;
}

.text-link {
  text-decoration: underline transparent;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.2s ease;
}

.text-link:hover {
  text-decoration-color: currentColor;
}

.heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.bilingual {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-5);
  max-width: 48rem;
}

/* ===== 並べる部品（ui/Stack.tsx） ===== */
.stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stack[data-gap='1'] {
  gap: var(--space-1);
}

.stack[data-gap='2'] {
  gap: var(--space-2);
}

.stack[data-gap='3'] {
  gap: var(--space-3);
}

.stack[data-gap='5'] {
  gap: var(--space-5);
}

.stack[data-gap='7'] {
  gap: var(--space-7);
}

.stack[data-gap='8'] {
  gap: var(--space-8);
}

/* ===== 画面の骨組み（ui/Layout.tsx） ===== */
.skip {
  position: fixed;
  z-index: 20;
  top: var(--space-2);
  left: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-brand);
  color: var(--color-on-brand);
  font: 500 var(--text-sm) / 1.5 var(--font-ja);
  translate: 0 -200%;
}

.skip:focus-visible {
  translate: none;
  outline-color: var(--color-on-brand);
  outline-offset: -4px;
}

.logo {
  position: fixed;
  z-index: 2;
  top: var(--header-top);
  left: 0;
  width: var(--rail);
  padding: 0 var(--space-2);
}

.logo img {
  width: 100%;
  max-width: 12rem;
  margin-inline: auto;
}

.ornament-left {
  position: fixed;
  bottom: var(--space-4);
  left: calc(var(--gutter) + var(--text-label) * 1.4 + var(--space-2));
  width: calc(var(--ornament) * 0.625);
}

.ornament-right {
  position: fixed;
  right: var(--gutter);
  bottom: var(--space-4);
  width: var(--ornament);
}

/* © は狭い画面ではページの最後に置き、PC は画面の下に貼り付ける（写真に重ならない広さがあるときだけ） */
.footer {
  padding: 0 var(--gutter) var(--space-4) var(--rail);
  text-align: center;
  font: 400 var(--text-xs) / 1.9 var(--font-en);
  letter-spacing: 0.05em;
}

@media (min-width: 1024px) {
  .footer {
    position: fixed;
    right: 0;
    bottom: var(--space-4);
    left: 0;
    padding: 0;
    pointer-events: none;
  }
}

/* ===== 上の見出し（ui/Header.tsx） ===== */
.header {
  position: fixed;
  z-index: 3;
  top: var(--header-top);
  right: 0;
  left: var(--rail);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-right: var(--gutter);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--space-6);
}

.header-kazari {
  flex: none;
  width: var(--kazari);
  margin-left: auto;
}

.header-rules {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-rules i {
  display: block;
  height: 1px;
  background: var(--color-brand);
}

.header-rules i:last-child {
  height: 6px;
}

/* PC は見出しを横に並べ、それより狭いときはサイドメニューのボタン */
/* 文字と間隔は 1280px（14px・12px）から 1600px（18px・16px）へなめらかに広げ、切り替えと飾りに重ならないようにする */
.global-nav {
  display: none;
  min-width: 0;
  font: 700 var(--text-nav) / 1.4 var(--font-en);
  letter-spacing: 0.02em;
}

.global-nav-list,
.global-nav-item {
  display: flex;
  align-items: center;
  gap: var(--nav-gap);
}

.global-nav-item {
  flex: none;
  white-space: nowrap;
}

.global-nav-sep {
  width: 1px;
  height: 1em;
  background: currentColor;
}

.menu-button {
  display: grid;
  place-items: center;
  width: var(--space-6);
  height: var(--space-6);
  margin-left: calc(var(--space-3) * -1);
}

.menu-button svg {
  width: var(--space-4);
  height: var(--space-4);
  fill: currentColor;
}

/*
 * 横並びの見出しは 6 つの行き先・テーマの切り替え・飾りが 1 行に収まる 1280px から。それより狭いとサイドメニュー。
 * 狭いときのテーマの切り替えはサイドメニューの中。.theme-switch（後ろの節）より強く書く
 */
.theme-switch.header-theme {
  display: none;
}

@media (min-width: 1280px) {
  .global-nav {
    display: block;
  }

  .menu-button {
    display: none;
  }

  .theme-switch.header-theme {
    display: inline-flex;
    margin-left: auto;
  }

  .header-kazari {
    margin-left: 0;
  }
}

/* ===== テーマの切り替え（ui/Theme.tsx。ui-sdk の SegmentedControl） ===== */
.theme-switch {
  position: relative;
  display: inline-flex;
  flex: none;
  padding: 2px;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.theme-switch-indicator {
  position: absolute;
  top: var(--segmented-control-indicator-top);
  left: var(--segmented-control-indicator-left);
  width: var(--segmented-control-indicator-width);
  height: var(--segmented-control-indicator-height);
  border-radius: 999px;
  background: var(--color-brand);
  transition:
    left 0.2s ease,
    width 0.2s ease;
}

.theme-switch-item {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--space-5);
  height: var(--space-5);
  border-radius: 999px;
  transition: color 0.2s ease;
}

.theme-switch-item svg {
  width: var(--space-3);
  height: var(--space-3);
  fill: currentColor;
}

.theme-switch-item[data-checked] {
  color: var(--color-on-brand);
}

/* サイドメニューの中は地が赤なので、白黒を逆にする */
.side-menu .theme-switch-indicator {
  background: var(--color-on-brand);
}

.side-menu .theme-switch-item[data-checked] {
  color: var(--color-brand);
}

.side-menu-theme {
  align-self: flex-start;
  margin-top: auto;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-indicator,
  .theme-switch-item {
    transition: none;
  }
}

/* ===== サイドメニュー（ui/SideMenu.tsx。ui-sdk の Drawer） ===== */
.side-menu-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-scrim);
}

.side-menu {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: min(85vw, 24rem);
  height: 100dvh;
  padding: var(--space-4) var(--gutter) var(--space-6);
  background: var(--color-brand);
  color: var(--color-on-brand);
  overflow-y: auto;
}

.side-menu-close {
  display: grid;
  place-items: center;
  align-self: flex-end;
  width: var(--space-6);
  height: var(--space-6);
  margin-right: calc(var(--space-3) * -1);
}

.side-menu-close svg {
  width: var(--space-4);
  height: var(--space-4);
  fill: currentColor;
}

.side-menu-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.side-menu-link {
  display: block;
  padding: var(--space-2) 0;
  font: 600 var(--text-eyebrow) / 1.3 var(--font-en);
  letter-spacing: 0.05em;
}

.side-menu :focus-visible {
  outline-color: var(--color-on-brand);
}

/* ===== 節（ui/Section.tsx）。左の列に縦書きの見出し、右に中身 ===== */
.section {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.section-label {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  align-items: flex-end;
  padding: 0 0 var(--space-4) var(--gutter);
}

.vertical {
  writing-mode: vertical-rl;
  rotate: 180deg;
  font: 400 var(--text-label) / 1.4 var(--font-en);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
  padding: var(--section-space) var(--gutter) var(--section-space) 0;
}

.section:first-child .section-body {
  padding-top: var(--page-top);
}

/* 節の中身を縦の真ん中に置く（JUDGE） */
.section[data-fill] .section-body {
  justify-content: center;
  min-height: 100dvh;
}

/* ===== 飾り（ui/Ornament.tsx） ===== */
.corners {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 48rem;
}

.corners img {
  width: clamp(1rem, 2.9vw, 2.625rem);
}

.kazari-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.kazari-row img {
  width: 100%;
}

.kazari-row img:last-child {
  rotate: 180deg;
}

/* ===== 写真のカード（ui/PersonCard.tsx）。白黒で、乗せると赤い幕と名前 ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  width: 100%;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.card a {
  position: relative;
  display: block;
  aspect-ratio: 1;
  /* 写真の重ね方（overlay）をカードの中だけで混ぜる */
  isolation: isolate;
}

.card a::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-shade);
}

.card img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%);
  mix-blend-mode: overlay;
}

.card-name {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  justify-content: center;
  padding: var(--space-3);
  color: var(--color-on-brand);
  font: 400 var(--text-body) / 1.5 var(--font-en);
  letter-spacing: 0.03em;
  text-align: center;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    background 0.3s ease;
}

.card a:hover .card-name,
.card a:focus-visible .card-name {
  opacity: 1;
  background: var(--color-veil);
}

/* 乗せられない端末（指で触る）は、名前を下に常に出す */
@media (hover: none) {
  .card-name {
    inset: auto 0 0;
    padding: var(--space-1) var(--space-2);
    background: var(--color-veil);
    font-size: var(--text-xs);
    opacity: 1;
  }
}

/* ===== 写真の帯（ui/PhotoStrip.tsx。ui-sdk の ScrollArea と Dialog） ===== */
.photo-strip {
  position: relative;
  width: 100%;
  padding-bottom: var(--space-4);
  --photo: calc((100% - var(--space-2) * 2) / 2.4);
}

@media (min-width: 640px) {
  .photo-strip {
    --photo: calc((100% - var(--space-2) * 3) / 3.4);
  }
}

@media (min-width: 1024px) {
  .photo-strip {
    --photo: calc((100% - var(--space-2) * 4) / 4.4);
  }
}

.photo-strip-viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.photo-strip-viewport::-webkit-scrollbar {
  display: none;
}

.photo-strip-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns), var(--photo));
  gap: var(--space-2);
}

.photo-button {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  transition: background 0.3s ease;
}

.photo-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.photo-button:hover {
  background: var(--color-brand);
}

.photo-button:hover img {
  opacity: 0.6;
}

.photo-strip-scrollbar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  height: 4px;
  background: var(--color-veil);
  opacity: 0.3;
  transition: opacity 0.2s ease;
}

.photo-strip:hover .photo-strip-scrollbar,
.photo-strip-scrollbar[data-scrolling] {
  opacity: 1;
}

.photo-strip-thumb {
  height: 100%;
  background: var(--color-brand);
}

/* ===== 窓（ui/Media.tsx。ui-sdk の Dialog）。CM の動画と写真の拡大 ===== */
.media-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-scrim);
}

.media-dialog {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  width: min(100%, 60rem);
  height: fit-content;
  max-height: 100dvh;
  margin: auto;
  padding: var(--space-3);
}

.media-dialog.is-photo {
  width: min(100%, 48rem);
}

.media-close {
  display: grid;
  place-items: center;
  width: var(--space-6);
  height: var(--space-6);
  background: var(--color-bg);
}

.media-close svg {
  width: var(--space-4);
  height: var(--space-4);
  fill: currentColor;
}

.media-body {
  width: 100%;
  padding: var(--space-2);
  background: var(--color-bg);
}

.media-body img {
  width: 100%;
  max-height: calc(100dvh - var(--space-10));
  object-fit: contain;
}

.media-video {
  aspect-ratio: 16 / 9;
}

.media-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ===== トップの中身（pages/Top.tsx） ===== */
.sponsor-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.thanks {
  font: 700 var(--text-thanks) / 1.2 var(--font-en);
  letter-spacing: 0.02em;
}

/* ===== 1 人のページ（pages/Profile.tsx）。PC は 文 | 写真、狭いときは 見出し → 写真 → 文 ===== */
.profile {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.profile-label {
  position: fixed;
  bottom: var(--space-4);
  left: var(--gutter);
}

.profile-body {
  grid-column: 2;
  display: grid;
  grid-template-areas: 'heading' 'images' 'text';
  gap: var(--space-7);
  padding: var(--page-top) var(--gutter) var(--section-space) 0;
}

.profile-heading {
  grid-area: heading;
}

.profile-images {
  grid-area: images;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.profile-images img {
  width: 100%;
}

.profile-text {
  grid-area: text;
}

@media (min-width: 1024px) {
  .profile-body {
    grid-template-areas: 'heading images' 'text images';
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: var(--space-9);
  }
}

/* ===== 見つからないページ（pages/NotFound.tsx） ===== */
.not-found {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100dvh;
}

.not-found-body {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--page-top) var(--gutter) var(--section-space) 0;
}
