/* ================================================================
   Ice Cream Market Analysis Report - Stylesheet
   Business Report Design with Dark Mode & Print Support
   ================================================================ */

/* --- CSS Variables (Light Mode) --- */
:root {
  --bg: #fafbfc;
  --surface: #ffffff;
  --surface-hover: #f0f4f8;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-dark: #1d4ed8;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --header-bg: rgba(255,255,255,0.92);
  --max-width: 1300px;
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #273449;
    --border: #334155;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-light: #1e3a5f;
    --accent-dark: #60a5fa;
    --success: #10b981;
    --success-light: #064e3b;
    --warning: #f59e0b;
    --warning-light: #451a03;
    --danger: #f87171;
    --danger-light: #450a0a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.5);
    --header-bg: rgba(15,23,42,0.94);
  }
  .kpi-card { background: var(--surface); }
  .chart-wrap { background: var(--surface); }
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.header-icon { font-size: 1.4rem; }

.header-period {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--accent-light);
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-weight: 500;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.header-nav a {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.header-nav a:hover,
.header-nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

/* --- Main Content --- */
.report {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
}

/* --- Sections --- */
.section {
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- KPI Grid --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card.kpi-primary {
  border-left: 4px solid var(--accent);
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.kpi-sub.positive { color: var(--success); }
.kpi-sub.negative { color: var(--danger); }

/* --- Summary Points --- */
.summary-points {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.summary-points h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.summary-points ol {
  padding-left: 1.25rem;
}

.summary-points li {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.summary-points li strong {
  color: var(--text);
}

/* --- Grid Layouts --- */
.macro-grid,
.pos-grid,
.competitor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.macro-card,
.pos-card,
.competitor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.macro-card h3,
.pos-card h3,
.competitor-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.macro-card p,
.pos-card p,
.competitor-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.65;
}

.macro-card p strong,
.pos-card p strong,
.competitor-card p strong {
  color: var(--text);
}

.full-width { grid-column: 1 / -1; }

/* --- Chart Wrappers --- */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  background: var(--surface);
}

.chart-wrap.chart-tall { height: 400px; }

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- Chart Legend --- */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.chart-legend span::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.4;
}

.product-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0.6rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  z-index: 1;
}

.product-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.product-table tbody tr:hover {
  background: var(--surface-hover);
}

.product-table .rank-col { width: 3rem; text-align: center; font-weight: 600; }
.product-table .abc-a { color: var(--success); font-weight: 700; }
.product-table .abc-b { color: var(--warning); font-weight: 600; }
.product-table .abc-c { color: var(--text-muted); }
.product-table .num-col { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Strategy Cards --- */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
}

.strategy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--accent);
}

.strategy-card.card-ceo { border-top-color: var(--accent); }
.strategy-card.card-sales { border-top-color: var(--success); }
.strategy-card.card-dev { border-top-color: var(--warning); }
.strategy-card.card-lotte { border-top-color: #dc2626; }
.strategy-card.card-morinaga { border-top-color: #2563eb; }
.strategy-card.card-glico { border-top-color: #d97706; }
.strategy-card.card-haagen { border-top-color: #7c3aed; }
.strategy-card.card-meiji { border-top-color: #059669; }
.strategy-card.card-others { border-top-color: #0891b2; }

/* --- Insight Banner --- */
.insight-banner {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.insight-banner strong {
  color: var(--accent);
}

/* --- Season Grid --- */
.season-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.season-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.season-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.season-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.65;
}

.season-card p strong {
  color: var(--text);
}

.season-card.full-width { grid-column: 1 / -1; }

.chart-wrap.chart-medium { height: 320px; }

/* --- Pack Stats --- */
.pack-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.pack-stat {
  text-align: center;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.pack-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.pack-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* --- Maker Stats Line --- */
.maker-stats {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.strategy-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.strategy-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.strategy-body h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.strategy-body ul {
  padding-left: 1.25rem;
}

.strategy-body li {
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.strategy-body li strong {
  color: var(--text);
}

/* --- Terminology Box --- */
.terminology-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-top: 1.25rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.terminology-box summary {
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  background: var(--surface-hover);
}

.terminology-box summary:hover {
  background: var(--accent-light);
}

.term-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
}

.term-item {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.term-item strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.1rem;
}

@media (max-width: 600px) {
  .term-grid { grid-template-columns: 1fr; }
}

/* --- Consumer Section --- */
.consumer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.consumer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.consumer-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.consumer-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.consumer-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.consumer-stat {
  text-align: center;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.cs-num {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.cs-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.15rem;
}

.source-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-top: 0.5rem;
}

.blindspot-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.blindspot strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: var(--text);
}

.blindspot p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .consumer-grid { grid-template-columns: 1fr; }
  .consumer-stat-row { grid-template-columns: repeat(3, 1fr); }
}

/* --- Synthesis Section --- */
.synthesis-methodology {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.synthesis-methodology h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  text-align: center;
}

.method-card {
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
}

.method-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.method-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.synthesis-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.synthesis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.synthesis-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.synthesis-card.card-challenge h3 { color: var(--danger); border-bottom-color: var(--danger); }
.synthesis-card.card-response h3 { color: var(--accent); border-bottom-color: var(--accent); }
.synthesis-card.card-future h3 { color: var(--success); border-bottom-color: var(--success); }

.challenge-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.challenge-item {
  padding: 0.75rem;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
}

.challenge-item strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.challenge-item p {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.response-table-wrap {
  overflow-x: auto;
}

.good { color: var(--success); font-weight: 600; }
.warn { color: var(--warning); font-weight: 600; }

.future-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.future-item {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
}

.future-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.4;
  line-height: 1;
  flex-shrink: 0;
}

.future-item strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.future-item p {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .method-grid { grid-template-columns: repeat(2, 1fr); }
  .challenge-list { grid-template-columns: 1fr; }
  .future-grid { grid-template-columns: 1fr; }
}
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .macro-grid,
  .pos-grid,
  .competitor-grid,
  .season-grid {
    grid-template-columns: 1fr;
  }

  .strategy-grid {
    grid-template-columns: 1fr;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .kpi-value {
    font-size: 1.3rem;
  }

  .chart-wrap { height: 240px; }
  .chart-wrap.chart-tall { height: 300px; }
}

@media (max-width: 600px) {
  .report { padding: 0.75rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card { padding: 0.75rem; }
  .kpi-value { font-size: 1.1rem; }
  .section-title { font-size: 1.2rem; }
}

/* --- Print --- */
@media print {
  .site-header {
    position: static;
    border-bottom: 1px solid #ccc;
  }
  .header-nav { display: none; }
  .chart-wrap { break-inside: avoid; height: 240px; }
  .chart-wrap.chart-tall { height: 320px; }
  .section { break-inside: avoid; margin-bottom: 1rem; }
  .kpi-grid { grid-template-columns: repeat(6, 1fr); }
  .kpi-card { box-shadow: none; border: 1px solid #ddd; }
  .pos-grid, .macro-grid, .competitor-grid {
    grid-template-columns: 1fr;
  }
  .site-footer { border-top: 1px solid #ccc; }
  body { font-size: 11px; }
}
