/* File: styles.css | Purpose: three.jsホームページのスタイル定義 | Notes: 3DキャンバスとモーダルUIを視覚的に調和させる */
@import url("https://fonts.googleapis.com/css2?family=Audiowide&display=swap");

:root {
  color-scheme: dark;
  --bg-gradient: #fff6ef;
  --accent: #7fffd4;
  --accent-strong: #00d8b3;
  --text-subtle: #fff6ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Audiowide", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-gradient);
  color: #1b1f2a;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100vw;
  overflow: auto;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.stage-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  /* iOS Safariのアドレスバー高さを含めないようdvhを優先する */
  height: 100dvh;
  overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
  /* iOS Safariでアドレスバー表示時に生じる上下の余白を埋める */
  body,
  .stage-container {
    min-height: -webkit-fill-available;
  }
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.overlay-controls {
  position: absolute;
  /* セーフエリア込みのオフセットを一箇所で管理 */
  --overlay-offset: clamp(12px, 2vh, 24px);
  bottom: var(--overlay-offset);
  right: clamp(12px, 4vw, 36px);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 3;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .overlay-controls {
    /* 実機SafariでボタンがブラウザUIに隠れないよう持ち上げる */
    bottom: calc(var(--overlay-offset) + env(safe-area-inset-bottom));
  }
}

/* 操作用ヒントとボタンを横並びにするグループ */
.overlay-action {
  display: flex;
  align-items: center;
  gap: 12px;
}

.overlay-hint {
  position: relative;
  bottom: auto;
  right: auto;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgb(5 8 20 / 0%);
  font-size: 0.8rem;
  color: var(--bg-gradient);
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.rotation-toggle {
  position: relative;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: rgb(5 8 20 / 0%);
  color: var(--bg-gradient);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.28);
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  z-index: 3;
  text-decoration: none;
}

.rotation-toggle:hover {
  background: rgba(5, 8, 20, 0.82);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.32);
}

.rotation-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.rotation-toggle[aria-pressed="true"] {
  background: rgba(5, 8, 20, 0.92);
  transform: translateY(1px);
}

.no-script {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #330;
  color: #ffd;
  padding: 12px 20px;
  border-radius: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 40px));
  padding: 32px 28px 24px;
  background: rgba(5, 7, 18, 0.44);
  border-radius: 20px;
  box-shadow: 0 10px 50px rgba(197, 197, 197, 0.5);
  /* border: 1px solid rgba(127, 255, 212, 0.2); */
  backdrop-filter: blur(2.5px);
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: rgba(127, 255, 212, 0.1);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.modal__close:hover {
  background: rgba(127, 255, 212, 0.25);
}

#modal-title {
  /* モーダル表示時の視認性を維持しつつ全体サイズを調整 */
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1.25rem;
  color: var(--text-subtle);
}

#modal-body {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-subtle);
}

@media (max-width: 640px) {
  /* モバイルでヒントを画面内に収めるためのレイアウト調整 */
  .overlay-controls {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    right: clamp(8px, 6vw, 24px);
  }

  .overlay-hint {
    font-size: 0.6rem;
    max-width: min(260px, calc(100vw - 32px));
    text-align: right;
    white-space: normal;
  }

  .overlay-action {
    font-size: 0.6rem;
    gap: 8px;
    justify-content: flex-end;
  }

  .rotation-toggle {
    font-size: 0.6rem;
  }
}
