/* portal.css */
.portal-home {
  --portal-bg: #ffffff;
  --portal-section: #f5f5f5;
  --portal-text: #222222;
  --portal-muted: #666666;
  --portal-highlight: #ff9900;
  --portal-highlight-strong: #e68700;
  --portal-highlight-dark: #e68600;
  --portal-highlight-soft: #fff1dd;
  --portal-border: #e6e6e6;
  --portal-radius: 14px;
  --portal-container: 1240px;

  color: var(--portal-text);
  background: var(--portal-bg);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

.portal-home .hero,
.portal-home .featured-section,
.portal-home .ranking,
.portal-home .updates,
.portal-home .new-releases,
.portal-home .sales,
.portal-home .media,
.portal-home .tags {
  width: min(100% - 1.5rem, var(--portal-container));
  margin-inline: auto;
}

.portal-home .section-box {
  background: var(--portal-section);
  border: 1px solid var(--portal-border);
  border-radius: 16px;
  padding: 1.25rem;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.portal-home .section-box.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.portal-home .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.portal-home .section-title {
  margin: 0;
  font-size: clamp(1.05rem, 2.5vw, 1.4rem);
  letter-spacing: 0.01em;
}

.portal-home .section-link {
  color: #333;
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 1px solid #c8c8c8;
}

.portal-home .section-link:hover {
  color: #111;
  border-bottom-color: #999;
}

.portal-home .section-empty {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.9rem;
}

.portal-home .hero {
  margin-top: 0.5rem;
}

.portal-home .hero-campaign {
  border-radius: 18px;
  overflow: hidden;
  min-height: 280px;
  position: relative;
  text-align: center;
  padding: clamp(2.25rem, 7vw, 5rem) 1.1rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 153, 0, 0.2), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(255, 153, 0, 0.14), transparent 40%),
    linear-gradient(135deg, #ffffff 0%, #fff4e5 62%, #ffffff 100%);
  border: 1px solid #ffdcb4;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.portal-home .hero-kicker {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: #1f1f1f;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 0.34rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 153, 0, 0.18);
}

.portal-home .hero-title {
  margin: 0;
  font-size: clamp(1.45rem, 4.8vw, 3rem);
  line-height: 1.22;
}

.portal-home .hero-copy {
  margin: 0.7rem auto 0;
  max-width: 56ch;
  color: #3c3c3c;
  font-size: clamp(0.95rem, 2.5vw, 1.12rem);
}

.portal-home .cta-button {
  margin-top: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.35rem;
  background: linear-gradient(180deg, #ffad2f 0%, var(--portal-highlight) 100%);
  box-shadow: 0 8px 16px rgba(255, 153, 0, 0.28);
  color: #181818;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.portal-home .cta-button:hover,
.portal-home .cta-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 22px rgba(255, 153, 0, 0.35);
  background: linear-gradient(180deg, #ffb945 0%, var(--portal-highlight-strong) 100%);
}

.portal-home .scroll-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(140px, 44vw);
  gap: 0.8rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.4rem;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
}

.portal-home .scroll-row > * {
  scroll-snap-align: start;
}

.portal-home .scroll-row.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.portal-home .scroll-row::-webkit-scrollbar {
  height: 8px;
}

.portal-home .scroll-row::-webkit-scrollbar-track {
  background: #ebebeb;
  border-radius: 999px;
}

.portal-home .scroll-row::-webkit-scrollbar-thumb {
  background: #cbcbcb;
  border-radius: 999px;
}

.portal-home .grid-books {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.portal-home .tag-area {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.portal-home .tag-chip {
  border: 1px solid #e2e2e2;
  border-radius: 999px;
  background: #fff;
  color: #2a2a2a;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.42rem 0.9rem;
  font-size: 0.83rem;
  font-weight: 700;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.portal-home .tag-chip:hover,
.portal-home .tag-chip:focus-visible {
  background: var(--portal-highlight);
  border-color: var(--portal-highlight);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .portal-home .cta-button,
  .portal-home .scroll-row,
  .portal-home .tag-chip {
    transition: none;
    scroll-behavior: auto;
  }
}

/* =============================================
   freeworks store-tabs 基本スタイル
   ============================================= */
.portal-home .freeworks-section {
  width: min(100% - 1.5rem, var(--portal-container));
  margin-inline: auto;
}

.portal-home .store-tabs-container {
  margin-bottom: 0.75rem;
}

.portal-home .store-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.portal-home .store-tab {
  flex-shrink: 0;
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  background: #fff;
  color: var(--portal-text);
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.portal-home .store-tab[aria-selected="true"] {
  background: var(--portal-highlight);
  border-color: var(--portal-highlight);
  color: #181818;
}

.portal-home .store-tab:hover:not([aria-selected="true"]) {
  background: var(--portal-highlight-soft);
  border-color: var(--portal-highlight);
}

.portal-home .store-panel[hidden] {
  display: none;
}

/* =============================================
   片手操作設定ウィジェット（旧方式・未使用）
   現在は one-hand.js によりハンバーガーメニュー内の設定UIを利用
   このスタイル群は後方確認用として一時残置
   ============================================= */
.one-hand-widget {
  position: fixed;
  bottom: 72px;
  right: 16px;
  z-index: 1000;
}

.one-hand-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.one-hand-panel {
  position: absolute;
  bottom: 52px;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 176px;
}

.one-hand-label {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #666;
}

.one-hand-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.one-hand-row:last-child {
  margin-bottom: 0;
}

.one-hand-btn {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f5f5f5;
  color: var(--portal-text, #222);
  padding: 0.4rem;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 38px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.one-hand-btn.is-active {
  background: var(--portal-highlight, #ff9900);
  border-color: var(--portal-highlight, #ff9900);
  color: #181818;
}

/* =============================================
   三本線メニュー内: 片手操作設定シート
   ============================================= */
.one-hand-menu-settings {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--portal-border, #e6e6e6);
}

.one-hand-menu-title {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: #222;
}

/* =============================================
   利き手設定: ウィジェット配置
   ============================================= */
body[data-handedness="left"] .one-hand-widget {
  right: auto;
  left: 16px;
}

body[data-handedness="left"] .one-hand-panel {
  right: auto;
  left: 0;
}

/* =============================================
   片手操作モード ON 時のUI配置制御
   ============================================= */

/* 下部固定CTA: 利き手側に寄せる */
body[data-one-hand="on"][data-handedness="right"] .portal-home .cta-button {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

body[data-one-hand="on"][data-handedness="left"] .portal-home .cta-button {
  display: block;
  margin-right: auto;
  margin-left: 0;
}

/* store-tabs: 利き手側から並べる（左手時は右端スタートで折り返し） */
body[data-one-hand="on"][data-handedness="left"] .portal-home .store-tabs {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* モーダル/ドロワー: 閉じる導線を利き手側に寄せる（スマホ限定） */
@media (max-width: 767px) {
  body[data-one-hand="on"][data-handedness="right"] :is(
    .modal,
    .drawer,
    .c-modal,
    .c-drawer,
    [role="dialog"],
    [aria-modal="true"]
  ) :is(
    .modal-close,
    .drawer-close,
    .close,
    .btn-close,
    [aria-label="閉じる"],
    [aria-label="Close"]
  ) {
    right: 16px;
    left: auto;
  }

  body[data-one-hand="on"][data-handedness="left"] :is(
    .modal,
    .drawer,
    .c-modal,
    .c-drawer,
    [role="dialog"],
    [aria-modal="true"]
  ) :is(
    .modal-close,
    .drawer-close,
    .close,
    .btn-close,
    [aria-label="閉じる"],
    [aria-label="Close"]
  ) {
    left: 16px;
    right: auto;
  }

  body[data-one-hand="on"] :is(
    .modal,
    .drawer,
    .c-modal,
    .c-drawer,
    [role="dialog"],
    [aria-modal="true"]
  ) :is(
    .modal-close,
    .drawer-close,
    .close,
    .btn-close,
    [aria-label="閉じる"],
    [aria-label="Close"]
  ) {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-home .store-tab,
  .one-hand-btn {
    transition: none;
  }
}

/* =============================================
   freeworks セクション: スマホ 2列グリッド
   ============================================= */
@media (max-width: 767px) {
  .portal-home .freeworks-section .store-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row;
    gap: 0.6rem;
    overflow-x: visible;
    overflow-y: visible;
    padding-bottom: 0;
    -webkit-overflow-scrolling: auto;
    scroll-snap-type: none;
  }

  .portal-home .freeworks-section .book-card {
    border: 1px solid var(--portal-border, #e6e6e6);
    border-radius: 12px;
    box-shadow: none;
  }

  .portal-home .freeworks-section .book-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 8px 10px;
  }

  .portal-home .freeworks-section .book-tags {
    order: 1;
    margin: 0;
    gap: 4px;
  }

  .portal-home .freeworks-section .book-title {
    order: 2;
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .portal-home .freeworks-section .book-tag {
    font-size: 0.62rem;
    min-height: 18px;
    padding: 0 6px;
  }

  .portal-home .freeworks-section .book-sub,
  .portal-home .freeworks-section .book-cta {
    display: none;
  }

  .portal-home .freeworks-section .book-store-link-list {
    display: none;
  }
}

.portal-fixed-cta {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  min-height: 52px;
  border-radius: 999px;
  background: var(--portal-highlight, #ff9900);
  color: #181818;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(255, 153, 0, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.portal-fixed-cta:hover,
.portal-fixed-cta:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 153, 0, 0.4);
}

.portal-fixed-note {
  margin: 0;
  font-size: 0.72rem;
  color: var(--portal-muted, #666);
}

/* 利き手: 下部CTAバーの寄せ位置 */
body[data-one-hand="on"][data-handedness="right"] .portal-fixed-bottom {
  align-items: flex-end;
}

body[data-one-hand="on"][data-handedness="left"] .portal-fixed-bottom {
  align-items: flex-start;
}

/* 固定バー分の下余白 */
.portal-home {
  padding-bottom: 96px;
}

/* ウィジェットを固定バーの上に配置 */
.one-hand-widget {
  bottom: 96px;
}

@media (min-width: 768px) {
  .portal-fixed-bottom {
    display: none;
  }

  .portal-home {
    padding-bottom: 0;
  }

  .one-hand-widget {
    bottom: 72px;
  }
}
