/* ============================================
   UI Components
   ============================================ */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 32px;
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  cursor: pointer;
  border: none;
  line-height: 1;
}

.btn--primary,
.prose .btn--primary {
  background: var(--color-primary);
  color: var(--color-text-white);
  text-decoration: none;
}


.btn--outline {
  background: var(--color-bg-card);
  color: var(--color-text);
  border: 2px solid var(--color-border);
}


.btn--secondary {
  background: var(--color-secondary);
  color: var(--color-text-white);
}


.btn--sm {
  padding: 8px 20px;
  font-size: var(--fs-sm);
}

.btn--cta-white {
  background: #fff;
  color: var(--color-primary);
  font-weight: var(--fw-bold);
}


.btn__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Hover effects (same as reference) --- */
.hover-lift {
  display: block;
  transition: transform 0.3s, box-shadow 0.3s;
  cursor: pointer;
}
.hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.hover-scale {
  transition: transform 0.3s;
  cursor: pointer;
}
.hover-scale:hover {
  transform: scale(1.05);
}

.btn-hover {
  transition: all 0.3s;
  cursor: pointer;
}
.btn-hover:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* --- Cards --- */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-xl);
}

.card--flat:hover {
  transform: none;
  box-shadow: none;
}

.card__icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.card__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.card__desc {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  line-height: var(--lh-normal);
}

/* --- Quick Nav (icon grid) --- */
.quick-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  max-width: 900px;
  margin: 0 auto;
}

.quick-nav__item {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.quick-nav__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-md);
}

.quick-nav__label {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--color-text);
}

/* --- Stat Card --- */
.stat {
  text-align: center;
  padding: var(--space-xl);
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.stat__number {
  font-family: var(--font-accent);
  font-size: var(--fs-4xl);
  font-weight: var(--fw-black);
  line-height: 1;
}

.stat__label {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  font-weight: var(--fw-medium);
  margin-top: var(--space-xs);
}

/* --- News Item --- */
.news-item {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-md);
  cursor: pointer;
}

.news-item__date {
  font-family: var(--font-accent);
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  font-weight: 600;
  white-space: nowrap;
  min-width: 90px;
}

.news-item__tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--color-text-white);
  white-space: nowrap;
}

/* 分類タグは同じ幅に揃える（最長の「北海道地本」「中四国地本」＝5文字） */
.news-item__tag--area {
  min-width: calc(5em + 16px);
  text-align: center;
}

.news-item__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  flex: 1;
}

.news-item__arrow {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--color-text-light);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.news-item:hover .news-item__arrow {
  color: var(--color-primary);
  transform: translateX(4px);
}

/* --- Marquee --- */
.marquee {
  overflow: hidden;
  background: var(--color-primary);
  padding: 12px 0;
}

.marquee__track {
  display: flex;
  gap: 48px;
  white-space: nowrap;
  animation: marquee 25s linear infinite;
}

.marquee__text {
  font-size: var(--fs-sm);
  color: var(--color-text-white);
  font-weight: 600;
  opacity: 0.9;
}

