/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* スキップリンク（アクセシビリティ） */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  z-index: 9999;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 10px;
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

:root {
  /* アースカラー - 温もりのあるテラコッタ系 */
  /* WCAG AA準拠のコントラスト比を確保 */
  --primary-color: #b5654c;          /* コントラスト改善 4.5:1以上 */
  --primary-hover: #9a5340;
  --primary-light: #f5ebe7;
  --secondary-color: #6b7a5d;        /* コントラスト改善 */
  --success-color: #5a7a5a;
  --warning-color: #996b3d;          /* コントラスト改善 */
  --background-color: #faf8f5;
  --card-background: #ffffff;
  --text-primary: #2d2825;           /* より濃く：コントラスト比7:1以上 */
  --text-secondary: #5a524b;         /* より濃く：コントラスト比4.5:1以上 */
  --border-color: #e8e2dc;
  --shadow-sm: 0 1px 2px rgba(61, 54, 50, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(61, 54, 50, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(61, 54, 50, 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* フォーカス表示の強化（アクセシビリティ） */
:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* リンクやボタンのフォーカス */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* 視覚的に隠すが、スクリーンリーダーには読み上げる */
.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;
}

/* Header */
.header {
  background: linear-gradient(135deg, #b5654c, #c98a5f);
  color: white;
  padding: 40px 0;
  text-align: center;
}

.header-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.header-subtitle {
  font-size: 1rem;
  opacity: 0.9;
}

/* Main */
.main {
  flex: 1;
  padding: 32px 0;
}

/* Section Titles */
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* Household Section */
.household-section {
  background: var(--card-background);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.household-selector {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 639px) {
  .household-selector {
    grid-template-columns: 1fr;
  }
}

.household-option {
  cursor: pointer;
}

.household-option input {
  display: none;
}

.household-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: 3px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
  background: white;
}

.household-option input:checked + .household-card {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.household-option:hover .household-card {
  border-color: var(--primary-color);
}

.household-icon {
  font-size: 3rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
}

.household-icon svg {
  transition: color 0.2s;
}

.household-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.household-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Search Section */
.search-section {
  background: var(--card-background);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.search-form {
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  .search-form {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.select-input {
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: white;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(194, 119, 94, 0.15);
}

.select-input:disabled {
  background-color: var(--background-color);
  cursor: not-allowed;
  opacity: 0.7;
}

.search-btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background-color: var(--primary-color);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.search-btn:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.search-btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

/* Filter Section */
.filter-section {
  background: var(--card-background);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--background-color);
  border: 2px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip:has(input:checked) {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.filter-chip input {
  display: none;
}

/* Results Section */
.results-section {
  margin-bottom: 24px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.results-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Support List */
.support-list {
  display: grid;
  gap: 16px;
}

@media (min-width: 768px) {
  .support-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .support-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Support Card */
.support-card {
  background: var(--card-background);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.support-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.support-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.support-card-scope {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.scope-national {
  background-color: #e8ded8;
  color: #6b4f42;
}

.scope-prefectural {
  background-color: #e5ebe2;
  color: #4a5d42;
}

.scope-municipal {
  background-color: #f5ebe0;
  color: #7a5c38;
}

.support-card-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 9999px;
  background-color: var(--background-color);
  color: var(--text-secondary);
}

.support-card-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.support-card-more {
  font-size: 0.875rem;
  color: var(--primary-color);
  font-weight: 500;
  text-align: right;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-background);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--background-color);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background-color 0.2s;
}

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

.modal-content {
  padding: 24px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-right: 40px;
}

.modal-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

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

.modal-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-section-content {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.modal-section-content ul {
  padding-left: 20px;
}

.modal-section-content li {
  margin-bottom: 4px;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

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

/* Notice Section */
.notice-section {
  margin-top: 32px;
}

.notice {
  background-color: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: var(--radius-md);
  padding: 16px;
}

.notice strong {
  display: block;
  color: #92400e;
  margin-bottom: 8px;
}

.notice p {
  font-size: 0.875rem;
  color: #78350f;
}

/* Footer */
.footer {
  background-color: var(--text-primary);
  color: white;
  padding: 20px 0;
  text-align: center;
  font-size: 0.875rem;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* No Results */
.no-results {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.no-results p {
  font-size: 1rem;
}

/* Responsive adjustments */
@media (max-width: 639px) {
  .header-title {
    font-size: 1.5rem;
  }

  .search-btn {
    width: 100%;
  }

  .support-card {
    padding: 16px;
  }
}
