/* ==========================================================================
   wordformation - Design System & Modern Styles
   Theme: Pure White, Gray, Blue (Strictly NO Purple)
   Color System: 100% Web Safe Colors (00, 33, 66, 99, CC, FF)
   ========================================================================== */

:root {
  /* 100% Web Safe Colors: Pure White, Gray, Blue (Strictly no reddish/purple tones) */
  --bg-main: #CCCCCC;              /* 眩しくない落ち着いたライトグレー・オフホワイト */
  --bg-surface: #FFFFFF;           /* 純白 */
  --bg-surface-subtle: #FFFFFF;    /* スロット背景 */
  --bg-surface-hover: #CCFFFF;     /* 爽やかなペールアクアブルー（紫感ゼロ） */
  
  --border-subtle: #CCCCCC;        /* 繊細なグレー枠線 */
  --border-medium: #999999;        /* 中間グレー枠線 */
  --border-focus: #0066CC;         /* フォーカス時の鮮やかな青 */
  --border-blue: #0066CC;          /* 純粋なブルー枠線 */
  --border-blue-subtle: #99CCFF;   /* 淡いスカイブルー枠線 */

  --accent-primary: #0066CC;       /* 純粋なクラシックブルー */
  --accent-secondary: #003366;     /* 落ち着いたディープブルー */
  --accent-light: #CCFFFF;         /* スッキリとした淡いシアンブルー */
  --accent-gradient: linear-gradient(135deg, #0066CC 0%, #0099FF 100%);
  --accent-glow: rgba(0, 102, 204, 0.25);
  
  --danger: #FF0033;
  --danger-bg: #FFCCCC;
  --danger-border: #FF0033;
  --danger-text: #CC0033;

  --text-primary: #000000;         /* 純粋な黒（最もクッキリ・紫感皆無） */
  --text-secondary: #333333;       /* 濃いニュートラルグレー */
  --text-muted: #666666;           /* 控えめなグレー */
  --text-blue: #0066CC;            /* アクセント純ブルー */

  /* Typography - Helvetica / Swiss Style */
  --font-display: "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic ProN", sans-serif;
  --font-mono: "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic ProN", sans-serif;

  /* Layout */
  --container-max-width: 640px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-main);
  /* 白とグレーのみの穏やかなグラデーション（紫は一切不使用） */
  background-image: radial-gradient(ellipse at 50% 0%, #FFFFFF 0%, #CCCCCC 85%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  border-top: 4px solid var(--accent-primary);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* 1-Column Container */
.app-container {
  width: 100%;
  max-width: var(--container-max-width);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  flex-shrink: 0;
  padding: 0 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 1.75rem;
  box-sizing: border-box;
}

/* ==========================================================================
   (1) Stage Section - 最上部：造語インスピレーションステージ
   ========================================================================== */
.stage-section {
  width: 100%;
}

.stage-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem 1.25rem;
  box-shadow: 
    0 8px 24px -4px rgba(0, 0, 0, 0.08),
    0 2px 6px -1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: hidden;
  transition: transform var(--transition-smooth), border-color var(--transition-smooth);
}

.word-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
}

.word-box {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 0.5rem;
  position: relative;
}

.slot-content {
  font-size: 1.55rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-primary);
  text-align: center;
  word-break: break-word;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--transition-spring), opacity var(--transition-fast);
}

.slot-content:hover {
  opacity: 0.75;
}

.slot-content:active {
  transform: scale(0.96);
}

/* Pin Button (言葉aの固定・ロック) */
.pin-btn {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.35;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  z-index: 2;
}

/* 言葉bのピンは右端に配置 */
.slot-b .pin-btn {
  left: auto;
  right: 2px;
}

.pin-btn:hover {
  opacity: 0.9;
  color: var(--text-primary);
  background: #EEEEEE;
}

.pin-btn.is-pinned {
  opacity: 1;
  color: var(--accent-primary);
}

.pin-btn.is-pinned svg {
  fill: var(--accent-primary);
}

.pin-btn:active {
  transform: scale(0.92);
}

