/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== THEME VARIABLES ===== */
:root {
  --font-display: 'Syne', sans-serif;
  --font-body: 'Noto Sans JP', sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: 0.22s ease;
}

[data-theme="light"] {
  --bg-page:    #f5f4f0;
  --bg-surface: #ffffff;
  --bg-muted:   #eeece6;
  --bg-accent:  #1a1a1a;
  --text-primary:   #111111;
  --text-secondary: #555550;
  --text-muted:     #999990;
  --text-on-accent: #ffffff;
  --border:     rgba(0,0,0,0.08);
  --border-med: rgba(0,0,0,0.14);
  --accent:     #e84f2f;
  --accent-soft:#fdf0ec;
  --badge-bg:   #f0efe9;
  --badge-text: #555550;
  --shadow:     0 2px 16px rgba(0,0,0,0.07);
  --shadow-hover: 0 6px 28px rgba(0,0,0,0.12);
  --hero-bg:    #1a1a1a;
  --hero-text:  #ffffff;
  --rank-1: #e8b829;
  --rank-2: #9aa4ad;
  --rank-3: #c87941;
}

[data-theme="dark"] {
  --bg-page:    #111111;
  --bg-surface: #1c1c1c;
  --bg-muted:   #242424;
  --bg-accent:  #ffffff;
  --text-primary:   #f0f0ee;
  --text-secondary: #aaa9a3;
  --text-muted:     #666660;
  --text-on-accent: #111111;
  --border:     rgba(255,255,255,0.07);
  --border-med: rgba(255,255,255,0.13);
  --accent:     #f06040;
  --accent-soft:#2a1a16;
  --badge-bg:   #2a2a2a;
  --badge-text: #aaa9a3;
  --shadow:     0 2px 16px rgba(0,0,0,0.4);
  --shadow-hover: 0 6px 28px rgba(0,0,0,0.6);
  --hero-bg:    #f0f0ee;
  --hero-text:  #111111;
  --rank-1: #e8b829;
  --rank-2: #9aa4ad;
  --rank-3: #c87941;
}

/* ===== BASE ===== */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.logo-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  line-height: 1;
}

.logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-btn {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.nav-btn:hover { background: var(--bg-muted); color: var(--text-primary); }
.nav-btn.active { background: var(--bg-accent); color: var(--text-on-accent); }

.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-med);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
  margin-left: 8px;
  color: var(--text-primary);
}

.theme-toggle:hover { background: var(--bg-muted); }

/* ===== HERO ===== */
.hero {
  background: var(--hero-bg);
  color: var(--hero-text);
  padding: 4rem 2rem 3rem;
  transition: background var(--transition);
}

.hero-inner { max-width: 1200px; margin: 0 auto; }

.hero-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.2em;
  opacity: 0.5;
  margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}

.hero-desc {
  font-size: 14px;
  opacity: 0.55;
  margin-bottom: 2.5rem;
}

.stats-row {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

[data-theme="dark"] .stat-card {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
}

.stat-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  color: var(--hero-text);
  letter-spacing: -0.04em;
}

.stat-label {
  font-size: 11px;
  color: var(--hero-text);
  opacity: 0.5;
}

/* ===== MAIN ===== */
.main { max-width: 1200px; margin: 0 auto; padding: 2rem; }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
}

.filter-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

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

.refresh-wrap { margin-left: auto; }

.refresh-btn {
  background: none;
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== ARTICLES GRID ===== */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* ===== ARTICLE CARD ===== */
.article-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-med);
  transform: translateY(-2px);
}

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

.rank-badge {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11px;
  min-width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rank-1 { background: var(--rank-1); color: #fff; }
.rank-2 { background: var(--rank-2); color: #fff; }
.rank-3 { background: var(--rank-3); color: #fff; }
.rank-other { background: var(--badge-bg); color: var(--badge-text); }

.card-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-muted);
  object-fit: cover;
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.tag-pill:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-icon { font-size: 13px; }
.likes-count { color: var(--accent); font-weight: 500; }

.card-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== TABS ===== */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== TAGS TAB ===== */
.tags-intro {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.popular-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2rem;
}

.pop-tag {
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}

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

/* ===== SEARCH TAB ===== */
.search-section { padding-top: 0.5rem; }

.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 2rem;
  max-width: 600px;
}

.search-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

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

.search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 24px;
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
}

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

/* ===== STATES ===== */
.loading-state, .empty-state, .error-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-size: 14px;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-med);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error-state { color: var(--accent); }

/* ===== FOOTER ===== */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  margin-top: 5rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-brand { display: flex; align-items: center; gap: 12px; }

.footer-logo-mark {
  width: 40px; height: 40px;
  background: var(--accent); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); flex-shrink: 0;
}

.footer-logo-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--text-primary); }
.footer-logo-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.footer-links { display: flex; gap: 3rem; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }

.footer-col-title {
  font-size: 11px; font-weight: 500; letter-spacing: 0.1em;
  color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px;
}

.footer-link { font-size: 13px; color: var(--text-secondary); text-decoration: none; transition: color var(--transition); }
.footer-link:hover { color: var(--accent); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  text-align: center; font-size: 11px; color: var(--text-muted);
}
.footer-bottom a { color: var(--accent); text-decoration: none; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 680px; max-height: 88vh;
  overflow-y: auto; position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.22s ease;
}

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

.modal-close {
  position: sticky; top: 1rem; float: right;
  margin: 1rem 1rem 0 0;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border-med); background: var(--bg-surface);
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); z-index: 10;
}
.modal-close:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.modal-inner { padding: 1.5rem 2rem 2rem; clear: both; }

.modal-rank { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 1rem; }

.modal-title {
  font-family: var(--font-display);
  font-size: clamp(18px, 3vw, 24px); font-weight: 700; line-height: 1.35;
  color: var(--text-primary); margin-bottom: 1.25rem;
}

.modal-author-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border);
}

.modal-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-muted); object-fit: cover; }
.modal-author-info p { font-size: 13px; color: var(--text-secondary); }
.modal-author-id { font-weight: 500; color: var(--text-primary) !important; }

.modal-stats { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.modal-stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-muted); border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem; gap: 2px; min-width: 80px;
}

.modal-stat-num { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--accent); }
.modal-stat-label { font-size: 10px; color: var(--text-muted); }

.modal-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 1.75rem; }
.modal-tag { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); border-radius: 100px; padding: 4px 14px; font-size: 12px; }

.modal-date { font-size: 12px; color: var(--text-muted); margin-bottom: 1.75rem; }

.modal-open-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; text-decoration: none;
  padding: 12px 28px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; transition: opacity var(--transition);
}
.modal-open-btn:hover { opacity: 0.85; }

/* ===== ANIMATIONS ===== */
.article-card {
  animation: fadeUp 0.3s ease both;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .header-inner { padding: 0 1rem; }
  .nav-btn { padding: 6px 10px; font-size: 12px; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .main { padding: 1.5rem 1rem; }
  .articles-grid { grid-template-columns: 1fr; }
  .logo-sub { display: none; }
}
