/* ========================================
   AI-MY Web Viewer - Refactored Styles
   Design: Component-based, Semantic Colors
   ======================================== */

/* ===== 1. CSS Variables (Design Tokens) ===== */
:root {
  /* Typography - Fluid & Responsive */
  /* 必然性：画面サイズに応じて文字サイズを自動調整し、可読性を維持 */
  --font-family: 'Virtual Boy', 'Shippori Mincho', 'IBM Plex Serif', serif;
  --font-size-base: clamp(18px, 2.5vw, 25px);
  --font-size-small: clamp(16px, 2vw, 20px);
  --letter-spacing: 0.02em;
  --line-height: 1.7;

  /* Spacing - Fluid & Responsive */
  /* 必然性：余白を画面幅に比例させ、情報密度を最適化 */
  --space-xs: 0.25em;
  --space-sm: 0.5em;
  --space-md: 1em;
  --space-lg: 1.5em;
  --space-xl: 2.5em;
  --space-fluid-xs: clamp(0.25em, 0.5vw, 0.5em);
  --space-fluid-sm: clamp(0.5em, 1vw, 1em);
  --space-fluid-md: clamp(1em, 2vw, 1.5em);
  --indent-size: 2ch;

  /* Colors - Semantic (State-based) */
  --color-bg-page-start: #DBEBEB;
  --color-bg-page-end: #C8DEDE;
  --color-bg-viewer: rgba(220, 220, 220, 0.65);
  --color-border: rgba(255, 255, 255, 0.4);
  --color-text-base: #4a4a4a;
  --color-text-subtle: #7a7a7a;

  /* JSON Element Colors (Content) */
  --color-key: #7F7F7F;
  --color-value-string: #FD9341;
  --color-value-number: #8c8c8c;
  --color-value-boolean: #32cd32;
  --color-value-null: #b0b0b0;
  --color-structure: #FF6B6B;

  /* Interactive Colors (State) */
  --color-interactive: #007bff;
  --color-interactive-hover: #0056b3;
  --color-interactive-active: #004085;
  --color-collapsed: #7a7a7a;  /* 統一されたグレー */
  --color-expanded: #7a7a7a;   /* 同じグレー（展開状態でも色を変えない） */

  /* Effects */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --glow-sm: 0 0 8px;
  --glow-md: 0 0 16px;

  /* Animation */
  --duration-fast: 150ms;
  --duration-base: 300ms;
  --duration-slow: 500ms;
  --ease-in-out: cubic-bezier(0.83, 0, 0.17, 1);
  --ease-out: cubic-bezier(0.0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  /* Layout */
  --max-width: 1024px;

  /* === Responsive Structure Symbols === */
  /* 必然性：{ } [ ] の巨大さを画面幅に比例させ、モバイルでの圧迫感を軽減 */
  --font-size-structure: clamp(60px, 15vw, 150px);

  /* === Responsive Decorative Images === */
  /* 必然性：装飾画像を画面サイズに応じてリサイズし、レイアウト崩れを防ぐ */
  --decorative-img-height: clamp(260px, 40vw, 520px);
  --decorative-img-overlap: clamp(120px, 18vw, 360px);
  --json-image-size: clamp(260px, 32vw, 420px);

  /* === Responsive Bouncing Logo === */
  /* 必然性：バウンスエリアを画面比率に応じて調整し、すべてのデバイスで適切な動きを実現 */
  --bounce-logo-left: clamp(10%, 33.2%, 40%);
  --bounce-logo-width: clamp(80%, 69.7%, 90%);
  --bounce-logo-height: clamp(12em, 21.6em, 24em);
  --bounce-logo-margin-top: clamp(14em, 23.6em, 26em);
}

/* ===== 2. Base Styles ===== */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,400;0,700;1,400;1,700&family=Shippori+Mincho:wght@400;700&display=swap');

/* Virtual Boy Font */
@font-face {
  font-family: 'Virtual Boy';
  src: url('/static/fonts/virtual-boy.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base) !important;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  color: var(--color-text-base);

  background: linear-gradient(135deg, var(--color-bg-page-start) 0%, var(--color-bg-page-end) 100%);
  background-attachment: fixed;
  min-height: 100vh;

  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-lg);

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ===== 3. Layout Components ===== */
#json-viewer {
  width: 100%;
  max-width: var(--max-width);

  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;

  padding: var(--space-xl);
  border: none;
  border-radius: 0;

  box-shadow: none;

  white-space: pre-wrap;
  word-wrap: break-word;

  animation: fadeInUp var(--duration-slow) var(--ease-out);

  position: relative;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 4. JSON Components ===== */

/* 4.1 JSONLine */
.json-line {
  display: block;
  margin-bottom: 0.3em;
  transition: all var(--duration-fast) var(--ease-out);
  opacity: 0;
  animation: fadeInStagger var(--duration-base) var(--ease-out) forwards;
  position: relative;
}


.json-line--structure {
  display: inline-block;
  margin-bottom: 0;
}

#json-viewer > .json-line--structure {
  display: block;
  margin-bottom: 0.3em;
}

@keyframes fadeInStagger {
  to { opacity: 1; }
}

.json-line:nth-child(n+1) { animation-delay: calc(var(--duration-fast) * 0.3); }
.json-line:nth-child(n+2) { animation-delay: calc(var(--duration-fast) * 0.6); }
.json-line:nth-child(n+3) { animation-delay: calc(var(--duration-fast) * 0.9); }
.json-line:nth-child(n+4) { animation-delay: calc(var(--duration-fast) * 1.2); }
.json-line:nth-child(n+5) { animation-delay: calc(var(--duration-fast) * 1.5); }

/* 4.2 JSONKey */
.json-key {
  color: var(--color-key);
  font-weight: 600;
  transition: all var(--duration-fast) var(--ease-out);
  display: inline-block;
  cursor: default;
  position: relative;
  z-index: 1;  /* スタッキングコンテキスト内で前面に */
}

.json-key:hover {
  color: var(--color-interactive-hover);
  transform: translateX(2px);
  text-shadow: var(--glow-sm) rgba(127, 127, 127, 0.3);
}

.json-key--small {
  font-size: var(--font-size-small);
  color: var(--color-text-subtle);
}

/* 4.3 JSONValue */
.json-value {
  display: inline;
  position: relative;
  z-index: 1;  /* スタッキングコンテキスト内で前面に */
}

.json-string {
  color: var(--color-value-string);
  word-break: break-all;
}

.json-number {
  color: var(--color-value-number);
  font-variant-numeric: tabular-nums;
}

.json-boolean {
  color: var(--color-value-boolean);
  font-weight: 600;
}

.json-null {
  color: var(--color-value-null);
  font-style: italic;
}

/* 4.4 JSONStructure */
.json-structure {
  color: var(--color-structure);
  font-weight: 700;
  /* 必然性：流動的サイズでモバイルからデスクトップまで適応 */
  font-size: var(--font-size-structure);
  text-shadow: var(--glow-sm) rgba(255, 230, 0, 0.5);
  position: relative;
  z-index: 2000;  /* すべての行より前面で装飾画像に埋もれない */
}

.json-structure--colon {
  font-size: var(--font-size-base);
  margin-right: 0.6ch;
  opacity: 0.7;
}

.json-structure--comma {
  font-size: var(--font-size-base);
  margin-left: -0.5ch;
  opacity: 0.6;
}

.json-structure--comma-large {
  /* 必然性：構造記号と同じ流動的サイズで一貫性を保つ */
  font-size: var(--font-size-structure);
}

/* 4.5 JSONImage */
.json-image {
  display: inline-flex;
  width: var(--json-image-size);
  height: var(--json-image-size);
  max-width: 100%;
  margin-left: var(--space-sm);
  vertical-align: middle;
  border-radius: 6px;
  overflow: hidden;
  transition: all var(--duration-base) var(--ease-out);
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  position: relative;
}

.json-image img {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  object-fit: cover;
  transition: transform var(--duration-fast) var(--ease-out);
}

.json-image img:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.json-image[data-loading="true"]::before {
  content: "⟳ Loading...";
  display: block;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.05);
  text-align: center;
  line-height: var(--json-image-size);
  color: var(--color-text-subtle);
  font-size: 20px;
}

