/**
 * TOPページ — html-chech index.html
 * .mock-section / .mock-container / .mock-scroll-outer と同じレイアウト規則
 */

/* ----- .mock-section ----- */
.home-section {
  padding: var(--space-8) var(--space-4);
  background: var(--color-base-2);
  box-sizing: border-box;
}

@media (min-width: 1280px) {
  .home-section {
    padding-inline: 0;
  }
}

.home-section--alt {
  background: var(--color-base-1);
}

.home-section--worries {
  background: var(--color-section-feed-bg);
  border-top: 1px solid var(--color-section-feed-border);
}

/* ----- .mock-container（theme .container とは別・モックと同じパディング） ----- */
.home-container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
  box-sizing: border-box;
}

@media (min-width: 1280px) {
  .home-container {
    --home-container-pad-x: clamp(
      var(--space-4),
      calc((100vw - var(--home-three-cards-width)) / 2),
      var(--layout-gutter-x-max)
    );
    padding-inline: var(--home-container-pad-x);
  }
}

/* カテゴリ塊は mock と同様、見出し・グリッドの margin で縦間隔（flex gap は使わない） */
.home-section--alt .home-section__head {
  margin-bottom: var(--space-6);
}

.home-section--cat-scroll .home-container {
  display: flex;
  flex-direction: column;
  gap: 1.875rem;
}

.home-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.home-section--cat-scroll .home-section__head {
  margin-bottom: 0;
}

.home-section__head--feed {
  align-items: flex-end;
}

/* .mock-heading */
.home-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.home-heading__bar {
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--color-main);
  flex-shrink: 0;
}

/* .mock-heading--feed / .mock-heading__bar--emerald */
.home-heading--feed {
  font-size: 1.5rem;
  font-weight: var(--font-weight-black);
  line-height: 1.2;
}

.home-heading__bar--accent {
  width: 4px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--home-section-heading-accent);
}

.home-link-more {
  font-size: var(--font-size-base);
  color: var(--color-main-dark);
  font-weight: var(--font-weight-bold);
  white-space: nowrap;
  text-decoration: none;
}

.home-link-more::after {
  content: " ›";
}

.home-link-more:hover {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.home-link-more:focus-visible {
  outline: 2px solid var(--color-main);
  outline-offset: 2px;
}

.home-link-more--feed {
  color: var(--home-section-heading-accent);
  padding-top: 4px;
  padding-bottom: 2px;
}

.home-link-more--desktop {
  display: inline-flex;
}

.home-feed-rail .home-feed-more-inline {
  display: none;
}

/* SP: 横スクロール / PC: 5件を1行で均等配分（auto-fit+200px だと5列目が折り返すため flex に変更） */
.home-cat-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: var(--space-4);
  margin: 0 0 var(--space-6);
  padding-inline: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* pan-x のみだとカード上で縦スワイプしたときページの縦スクロールが
     ブロックされ「数秒スクロールが固まる」ため、縦パンも許可する。 */
  touch-action: pan-x pan-y;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: var(--space-2);
}

/* SP 限定で、padding を持つ親（.home-container / .container）配下のときだけ
   「左右に飛び出させて画面端まで広げる」挙動を有効化する。
   別レイアウト下で使われたときの横はみ出し（左右ぶれ）を防ぐため、限定スコープにする。 */
@media (max-width: 768px) {
  .home-container > .home-cat-grid,
  .container > .home-cat-grid {
    margin-inline: calc(-1 * var(--space-4));
    padding-inline: var(--space-4);
    width: calc(100% + 2 * var(--space-4));
    scroll-padding-inline: var(--space-4);
  }
}

/* SP: カテゴリ探すセクションを画面全幅スクロールに
   body { overflow-x: clip } があるためネガティブマージン方式は使えず、
   セクション・コンテナの横 padding を除去してグリッドを自然に全幅に広げる方式を採用 */
