/* ==========================================================================
   responsive.css  —  Mobile/Tablet only（PC >=1100px は非適用）
   - 画像/動画のフィット
   - グリッド/2カラム調整
   - ハンバーガー位置・レイヤー
   - 検索窓の幅の統一
   - トップ画像(#mainimg)の非表示＆余白除去
   - 見出し（英字）の縮小・改行防止
   - section.bg1 の上マージン
   ========================================================================== */

/* ====== 汎用：1100px以下（PCはノータッチ） ============================== */
@media screen and (max-width: 1100px) {

  /* メディア要素は親幅にフィット */
  img, video, canvas, svg { max-width: 100%; height: auto; }
  iframe { max-width: 100%; }

  /* サムネイルグリッド（カード） */
  .list-grid-trimming {
    display: grid;
    grid-template-columns: repeat(3, 1fr) !important; /* 3列 */
    gap: 0.75rem;
  }

  /* テーブルのはみ出し対策 */
  table { width: 100%; border-collapse: collapse; }
  .table-scroll, .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll > table, .table-wrapper > table { min-width: 640px; }

  /* （任意）SP/Tabletの文字組みを少し読みやすく */
  html { line-height: 1.75; }
}

/* ====== 2カラム：900px以下で縦積み ====================================== */
@media screen and (max-width: 900px) {
  .c2 { display: block !important; }
  .c2 .small-box,
  .c2 .large-box { width: 100% !important; }
}

/* ====== スマホ中心：700px以下 =========================================== */
@media screen and (max-width: 700px) {

  /* ヘッダーを絶対配置の基準に */
  header { position: relative; padding-top: 40px; }

  /* ハンバーガー（全ページ共通）— 左上固定＆最前面 */
  #menubar_hdr{
    position: fixed !important;
    top: 10px;
    left: 4px;              /* もっと左に寄せたいなら 0〜6px で調整 */
    z-index: 10000 !important;
    min-width: 44px; min-height: 44px;
    margin: 0 !important;
  }

  /* メニュー本体はオーバーレイ最前面（×よりは背面） */
  #menubar{
    position: fixed !important;
    left: 0; top: 0; width: 100%; height: 100%;
    z-index: 9000 !important;
  }

  /* 検索フォーム：全ページで横幅を完全統一（親パディングに影響されない） */
  header .search-form{
    position: static !important;      /* 絶対配置を解除 */
    display: flex;
    gap: .5rem;
    width: calc(100vw - 48px) !important;  /* 画面幅−左右余白(24px×2) */
    max-width: 520px !important;           /* 検索結果ページ寄りの見た目。必要なら 540/560px に */
    margin: 0 auto 8px !important;
    box-sizing: border-box;
    z-index: 1 !important;                 /* メニューより背面にして重なり防止 */
  }
  header .search-form input[type="text"]{ flex: 1 1 auto; min-width: 0; }
  header .search-form button{ flex: 0 0 auto; white-space: nowrap; }

  /* トップページのロゴ（少し小さく） */
  .home header #logo{
    position: static !important; transform: none !important;
    width: 65% !important;            /* きつければ 60% / 55% に */
    margin: 8px auto 6px;
  }
  #logo img{ width: 100%; height: auto; display: block; }

  /* 下層ページ（プロフィール/レポート/検索結果など）のロゴも縦並びで中央寄せ */
  body:not(.home) header{
    display: flex; flex-direction: column; align-items: center; gap: 8px;
  }
  body:not(.home) header #logo{
    position: static !important; transform: none !important;
    width: 60% !important; margin: 0 auto 4px;
  }

  /* トップの大画像（#mainimg）：スマホは非表示＋スペース除去 */
  #mainimg{
    display: none !important;
    height: 0 !important; margin: 0 !important; padding: 0 !important;
    clip-path: none !important; position: static !important;  /* 念のため */
    background: none !important;
  }

  /* 英字の大見出し（改行せず自動縮小）— Greetings / Activity Report 等 */
  h1 .hosoku, h2 .hosoku{
    font-size: clamp(22px, 9vw, 46px);
    line-height: 1.05;
    white-space: nowrap;              /* 2行落ち防止 */
    letter-spacing: 0.02em;
    overflow: hidden; text-overflow: ellipsis;
  }

  /* section.bg1 の上マージン */
  section.bg1 { margin-top: 30px !important; }
}