.json-image[data-error="true"]::before {
  content: "✕ Error";
  background: rgba(255, 0, 0, 0.1);
  color: #c00;
}

/* 4.6 ImagePlaceholder */
.json-placeholder {
  display: inline-block;
  width: var(--json-image-size);
  height: var(--json-image-size);
  background: linear-gradient(135deg, #e0e0e0 0%, #f0f0f0 100%);
  border: 1px dashed var(--color-border);
  border-radius: 4px;
  text-align: center;
  line-height: var(--json-image-size);
  color: var(--color-text-subtle);
  font-size: 20px;
  margin-left: var(--space-sm);
  vertical-align: middle;
}

.json-placeholder::before {
  content: "[IMG]";
}

/* 4.7 Decorative Background Image (for specific sections like collective-info) */

.json-line.has-decorative-image {
  position: relative;
  margin-top: calc(var(--decorative-img-height) - var(--decorative-img-overlap));
}

.json-line.has-decorative-image::before {
  content: '';
  position: absolute;
  /* 必然性：左端から全幅で配置し、視覚的バランスを取る */
  width: 100%;
  height: var(--decorative-img-height);
  background-image: url('/static/neko.jpg');
  background-size: cover;
  background-position: center;
  border-radius: 16px;
  left: 0;
  bottom: calc(100% - var(--decorative-img-overlap));
  z-index: -1;  /* スタッキングコンテキスト内で背面に */
  pointer-events: none;  /* Allow clicking through the image */
  box-shadow: 0 25px 80px rgba(15, 34, 61, 0.25);
}

/* 必然性：テキストコンテンツを確実に装飾画像の前面に配置 */
/* すべての子要素と子孫要素を前面に */
.json-line.has-decorative-image *,
.json-line.has-decorative-image > * {
  position: relative;
  z-index: 1;  /* スタッキングコンテキスト内で前面に */
}

/* 必然性：装飾画像と重なるキーをオレンジ色にして視認性を確保 */
.json-line.has-decorative-image > .json-key,
.json-line.has-decorative-image > .collapsible-section > .collapsible-section__trigger {
  color: var(--color-structure) !important;  /* { } と同じオレンジ色 #FF6B6B */
}

/* 必然性：モバイルでは装飾画像を非表示、情報密度を下げて可読性を優先 */
@media (max-width: 768px) {
  .json-line.has-decorative-image::before {
    display: none;
  }
}

/* ===== 5. Collapsible Component ===== */

/* 5.1 CollapsibleSection */
.collapsible-section {
  transition: all 900ms var(--ease-in-out);
}

.collapsible-section__trigger {
  cursor: pointer;
  position: relative;
  font-size: 50px;
  transition: all var(--duration-base) var(--ease-out);
  user-select: none;
}

.collapsible-section__trigger::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-interactive);
  transition: width var(--duration-base) var(--ease-out);
}

