/* ============================================================
   支援ナビ — Design System (大野商工会議所トンマナ準拠)
   ============================================================ */

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

:root {
  /* Brand — 大野CCI Red */
  --cci-red: #E60012;
  --cci-red-dark: #C4000F;
  --cci-red-light: #FFF0F0;
  --cci-red-100: #FFE5E7;

  /* Neutral */
  --black: #1a1a1a;
  --gray-900: #222222;
  --gray-800: #333333;
  --gray-700: #4a4a4a;
  --gray-600: #666666;
  --gray-500: #888888;
  --gray-400: #aaaaaa;
  --gray-300: #cccccc;
  --gray-200: #e5e5e5;
  --gray-100: #f2f2f2;
  --gray-50: #f8f8f8;
  --white: #ffffff;

  /* Status */
  --status-active: #E60012;
  --status-upcoming: #F59E0B;
  --status-preparing: #3B82F6;
  --status-closed: #9CA3AF;
  --status-always: #8B5CF6;

  /* Category accents */
  --cat-subsidy: #E60012;
  --cat-grant: #9333EA;
  --cat-loan: #059669;
  --cat-tax: #D97706;
  --cat-consult: #2563EB;
  --cat-cert: #0891B2;

  /* Level */
  --level-national: #E60012;
  --level-pref: #2563EB;
  --level-city: #059669;

  /* Layout */
  --container-max: 1280px;
  --header-height: 64px;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  /* Shadows — subtle */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.1);

  --transition: .2s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  background: var(--white);
  color: var(--gray-800);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ============================================================
   Header — White with red accent line
   ============================================================ */
.header {
  background: var(--white);
  border-bottom: 3px solid var(--cci-red);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 24px;
}

.logo-text {
  font-size: 22px;
  font-weight: 900;
  color: var(--cci-red);
  letter-spacing: .02em;
  background: none;
  -webkit-text-fill-color: var(--cci-red);
}

.header-subtitle {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 400;
  letter-spacing: .04em;
  border-left: 2px solid var(--gray-200);
  padding-left: 14px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 11px;
}

.meta-label {
  color: var(--gray-400);
  font-weight: 400;
}

.meta-value {
  color: var(--gray-700);
  font-weight: 500;
}