@media (max-width: 768px) {
  .home-section--cat-explore {
    padding-inline: 0;
  }

  .home-section--cat-explore > .home-container {
    padding-inline: 0;
  }

  /* 見出しとタグ行には個別に左右パディングを復元 */
  .home-section--cat-explore .home-section__head,
  .home-section--cat-explore .home-tags-row {
    padding-inline: var(--space-4);
  }

  /* グリッド: ネガティブマージン不要・左パディングで整列 */
  .home-section--cat-explore .home-cat-grid {
    margin-inline: 0;
    padding-inline-start: var(--space-4);
    padding-inline-end: 0;
    width: 100%;
    scroll-padding-inline-start: var(--space-4);
  }

  /* 3枚目のぞき見が出るようカード幅を縮小 */
  .home-section--cat-explore .home-cat-card {
    flex: 0 0 38vw;
  }
}

.home-cat-grid::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

@media (min-width: 769px) {
  .home-cat-grid {
    flex-wrap: nowrap;
    gap: var(--space-6);
    margin: 0 0 var(--space-6);
    padding-inline: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: visible;
    overflow-y: visible;
    touch-action: auto;
    scroll-snap-type: none;
    padding-bottom: 0;
  }
}

.home-cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-lg);
  flex: 0 0 min(42vw, calc(var(--space-8) * 4 + var(--space-10)));
  min-width: 0;
  scroll-snap-align: start;
  transition:
    opacity var(--transition-fast),
    box-shadow var(--transition-fast);
}

@media (min-width: 769px) {
  .home-cat-card {
    flex: 1 1 0;
    scroll-snap-align: none;
  }
}

.home-cat-card:hover {
  opacity: 0.92;
}

.home-cat-card:focus-visible {
  outline: 2px solid var(--color-main);
  outline-offset: 3px;
}

.home-cat-card__visual {
  position: relative;
  width: 100%;
  aspect-ratio: 230 / 153;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  margin-bottom: var(--space-3);
  background: var(--color-base-2);
  display: block;
  overflow: hidden;
}

.home-cat-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.home-cat-card__label {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

/* .mock-tags-row / .mock-tag */
.home-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.home-tags-row__label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  margin-right: var(--space-2);
}

/* 記事詳細・相談詳細ページの「おすすめタグ」と同じピル型ビジュアルで揃える */
.home-tags-row__tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  background: var(--color-thread-detail-pill-hash-bg);
  color: var(--color-thread-detail-muted);
  text-decoration: none;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast);
}

.home-tags-row__tag:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
  opacity: 1;
}

.home-tags-row__tag:focus-visible {
  outline: 2px solid var(--color-main);
  outline-offset: 2px;
}

/* .mock-scroll-outer（mock.css と同じ: 見出し列幅と先頭カードの左を揃える） */
.home-scroll-outer {
  width: 100%;
  max-width: min(var(--container-wide-max), 100%);
  margin-top: 0;
  margin-inline: auto;
  padding-inline: 0;
  box-sizing: border-box;
}

@media (min-width: 1280px) {
  .home-container .home-scroll-outer {
    width: calc(100% + var(--home-container-pad-x));
    max-width: min(100vw, var(--container-wide-max));
    margin-left: 0;
    margin-right: calc(-1 * var(--home-container-pad-x));
    margin-inline: 0;
  }
}

/* .mock-scroll.mock-scroll--worries */
.home-feed-scroll {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  gap: min(
    var(--home-scroll-gap-max),
    max(var(--home-scroll-gap-min), calc((100% - var(--home-three-cards-width)) / 2))
  );
  overflow-x: auto;
  padding-bottom: var(--space-4);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  cursor: grab;
  scrollbar-width: none;
  -ms-overflow-style: none;
  min-width: 0;
}

.top-page .home-feed-rail .home-feed-scroll::after {
  content: "";
  flex: 0 0 0;
  width: 0;
  pointer-events: none;
}

.home-feed-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* リンクドラッグで横スクロールが奪われない（mock.css .mock-scroll a） */
.home-feed-scroll a {
  -webkit-user-drag: none;
  user-select: none;
}

.home-feed-scroll.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