/* ====== さらに狭い端末：420px以下 ====================================== */
@media screen and (max-width: 420px) {
  .list-grid-trimming { grid-template-columns: 1fr !important; }  /* 1列 */
  h1 .hosoku, h2 .hosoku{ font-size: clamp(20px, 8.5vw, 38px); }
}

@media screen and (max-width: 700px) {
  .home #mainimg{
    display: none !important;
    position: static !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    clip-path: none !important;
    background: none !important;
  }
  /* ヘッダーの下余白を最小化して“空欄”を作らない */
  .home header{
    min-height: 0 !important;
    height: auto !important;
    padding-bottom: 8px !important;
  }
}

@media screen and (max-width: 700px) {
      /* ヘッダーを基準にする */
  header { position: relative; }
   /* 閉じてる通常時：追従ナシ＆左上“端”に配置 */
  #menubar_hdr{
    position: absolute !important;  /* ← スクロール追従をやめる */
    top: 0 !important;
    left: 0 !important;             /* ピッタリ左端 */
    margin: 0 !important;
    z-index: 400 !important;
    min-width: 44px; min-height: 44px;
  }

  /* メニュー本体は最前面のオーバーレイ */
  #menubar{
    position: fixed !important;
    left: 0; top: 0; width: 100%; height: 100%;
    z-index: 9000 !important;
  }

  /* 開いた時（×表示時）は最前面で固定しておく（閉じるため） */
  #menubar_hdr.ham{
    position: fixed !important;
    top: 8px !important;
    left: 0 !important;
    z-index: 10000 !important;
  }
}

@media screen and (max-width: 700px) {
  body:not(.home) header{
    padding-top: 14px !important;   /* もっと詰めたいなら 10〜12px へ */
    padding-bottom: 8px !important;
  }
  /* 見出しがまだ遠い場合の保険（任意） */
  main > section:first-of-type{ margin-top: 12px !important; }
}

@media screen and (max-width: 700px) {
  header .search-form{
    position: static !important;
    display: flex;
    gap: .5rem;
    width: calc(100vw - 48px) !important;  /* 画面幅 − 左右24pxずつの余白 */
    max-width: 520px !important;           /* ← 検索結果ページの見た目に合わせる値 */
    margin: 0 auto 8px !important;
    box-sizing: border-box;
    z-index: 1 !important;                 /* メニュー背面 */
  }
  header .search-form input[type="text"]{ flex: 1 1 auto; min-width: 0; }
  header .search-form button{ flex: 0 0 auto; white-space: nowrap; }
}

