/* assets/css/header.css
   CryptoDepth header layout（スマホ：ハンバーガー＋ロゴ、PC：ロゴ＋中央検索）
================================================ */

@layer comp {

  :root{
    --header-h: 56px;
  }

  /* ===== 共通レイヤー ===== */

  .site-header{
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--cd-bg, #0b1016);
    border-bottom: 1px solid var(--cd-border, rgba(255,255,255,.12));
    color: var(--cd-fg, #e6edf3);
  }

  /* モバイル基準レイアウト
     [ハンバーガー][ロゴ]
  ------------------------------------------------ */

  .site-header .header-inner{
    /* 横幅・左右余白は .container が担当 */
    padding-block: 8px;

    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "nav brand";
    column-gap: 0;
    align-items: center;
    min-height: var(--header-h);
    position: relative; /* PCでの検索バー絶対配置の基準 */
  }

  /* ハンバーガー */

  .nav-toggle{
    grid-area: nav;
    appearance: none;
    border-radius: 10px;
    border: 0 solid var(--cd-border, rgba(255,255,255,.12));
    background: color-mix(in oklab, var(--cd-bg, #0b1016), white 2%);
    color: var(--cd-fg, #e6edf3);
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .nav-toggle__bars{
    width: 18px;
    height: 14px;
    position: relative;
    display: inline-block;
  }

  .nav-toggle__bars::before,
  .nav-toggle__bars::after,
  .nav-toggle__bars span{
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
  }

  .nav-toggle__bars::before{ top: 0; }
  .nav-toggle__bars::after{ bottom: 0; }
  .nav-toggle__bars span{ top: 50%; transform: translateY(-50%); }

  /* ロゴ */

  .brand{
    grid-area: brand;
    display: flex;
    align-items: center;
  }

  .brand__link{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
  }

  .brand__text{
    font-weight: 600;
    font-size: clamp(1.2rem, 0.9rem + 0.9vw, 1.8rem);
    white-space: nowrap;
  }

  /* モバイルではヘッダー検索は非表示（ハンバーガー → ドロワーで検索） */

  .header-search{
    display: none;
  }

  /* ===== PCレイアウト（834px〜）
     ロゴ左 + 画面中央に検索バー
  ------------------------------------------------ */

  @media (min-width: 834px){

    .site-header .header-inner{
      /* PC ではヘッダー帯を全幅に伸ばす */
      max-width: none;
      margin-inline: 0;
      grid-template-columns: 180px 1fr;
      grid-template-areas: "brand brand";
      column-gap: 12px;
    }

    .nav-toggle{
      display: none;
    }

    .brand{
      justify-self: flex-start;
    }

    /* YouTube風：中央に固定幅の検索バーを絶対配置 */
    .header-search{
      display: flex;
      align-items: center;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: min(720px, 60vw);   /* 画面に応じて縮む */
      pointer-events: auto;
    }

    /* PC ではドロワーは使わない */
    .site-drawer{
      display: none !important;
    }
  }

  /* ===== ヘッダー検索フォーム ===== */

  .header-search-form{
    display: flex;
    align-items: stretch;
    width: 100%;
    border-radius: 999px;
    border: 1px solid color-mix(in oklab, var(--cd-border), var(--cd-accent) 18%);
    background: color-mix(in oklab, var(--cd-bg), white 5%);
    overflow: hidden;

    /* 通常時もごく薄く光らせる */
    box-shadow:
      0 0 0 1px rgba(125, 227, 255, .08),
      0 0 12px rgba(0, 0, 0, .55);

    transition:
      border-color .18s ease,
      box-shadow .18s ease,
      background-color .18s ease;
  }

  /* ホバーで「存在感＋1段階」 */
  .header-search-form:hover{
    border-color: color-mix(in oklab, var(--cd-border), var(--cd-accent) 35%);
    box-shadow:
      0 0 0 1px rgba(125, 227, 255, .18),
      0 0 18px rgba(125, 227, 255, .15);
    background: rgba(0,0,0,.55);
  }

  /* クリック中（入力フォーカス中）は強めグロー */
  .header-search-form:focus-within{
    border-color: var(--cd-accent);
    box-shadow:
      0 0 0 1px rgba(125, 227, 255, .85),
      0 0 24px rgba(125, 227, 255, .45);
    background: color-mix(in oklab, var(--cd-bg), var(--cd-accent) 10%);
  }

  .header-search-input{
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--cd-fg, #e6edf3);
    font-size: .9rem;
    outline: none;
  }

  .header-search-input::placeholder{
    color: var(--cd-muted, #a7b0ba);
  }

  .header-search-input:focus-visible{
    outline: none;
  }

  /* 右端の虫眼鏡ボタン（YouTubeタイプ） */

  .header-search-button{
    flex: 0 0 auto;
    width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-left: 1px solid var(--cd-border, rgba(255,255,255,.12));
    background: rgba(255,255,255,.04);
    cursor: pointer;
    color: #ffffff;
    transition:
      border-color .18s ease,
      background-color .18s ease;
  }

  .header-search-button:hover{
    background: rgba(255,255,255,.08);
  }

  /* focus 時にボタン境界もそろえる */
  .header-search-form:focus-within .header-search-button{
    border-left-color: var(--cd-accent, #66e0ff);
    background: rgba(255,255,255,.08);
  }

  /* アイコンサイズの役割分離 */
  .header-search-button-icon{
    width: 20px;
    height: 20px;
  }

  .header-search-icon{
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--cd-fg, #e6edf3);
    opacity: .9;
  }

  /* Enter送信用の隠しsubmit（付けている場合用） */
  .header-search-submit{
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }

  /* ===== スマホ用ドロワー ===== */

  .site-drawer[hidden]{
    display: none !important;
  }

  .site-drawer{
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: var(--cd-bg, #0b1016);
    border-top: 1px solid var(--cd-border, rgba(255,255,255,.12));
    z-index: 120;
    display: flex;
    justify-content: center;
  }

  .site-drawer-inner{
    width: 100%;
    max-width: var(--container-max, 1200px);
    padding: 16px var(--cd-gutter, 16px) 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* ドロワー内検索は search.css の .search-form / .search-field を流用 */

  .drawer-menu{
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .drawer-menu a{
    display: block;
    padding: 8px 4px;
    color: var(--cd-fg, #e6edf3);
    text-decoration: none;
  }

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

  .site-drawer-close{
    align-self: flex-end;
    margin-top: 8px;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--cd-muted, #a7b0ba);
    font-size: 1.5rem;
    cursor: pointer;
  }

} /* @layer comp */
