/* ============================================================
   BIOTOPE Design System for spec-comparison (Public Facing)
   「削ぎ落とす」ではなく「選び抜く」ミニマリズム

   WCAG AA準拠: すべてのテキストはコントラスト比4.5:1以上
   ============================================================ */

/* ------------------------------------------------------------
   CSS Variables (Design Tokens)
   ------------------------------------------------------------ */
:root {
  /* カラーパレット（WCAG AA準拠） */
  --color-primary: #142803;       /* ブランドカラー（深緑） */
  --color-primary-light: #E8F5E9;
  --color-primary-dark: #0A1401;

  --color-text: #1A1A1A;          /* コントラスト比 16:1 */
  --color-text-muted: #4A4A4A;    /* コントラスト比 8:1 */
  --color-text-light: #6B6B6B;    /* コントラスト比 5:1 */

  --color-accent: #007AFF;        /* Apple Blue */
  --color-accent-light: #E3F2FD;
  --color-error: #B71C1C;
  --color-success: #34C759;       /* Apple Green */

  --color-bg: #F9F9F9;
  --color-card: #FFFFFF;
  --color-border: #D0D0D0;
  --color-border-light: #E8E8E8;

  /* フォーカスリング */
  --color-focus-ring: #007AFF;
  --color-focus-bg: rgba(0, 122, 255, 0.08);

  /* タイポグラフィ */
  --font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  --line-height: 1.8;
  --line-height-tight: 1.4;

  /* スペーシング（8の倍数） */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* ボーダー */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* シャドウ */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* トランジション */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   アクセシビリティ
   ------------------------------------------------------------ */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--color-primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top var(--transition-fast);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-md);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.main-content {
  flex: 1;
  padding: var(--space-lg) 0 var(--space-3xl);
}

/* ------------------------------------------------------------
   Header（外部向け - より目立つデザイン）
   ------------------------------------------------------------ */
.header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  padding: var(--space-2xl) 0;
  text-align: center;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.site-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.5px;
}

.site-subtitle {
  font-size: var(--font-size-base);
  opacity: 0.9;
}

/* ------------------------------------------------------------
   Info Box
   ------------------------------------------------------------ */
.info-box {
  background: var(--color-accent-light);
  border: 1px solid rgba(0, 122, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.info-text {
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.remaining-text {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.remaining-count {
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
  font-size: var(--font-size-lg);
}

.limit-text {
  color: var(--color-text-light);
}

/* ------------------------------------------------------------
   Card
   ------------------------------------------------------------ */
.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-primary-light);
}

/* ------------------------------------------------------------
   Search Box
   ------------------------------------------------------------ */
.search-box {
  position: relative;
  margin-bottom: var(--space-md);
}

.search-input {
  width: 100%;
  padding: var(--space-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:hover {
  border-color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-focus-bg);
  outline: none;
}

.hint-text {
  display: block;
  margin-top: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* 検索インジケーター */
.search-indicator {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.search-indicator[hidden] {
  display: none;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background-color: var(--color-accent);
  border-radius: 50%;
  margin: 0 2px;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* ------------------------------------------------------------
   Search Results
   ------------------------------------------------------------ */
.search-results {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.search-results[hidden] {
  display: none;
}

.product-list-info {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
}

.search-result-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: var(--color-focus-bg);
}

.search-result-item:focus {
  background-color: var(--color-focus-bg);
  outline: none;
}

.search-result-item.selected {
  background-color: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
}

.product-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
}

.product-info-number {
  background-color: var(--color-border-light);
  color: var(--color-text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
}

.product-name {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.brand-name {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.no-results {
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------
   Selected Section
   ------------------------------------------------------------ */
.selected-section {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
}

.selected-section[hidden] {
  display: none;
}

.selected-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
}

.selected-count {
  font-weight: var(--font-weight-normal);
  color: var(--color-text-muted);
}

.selected-list {
  list-style: none;
  margin-bottom: var(--space-md);
}

.selected-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-card);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  box-shadow: var(--shadow-sm);
}

.selected-item-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.selected-item-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.selected-item-brand {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.remove-btn {
  background: none;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: var(--space-xs);
  font-size: var(--font-size-base);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.remove-btn:hover {
  background: rgba(183, 28, 28, 0.1);
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: #0056b3;
}

.btn-primary:disabled {
  background: var(--color-border);
  cursor: not-allowed;
}

.generate-button {
  margin-top: var(--space-md);
}

/* ------------------------------------------------------------
   Result Section
   ------------------------------------------------------------ */
.result-section[hidden] {
  display: none;
}

.comparison-result iframe {
  width: 100%;
  min-height: 600px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: white;
}

/* ------------------------------------------------------------
   Loading Overlay
   ------------------------------------------------------------ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-content {
  text-align: center;
  max-width: 300px;
}

/* プログレスリング */
.progress-ring {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  position: relative;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring__background {
  fill: none;
  stroke: var(--color-border-light);
  stroke-width: 8;
}

.progress-ring__progress {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 201.06;
  stroke-dashoffset: 201.06;
  transition: stroke-dashoffset 0.3s ease;
}

.loading-text {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.4px;
}

.loading-subtext {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: var(--line-height-tight);
}

/* 処理ステップ表示 */
.loading-steps {
  margin-top: var(--space-lg);
  text-align: left;
}

.step-item {
  display: flex;
  align-items: center;
  margin: var(--space-sm) 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInStep 0.5s ease forwards;
}

.step-item.active {
  color: var(--color-text);
}

.step-item.complete {
  color: var(--color-success);
}

.step-icon {
  width: 20px;
  height: 20px;
  margin-right: var(--space-sm);
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-item.complete .step-icon::after {
  content: '\2713';
  font-size: 12px;
  font-weight: bold;
}

@keyframes fadeInStep {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* パルスアニメーション */
.loading-overlay.pulse .progress-ring {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */
.footer {
  background: var(--color-card);
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-lg) 0;
  text-align: center;
}

.footer-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.footer-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-copyright {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  .site-title {
    font-size: var(--font-size-2xl);
  }

  .header {
    padding: var(--space-xl) 0;
  }

  .card {
    padding: var(--space-lg);
  }

  .search-input {
    font-size: var(--font-size-base);
    padding: var(--space-sm) var(--space-md);
  }

  .btn {
    padding: var(--space-sm) var(--space-md);
    min-height: 44px;
  }
}