@media screen and (max-width: 700px) {
  /* ヘッダーの並びを全ページで共通（縦並び・中央寄せ・一定余白） */
  .home header,
  body:not(.home) header {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    padding-top: 28px !important;     /* ← ここを+/-2pxで微調整OK */
    padding-bottom: 10px !important;
  }

  /* ハンバーガー：閉じてる時は追従しない＆左端ぴったり */
  #menubar_hdr{
    position: absolute !important;    /* 追従オフ */
    top: 8px !important;
    left: 0 !important;
    z-index: 400 !important;
    min-width: 44px; min-height: 44px;
    margin: 0 !important;
  }
  /* 開いた時（×表示時）だけは最前面で固定 */
  #menubar_hdr.ham{
    position: fixed !important;
    top: 10px !important;
    left: 0 !important;
    z-index: 10000 !important;
  }

  /* ロゴ（タイトル）サイズ＆位置を共通化 */
  .home #logo,
  body:not(.home) #logo {
    position: static !important;
    transform: none !important;
    margin: 0 auto 6px !important;
  }
  .home #logo { width: 65% !important; }       /* ホームは少しだけ大きめ */
  body:not(.home) #logo { width: 60% !important; }

  /* 検索窓：全ページで同じ横幅（検索結果ページ基準） */
  header .search-form{
    position: static !important;
    display: flex !important;
    gap: .5rem !important;
    width: calc(100vw - 48px) !important;  /* 画面幅 − 左右24pxずつ */
    max-width: 520px !important;           /* 必要なら 540/560px に変更 */
    margin: 0 auto 8px !important;
    box-sizing: border-box !important;
    z-index: 1 !important;
  }
  header .search-form input[type="text"]{ flex: 1 1 auto; min-width: 0; }
  header .search-form button{ flex: 0 0 auto; white-space: nowrap; }

  /* トップの花画像：非表示＆空欄を作らない（ホームのみ） */
  .home #mainimg{
    display: none !important;
    position: static !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    clip-path: none !important;
    background: none !important;
  }

  /* 下層の見出しがまだ遠い時はここで詰める（必要なら） */
  body:not(.home) main > section:first-of-type { margin-top: 12px !important; }
}

/* === SP：検索窓の位置を Home/下層で完全にそろえる ===================== */
@media screen and (max-width: 700px) {
  /* ヘッダーのレイアウトを全ページで共通（縦並び/中央寄せ/同じ余白） */
  .home header,
  body:not(.home) header {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    padding-top: 28px !important;   /* 必要なら 26〜30px で微調整 */
    padding-bottom: 10px !important;
    padding-left: 0 !important;     /* ← 左端に要素を寄せたいので揃える */
    padding-right: 0 !important;
  }

  /* ロゴを先、検索窓を後に“順番固定”。ページごとのDOM順が違っても揃う */
  header #logo { order: 1; margin: 0 auto 6px !important; }
  header .search-form {
    order: 2;
    position: static !important;    /* 絶対配置を無効化してズレ防止 */
    top: auto !important; right: auto !important; left: auto !important;
    margin: 0 auto 8px !important;

    /* 幅は検索結果ページ基準で統一（親のパディングに左右されない） */
    display: flex; gap: .5rem;
    width: calc(100vw - 48px) !important;  /* 画面幅 − 左右24pxずつ */
    max-width: 520px !important;           /* 検索結果ページに合わせる。必要なら 540/560px に */
    box-sizing: border-box;
    z-index: 1 !important;
  }
  header .search-form input[type="text"] { flex: 1 1 auto; min-width: 0; }
  header .search-form button { flex: 0 0 auto; white-space: nowrap; }

  /* ハンバーガーは閉じてる時だけ“追従なし”で左上端に固定 */
  #menubar_hdr {
    position: absolute !important; top: 8px !important; left: 0 !important;
    margin: 0 !important; z-index: 400 !important;
    min-width: 44px; min-height: 44px;
  }
  /* 開いた時（×表示時）は最前面に */
  #menubar_hdr.ham { position: fixed !important; top: 10px !important; left: 0 !important; z-index: 10000 !important; }
}

@media screen and (max-width: 700px) {
  body:not(.home):not(.search-page) header .search-form {
    position: static !important;   /* 念のため絶対配置を解除 */
    padding-top: 9px !important;
  }
}

@media screen and (max-width: 700px) {
  .home header #logo {
    position: static !important;   /* 絶対配置を無効化 */
    top: auto !important;
    left: auto !important;
    transform: none !important;
    animation: none !important;    /* CSSアニメ無効 */
    transition: none !important;   /* トランジション無効 */
    margin: 12px auto 8px;         /* 置き直し用の余白（好みで調整） */
    width: 65% !important;         /* 大きさはお好みで 60–70% あたり */
  }
}