/* Word Slot Pop Animation */
.word-pop {
  animation: wordPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wordPop {
  0% {
    transform: scale(0.85) translateY(4px);
    opacity: 0.3;
  }
  60% {
    transform: scale(1.08) translateY(-2px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.connector {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1.5px solid var(--border-blue-subtle);
  color: var(--accent-primary);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform var(--transition-spring), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.connector:hover {
  background: #f0f7ff;
  border-color: var(--accent-primary);
  box-shadow: 0 3px 8px rgba(0, 102, 204, 0.18);
  transform: scale(1.08);
}

.connector:active {
  transform: scale(0.92);
}

.connector.spin {
  transform: rotate(180deg);
}

/* Combined Preview & Copy Bar */
.combined-bar {
  display: flex;
  justify-content: center;
  padding-bottom: 1em; /* 1文字分の下余白 */
}

.combined-preview {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 1.3rem;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
}

.combined-preview:hover {
  background: #FFFFFF;
  border-color: var(--border-medium);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.combined-preview:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.combined-text {
  font-size: 1.575rem; /* 1.05remの1.5倍 */
  font-weight: 700;
  color: var(--text-blue);
  letter-spacing: 0.02em;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.copy-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  background: #CCCCCC;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.combined-preview:hover .copy-hint {
  background: #999999;
  color: #FFFFFF;
}

/* ==========================================================================
   (2) Input Section - 言葉を入力するフォーム
   ========================================================================== */
.input-section {
  width: 100%;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  border-bottom: none;
  display: flex;
  justify-content: center;
  padding: 1.75rem 1.25rem 1.25rem;
  box-sizing: border-box;
}

.input-inner {
  width: 100%;
  max-width: var(--container-max-width);
}

.word-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  border-radius: 18px 36px 36px 18px; /* 左側はしっかりと目に見える角丸(18px)、右側は半円カプセル(36px) */
  min-height: 70px; /* 縦幅を従来の約1.3倍に設定 */
  padding: 0.5rem 0.7rem 0.5rem 1.5rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
  transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 
    0 4px 16px rgba(0, 102, 204, 0.18),
    0 0 0 3px var(--accent-glow);
}

.word-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-primary);
  padding: 0.6rem 0;
}

.word-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.submit-btn {
  background: #0066CC;
  border: 1px solid #0066CC;
  border-radius: var(--radius-full);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.62rem 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.submit-btn:hover {
  background: #003366;
  border-color: #003366;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.submit-btn:active {
  transform: scale(0.96);
}


/* ==========================================================================
   (3) Tag Cloud Section - 登録した言葉一覧
   ========================================================================== */
.cloud-section {
  width: 100%;
  flex: 1;
  background: var(--bg-surface);
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 0.5em 1.25rem 4rem; /* タグクラウドと入力フォームの間に1文字の半分の高さの余白 */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cloud-inner {
  width: 100%;
  max-width: var(--container-max-width);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-height: 80px;
  align-content: flex-start;
}

/* Individual Tag */
.word-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: #FFFFFF;
  border: 1.5px solid var(--border-blue-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  max-width: 100%;
  word-break: break-word;
  transition: all var(--transition-fast);
  animation: tagAppear 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tagAppear {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Active in Stage highlight: 純粋な青背景に白文字 */
.word-tag.is-active {
  border-color: var(--accent-primary);
  background: #0066CC;
  color: #FFFFFF;
  font-weight: 700;
}

/* Tag Hover - Intuitive Deletion Indicator (ボタンサイズを維持してレイアウト崩れを防止) */
.word-tag:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  transform: translateY(-1px);
}

.word-tag:active {
  transform: scale(0.92);
}

/* Tag Leaving Animation (on instant delete) */
.word-tag.is-leaving {
  animation: tagDisappear 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

@keyframes tagDisappear {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.4);
    opacity: 0;
    margin-right: -2rem;
  }
}

.cloud-empty-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  width: 100%;
  padding: 2rem 0;
}

/* Cloud Footer & Clear Action */
.cloud-footer {
  margin-top: auto;
  padding-top: 2.5rem;
  padding-bottom: 2em; /* 2文字分の下余白 */
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.btn-clear {
  background: #FFFFFF;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.32rem 0.85rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all var(--transition-fast);
}

.btn-clear:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 102, 204, 0.15);
}

.btn-clear:active {
  transform: scale(0.96);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #000000;
  border: 1px solid #333333;
  color: #FFFFFF;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 520px) {
  body {
    padding: 0;
  }

  .app-container {
    padding: 0 0.75rem;
    gap: 1.25rem;
    margin-top: 1rem;
    margin-bottom: 1.25rem;
  }

  .stage-card {
    padding: 1.25rem 0.9rem 1rem;
  }

  .word-slots {
    gap: 0.45rem;
  }

  .slot-content {
    font-size: clamp(0.95rem, 4.2vw, 1.3rem);
  }

  .word-box {
    min-height: 58px;
    padding: 0.5rem 0.35rem;
  }

  .pin-btn {
    top: 0px;
    left: 0px;
    width: 24px;
    height: 24px;
  }

  .slot-b .pin-btn {
    left: auto;
    right: 0px;
  }

  .pin-btn svg {
    width: 13px;
    height: 13px;
  }

  .connector {
    width: 28px;
    height: 28px;
  }

  .connector svg {
    width: 16px;
    height: 16px;
  }

  .word-input {
    font-size: 1.05rem;
    padding: 0.5rem 0;
  }

  .input-wrapper {
    min-height: 62px; /* モバイルでも縦幅を約1.3倍に */
    padding: 0.42rem 0.55rem 0.42rem 1.1rem;
    border-radius: 15px 31px 31px 15px;
  }

  .submit-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
  }

  .combined-preview {
    max-width: 100%;
    padding: 0.45rem 0.9rem;
  }

  .combined-text {
    font-size: clamp(1.15rem, 5vw, 1.45rem); /* 約1.5倍 */
  }

  .input-section {
    padding: 1.25rem 0.75rem 1rem;
  }

  .cloud-section {
    padding: 0.5em 0.75rem 4rem;
  }
}