/* 各項目をリンク化 */
.marquee__link {
  display: inline-block;
  margin-right: 48px;
  color: inherit;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.marquee__link:last-child {
  margin-right: 0;
}

.marquee__link:hover,
.marquee__link:focus-visible {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ホバー／キーボードフォーカス中はスクロールを止めてクリックしやすくする */
.marquee:hover .marquee__track,
.marquee:focus-within .marquee__track {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .marquee__track {
    animation: none;
  }
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* --- Activity Card (icon + text horizontal) --- */
.activity-card {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
}

.activity-card__icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.activity-card__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.activity-card__desc {
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  line-height: var(--lh-normal);
}

/* --- CTA Section --- */
.cta {
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.cta__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
  color: var(--color-text-white);
  margin-bottom: var(--space-md);
}

.cta__desc {
  font-size: var(--fs-md);
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: var(--space-xl);
}

/* --- Breadcrumb --- */
.breadcrumb {
  padding: var(--space-md) 0;
  font-size: var(--fs-sm);
  color: var(--color-text-light);
}

.breadcrumb a {
  color: var(--color-text-light);
  transition: color var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

.breadcrumb__separator {
  margin: 0 var(--space-sm);
}

/* --- Page Hero (sub pages) --- */
.page-hero {
  background: var(--gradient-hero);
  padding: var(--space-4xl) 0;
  position: relative;
  overflow: hidden;
}

.page-hero__circle {
  position: absolute;
  border-radius: 50%;
  animation: pageHeroFloat 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pageHeroFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-12px) scale(1.04); }
  50% { transform: translateY(-4px) scale(0.96); }
  75% { transform: translateY(-16px) scale(1.02); }
}

@keyframes floatingNote {
  0%, 100% { transform: translateY(0) rotate(var(--note-rotate, 0deg)); opacity: 1; }
  25% { transform: translateY(-20px) rotate(calc(var(--note-rotate, 0deg) + 5deg)); }
  50% { transform: translateY(-8px) rotate(calc(var(--note-rotate, 0deg) - 3deg)); opacity: 0.6; }
  75% { transform: translateY(-25px) rotate(calc(var(--note-rotate, 0deg) + 8deg)); }
}

.page-hero__label {
  font-family: var(--font-accent);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 4px;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.page-hero__title {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-black);
  color: var(--color-text);
}

/* --- Scroll reveal animation --- */
.reveal {
  opacity: 0;
  translate: 0 40px;
  transition: opacity var(--transition-reveal), translate var(--transition-reveal);
}

.reveal.is-visible {
  opacity: 1;
  translate: 0 0;
}

.reveal--delay-1 { transition-delay: 0.1s; }
.reveal--delay-2 { transition-delay: 0.2s; }
.reveal--delay-3 { transition-delay: 0.3s; }
.reveal--delay-4 { transition-delay: 0.4s; }
.reveal--delay-5 { transition-delay: 0.5s; }

/* --- Content Prose (for text-heavy pages) --- */
.prose {
  max-width: var(--max-width-narrow);
  line-height: var(--lh-loose);
}

.prose h2 {
  font-size: var(--fs-xl);
  margin-top: var(--space-3xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-primary);
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.prose h2 .heading-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.prose h3 {
  font-size: var(--fs-lg);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.prose h3 .heading-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.prose p {
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.prose ul,
.prose ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-xl);
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li {
  margin-bottom: var(--space-sm);
}

/* 金額テーブル（3列以上）の数字を右寄せ・等幅 */
.prose table.table--wide td:not(:first-child) {
  text-align: right;
  font-family: var(--font-accent);
  font-variant-numeric: tabular-nums;
}

/* 数値セル（data-unit付き）は右寄せ・等幅・単位付加 */
.prose td[data-unit] {
  text-align: right;
  font-family: var(--font-accent);
  font-variant-numeric: tabular-nums;
}
.prose td[data-unit]::after {
  content: attr(data-unit);
}

/* 2列テーブル（key-value形式）は幅を抑える */
.prose table:not(.table--wide) {
  width: auto;
  max-width: 100%;
}

/* ダウンロードリストのリンク色 */
.prose .download-list a:not(.btn) {
  color: var(--color-secondary);
  text-decoration: none;
}

.prose .download-list a:not(.btn):hover {
  color: var(--color-secondary-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose a:not(.btn) {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose a:not(.btn):hover {
  color: var(--color-primary-dark);
}

/* テーブル */
.prose table {
  width: 100%;
  margin-bottom: 1rem;
  border: none;
  border-radius: 12px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #f8f9fb 0%, #fff 100%);
  box-shadow: 0 2px 16px rgba(0,0,0,0.05);
}

.prose th,
.prose td {
  padding: 0.6rem 0.85rem;
  border: none;
  text-align: left;
  font-size: var(--fs-md);
}

.prose th {
  background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-secondary-dark) 100%);
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.prose tr {
  transition: background 0.2s ease;
}

.prose tbody tr:hover td {
  background: rgba(69, 123, 157, 0.06);
}

.prose tr:nth-child(even) td {
  background: rgba(69, 123, 157, 0.03);
}

.prose tr:nth-child(even):hover td {
  background: rgba(69, 123, 157, 0.08);
}

.prose td {
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.prose tr:last-child td {
  border-bottom: none;
}

/* スマホ: テーブルをカード形式に変換 */
@media (max-width: 640px) {
  /* 幅広テーブルは横スクロールのまま */
  .prose table.table--wide {
    display: table;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(135deg, #f8f9fb 0%, #fff 100%);
    box-shadow: 0 2px 16px rgba(0,0,0,0.05);
    border-radius: 12px;
    font-size: var(--fs-xs);
  }
  .prose table.table--wide th {
    background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-secondary-dark) 100%);
    color: #fff;
    padding: 0.5rem 0.6rem;
    font-size: var(--fs-xs);
  }
  .prose table.table--wide td {
    padding: 0.4rem 0.6rem;
  }

  /* 通常テーブルはカード形式に変換 */
  .prose table:not(.table--wide) {
    display: block;
    overflow-x: visible;
    box-shadow: none;
    background: none;
  }
  .prose table:not(.table--wide) thead {
    display: none;
  }
  .prose table:not(.table--wide) tbody,
  .prose table:not(.table--wide) tr {
    display: block;
  }
  .prose table:not(.table--wide) tr {
    background: #fff;
    border: 1px solid var(--color-border);
    border-bottom: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  }
  .prose table:not(.table--wide) tr:last-child {
    border-bottom: 1px solid var(--color-border);
  }
  .prose table:not(.table--wide) td,
  .prose table:not(.table--wide) th {
    display: block;
    width: 100%;
    white-space: normal;
    padding: 0.5rem 1rem;
    background: #fff !important;
    border: none;
    border-bottom: none;
    color: var(--color-text);
  }
  .prose table:not(.table--wide) th {
    background: var(--color-secondary) !important;
    color: #fff;
    font-size: var(--fs-sm);
    padding: 0.6rem 1rem;
  }
  .prose table:not(.table--wide) td::before {
    content: attr(data-label);
    display: block;
    font-weight: var(--fw-bold);
    font-size: 10px;
    color: var(--color-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.1rem;
  }
  .prose table:not(.table--wide) td:first-child {
    padding-top: 0.85rem;
  }
  .prose table:not(.table--wide) td:last-child {
    padding-bottom: 0.85rem;
  }
  .prose table:not(.table--wide) tr:nth-child(even) td {
    background: none;
  }
}

.prose tr:nth-child(odd) td {
  background: var(--color-bg-card);
}

.prose tr:hover td {
  background: rgba(230, 57, 70, 0.04);
}

.prose tr:last-child td {
  border-bottom: none;
}

/* th が左列にある横並びテーブル（key-value形式） */
.prose td:first-child,
.prose td:last-child {
  white-space: nowrap;
}

.prose tr td:first-child {
  border-right: 1px solid var(--color-border);
}

.prose tr th:only-child,
.prose tr th[colspan] {
  text-align: left;
}


/* --- Activity Filter Buttons --- */
.activity-filter__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg-card);
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.activity-filter__btn:hover {
  border-color: var(--btn-color, var(--color-secondary));
  color: var(--btn-color, var(--color-secondary));
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.activity-filter__btn.is-active {
  background: var(--btn-color, var(--color-secondary));
  border-color: var(--btn-color, var(--color-secondary));
  color: #fff;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}

/* --- Accordion --- */
.accordion {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.accordion__item {
  border-bottom: 1px solid var(--color-border);
}

.accordion__item:last-child {
  border-bottom: none;
}

.accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-card);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.accordion__trigger:hover {
  background: var(--color-bg-soft);
}

.accordion__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.3s;
  color: var(--color-text-light);
}

.accordion__item.is-open .accordion__icon {
  transform: rotate(180deg);
}

.accordion__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.accordion__item.is-open .accordion__body {
  max-height: 5000px;
}

.accordion__content {
  padding: var(--space-md) var(--space-xl) var(--space-xl);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: var(--color-text);
}

.accordion__content p {
  margin-bottom: var(--space-md);
}

.accordion__content h3 {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.accordion__content h4 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
}

.accordion__content ul,
.accordion__content ol {
  padding-left: var(--space-xl);
  margin-bottom: var(--space-md);
}

.accordion__content ul { list-style: disc; }
.accordion__content ol { list-style: decimal; }

.accordion__content li {
  margin-bottom: var(--space-xs);
}

/* ============================================
   Responsive Components
   ============================================ */

@media (max-width: 1024px) {
  .quick-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat__number {
    font-size: var(--fs-3xl);
  }
}

@media (max-width: 768px) {
  .btn {
    padding: 12px 24px;
    font-size: var(--fs-sm);
  }

  .quick-nav {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 100px;
    gap: var(--space-md);
  }

  .quick-nav__icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .quick-nav__item {
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
  }

  .quick-nav__label {
    font-size: var(--fs-base);
    line-height: 1.35;
    text-align: center;
  }

  .news-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .news-item__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .page-hero {
    padding: var(--space-3xl) 0;
  }

  .page-hero__title {
    font-size: var(--fs-xl);
  }

  .card__icon {
    width: 48px;
    height: 48px;
  }

  .stat__number {
    font-size: var(--fs-2xl);
  }
}

/* --- 記事一覧バナー（下層ページ用） --- */
.news-banner {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-lg) 0 var(--space-2xl);
  color: var(--color-text);
  text-decoration: none;
}

.prose a.news-banner {
  color: var(--color-text);
  text-decoration: none;
}

.news-banner__icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.news-banner__icon svg {
  width: 100%;
  height: 100%;
}

.news-banner__body {
  flex: 1;
  min-width: 0;
}

.news-banner__title {
  display: block;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}

.news-banner__desc {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--color-text-light);
  line-height: var(--lh-normal);
}

.news-banner__arrow {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--color-accent-purple);
}

@media (max-width: 640px) {
  .news-banner {
    gap: var(--space-md);
    padding: var(--space-lg);
  }
  .news-banner__icon {
    width: 40px;
    height: 40px;
  }
}

/* --- read more で折りたたむ詳細（details/summary） --- */
.read-more-details {
  margin: var(--space-lg) 0;
}

.read-more-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-accent);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  padding: 8px 18px;
  border: 1px solid var(--color-border-hover);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.read-more-details > summary::-webkit-details-marker { display: none; }

.read-more-details > summary::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--transition-fast);
}

.read-more-details[open] > summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.read-more-details > summary:hover {
  background: var(--color-bg-soft);
  border-color: var(--color-primary);
}

.read-more-details[open] > summary {
  margin-bottom: var(--space-md);
}

/* 記事本文のPDFリンクにアイコン（画像を囲むリンクは除く） */
#post-body a[href$=".pdf" i]:not(:has(img)) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
#post-body a[href$=".pdf" i]:not(:has(img))::before {
  content: "";
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Crect x='4' y='2' width='16' height='20' rx='2' fill='%23B71C1C' opacity='0.12' stroke='%23B71C1C' stroke-width='1.5'/%3E%3Ctext x='12' y='16' text-anchor='middle' fill='%23B71C1C' font-size='7' font-weight='bold' font-family='sans-serif'%3EPDF%3C/text%3E%3C/svg%3E") no-repeat center / contain;
}
