/* Nihatori Games – Yahoo!ニュース風 UI（スマホファースト） */

:root {
  --header-bg: #fff;
  --header-border: #e5e5e5;
  --tab-active: #e60012;
  --tab-inactive: #333;
  --body-bg: #f5f5f5;
  --card-bg: #fff;
  --text: #333;
  --text-muted: #666;
  --text-meta: #999;
  --skeleton-bg: #e8e8e8;
  --skeleton-shine: rgba(255,255,255,0.5);
  --sidebar-bg: #fff;
  --sidebar-border: #e5e5e5;
  --row-border: #eee;
  --badge-new-bg: #fee;
  --shadow: rgba(0,0,0,0.06);
}

/* Dark mode: follows system preference (prefers-color-scheme) */
@media (prefers-color-scheme: dark) {
  :root {
    --header-bg: #1a1a1a;
    --header-border: #333;
    --tab-active: #ff4444;
    --tab-inactive: #ccc;
    --body-bg: #121212;
    --card-bg: #1e1e1e;
    --text: #e0e0e0;
    --text-muted: #b0b0b0;
    --text-meta: #888;
    --skeleton-bg: #2a2a2a;
    --skeleton-shine: rgba(255,255,255,0.06);
    --sidebar-bg: #1e1e1e;
    --sidebar-border: #333;
    --row-border: #333;
    --badge-new-bg: #3d2020;
    --shadow: rgba(0,0,0,0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--body-bg);
  padding-top: 96px; /* header + tabs */
}

/* 記事ページ：上段固定ヘッダーのみ・本文はスクロール */
body.article-page {
  padding-top: 48px;
}
body.article-page .site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}
.article-body {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
  min-height: 100vh;
}

/* ----- 固定ヘッダー ----- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  text-decoration: none;
  color: var(--text);
}

.logo-axo {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.logo-text {
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 10;
}

.lang-switcher-wrap {
  margin-right: 4px;
  position: relative;
}

.lang-switcher {
  position: relative;
}

.lang-btn {
  font-size: 12px;
  min-width: auto;
  width: auto;
  padding: 6px 10px;
}

.lang-btn-text {
  white-space: nowrap;
}

.lang-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 140px;
  padding: 6px 0;
  background: var(--card-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 300;
}

.lang-dropdown.lang-dropdown-open {
  display: flex;
}

.lang-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  box-sizing: border-box;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.lang-option:hover {
  background: var(--sidebar-border);
}

.lang-option.lang-active {
  font-weight: 600;
  color: var(--tab-active);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* メニュー開時は背景スクロール防止 */
body.menu-open {
  overflow: hidden;
}

/* ----- スマホ用ドロワー（ハンバーガーでピックアップ表示） ----- */
@media (max-width: 767px) {
  #mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    visibility: hidden;
  }

  body.menu-open #mobile-drawer {
    pointer-events: auto;
    visibility: visible;
  }

  .mobile-drawer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  body.menu-open .mobile-drawer-overlay {
    opacity: 1;
  }

  .mobile-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 85vw);
    max-width: 100%;
    background: var(--card-bg);
    box-shadow: -2px 0 8px var(--shadow);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  body.menu-open .mobile-drawer-panel {
    transform: translateX(0);
  }

  .mobile-drawer-close {
    align-self: flex-end;
    margin: 8px 12px;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
  }

  .mobile-drawer-close:hover {
    color: var(--text);
  }

  .mobile-drawer-inner {
    padding: 0 16px 24px;
    flex: 1;
  }

  .mobile-drawer-label {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
  }

  .mobile-drawer-links {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mobile-drawer-links li {
    margin-bottom: 4px;
  }

  .mobile-drawer-links a {
    display: block;
    padding: 10px 0;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid var(--row-border);
  }

  .mobile-drawer-links a:hover {
    text-decoration: underline;
  }

  .mobile-drawer-social {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--sidebar-border);
  }

  .mobile-drawer-social .social-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-drawer-social .social-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 0;
  }

  .mobile-drawer-social .social-link:hover {
    text-decoration: underline;
  }
}

@media (min-width: 768px) {
  #mobile-drawer {
    display: none !important;
  }
}

/* ----- カテゴリタブ（横スクロール） ----- */
.category-tabs {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

.tabs-scroll {
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 8px;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--tab-inactive);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
  color: var(--tab-active);
}

.tab.active {
  color: var(--tab-active);
  border-bottom-color: var(--tab-active);
}

/* ----- 検索バー ----- */
.search-bar {
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 16px 0;
}

.search-bar.search-bar--hidden {
  display: none;
}

.search-inner {
  display: flex;
  gap: 4px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 14px;
  border-radius: 16px;
  border: 1px solid var(--row-border);
  outline: none;
}