.home-feed-empty {
  margin: 0;
  padding: var(--space-4) 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.home-feed-rail .home-feed-scroll .thread-card--home-rail {
  flex: 0 0 var(--home-feed-card-width);
  width: var(--home-feed-card-width);
  max-width: min(var(--home-feed-card-width), 85vw);
  scroll-snap-align: start;
}

@media (min-width: 769px) {
  .home-feed-rail .home-scroll-outer {
    padding-right: 0;
  }

  .home-feed-rail.home-section--ranked .thread-card__rank-badge {
    left: -6px;
    right: auto;
  }

  .home-feed-rail .home-feed-scroll::after {
    flex: 0 0 clamp(var(--space-6), 4vw, var(--space-10));
    width: clamp(var(--space-6), 4vw, var(--space-10));
  }

  .home-feed-rail .home-feed-scroll {
    align-items: stretch;
    width: 100%;
    max-width: 100%;
  }

  .home-feed-rail .home-feed-item {
    display: flex;
    align-self: stretch;
  }

  .home-feed-rail .home-feed-item .thread-card--home-rail {
    display: flex;
    flex-direction: column;
    min-height: 100%;
  }

  .home-feed-rail .home-feed-item .thread-card--home-rail .thread-card__footer {
    margin-top: auto;
  }
}

.home-feed-rail.home-section--ranked .thread-card--ranked {
  position: relative;
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  width: 44px;
  height: 52px;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}

@keyframes top-rank-shine {
  0% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

.home-feed-rail.home-section--ranked .thread-card__rank-face {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 44px;
  height: 52px;
  clip-path: polygon(0 0, 100% 0, 100% 82%, 50% 100%, 0 82%);
  color: var(--color-base-1);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge--sub .thread-card__rank-face {
  background: linear-gradient(
    160deg,
    var(--color-rank-sub-light) 0%,
    var(--color-rank-sub-mid) 50%,
    var(--color-rank-sub-dark) 100%
  );
  color: var(--color-text-primary);
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge--1 .thread-card__rank-face {
  background: linear-gradient(
    160deg,
    var(--color-rank-gold-light) 0%,
    var(--color-rank-gold-mid) 40%,
    var(--color-rank-gold-dark) 100%
  );
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge--2 .thread-card__rank-face {
  background: linear-gradient(
    160deg,
    var(--color-rank-silver-light) 0%,
    var(--color-rank-silver-mid) 50%,
    var(--color-rank-silver-dark) 100%
  );
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge--3 .thread-card__rank-face {
  background: linear-gradient(
    160deg,
    var(--color-rank-bronze-light) 0%,
    var(--color-rank-bronze-mid) 50%,
    var(--color-rank-bronze-dark) 100%
  );
}

.home-feed-rail.home-section--ranked .thread-card__rank-crown {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.home-feed-rail.home-section--ranked .thread-card__rank-digit {
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--color-text-primary) 20%, transparent 80%);
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge--sub .thread-card__rank-digit {
  text-shadow: none;
}

.home-feed-rail.home-section--ranked .thread-card__rank-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    color-mix(in srgb, var(--color-base-1) 45%, transparent 55%) 45%,
    color-mix(in srgb, var(--color-base-1) 10%, transparent 90%) 55%,
    transparent 100%
  );
  animation: top-rank-shine 3.8s ease-in-out infinite;
  animation-delay: 0.6s;
}

.home-feed-rail.home-section--ranked .thread-card__rank-badge--sub .thread-card__rank-shine {
  display: none;
}

.home-feed-rail.home-section--ranked .thread-card--ranked .thread-card__top-meta {
  padding-left: calc(44px + var(--space-3));
}

@media (prefers-reduced-motion: reduce) {
  .home-feed-rail.home-section--ranked .thread-card__rank-shine {
    animation: none;
    display: none;
  }
}

/* 「もっと見る」一覧（縦並び）：左をコンテンツ列に揃える（中央寄せは見出しとズレる） */
.top-page .feed-list.card-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  align-items: flex-start;
  width: 100%;
}

.top-page .feed-list .thread-card--home-rail {
  flex: none;
  width: 100%;
  max-width: var(--home-feed-card-width);
  scroll-snap-align: none;
}

.top-page__list-wrap {
  padding-block: var(--space-8);
}

@media (max-width: 768px) {
  .home-feed-rail .home-scroll-outer {
    overflow-x: hidden;
  }

  .top-page .home-feed-rail .home-scroll-outer {
    padding-right: 0;
  }

  .top-page .home-feed-rail .home-feed-scroll::after {
    content: none;
    flex-basis: 0;
    width: 0;
  }

  .home-link-more--desktop {
    display: none;
  }

  .home-feed-rail.home-section--ranked .thread-card__rank-badge {
    left: auto;
    right: var(--space-2);
    height: 42px;
  }

  .home-feed-rail.home-section--ranked .thread-card--ranked .thread-card__top-meta {
    padding-left: 0;
    padding-right: calc(44px + var(--space-3));
  }

  .home-feed-rail.home-section--ranked .thread-card__rank-face {
    height: 42px;
  }

  .home-section--cat-scroll .home-container {
    gap: var(--space-6);
  }

  .home-section__head--feed {
    justify-content: flex-start;
    margin-bottom: var(--space-3);
  }

  .home-feed-rail .home-feed-item {
    width: 100%;
  }

  .home-feed-rail .home-feed-item--mobile-hidden {
    display: none;
  }

  .home-feed-rail .home-feed-more-inline {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-top: var(--space-1);
  }

  .home-feed-rail .home-feed-more-inline .home-link-more {
    display: inline-flex;
    align-items: center;
  }

  .home-feed-rail .home-feed-scroll {
    flex-direction: column;
    gap: 2.4rem; /* 24px -> 約38px（1.6倍・スマホのみ） */
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: 0;
    scroll-snap-type: none;
    touch-action: auto;
    cursor: default;
  }

  .home-feed-rail .home-feed-scroll .thread-card--home-rail {
    flex: none;
    width: 100%;
    max-width: 100%;
    scroll-snap-align: none;
  }

  .top-page__list-wrap {
    padding-block: var(--space-6);
  }
}

/* --------------------------------------------------------------------------
   TOP: インタビュー記事の横スクロール / PC3列 (home-interview-rail)
   .home-feed-rail と同じ外枠（.home-section / .home-container /
   .home-scroll-outer）を使用し、カード部分だけ .article-card を採用。
   -------------------------------------------------------------------------- */
.home-interview-scroll {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  gap: min(
    var(--home-scroll-gap-max),
    max(var(--home-scroll-gap-min), calc((100% - var(--home-three-cards-width)) / 2))
  );
  overflow-x: auto;
  padding-bottom: var(--space-4);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  cursor: grab;
  scrollbar-width: none;
  -ms-overflow-style: none;
  min-width: 0;
}

.home-interview-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.home-interview-scroll a {
  -webkit-user-drag: none;
  user-select: none;
}

.home-interview-scroll.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

.home-interview-item {
  flex: 0 0 var(--home-feed-card-width);
  width: var(--home-feed-card-width);
  max-width: min(var(--home-feed-card-width), 85vw);
  scroll-snap-align: start;
  display: flex;
}

.home-interview-item .article-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.home-interview-item .article-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.home-interview-item .article-card__thumb {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-border-light);
}

.home-interview-item .article-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-interview-item .article-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
}

.home-interview-item .article-card__type {
  align-self: flex-start;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-main);
  color: var(--color-text-inverse);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
}

