/* ════════════════════════════════════════════
   NECOKOUCAN LEGEND v2.2 — スマホ対応CSS（nk-responsive.css）
   functions.php から全ページに読み込む。
   各テンプレートの <style> は wp_head() より後に出力されるため、
   ここでは頭に html body を付けて詳細度で上書きする。
   PC表示（901px以上）には一切影響しない。
   ════════════════════════════════════════════ */

/* ── [0] 横はみ出しの根絶（iOSでも確実に効く clip を優先） ── */
@supports (overflow: clip) {
  html, body { overflow-x: clip; }
}
html body #nk-illust-wrap,
html body #nk-tourism-wrap,
html body #nk-history-wrap,
html body #nk-goods-wrap,
html body #nk-itcad-wrap,
html body #nk-blog-wrap { overflow-x: clip; }

/* ── [1] 記事内テーブル：横スクロール枠（nk-mobile.js が自動で包む） ── */
.nk-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 1.6em;
}
.nk-table-scroll > table { margin-bottom: 0 !important; }

/* ── [2] ハンバーガーボタン・メニュー（PCでは非表示） ── */
.nk-menu-toggle,
.nk-mnav { display: none; }

@media (max-width: 900px) {

  /* ── ナビバー本体（header.php 版・nk-navbar.php 版の両方） ── */
  html body .nk-navbar {
    padding: 10px 12px 10px 16px;
    justify-content: flex-start;
    gap: 8px;
  }
  html body .nk-navbar.nk-mnav-open {
    background: rgba(8,14,22,0.98);
    border-bottom-color: rgba(0,150,220,0.28);
  }
  html body .nk-logo { min-width: 0; flex: 0 1 auto; }
  html body .nk-logo-main {
    font-size: clamp(20px, 6.2vw, 30px);
    letter-spacing: 3px;
    white-space: nowrap;
  }
  html body .nk-logo-sub { display: none; }

  html body .nk-nav-links { margin-left: auto; gap: 0; flex-shrink: 0; }
  html body .nk-nav-links li:not(:last-child) { display: none; }
  html body .nk-nav-links .btn-nav {
    display: inline-block;
    padding: 8px 14px;
    font-size: 13px;
    letter-spacing: 2px;
    white-space: nowrap;
    line-height: 1.4;
  }

  /* ── ハンバーガーボタン ── */
  html body .nk-menu-toggle {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 5px;
    width: 42px; height: 42px; flex-shrink: 0;
    padding: 0; margin: 0;
    background: transparent;
    border: 0.5px solid rgba(0,180,220,0.3);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  html body .nk-menu-toggle span {
    display: block; width: 20px; height: 1.5px;
    background: var(--nk-cyan2, #4dc8ef);
    transition: transform 0.25s, opacity 0.2s;
  }
  html body .nk-mnav-open .nk-menu-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  html body .nk-mnav-open .nk-menu-toggle span:nth-child(2) { opacity: 0; }
  html body .nk-mnav-open .nk-menu-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

  /* ── ドロップダウンメニュー（ナビバー直下に展開） ── */
  html body .nk-mnav {
    display: block;
    position: absolute; top: 100%; left: 0; right: 0;
    max-height: 0; overflow: hidden;
    background: rgba(8,14,22,0.98);
    border-bottom: 0.5px solid transparent;
    transition: max-height 0.3s ease, border-color 0.3s;
  }
  html body .nk-mnav-open .nk-mnav {
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    border-bottom-color: rgba(0,150,220,0.28);
  }
  html body .nk-mnav a {
    display: block;
    padding: 15px 24px;
    font-family: var(--nk-font-army);
    font-size: 15px; letter-spacing: 3px;
    color: rgba(180,215,235,0.8);
    border-top: 0.5px solid rgba(0,150,220,0.1);
    text-decoration: none;
  }
  html body .nk-mnav a:active,
  html body .nk-mnav a:hover { color: #ffffff; background: rgba(0,110,190,0.15); }
  html body .nk-mnav a.nk-mnav-shop {
    margin: 12px 24px 20px;
    text-align: center;
    background: rgba(0,110,190,0.85);
    color: #ffffff;
    border: 0.5px solid rgba(0,180,220,0.4);
  }
}

/* ── [3] SHOPバナー装飾テキスト（トップ・戦史・記事） ── */
@media (max-width: 768px) {
  html body .nk-banner-deco-text,
  html body .nk-shop-deco-text {
    white-space: normal;
    flex-shrink: 1;
    min-width: 0;
    letter-spacing: 2px;
    text-align: center;
  }
  html body .nk-banner-deco-diamond,
  html body .nk-shop-deco-diamond { flex-shrink: 0; }
  html body .nk-banner-deco-line,
  html body .nk-shop-deco-line { min-width: 12px; }

  /* トップページ SHOPバナーのボタン */
  html body .nk-banner-btn { padding: 14px 24px; letter-spacing: 2px; }
  html body .nk-banner-meta { flex-wrap: wrap; justify-content: center; }

  /* ── 記事末尾 SHOPバナー（single.php） ── */
  html body .nk-article-shop { padding: 40px 16px; }
  html body .nk-article-shop-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    padding: 24px 20px;
    text-align: center;
  }
  html body .nk-asb-label { justify-content: center; }
  html body .nk-asb-title { letter-spacing: 3px; }
  html body .nk-asb-meta { flex-wrap: wrap; justify-content: center; }
  html body .nk-asb-btn { padding: 14px 20px; letter-spacing: 3px; }
}

/* ── [4] カードグリッド：狭い端末で1枚が画面幅を超えないように ── */
@media (max-width: 900px) {
  html body #nk-illust-wrap .nk-grid,
  html body #nk-tourism-wrap .nk-grid,
  html body #nk-history-wrap .nk-grid,
  html body #nk-goods-wrap .nk-grid,
  html body #nk-itcad-wrap .nk-grid,
  html body #nk-blog-wrap .nk-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)) !important;
  }
  html body .nk-cards {
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  }
}

/* ── [5] 記事ページ：前後ナビを縦積みに ── */
@media (max-width: 600px) {
  html body .nk-post-nav { grid-template-columns: 1fr; }
  html body .nk-post-nav-item { padding: 22px 20px; }
  html body .nk-post-nav-item.next {
    border-left: none;
    border-top: 0.5px solid var(--nk-border);
  }
}

/* ── [6] フッターロゴ ── */
@media (max-width: 600px) {
  html body .nk-footer-logo-main {
    font-size: clamp(24px, 8vw, 38px);
    letter-spacing: 4px;
  }
  html body .nk-footer-logo-sub,
  html body .nk-footer-tagline { letter-spacing: 2px; }
}

/* ── [7] 小型スマホ（iPhone SE 等） ── */
@media (max-width: 380px) {
  html body .nk-navbar { padding-left: 12px; padding-right: 10px; gap: 6px; }
  html body .nk-nav-links .btn-nav { padding: 7px 10px; letter-spacing: 1px; }
  html body .nk-menu-toggle { width: 38px; height: 38px; }
}

/* ── [8] トップページ HERO：スマホでは狙撃手の顔を画面中央に ── */
@media (max-width: 768px) {
  html body .nk-hero {
    height: auto;
    min-height: 100vh; min-height: 100svh;
    justify-content: flex-end;
    padding-top: 64vh; padding-top: 64svh;
  }
  /* 画像はヒーロー上部に固定高さで配置（本文が長くても顔が拡大されない） */
  html body .nk-hero-image,
  html body .nk-hero-overlay {
    inset: 0 0 auto 0;
    height: 88vh; height: 88svh;
  }
  html body .nk-hero-image img { object-position: 43% 50%; }
  /* 左からの暗幕をやめ、上（ナビ下）と下（本文の背景）だけ暗くする */
  html body .nk-hero-overlay {
    background:
      linear-gradient(to bottom, rgba(6,12,20,0.75) 0%, rgba(6,12,20,0) 14%),
      linear-gradient(to top, rgba(6,12,20,1) 0%, rgba(6,12,20,0.9) 18%, rgba(6,12,20,0.5) 32%, rgba(6,12,20,0) 48%);
  }
  /* レチクルを顔の位置へ */
  html body .nk-reticle-wrap {
    left: 50%;
    top: 32vh; top: 32svh;
    width: 170px; height: 170px;
  }
  html body .nk-coord { top: 76px; left: 16px; }
  html body .nk-side-text { display: none; }
  html body .nk-hero-bg { background: #060c14; }
  /* 大見出しが画面幅に収まるように */
  html body .nk-hero-title {
    font-size: clamp(52px, 18vw, 80px);
    letter-spacing: 4px;
  }
}
