/* ===== CSS変数 ===== */
[data-theme="light"] {
  --bg: #faf7f2;
  --bg-sub: #f2ede4;
  --bg-card: #ffffff;
  --bg-header: rgba(250, 247, 242, 0.95);
  --bg-hero: #1a0a00;
  --text: #1c1008;
  --text-sub: #6b5a47;
  --text-muted: #a09080;
  --accent: #c0392b;
  --accent2: #e67e22;
  --accent-light: #fdecea;
  --border: #e8ddd0;
  --border-light: #f0ebe2;
  --card-shadow: 0 2px 16px rgba(100,60,20,0.08);
  --card-shadow-hover: 0 8px 32px rgba(100,60,20,0.18);
  --modal-bg: rgba(28, 16, 8, 0.85);
  --tag-bg: #f5ede0;
  --tag-text: #8b4513;
  --logo-coco: #1c1008;
  --logo-uki: #c0392b;
  --hero-text: #faf0e6;
  --spinner: #c0392b;
}

[data-theme="dark"] {
  --bg: #0e0a06;
  --bg-sub: #1a1208;
  --bg-card: #1e1610;
  --bg-header: rgba(14, 10, 6, 0.95);
  --bg-hero: #080502;
  --text: #f0e8d8;
  --text-sub: #c8b090;
  --text-muted: #806848;
  --accent: #e05a4a;
  --accent2: #f0962a;
  --accent-light: #2a1208;
  --border: #2e2018;
  --border-light: #241a10;
  --card-shadow: 0 2px 16px rgba(0,0,0,0.4);
  --card-shadow-hover: 0 8px 32px rgba(0,0,0,0.7);
  --modal-bg: rgba(0, 0, 0, 0.92);
  --tag-bg: #2a1a08;
  --tag-text: #e0a060;
  --logo-coco: #f0e8d8;
  --logo-uki: #e05a4a;
  --hero-text: #faf0e6;
  --spinner: #e05a4a;
}

/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif JP', 'Yu Mincho', '游明朝', serif;
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
img { display: block; max-width: 100%; }

/* ===== ヘッダー ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 68px;
  flex-wrap: wrap;
}

.logo-area { flex-shrink: 0; }

.logo {
  font-family: 'DM Mono', monospace;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-coco { color: var(--logo-coco); }
.logo-uki  { color: var(--logo-uki); }

.logo-tagline {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-top: 2px;
  font-family: 'Noto Serif JP', serif;
}

.header-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.nav-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: 'Noto Serif JP', serif;
  color: var(--text-sub);
  border: 1px solid var(--border);
  background: transparent;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.search-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
}

.search-input {
  padding: 6px 12px;
  font-size: 0.82rem;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  width: 200px;
  font-family: 'Noto Serif JP', serif;
}

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

.search-btn {
  padding: 6px 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  border-radius: 0;
  transition: opacity 0.2s;
}

.search-btn:hover { opacity: 0.85; }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.theme-toggle:hover { border-color: var(--accent); transform: scale(1.08); }

/* ===== ヒーロー ===== */
.hero {
  position: relative;
  background: var(--bg-hero);
  overflow: hidden;
  padding: 80px 24px 60px;
  text-align: center;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 波紋アニメーション（北斎の波モチーフ） */
.hero-wave {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(192, 57, 43, 0.2);
  animation: waveExpand 6s ease-out infinite;
}

.wave1 { width: 300px; height: 300px; top: -50px; left: 10%; animation-delay: 0s; }
.wave2 { width: 500px; height: 500px; top: -100px; right: 5%; animation-delay: 2s; }
.wave3 { width: 200px; height: 200px; bottom: -30px; left: 50%; animation-delay: 4s; }

@keyframes waveExpand {
  0%   { transform: scale(0.8); opacity: 0.4; }
  50%  { opacity: 0.15; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* 和柄背景 */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(192,57,43,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(230,126,34,0.06) 0%, transparent 50%);
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.hero-title-jp {
  font-family: 'Shippori Mincho', serif;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 800;
  color: var(--hero-text);
  letter-spacing: 0.15em;
  line-height: 1;
  text-shadow: 0 2px 20px rgba(192,57,43,0.4);
}

.hero-title-en {
  font-family: 'DM Mono', monospace;
  font-size: clamp(0.75rem, 2vw, 1rem);
  color: var(--accent);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.hero-desc {
  color: rgba(250, 240, 230, 0.6);
  font-size: 0.9rem;
  margin-bottom: 32px;
  letter-spacing: 0.05em;
}

.hero-stats {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 40px;
  padding: 12px 28px;
  backdrop-filter: blur(10px);
}

.stat-item { text-align: center; }

.stat-num {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 1.4rem;
  color: var(--accent2);
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  color: rgba(250,240,230,0.5);
  letter-spacing: 0.05em;
  margin-top: 3px;
}

.stat-divider { color: rgba(255,255,255,0.2); font-size: 1.2rem; }

/* ===== メインコンテンツ ===== */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  min-height: 400px;
}

/* ===== ローディング ===== */
.loading-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 20px;
}

.loading-spinner {
  position: relative;
  width: 50px;
  height: 50px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--spinner);
  animation: spinRing 1s linear infinite;
}

.ring2 {
  inset: 8px;
  border-top-color: var(--accent2);
  animation-duration: 0.7s;
  animation-direction: reverse;
}

@keyframes spinRing { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

/* ===== エラー ===== */
.error-area {
  text-align: center;
  padding: 60px 24px;
}

.error-icon { font-size: 2.5rem; margin-bottom: 12px; }
.error-msg { color: var(--text-sub); margin-bottom: 20px; }

.retry-btn {
  padding: 10px 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: 'Noto Serif JP', serif;
  transition: opacity 0.2s;
}

.retry-btn:hover { opacity: 0.85; }

.hidden { display: none !important; }

/* ===== ギャラリーグリッド ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

/* ===== カード ===== */
.card {
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  animation: cardFadeIn 0.4s ease both;
}

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

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

.card-img-wrap {
  position: relative;
  width: 100%;
  padding-top: 120%;
  overflow: hidden;
  background: var(--bg-sub);
}

.card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}

.card:hover .card-img { transform: scale(1.06); }

.card-no-img {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
}

.card-body {
  padding: 12px 14px 14px;
}

.card-tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  font-family: 'DM Mono', monospace;
}