/* コラム・Tips レール: バッジ色だけ差別化（レイアウトは interview-rail と共有） */
.home-tip-rail .home-interview-item .article-card__type--tip {
  background: var(--color-accent-2);
}

.home-interview-item .article-card__subject {
  margin: 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.home-interview-item .article-card__title {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  line-height: 1.5;
}

.home-interview-item .article-card__title a {
  color: inherit;
  text-decoration: none;
}

.home-interview-item .article-card__title a:hover {
  color: var(--color-main);
}

.home-interview-item .article-card__date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.home-interview-rail .home-interview-more-inline {
  display: none;
}

@media (min-width: 769px) {
  .home-interview-rail .home-interview-scroll {
    align-items: stretch;
    width: 100%;
    max-width: 100%;
  }

  .home-interview-item .article-card {
    flex: 1;
    min-height: 100%;
  }
}

@media (max-width: 768px) {
  .home-interview-rail .home-scroll-outer {
    overflow-x: hidden;
  }

  .home-interview-rail .home-interview-scroll {
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: 0;
    scroll-snap-type: none;
    touch-action: auto;
    cursor: default;
  }

  .home-interview-rail .home-interview-item {
    flex: none;
    width: 100%;
    max-width: 100%;
    scroll-snap-align: none;
  }

  .home-interview-rail .home-interview-item--mobile-hidden {
    display: none;
  }

  .home-interview-rail .home-interview-more-inline {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-top: var(--space-1);
  }

  .home-interview-rail .home-interview-more-inline .home-link-more {
    display: inline-flex;
    align-items: center;
  }
}