.search-input:focus {
  border-color: var(--tab-active);
}

.search-button {
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px solid var(--row-border);
  background: #fff;
  color: var(--tab-inactive);
  font-size: 13px;
  cursor: pointer;
}

.search-clear {
  background: #f5f5f5;
}

/* ----- レイアウト（メイン＋サイドバー）・幅を狭く ----- */
.layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
}

@media (min-width: 768px) {
  .layout {
    max-width: 960px;
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 24px;
    padding: 16px 24px;
  }

  body {
    padding-top: 96px;
  }
}

.main-content {
  min-width: 0;
}

/* ----- ページコンテンツ（タブごと差し替え） ----- */
.page-content {
  min-height: 200px;
}

.tab-page {
  display: block;
}

.tab-page[hidden] {
  display: none !important;
}

/* ----- ヒーローカード（1枚目・大） ----- */
.hero-card {
  margin-bottom: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
}

.hero-card:empty {
  display: none;
}

.hero-card a {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.hero-card .hero-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 220px;
  background: var(--body-bg);
  overflow: hidden;
}

.hero-card .hero-image-wrap img,
.hero-card .hero-image-wrap .img-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}

.hero-card .hero-image-wrap,
.article-row .row-thumb {
  position: relative;
}

.hero-thumb-placeholder .thumb-prep-text,
.row-thumb-placeholder .thumb-prep-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.row-thumb-placeholder .thumb-prep-text {
  font-size: 0.65rem;
}

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

.hero-card .hero-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.hero-card .hero-meta .badge-new {
  padding: 2px 6px;
  background: var(--badge-new-bg);
  color: var(--tab-active);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.hero-card .hero-meta .badge-updating,
.article-row .badge-updating {
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* ----- 記事リスト（2枚目以降・行型） ----- */
.article-list {
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
}

.article-list:empty {
  display: none;
}

.article-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--row-border);
  text-decoration: none;
  color: var(--text);
}

.article-row:last-child {
  border-bottom: none;
}

.article-row .row-thumb {
  flex-shrink: 0;
  width: 100px;
  height: 70px;
  background: var(--body-bg);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.article-row .row-thumb img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}

.hero-title-news,
.row-title-news {
  font-weight: 400;
}

.fav-toggle {
  display: inline-block;
  margin-right: 4px;
  color: #bbb;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.fav-toggle.is-fav {
  color: #facc15;
}

.sns-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sns-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  background: var(--body-bg);
  color: var(--tab-active);
}

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

.article-row .row-thumb img,
.article-row .row-thumb .img-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-row .row-body {
  flex: 1;
  min-width: 0;
}

.article-row .row-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-row .row-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-meta);
}

/* ----- スケルトン ----- */
.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-hero {
  height: 180px;
  background: linear-gradient(
    90deg,
    var(--skeleton-bg) 0%,
    var(--skeleton-shine) 50%,
    var(--skeleton-bg) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shine 1.2s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-item {
  height: 88px;
  background: linear-gradient(
    90deg,
    var(--skeleton-bg) 0%,
    var(--skeleton-shine) 50%,
    var(--skeleton-bg) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shine 1.2s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-list[aria-hidden="false"] {
  display: flex;
}

.skeleton-list[aria-hidden="true"],
.skeleton-list.hidden {
  display: none;
}

/* ----- 空メッセージ ----- */
.empty-message {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-meta);
  font-size: 14px;
  background: var(--card-bg);
  border-radius: 8px;
}

/* ----- ページネーション ----- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pagination-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pagination-btn:hover {
  background: var(--accent);
  color: #fff;
}
.pagination-info {
  font-size: 14px;
  color: var(--text-meta);
}

.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-jump-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-meta);
}

.pagination-jump-input {
  width: 4rem;
  padding: 4px 6px;
  font-size: 13px;
  border-radius: 4px;
  border: 1px solid var(--row-border);
  text-align: center;
}

.pagination-jump-total {
  font-size: 12px;
}

/* ----- サイドバー ----- */
.sidebar {
  display: none;
}

@media (min-width: 768px) {
  .sidebar {
    display: block;
    position: sticky;
    top: 110px;
    align-self: start;
  }

  .sidebar-inner {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px var(--shadow);
  }

  .sidebar-label {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
  }

  .sidebar-links {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .sidebar-links li {
    margin-bottom: 8px;
  }

  .sidebar-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
  }

  .sidebar-links a:hover {
    text-decoration: underline;
  }

  .sidebar-social {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--sidebar-border);
  }

  .social-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .social-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
  }

  .social-link:hover {
    background-color: var(--body-bg);
    text-decoration: none;
  }

  .social-link span {
    font-size: 18px;
  }
}