.btn-print {
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-print:hover {
  border-color: var(--cci-red);
  color: var(--cci-red);
}

/* ============================================================
   Stats Bar
   ============================================================ */
.stats-bar {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.stats-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.stat-number {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 400;
}

.stat-active {
  background: var(--cci-red-100);
  color: var(--cci-red);
  border-color: var(--cci-red-100);
}

.stat-upcoming {
  background: #FEF3C7;
  color: #B45309;
}

.stat-preparing {
  background: #DBEAFE;
  color: #1D4ED8;
}

.stat-always {
  background: #EDE9FE;
  color: #6D28D9;
}

.stat-total {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ============================================================
   Alert Bar
   ============================================================ */
.alert-bar {
  background: var(--cci-red-light);
  border-bottom: 2px solid var(--cci-red);
}

.alert-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--cci-red-dark);
}

.alert-icon {
  font-size: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: var(--header-height);
  z-index: 90;
}

.filter-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-group {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-categories {
  flex: 1;
}

.filter-buttons {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-btn,
.filter-chip {
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.filter-btn:hover,
.filter-chip:hover {
  border-color: var(--cci-red);
  color: var(--cci-red);
}

.filter-btn.active {
  background: var(--cci-red);
  color: var(--white);
  border-color: var(--cci-red);
}

.filter-chip.active {
  background: var(--cci-red-100);
  color: var(--cci-red);
  border-color: var(--cci-red);
  font-weight: 600;
}

.filter-icon {
  margin-right: 3px;
}

/* ============================================================
   View Toggle
   ============================================================ */
.view-toggle-bar {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.view-toggle-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.view-toggle {
  display: flex;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-btn {
  background: var(--white);
  border: none;
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.view-btn:hover {
  color: var(--cci-red);
}

.view-btn.active {
  background: var(--cci-red);
  color: var(--white);
}

.view-info {
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================================
   Timeline Section
   ============================================================ */
.timeline-section {
  padding: 24px;
  max-width: var(--container-max);
  margin: 0 auto;
  overflow-x: auto;
}

.timeline-container {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 20px;
  position: relative;
  min-width: 900px;
}

.timeline-header {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 0;
  position: relative;
}

.timeline-month {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  position: relative;
}

.timeline-month.current {
  color: var(--cci-red);
  background: var(--cci-red-light);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  font-weight: 800;
}

.timeline-body {
  position: relative;
}

.timeline-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--gray-100);
  min-height: 40px;
  position: relative;
  transition: var(--transition);
  cursor: pointer;
}

.timeline-row:hover {
  background: var(--gray-50);
}

.timeline-row-label {
  width: 220px;
  min-width: 220px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.timeline-row-label .level-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 50px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid;
}

.level-国 {
  background: #FFF0F0;
  color: var(--cci-red);
  border-color: var(--cci-red) !important;
}

.level-県 {
  background: #EFF6FF;
  color: #2563EB;
  border-color: #2563EB !important;
}

.level-市 {
  background: #ECFDF5;
  color: #059669;
  border-color: #059669 !important;
}

.timeline-row-track {
  flex: 1;
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
}

.timeline-bar {
  position: absolute;
  height: 20px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--white);
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
  min-width: 4px;
}

.timeline-bar:hover {
  transform: scaleY(1.4);
  z-index: 3;
  box-shadow: var(--shadow-md);
}

.timeline-bar.status-active {
  background: var(--cci-red);
}

.timeline-bar.status-upcoming {
  background: #F59E0B;
}

.timeline-bar.status-preparing {
  background: #3B82F6;
}

.timeline-bar.status-closed {
  background: var(--gray-300);
}

.timeline-bar.status-always {
  background: #8B5CF6;
  opacity: .6;
}

.timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--cci-red);
  z-index: 5;
  pointer-events: none;
}

.timeline-today::before {
  content: '今日';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  color: var(--white);
  background: var(--cci-red);
  padding: 1px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.timeline-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--gray-100);
  z-index: 0;
}

/* ============================================================
   Cards Section
   ============================================================ */
.cards-section {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 24px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.support-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.support-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.support-card:hover {
  border-color: var(--cci-red);
  box-shadow: var(--shadow-md);
}

.support-card[data-category="subsidy"]::before { background: var(--cci-red); }
.support-card[data-category="grant"]::before { background: #9333EA; }
.support-card[data-category="loan"]::before { background: #059669; }
.support-card[data-category="tax"]::before { background: #D97706; }
.support-card[data-category="consult"]::before { background: #2563EB; }
.support-card[data-category="certification"]::before { background: #0891B2; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-badges {
  display: flex;
  gap: 4px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.badge-level {
  border: 1px solid;
}

.badge-level[data-level="国"] {
  background: #FFF0F0;
  color: var(--cci-red);
  border-color: var(--cci-red);
}

.badge-level[data-level="県"] {
  background: #EFF6FF;
  color: #2563EB;
  border-color: #2563EB;
}

.badge-level[data-level="市"] {
  background: #ECFDF5;
  color: #059669;
  border-color: #059669;
}

.badge-status {
  letter-spacing: .02em;
}

.badge-status.active {
  background: var(--cci-red-100);
  color: var(--cci-red);
}

.badge-status.upcoming {
  background: #FEF3C7;
  color: #B45309;
}

.badge-status.preparing {
  background: #DBEAFE;
  color: #1D4ED8;
}

.badge-status.closed {
  background: var(--gray-100);
  color: var(--gray-500);
}

.badge-status.always {
  background: #EDE9FE;
  color: #6D28D9;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.4;
  margin-bottom: 6px;
}

.card-what {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.7;
  margin-bottom: 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.card-info-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.card-info-label {
  font-size: 10px;
  color: var(--gray-400);
  font-weight: 600;
  letter-spacing: .04em;
}

.card-info-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
}

.card-info-value.amount {
  color: var(--cci-red);
}

.card-schedule {
  font-size: 10px;
  color: var(--gray-500);
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-schedule-icon {
  font-size: 12px;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalIn .2s ease;
  border-top: 4px solid var(--cci-red);
}

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

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 12px 12px 0 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  z-index: 10;
}

.modal-close:hover {
  border-color: var(--cci-red);
  color: var(--cci-red);
}

.modal-content {
  padding: 16px 24px 24px;
}

.modal-level-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 3px;
  margin-bottom: 6px;
  border: 1px solid;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 6px;
  line-height: 1.4;
}

.modal-what {
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--cci-red-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--cci-red);
  line-height: 1.7;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.modal-info-box {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  border: 1px solid var(--gray-100);
}

.modal-info-box.full { grid-column: 1 / -1; }

.modal-info-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  margin-bottom: 2px;
  letter-spacing: .04em;
}

.modal-info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.modal-info-value.big {
  font-size: 20px;
  font-weight: 800;
  color: var(--cci-red);
}

.modal-section {
  margin-bottom: 14px;
}

.modal-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-list {
  list-style: none;
  padding: 0;
}

.modal-list li {
  font-size: 12px;
  color: var(--gray-700);
  padding: 3px 0 3px 16px;
  position: relative;
  line-height: 1.6;
}

.modal-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--cci-red);
  font-weight: bold;
  font-size: 11px;
}

.modal-tip {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--gray-700);
  border-left: 3px solid var(--cci-red);
  line-height: 1.7;
  margin-top: 14px;
}

.modal-tip-label {
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  color: var(--cci-red);
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cci-red);
  color: var(--white);
  padding: 8px 18px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  margin-top: 14px;
  transition: var(--transition);
}

.modal-link:hover {
  background: var(--cci-red-dark);
}

.modal-schedule-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.modal-schedule-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-schedule-table td:first-child {
  font-weight: 600;
  color: var(--gray-500);
  width: 110px;
}

.modal-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: var(--gray-900);
  color: var(--gray-400);
  margin-top: 40px;
}

.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 28px 24px;
  text-align: center;
}

