/*
 * ブログのスマホ表示（全ページ）: ヘッダー・メニュー（ドロワー）・画面下の固定メニュー
 * ショップ iic-shop.net のスマホ表示と同じ見た目・寸法にそろえる
 * ※ 固定メニュー（.iic-footbar）はショップの snippets/iic-sp-footbar.liquid と同じ。変更時は両方直す
 */

.iic-sph-wrap,
.iic-sph,
.iic-drawer,
.iic-drawer-overlay,
.iic-footbar {
  display: none;
}

@media only screen and (max-width: 767px) {
  :root {
    --iic-footbar-h: 60px;
    --iic-text: #2a3743;
    --iic-border: #e0dfdf;
  }

  /* ---------- ヘッダー（ロゴ左・検索／メニュー／カート右） ---------- */
  /* 賢威の元ヘッダー枠（中身は非表示）の上余白 4px を消す */
  .keni-header_wrap {
    padding-top: 0;
  }
  /* サイドバーのリスト先頭の「▶」がページ左上に飛ばないよう、各項目を基準にする */
  .keni-sub .keni-section_wrap li {
    position: relative;
  }
  /* 外枠で高さ95pxを確保し、スクロール後は中身だけを細いヘッダー（64px）として上部に固定する */
  .iic-sph-wrap {
    display: block;
    height: 95px;
  }
  .iic-sph {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 95px;
    padding: 0 7px 0 17px;
    background: #fff;
    border-bottom: 1px solid var(--iic-border);
  }
  .iic-sph-wrap.is-stuck .iic-sph {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 64px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: iic-sph-in 0.3s ease;
  }
  .iic-sph-wrap.is-stuck .iic-sph__logo,
  .iic-sph-wrap.is-stuck .iic-sph__logo img {
    width: 84px;
  }
  @keyframes iic-sph-in {
    from {
      transform: translateY(-100%);
    }
    to {
      transform: translateY(0);
    }
  }
  /* WordPress のログイン中（管理バー表示中）は、その下に固定する */
  .admin-bar .iic-sph-wrap.is-stuck .iic-sph {
    top: var(--iic-adminbar-h, 0px);
  }

  /* 賢威の「ページの先頭へ」ボタン：固定メニューに隠れないよう上に移し、丸くする */
  .page-top {
    right: 12px !important;
    bottom: calc(var(--iic-footbar-h) + 12px + env(safe-area-inset-bottom, 0px)) !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50%;
    overflow: hidden;
    opacity: 0.85;
  }
  .page-top a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
  }
  .iic-sph__logo {
    display: block;
    width: 120px;
  }
  .iic-sph__logo img {
    display: block;
    width: 120px;
    height: auto;
  }
  .iic-sph__icons {
    display: flex;
    align-items: center;
  }
  .iic-sph__btn,
  .iic-sph__btn:hover,
  .iic-sph__btn:focus,
  .iic-sph__btn:visited {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 48px;
    margin: 0;
    padding: 0 6px;
    font: inherit;
    border: 0;
    background: none;
    color: var(--iic-text);
    text-decoration: none;
    cursor: pointer;
  }
  /* アイコンの下の文字（ショップのヘッダーと同じ：ログイン・検索・メニュー・カート） */
  .iic-sph__label {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }
  .iic-sph__btn svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5px;
  }
  .iic-sph__btn svg circle {
    fill: currentColor;
  }
  .iic-sph__btn:focus-visible {
    outline: 2px solid var(--iic-text);
    outline-offset: -4px;
  }

  /* ---------- メニュー（右から開くドロワー） ---------- */
  .iic-drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }
  .iic-drawer {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100001;
    width: 350px;
    max-width: 88vw;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    color: var(--iic-text);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.4s ease, visibility 0.4s;
  }
  .iic-drawer-open .iic-drawer {
    transform: translateX(0);
    visibility: visible;
  }
  .iic-drawer-open .iic-drawer-overlay {
    opacity: 1;
    visibility: visible;
  }
  .iic-drawer-open {
    overflow: hidden;
  }
  .iic-drawer__inner {
    padding: 20px 20px 40px;
  }
  /* ブログ共通CSSのボタン・リンクの transition（0.3s）で表示切替が遅れ、フォーカスできないのを防ぐ */
  .iic-drawer button,
  .iic-drawer a {
    transition: none;
  }
  .iic-drawer__head {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 12px;
  }
  .iic-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 -10px 0 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--iic-text);
    cursor: pointer;
  }
  .iic-drawer__close svg {
    width: 34px;
    height: 34px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5px;
  }
  .iic-drawer ul,
  .iic-drawer li {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .iic-drawer__list > li {
    border-top: 1px solid var(--iic-border);
  }
  .iic-drawer__list > li:last-child {
    border-bottom: 1px solid var(--iic-border);
  }
  .iic-drawer__row {
    display: flex;
    align-items: stretch;
  }
  .iic-drawer__link,
  .iic-drawer__link:hover,
  .iic-drawer__link:focus,
  .iic-drawer__link:visited {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 8px;
    padding: 15px 0;
    color: var(--iic-text);
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.03em;
    text-decoration: none;
  }
  .iic-drawer__link svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 3px;
  }
  .iic-drawer__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    margin: 8px 0;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--iic-border);
    background: none;
    color: var(--iic-text);
    cursor: pointer;
  }
  .iic-drawer__toggle svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2px;
    transition: transform 0.3s;
  }
  .iic-drawer__toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }
  .iic-drawer__sub {
    display: none;
    padding: 0 0 10px 12px !important;
  }
  .iic-drawer__sub.is-open {
    display: block;
  }
  .iic-drawer__sub a,
  .iic-drawer__sub a:hover,
  .iic-drawer__sub a:focus,
  .iic-drawer__sub a:visited {
    display: block;
    padding: 8px 0;
    color: var(--iic-text);
    font-size: 16px;
    text-decoration: none;
  }
  .iic-drawer__social {
    display: flex;
    flex-wrap: wrap;
    margin-top: 16px !important;
    border-top: 1px solid var(--iic-border);
    border-left: 1px solid var(--iic-border);
  }
  .iic-drawer__social li {
    flex: 0 0 33.333%;
    border-right: 1px solid var(--iic-border);
    border-bottom: 1px solid var(--iic-border);
  }
  .iic-drawer__social a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    color: var(--iic-text);
  }
  .iic-drawer__social svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
  }

  /* ---------- 画面下の固定メニュー（ショップと同じ） ---------- */
  body {
    padding-bottom: calc(var(--iic-footbar-h) + env(safe-area-inset-bottom, 0px));
  }
  .iic-footbar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #333;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
  }
  .iic-footbar__list {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: var(--iic-footbar-h);
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
  }
  .iic-footbar__list li {
    margin: 0 !important;
    padding: 0;
    list-style: none;
  }
  .iic-footbar__list li + li {
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }
  .iic-footbar__link,
  .iic-footbar__link:hover,
  .iic-footbar__link:focus,
  .iic-footbar__link:visited {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-decoration: none;
  }
  .iic-footbar__link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
  }
  .iic-footbar__icon {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

@media (prefers-reduced-motion: reduce) {
  .iic-drawer,
  .iic-drawer-overlay,
  .iic-drawer__toggle svg {
    transition: none;
  }
}