.collapsible-section__trigger:hover {
  color: var(--color-interactive-hover);
  transform: translateX(4px) scale(1.02);
}

.collapsible-section__trigger:hover::before {
  width: 100%;
}

.collapsible-section__trigger:active {
  transform: translateX(4px) scale(0.98);
}

.collapsible-section__content {
  overflow: hidden;
  transition:
    max-height 900ms var(--ease-in-out),
    opacity 900ms var(--ease-in-out);
  max-height: 0;
  opacity: 0;
}

/* 5.2 State: Collapsed */
.collapsible-section[data-state="collapsed"] .collapsible-section__trigger {
  color: var(--color-collapsed);
}

.collapsible-section[data-state="collapsed"] .collapsible-section__content {
  opacity: 0;
  max-height: 0;
}

/* 5.3 State: Expanded */
.collapsible-section[data-state="expanded"] .collapsible-section__trigger {
  color: var(--color-expanded);
  text-decoration: underline;
  text-decoration-color: rgba(122, 122, 122, 0.4);  /* グレーの下線 */
  text-underline-offset: 4px;
}

.collapsible-section[data-state="expanded"] .collapsible-section__content {
  opacity: 1;
}

/* 5.4 CollapsibleItem */
.collapsible-item {
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
  border-bottom: 1px solid transparent;
}