.footer-contact {
  font-size: 16px;
  color: var(--white);
  margin-bottom: 6px;
}

.footer-contact strong {
  color: var(--cci-red);
}

.footer-note {
  font-size: 11px;
  color: var(--gray-500);
  margin-bottom: 14px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--gray-400);
  text-decoration: none;
  font-size: 12px;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--cci-red);
}

.footer-credit {
  font-size: 10px;
  color: var(--gray-600);
  padding-top: 14px;
  border-top: 1px solid var(--gray-700);
}

/* ============================================================
   Print
   ============================================================ */
@media print {
  .header { position: static; border-bottom-color: var(--gray-300); }
  .filter-bar, .view-toggle-bar, .btn-print, .modal-overlay, .alert-bar { display: none !important; }
  .cards-section { display: block !important; }
  .timeline-section { display: block !important; }
  .support-card { break-inside: avoid; border: 1px solid var(--gray-300); }
  .support-card:hover { box-shadow: none; border-color: var(--gray-300); }
  .footer { background: var(--white); color: var(--gray-700); }
  .footer-contact { color: var(--gray-900); }
  .footer-contact strong { color: var(--gray-900); }
  body { background: var(--white); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 10px 16px;
    gap: 4px;
  }

  .header-subtitle {
    border-left: none;
    padding-left: 0;
  }

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

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

  .timeline-section {
    padding: 12px;
  }

  .stats-inner {
    justify-content: flex-start;
  }
}

/* ============================================================
   Animations — Subtle
   ============================================================ */
.support-card {
  animation: cardIn .25s ease backwards;
}

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

.support-card:nth-child(1) { animation-delay: .02s; }
.support-card:nth-child(2) { animation-delay: .04s; }
.support-card:nth-child(3) { animation-delay: .06s; }
.support-card:nth-child(4) { animation-delay: .08s; }
.support-card:nth-child(5) { animation-delay: .1s; }
.support-card:nth-child(6) { animation-delay: .12s; }
.support-card:nth-child(7) { animation-delay: .14s; }
.support-card:nth-child(8) { animation-delay: .16s; }
.support-card:nth-child(9) { animation-delay: .18s; }
.support-card:nth-child(10) { animation-delay: .2s; }
