/* =============================================================================
   August WordPress Theme - Mobile App Bottom Nav & Responsive Stylesheet
   Author URI: https://clearmoon.stars.ne.jp/
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. BASE / MOBILE ALL SIZES (< 768px)
   ----------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  word-wrap: break-word;
}

img,
iframe,
video {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- ヘッダー領域 --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 999;
  background: var(--color-surface, #ffffff);
  border-bottom: 1px solid var(--color-border-light, #e2e8f0);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0.5rem 0;
  gap: 0.75rem;
}

.site-branding {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
}

.site-title {
  font-size: clamp(0.95rem, 3.5vw, 1.3rem);
  font-weight: 800;
  margin: 0;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.site-title a {
  color: var(--color-text-main, #0f172a);
  text-decoration: none;
  display: inline;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.site-description {
  font-size: 0.75rem;
  color: var(--color-text-muted, #94a3b8);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* モバイル表示時（〜768px）: サイドバー＆旧メニューを完全非表示 */
@media (max-width: 768px) {
  
  /* サイドバーと上部ナビ・ハンバーガーを非表示 */
  .sidebar-area,
  .primary-navigation,
  .nav-toggle,
  .header-search {
    display: none !important;
  }

  /* メインコンテンツを全幅表示 */
  .content-wrapper {
    display: block !important;
    margin-top: 1rem;
    padding-bottom: 75px !important; /* ボトムナビの高さ分の余白 */
  }

  .main-area {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  /* アプリ風 固定ボトムナビゲーション (画面最下部) */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: var(--color-surface, #ffffff);
    border-top: 1px solid var(--color-border, #e2e8f0);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    z-index: 1500;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
  }

  /* 上へ戻るボタンをボトムナビ（62px）の上に配置 */
  .back-to-top {
    bottom: 78px !important;
    right: 16px !important;
    z-index: 1600 !important;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    color: var(--color-text-sub, #475569);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s ease, background-color 0.2s ease;
  }

  .bottom-nav-item:active,
  .bottom-nav-item.is-active {
    color: var(--color-primary, #2563eb);
    font-weight: 700;
  }

  .bottom-nav-item .nav-icon {
    font-size: 1.25rem;
    line-height: 1;
  }

  .bottom-nav-item .nav-label {
    font-size: 0.72rem;
    line-height: 1.1;
  }

  /* モーダル表示スタイル (スマホ全画面フィット) */
  .app-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: flex-end; /* スライドアップ表示 */
    justify-content: center;
  }

  .app-modal-overlay.is-active {
    display: flex;
  }

  .app-modal-content {
    background: var(--color-surface, #ffffff);
    width: 100%;
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
    overflow: hidden;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .app-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--color-border-light, #f1f5f9);
  }

  .app-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-main, #0f172a);
  }

  .modal-close-btn {
    background: var(--color-surface-hover, #f1f5f9);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--color-text-sub, #475569);
    cursor: pointer;
  }

  .app-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 70vh;
  }

  /* カテゴリーリスト表示 */
  .mobile-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-category-list li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.2rem;
    background: var(--color-bg, #f8fafc);
    border: 1px solid var(--color-border-light, #e2e8f0);
    border-radius: var(--radius-md, 12px);
    text-decoration: none;
    color: var(--color-text-main, #0f172a);
    font-weight: 600;
    transition: background-color 0.2s ease;
  }

  .mobile-category-list li a:active {
    background: var(--color-primary-light, #eff6ff);
    border-color: var(--color-primary, #2563eb);
  }

  .mobile-category-list .cat-count {
    font-size: 0.8rem;
    color: var(--color-text-muted, #94a3b8);
    background: var(--color-surface, #ffffff);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
  }

  /* 詳細検索フォーム */
  .mobile-search-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
  }

  .search-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .search-field-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-main, #0f172a);
  }

  .mobile-search-input,
  .mobile-search-select {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border, #cbd5e1);
    border-radius: var(--radius-md, 12px);
    font-size: 0.95rem;
    background: var(--color-bg, #f8fafc);
    color: var(--color-text-main, #0f172a);
    outline: none;
  }

  .mobile-search-input:focus,
  .mobile-search-select:focus {
    border-color: var(--color-primary, #2563eb);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--color-primary-light, #eff6ff);
  }

  .mobile-search-submit-btn {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md, 12px);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    margin-top: 0.5rem;
  }
}

/* --- PC表示時（769px〜）: ボトムナビゲーション非表示 --- */
@media (min-width: 769px) {
  .mobile-bottom-nav,
  .app-modal-overlay {
    display: none !important;
  }
}

/* --- 動画カードグリッド --- */
.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  width: 100%;
}

@media (min-width: 480px) and (max-width: 767px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.video-card {
  width: 100%;
  background: var(--color-surface, #ffffff);
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
  border: 1px solid var(--color-border-light, #e2e8f0);
}

.video-card-content {
  padding: 1rem;
}

.video-card-title {
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0.4rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.video-card-title a {
  color: var(--color-text-main, #0f172a);
  text-decoration: none;
}

/* --- カスタムヘッダーバナー --- */
.custom-header-banner {
  width: 100%;
  margin: 1rem 0;
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
  line-height: 0;
}

.custom-header-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* --- ヒーローバナー --- */
.hero-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  padding: 2.5rem 1.5rem;
  border-radius: var(--radius-lg, 18px);
  margin: 1rem 0;
  text-align: center;
}

.hero-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
}

.hero-description {
  font-size: 0.9rem;
  opacity: 0.9;
  margin: 0;
}

/* --- フッター --- */
.site-footer {
  background: var(--color-surface, #ffffff);
  border-top: 1px solid var(--color-border, #e2e8f0);
  margin-top: 3rem;
  padding: 2rem 0 1.5rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-light, #f1f5f9);
  font-size: 0.85rem;
  color: var(--color-text-muted, #94a3b8);
  text-align: center;
}

/* --- PC表示時のグリッド・レイアウト設定 (769px+) --- */
@media (min-width: 769px) {

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .header-search {
    display: block;
  }

  .search-form {
    display: flex;
    align-items: center;
    background: var(--color-bg, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-full, 9999px);
    padding: 0.2rem 0.5rem 0.2rem 0.8rem;
  }

  .search-field {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.85rem;
    width: 140px;
  }

  .search-submit {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text-sub, #475569);
    display: flex;
    align-items: center;
  }

  .content-wrapper {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
    margin-top: 1.5rem;
  }

  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .footer-inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
  }

  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (min-width: 1025px) {
  .video-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .search-field {
    width: 180px;
  }
}