.collapsible-item:hover {
  background: rgba(0, 123, 255, 0.08);
  border-bottom-color: var(--color-interactive-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 123, 255, 0.15);
}

.collapsible-item:active {
  transform: translateY(0);
}

.collapsible-item--summary {
  color: #888;
  font-style: italic;
  text-decoration: none;
}

.collapsible-item--summary:hover {
  color: #666;
  background: rgba(0, 0, 0, 0.03);
}

/* ===== 6. Utilities ===== */

/* 6.1 Spacing */
.u-indent-1 { padding-left: calc(var(--indent-size) * 1); }
.u-indent-2 { padding-left: calc(var(--indent-size) * 2); }
.u-indent-3 { padding-left: calc(var(--indent-size) * 3); }

/* 6.2 Display */
.u-hidden { display: none !important; }
.u-inline { display: inline !important; }
.u-block { display: block !important; }

/* 6.3 Text */
.u-text-small {
  font-size: var(--font-size-small);
  color: var(--color-text-subtle);
}

/* ===== 7. Responsive Design ===== */
/* 必然性：clamp()による流動的サイズを基本とし、メディアクエリは微調整のみ */

/* Tablet: 769px - 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    /* 必然性：タブレットサイズの最適化、デスクトップとモバイルの中間点 */
    --bounce-logo-left: 25%;
    --bounce-logo-width: 75%;
    --bounce-logo-height: 18em;
    --bounce-logo-margin-top: 20em;
    --json-image-size: clamp(240px, 45vw, 360px);
  }
}

/* Mobile: 481px - 768px */
@media (max-width: 768px) {
  :root {
    /* 必然性：モバイルの余白を縮小し、画面領域を有効活用 */
    --space-xl: 1.5em;
    --bounce-logo-left: 5%;
    --bounce-logo-width: 90%;
    --bounce-logo-height: 14em;
    --bounce-logo-margin-top: 16em;
    --json-image-size: clamp(200px, 70vw, 300px);
  }

  #json-viewer {
    padding: var(--space-lg);
    border-radius: 12px;
  }

}

/* Small Mobile: < 480px */
@media (max-width: 480px) {
  :root {
    /* 必然性：小画面での余白をさらに縮小、読みやすさを維持 */
    --space-lg: 1em;
    --bounce-logo-left: 5%;
    --bounce-logo-width: 90%;
    --bounce-logo-height: 12em;
    --bounce-logo-margin-top: 14em;
    --json-image-size: clamp(180px, 85vw, 240px);
  }

  body {
    padding: var(--space-md);
  }

  #json-viewer {
    padding: var(--space-md);
    border-radius: 8px;
  }

}

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

.collapsible-section__trigger:focus-visible,
.collapsible-item:focus-visible {
  outline: 2px solid var(--color-interactive);
  outline-offset: 4px;
  border-radius: 4px;
}

::selection {
  background: rgba(253, 147, 65, 0.3);
  color: inherit;
}

::-moz-selection {
  background: rgba(253, 147, 65, 0.3);
  color: inherit;
}

/* ===== 9. Bouncing Logo ===== */
.bouncing-logo-wrapper {
  position: absolute;
  /* 必然性：流動的配置でデスクトップからモバイルまでバウンスエリアを最適化 */
  left: var(--bounce-logo-left);
  top: 2em;
  width: var(--bounce-logo-width);
  height: var(--bounce-logo-height);
  z-index: 1;
  overflow: hidden;
}

.bouncing-logo {
  position: absolute;
  display: block;
  will-change: transform;
}

.bouncing-logo-wrapper ~ .json-line {
  clear: both;
}

.bouncing-logo-wrapper ~ .json-line:first-of-type {
  /* 必然性：バウンスエリアの高さに連動して余白を調整 */
  margin-top: var(--bounce-logo-margin-top);
}