.card-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 5px;
}

.card-artist {
  font-size: 0.72rem;
  color: var(--text-sub);
  font-style: italic;
}

.card-date {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== もっと見る ===== */
.load-more-area {
  text-align: center;
  margin-top: 40px;
}

.load-more-btn {
  padding: 12px 40px;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: 30px;
  font-size: 0.9rem;
  font-family: 'Noto Serif JP', serif;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  background: transparent;
}

.load-more-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(6px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-card);
  border-radius: 14px;
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid var(--border);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s;
}

.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-sub);
  color: var(--text-sub);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover { background: var(--accent); color: #fff; }

.modal-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.modal-img-wrap {
  position: relative;
  background: var(--bg-sub);
  min-height: 300px;
  border-radius: 14px 0 0 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 80vh;
}

.modal-img-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sub);
  z-index: 2;
}

.modal-img-loading.hidden { display: none; }

.modal-info {
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.modal-period {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.modal-title {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.modal-artist {
  font-size: 0.9rem;
  color: var(--text-sub);
  font-style: italic;
}

.modal-meta { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.meta-row {
  font-size: 0.78rem;
  color: var(--text-sub);
  line-height: 1.5;
  padding: 6px 10px;
  background: var(--bg-sub);
  border-radius: 6px;
  border-left: 2px solid var(--border);
}

.meta-row:empty { display: none; }

.modal-link {
  display: inline-block;
  margin-top: auto;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 0.82rem;
  text-align: center;
  transition: opacity 0.2s;
  letter-spacing: 0.03em;
}

.modal-link:hover { opacity: 0.85; }

/* ===== フッター ===== */
.site-footer {
  background: var(--bg-sub);
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
}

.footer-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-logo {
  font-family: 'DM Mono', monospace;
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.footer-desc { font-size: 0.8rem; color: var(--text-sub); }
.footer-api  { font-size: 0.72rem; color: var(--text-muted); }
.footer-api a { color: var(--accent); text-decoration: underline; }

.footer-links {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.footer-links a {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

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

.footer-copy { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.footer-copy a { color: var(--text-sub); }

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
  .header-inner { height: auto; padding: 12px 0; gap: 10px; }
  .header-nav { order: 3; width: 100%; }
  .search-input { width: 140px; }

  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

  .modal-inner { grid-template-columns: 1fr; }
  .modal-img-wrap { border-radius: 14px 14px 0 0; min-height: 220px; }
  .modal-info { padding: 20px; }
}

@media (max-width: 480px) {
  .hero { padding: 50px 16px 40px; }
  .main-content { padding: 24px 16px 40px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
