/* ==========================================================================
   Clinic Interactive Art - Design Tokens (CSS Custom Properties)
   ==========================================================================
   やわらかく温かみのあるトーンで統一したデザイントークン定義。
   全コンポーネントはこのファイルの変数を参照すること。

   参照: docs/ART_DIRECTION.md
   ========================================================================== */

/* --------------------------------------------------------------------------
   Web Fonts
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=M+PLUS+Rounded+1c:wght@300;400;500;700&display=swap');

/* --------------------------------------------------------------------------
   Root - グローバルデザイントークン
   -------------------------------------------------------------------------- */
:root {

  /* ======================================================================
     Typography
     ====================================================================== */
  --font-family-main: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', sans-serif;
  --font-family-display: 'M PLUS Rounded 1c', 'Noto Sans JP', sans-serif;

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-md: 1rem;       /* 16px */
  --font-size-lg: 1.25rem;    /* 20px */
  --font-size-xl: 1.5rem;     /* 24px */
  --font-size-2xl: 2rem;      /* 32px */
  --font-size-3xl: 2.5rem;    /* 40px */
  --font-size-4xl: 3rem;      /* 48px */
  --font-size-5xl: 4rem;      /* 64px */

  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;

  --line-height-tight: 1.4;
  --line-height-normal: 1.7;
  --line-height-relaxed: 2.0;

  --letter-spacing-tight: -0.02em;
  --letter-spacing-normal: 0.04em;
  --letter-spacing-wide: 0.08em;

  /* ======================================================================
     Brand Colors - 共通パレット
     ====================================================================== */
  --color-primary: #5b8a72;
  --color-primary-light: #7fb09a;
  --color-primary-dark: #3d6b54;

  --color-secondary: #e8a87c;
  --color-secondary-light: #f2c9a8;
  --color-secondary-dark: #c88555;

  --color-accent: #d4a5e5;
  --color-accent-light: #e6c8f0;
  --color-accent-dark: #b07cc8;

  /* ======================================================================
     Background Colors
     ====================================================================== */
  --color-bg-base: #faf8f5;
  --color-bg-warm: #fff5ee;
  --color-bg-cool: #f0f4f8;
  --color-bg-muted: #f3f0ec;
  --color-bg-elevated: #ffffff;
  --color-bg-overlay: rgba(61, 53, 41, 0.4);

  /* ======================================================================
     Background Gradients
     ====================================================================== */
  --bg-gradient-main: linear-gradient(160deg, #f0f4f0 0%, #faf8f5 40%, #fff5ee 100%);
  --bg-gradient-warm: linear-gradient(160deg, #fff5ee 0%, #fce4ec 50%, #fff0e0 100%);
  --bg-gradient-cool: linear-gradient(160deg, #e8f4f8 0%, #f0f4f8 50%, #eef0fa 100%);
  --bg-gradient-nature: linear-gradient(160deg, #e8f5e9 0%, #f0f8f0 50%, #faf8f5 100%);
  --bg-gradient-menu: linear-gradient(160deg, #f0f4f0 0%, #f8f0fa 40%, #fce4ec 100%);

  /* ======================================================================
     Surface Colors
     ====================================================================== */
  --surface-white: #ffffff;
  --surface-cream: #faf8f5;
  --surface-light: #f5f2ee;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --surface-glass-hover: rgba(255, 255, 255, 0.95);
  --surface-overlay: rgba(61, 53, 41, 0.3);

  /* ======================================================================
     Text Colors
     ====================================================================== */
  --color-text-primary: #3d3529;
  --color-text-secondary: #7a7265;
  --color-text-subtle: #b0a89e;
  --color-text-inverse: #faf8f5;
  --color-text-link: #5b8a72;
  --color-text-link-hover: #3d6b54;
  --color-text-on-primary: #ffffff;
  --color-text-on-dark: #faf8f5;

  /* ======================================================================
     Semantic / Status Colors
     ====================================================================== */
  --color-success: #7cb07f;
  --color-warning: #e8c170;
  --color-error: #d98b8b;
  --color-info: #80aec8;

  /* ======================================================================
     Border Colors
     ====================================================================== */
  --color-border-default: #e5e0da;
  --color-border-subtle: #f0ece6;
  --color-border-strong: #c8c0b6;

  /* ======================================================================
     作品テーマ: こびとの森 (Creature Forest)
     ====================================================================== */
  --creature-bg-deep: #1a3a2a;
  --creature-bg-mid: #4a7c59;
  --creature-bg-light: #a8d5ba;
  --creature-accent-pink: #f2b5d4;
  --creature-accent-gold: #fce38a;
  --creature-body-base: #f5f0e1;
  --creature-body-highlight: #f4845f;
  --creature-glow: rgba(252, 227, 138, 0.3);
  --creature-shadow: rgba(26, 58, 42, 0.2);
  --creature-particle-leaf: #6dbf8b;
  --creature-particle-petal: #f7c5d9;
  --creature-particle-light: #fff8e1;

  /* ======================================================================
     作品テーマ: おとのキャンバス (Sound Canvas)
     ====================================================================== */
  --sound-bg: #f8f6f0;
  --sound-bg-texture: rgba(210, 200, 185, 0.08);
  --sound-stroke-purple: #b8b5e0;
  --sound-stroke-blue: #8ecae6;
  --sound-stroke-peach: #ffb4a2;
  --sound-stroke-yellow: #fde68a;
  --sound-stroke-green: #a7c4a0;
  --sound-stroke-highlight: rgba(255, 255, 255, 0.6);
  --sound-ripple: rgba(184, 181, 224, 0.2);
  --sound-fade: rgba(248, 246, 240, 0.05);

  /* ======================================================================
     作品テーマ: にじいろシャボン (Rainbow Bubbles)
     ====================================================================== */
  --bubble-bg-top: #e0f0ff;
  --bubble-bg-bottom: #faf8f5;
  --bubble-pink: #ffc6d9;
  --bubble-blue: #c6e2ff;
  --bubble-mint: #c6f5e2;
  --bubble-lavender: #dcc6ff;
  --bubble-lemon: #fff5c6;
  --bubble-highlight: #ffffff;
  --bubble-sparkle: rgba(255, 215, 0, 0.7);
  --bubble-film-start: rgba(255, 198, 217, 0.4);
  --bubble-film-end: rgba(198, 226, 255, 0.4);
  --bubble-shadow: rgba(180, 180, 220, 0.15);

  /* ======================================================================
     Card Artwork Themes (メニューカード用)
     ====================================================================== */
  --card-forest-bg: linear-gradient(145deg, #a8d5ba 0%, #4a7c59 100%);
  --card-forest-icon: #1a3a2a;
  --card-sound-bg: linear-gradient(145deg, #b8b5e0 0%, #ffb4a2 100%);
  --card-sound-icon: #7a6b8a;
  --card-bubble-bg: linear-gradient(145deg, #c6e2ff 0%, #ffc6d9 100%);
  --card-bubble-icon: #8a7cb0;

  /* ======================================================================
     Border Radius
     ====================================================================== */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* ======================================================================
     Shadows - やわらかいドロップシャドウ (暖色系ベース)
     ====================================================================== */
  --shadow-xs: 0 1px 2px rgba(61, 53, 41, 0.04);
  --shadow-sm: 0 2px 8px rgba(61, 53, 41, 0.06);
  --shadow-md: 0 4px 16px rgba(61, 53, 41, 0.08);
  --shadow-lg: 0 8px 32px rgba(61, 53, 41, 0.10);
  --shadow-xl: 0 16px 48px rgba(61, 53, 41, 0.12);
  --shadow-inner: inset 0 2px 4px rgba(61, 53, 41, 0.04);
  --shadow-card: 0 8px 32px rgba(61, 53, 41, 0.08);
  --shadow-card-hover: 0 12px 40px rgba(61, 53, 41, 0.14);
  --shadow-button: 0 4px 16px rgba(91, 138, 114, 0.2);
  --shadow-glow-primary: 0 0 20px rgba(91, 138, 114, 0.25);
  --shadow-glow-accent: 0 0 20px rgba(212, 165, 229, 0.25);

  /* ======================================================================
     Spacing
     ====================================================================== */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* ======================================================================
     Animation Easing
     ====================================================================== */

  /* 標準イージング */
  --ease-out: cubic-bezier(0.0, 0.0, 0.2, 1.0);
  --ease-in: cubic-bezier(0.4, 0.0, 1.0, 1.0);
  --ease-in-out: cubic-bezier(0.4, 0.0, 0.2, 1.0);

  /* 弾性・オーバーシュート */
  --ease-overshoot: cubic-bezier(0.34, 1.56, 0.64, 1.0);
  --ease-bounce: cubic-bezier(0.34, 1.8, 0.64, 1.0);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* やわらかい動き（有機的表現向け） */
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1.0);
  --ease-gentle: cubic-bezier(0.4, 0.0, 0.6, 1.0);

  /* 呼吸アニメーション向け */
  --ease-breathe: cubic-bezier(0.45, 0.05, 0.55, 0.95);

  /* ======================================================================
     Animation Duration
     ====================================================================== */
  --duration-instant: 80ms;
  --duration-fast: 150ms;
  --duration-quick: 250ms;
  --duration-normal: 400ms;
  --duration-slow: 700ms;
  --duration-slower: 1000ms;
  --duration-ambient: 2000ms;
  --duration-breathe: 4000ms;

  /* ======================================================================
     Touch Target
     ====================================================================== */
  --touch-target-min: 80px;
  --touch-target-comfortable: 100px;
  --touch-target-large: 120px;

  /* ======================================================================
     Z-index Scale
     ====================================================================== */
  --z-canvas: 1;
  --z-content: 10;
  --z-ui: 10;
  --z-back-button: 20;
  --z-overlay: 50;
  --z-attract: 100;
  --z-modal: 200;
  --z-toast: 300;
  --z-tooltip: 400;

  /* ======================================================================
     Screen Brightness Limits
     ====================================================================== */
  --brightness-min: 0.6;
  --brightness-max: 0.85;
}

/* --------------------------------------------------------------------------
   Base Reset & Defaults
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-main);
  font-weight: var(--font-weight-regular);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  letter-spacing: var(--letter-spacing-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-base);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* --------------------------------------------------------------------------
   作品テーマ コンテナ
   -------------------------------------------------------------------------- */

/* こびとの森 */
[data-theme="creature-forest"] {
  --theme-bg: var(--creature-bg-deep);
  --theme-bg-mid: var(--creature-bg-mid);
  --theme-bg-light: var(--creature-bg-light);
  --theme-accent-1: var(--creature-accent-pink);
  --theme-accent-2: var(--creature-accent-gold);
  --theme-glow: var(--creature-glow);
  --theme-shadow: var(--creature-shadow);
  background: linear-gradient(
    180deg,
    var(--creature-bg-deep) 0%,
    var(--creature-bg-mid) 60%,
    var(--creature-bg-light) 100%
  );
}

/* おとのキャンバス */
[data-theme="sound-canvas"] {
  --theme-bg: var(--sound-bg);
  --theme-accent-1: var(--sound-stroke-purple);
  --theme-accent-2: var(--sound-stroke-blue);
  --theme-accent-3: var(--sound-stroke-peach);
  --theme-glow: var(--sound-ripple);
  --theme-shadow: var(--shadow-sm);
  background: var(--sound-bg);
}

/* にじいろシャボン */
[data-theme="rainbow-bubbles"] {
  --theme-bg: var(--bubble-bg-top);
  --theme-accent-1: var(--bubble-pink);
  --theme-accent-2: var(--bubble-blue);
  --theme-accent-3: var(--bubble-mint);
  --theme-accent-4: var(--bubble-lavender);
  --theme-glow: var(--bubble-sparkle);
  --theme-shadow: var(--bubble-shadow);
  background: linear-gradient(
    180deg,
    var(--bubble-bg-top) 0%,
    var(--bubble-bg-bottom) 100%
  );
}

/* --------------------------------------------------------------------------
   Display Font Utility
   -------------------------------------------------------------------------- */
.font-display {
  font-family: var(--font-family-display);
}

/* --------------------------------------------------------------------------
   Ambient Animations (共通キーフレーム)
   -------------------------------------------------------------------------- */

/* ゆるやかな呼吸 */
@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

/* ふわふわ浮遊 */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* やわらかいフェードイン */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* やわらかいフェードアウト */
@keyframes fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* きらきら */
@keyframes sparkle {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* タッチリップル */
@keyframes ripple {
  from {
    transform: scale(0);
    opacity: 0.5;
  }
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   Utility: アニメーションクラス
   -------------------------------------------------------------------------- */
.animate-breathe {
  animation: breathe var(--duration-breathe) var(--ease-breathe) infinite;
}

.animate-float {
  animation: float 3s var(--ease-gentle) infinite;
}

.animate-fade-in {
  animation: fade-in var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-out {
  animation: fade-out var(--duration-normal) var(--ease-in) forwards;
}

.animate-sparkle {
  animation: sparkle 2s var(--ease-soft) infinite;
}

/* --------------------------------------------------------------------------
   Accessibility: Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   Kiosk Mode: タッチ最適化
   -------------------------------------------------------------------------- */
button,
[role="button"],
.touchable {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* --------------------------------------------------------------------------
   Kiosk Mode: コンテキストメニュー・ドラッグ無効化
   -------------------------------------------------------------------------- */
img,
canvas,
video {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

canvas.interactive {
  pointer-events: auto;
  touch-action: none;
}