/* ===== 10. Print Styles ===== */
@media print {
  body {
    background: white;
  }

  #json-viewer {
    background: white;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .json-key,
  .json-string,
  .json-structure {
    text-shadow: none;
  }

  .collapsible-section[data-state="collapsed"] .collapsible-section__content {
    height: auto;
    opacity: 1;
  }
}

/* ===== 11. Navigation Bar (Publishing Layer) ===== */
/* 必然性：常時表示メニューバーでサイトマップ的役割を実現 */

.nav-bar {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: rgba(253, 147, 65, 0.1);
  border: 1px solid #FD9341;
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  max-width: 600px;
}

.nav-bar__title {
  display: none; /* Hide title for cleaner look */
}

.nav-bar__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.nav-bar__tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--json-string-color);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  white-space: nowrap;
}

.nav-bar__tag:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  filter: brightness(1.1);
}

.nav-bar__tag:active {
  transform: scale(0.95);
}

/* レスポンシブ：モバイルでは下部に配置 */
@media (max-width: 768px) {
  .nav-bar {
    top: auto;
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    justify-content: center;
  }

  .nav-bar__tags {
    justify-content: center;
  }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  .nav-bar {
    background: rgba(253, 147, 65, 0.15);
    border-color: #FD9341;
  }

  .nav-bar__lang-switcher {
    color: rgba(255, 255, 255, 0.9);
  }

  .nav-bar__lang-separator {
    color: rgba(255, 255, 255, 0.4);
  }
}

/* Language Switcher */
.nav-bar__lang-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.8);
}

.nav-bar__lang-button {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  transition: opacity 200ms ease;
  text-decoration: none;
}

.nav-bar__lang-button:hover {
  opacity: 0.7;
}

.nav-bar__lang-button.active {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.nav-bar__lang-separator {
  color: rgba(0, 0, 0, 0.4);
  user-select: none;
  pointer-events: none;
}

/* ===== 12. Publishing Click Overlay ===== */
/* 必然性：AI-MY Product Publishing セクション全体をクリック可能にする透明オーバーレイ */

.publishing-click-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100px;  /* Cover the description area */
  cursor: pointer;
  z-index: 10;
  background: transparent;
  transition: background 200ms ease;
}

.publishing-click-overlay:hover {
  background: rgba(253, 147, 65, 0.05);  /* Subtle highlight on hover */
}

/* ===== 13. Featured Product Hero (Legacy - can be removed) ===== */
/* 必然性：最新プロダクトを視覚的に強調し、探索への入口を提供 */

.featured-product-hero {
  position: relative;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto 3em;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.featured-product-hero:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.featured-product-hero__image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: cover;
}

.featured-product-hero__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: white;
  padding: 2em;
  transform: translateY(0);
  transition: transform 300ms ease;
}

.featured-product-hero:hover .featured-product-hero__overlay {
  transform: translateY(-8px);
}

.featured-product-hero__title {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: bold;
  margin: 0 0 0.5em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.featured-product-hero__subtitle {
  font-size: clamp(14px, 2vw, 18px);
  margin: 0;
  opacity: 0.9;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* レスポンシブ：モバイルでは高さを抑える */
@media (max-width: 768px) {
  .featured-product-hero {
    margin-bottom: 2em;
  }

  .featured-product-hero__image {
    max-height: 300px;
  }

  .featured-product-hero__overlay {
    padding: 1.5em;
  }
}

/* ===== 13. AI-MY Deep CTA Button ===== */
.deep-cta-button {
  display: inline-block;
  padding: 0.8em 1.6em;
  font-family: var(--font-family);
  font-size: var(--base-font-size);
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--json-string-color), var(--json-structure-color));
  border: 2px solid var(--json-structure-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 200ms ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.deep-cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  filter: brightness(1.1);
}

.deep-cta-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ===== 14. AI-MY Deep Modal ===== */
.deep-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.deep-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.deep-modal__content {
  position: relative;
  background: var(--page-background-color);
  border: 3px solid var(--json-structure-color);
  border-radius: 8px;
  padding: 2.5em;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  z-index: 10001;
}

.deep-modal__content h3 {
  margin: 0 0 0.8em;
  font-size: 1.6em;
  color: var(--json-structure-color);
  font-family: var(--font-family);
}

.deep-modal__content p {
  margin: 0.6em 0;
  line-height: 1.7;
  color: var(--base-text-color);
  font-family: var(--font-family);
}

.deep-modal__close {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 2em;
  line-height: 1;
  color: var(--json-key-color);
  cursor: pointer;
  transition: color 150ms ease;
}

.deep-modal__close:hover {
  color: var(--json-structure-color);
}

/* モバイル対応 */
@media (max-width: 768px) {
  .deep-modal__content {
    padding: 2em;
    max-width: 90%;
  }

  .deep-modal__content h3 {
    font-size: 1.3em;
  }

  .deep-cta-button {
    padding: 0.7em 1.4em;
    font-size: clamp(16px, 4vw, 20px);
  }
}

/* ===== AI Mode - Plain View ===== */
/* 必然性：AIが読むのと同じプレーンなデータ構造を人間にも見せる */

body.ai-mode {
  background: #fff !important;
  transition: background 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

#json-viewer.ai-mode {
  /* Override all fancy styling with plain, monochrome design */
  font-family: Arial, 'Helvetica Neue', sans-serif !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  letter-spacing: 0 !important;
  color: #333 !important;
  background: #fff !important;
  transition: all 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* AI Mode: Color-coded for readability (subtle palette) */
#json-viewer.ai-mode .json-key {
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 14px !important;
  color: #0066cc !important; /* Blue for keys */
  font-weight: 600 !important;
}

#json-viewer.ai-mode .json-string {
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 14px !important;
  color: #22863a !important; /* Green for strings */
}

#json-viewer.ai-mode .json-number {
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 14px !important;
  color: #b35900 !important; /* Orange for numbers */
}

#json-viewer.ai-mode .json-boolean {
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 14px !important;
  color: #6f42c1 !important; /* Purple for booleans */
}

#json-viewer.ai-mode .json-null {
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 14px !important;
  color: #6a737d !important; /* Gray for null */
}

#json-viewer.ai-mode .json-value {
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 14px !important;
  color: #333 !important; /* Default black */
}

/* AI Mode: Structure symbols */
#json-viewer.ai-mode .json-structure {
  font-size: 14px !important;
  color: #666 !important;
  font-weight: normal !important;
}

/* AI Mode: No large structure symbols */
#json-viewer.ai-mode .json-line--structure .json-structure {
  font-size: 14px !important;
}

/* AI Mode: Hide all decorative images */
#json-viewer.ai-mode .json-line.has-decorative-image::before {
  display: none !important;
}

#json-viewer.ai-mode .json-line.has-decorative-image {
  margin-top: 0 !important;
}

/* AI Mode: Hide all images, show URL text only */
#json-viewer.ai-mode .json-image {
  display: none !important;
}

/* AI Mode: Bouncing logo fills entire viewport */
body.ai-mode .bouncing-logo-wrapper {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 1 !important;
  pointer-events: none !important; /* Don't block clicks */
}

body.ai-mode .bouncing-logo-wrapper ~ .json-line:first-of-type {
  margin-top: 0 !important; /* Remove margin since logo is fullscreen */
}

/* AI Mode: Disable hover effects */
#json-viewer.ai-mode .collapsible-section__trigger:hover,
#json-viewer.ai-mode .json-image:hover,
#json-viewer.ai-mode .nav-bar__tag:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* AI Mode: Plain collapsible sections */
#json-viewer.ai-mode .collapsible-section__trigger {
  font-size: 14px !important;
  color: #333 !important;
  background: transparent !important;
  border: none !important;
  padding: 4px 0 !important;
}

/* AI Mode: No animations */
#json-viewer.ai-mode .collapsible-section__content {
  transition: none !important;
}

/* AI Mode: Indentation (use inline style from JS) */
/* Indentation is set via inline style: padding-left: ${indentLevel * 2}ch */

/* AI Mode: Show aiOnlyKeys (handled in JS) */
/* aiOnlyKeys will be rendered when in AI mode */

/* Human Mode: Restore fancy styling (default) */
#json-viewer.human-mode {
  transition: all 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
