/* =========================================================
   Rin Blog Apps — portal.css
   ページ1固有:ツールバー / アイコンビュー(ボード) /
   ギャラリービュー(ステージ+レール)
   サムネイルは白枠に入れず、画像そのものをカードとして見せる
   ========================================================= */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- ツールバー ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  margin-bottom: 26px;
}

.filter-group { display: flex; gap: 8px; }

.filter-chip {
  padding: 7px 18px;
  border: 1px solid var(--desk-line);
  border-radius: 999px;
  background: var(--desk-tint);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease;
}

.filter-chip:hover { background: rgba(255, 255, 255, .75); color: var(--ink); }

/* 選択中は赤(選択=赤リングと同じ言語) */
.filter-chip.is-on {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 5px rgba(96, 74, 42, .28);
}

.view-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--desk-tint);
  border: 1px solid var(--desk-line);
}

.view-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  transition: background .15s ease;
}

.view-toggle svg { width: 17px; height: 17px; fill: var(--ink-soft); }

.view-toggle:hover { background: rgba(255, 255, 255, .75); }

.view-toggle.is-on { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); }
.view-toggle.is-on svg { fill: #fff; }

/* =========================================================
   サムネイル共通:「画像そのもの」がカード
   (ボード / レール / ステージで共用)
   ========================================================= */
.shot { position: relative; }

.shot-img {
  width: 100%;
  aspect-ratio: 300 / 169;
  /* 全OGPが1200×676(=300:169)で統一されているため cover でもトリミングなし */
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 3px 8px rgba(96, 74, 42, .20), 0 12px 24px rgba(96, 74, 42, .14);
  transition: box-shadow .18s ease;
}

/* 番号プレート(画像左上の角にオーバーレイ) */
.shot .num-plate {
  position: absolute;
  top: -9px;
  left: -7px;
  z-index: 2;
}

/* カテゴリチップ(画像右下の内側にオーバーレイ) */
.cat-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.cat-chip.game { background: var(--cat-game); }
.cat-chip.tool { background: var(--cat-tool); }

.shot .cat-chip {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  box-shadow: 0 2px 5px rgba(40, 28, 12, .35);
}

/* 選択リング(太い赤・画像の輪郭を直接囲う) */
.pick-ring {
  position: absolute;
  inset: -7px;
  border: 4px solid var(--accent);
  border-radius: 21px;
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   アイコンビュー(ボード)
   ========================================================= */
.board-grid {
  list-style: none;
  margin: 0 auto;
  padding: 14px 4px 4px;
  max-width: 1020px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
  gap: 38px 30px;
}

.app-card {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-card.is-filtered { display: none; }

.app-card .shot { transition: transform .18s ease; }

.app-card.is-picked .pick-ring { opacity: 1; }

/* 卓上の名前(画像下) */
.card-label {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

/* ホバー時:番号札+名前札の2連ツールチップ */
.hover-tags {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translate(-50%, 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 5;
}

.tag-num {
  padding: 2px 12px;
  border-radius: 7px;
  background: var(--plate);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 2px 5px rgba(96, 74, 42, .30);
}

.tag-name {
  position: relative;
  padding: 5px 14px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(96, 74, 42, .28);
}

/* 名前札の下向きしっぽ */
.tag-name::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--card);
  border-bottom-width: 0;
}

@media (hover: hover) {
  .app-card:hover .hover-tags,
  .app-card:focus-visible .hover-tags {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  /* 画像自体がふわっと浮く */
  .app-card:hover .shot { transform: translateY(-5px); }
  .app-card:hover .shot-img {
    box-shadow: 0 8px 14px rgba(96, 74, 42, .22), 0 20px 38px rgba(96, 74, 42, .18);
  }
}

/* =========================================================
   ギャラリービュー(ステージ+レール)
   ========================================================= */
.stage-panel-area {
  position: relative;
  max-width: 880px;
  margin: 6px auto 0;
  /* 吹き出しのしっぽ位置(JSが更新) */
  --beak-x: 50%;
}

.stage-panel {
  display: grid;
  grid-template-columns: minmax(0, 11fr) minmax(0, 9fr);
  gap: 22px;
  align-items: center;
  padding: 22px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  box-shadow: var(--shadow-card);
}

/* パネル内も画像を直接見せる(枠・下地なし) */
.stage-art {
  aspect-ratio: 300 / 169;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(96, 74, 42, .16);
}

.stage-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-body { color: var(--ink); min-width: 0; }

.stage-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
}

.stage-title {
  margin: 0 0 8px;
  font-size: clamp(19px, 3vw, 24px);
  font-weight: 800;
  line-height: 1.35;
}

.stage-desc {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink-soft);
}

/* 吹き出しポインタ(レール側へ伸びるしっぽ) */
.stage-beak {
  position: absolute;
  top: 100%;
  left: var(--beak-x);
  transform: translateX(-50%);
  border: 14px solid transparent;
  border-top: 16px solid var(--card);
  border-bottom-width: 0;
  filter: drop-shadow(0 4px 3px rgba(96, 74, 42, .22));
  transition: left .3s ease;
}

/* ---------- レール(下部カルーセル) ---------- */
.rail-wrap { margin-top: 34px; }

.rail {
  list-style: none;
  margin: 0;
  display: flex;
  gap: 26px;
  padding: 22px 18px 30px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 98, 60, .40) transparent;
}

.rail-item {
  position: relative;
  flex: 0 0 168px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rail-item .shot-img {
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(96, 74, 42, .20), 0 8px 16px rgba(96, 74, 42, .12);
}

.rail-item .pick-ring {
  inset: -6px;
  border-radius: 18px;
}

.rail-item.is-picked .pick-ring { opacity: 1; }

.rail-label {
  margin-top: 9px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   アニメーション(reduced-motion時は再生しない)
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {
  /* 出現 */
  .app-card {
    animation: deal-in .4s ease backwards;
  }

  @keyframes deal-in {
    from { opacity: 0; transform: translateY(14px) scale(.96); }
    to   { opacity: 1; transform: none; }
  }

  /* 選択時:太い赤リングの脈動 */
  .app-card.is-picked .pick-ring,
  .rail-item.is-picked .pick-ring {
    animation: ring-pulse 1.1s ease-in-out infinite;
  }

  @keyframes ring-pulse {
    0%, 100% { transform: scale(1);     opacity: 1; }
    50%      { transform: scale(1.04);  opacity: .65; }
  }

  /* 選択時:画像が弾むバウンス */
  .app-card.is-picked .shot,
  .rail-item.is-picked .shot {
    animation: card-bounce .5s cubic-bezier(.34, 1.56, .64, 1);
  }

  @keyframes card-bounce {
    0%   { transform: translateY(0); }
    35%  { transform: translateY(-12px) scale(1.03); }
    65%  { transform: translateY(3px); }
    100% { transform: translateY(0); }
  }

  /* ステージ詳細の切替 */
  .stage-panel.is-flipping .stage-art,
  .stage-panel.is-flipping .stage-body {
    animation: stage-in .3s ease;
  }

  @keyframes stage-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
  }
}

/* =========================================================
   レスポンシブ
   ========================================================= */
@media (max-width: 760px) {
  .stage-panel {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }
  .rail-item { flex-basis: 138px; }
}

@media (max-width: 560px) {
  .board-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px 18px;
  }
  .card-label { font-size: 11px; }
  .shot-img { border-radius: 11px; }
  .pick-ring { inset: -6px; border-radius: 17px; }
  .shot .num-plate { top: -8px; left: -5px; font-size: 10px; padding: 2px 8px; }
  .shot .cat-chip { right: 6px; bottom: 6px; }
  .cat-chip { font-size: 10px; }
  .rail { gap: 20px; }
  .rail-item { flex-basis: 118px; }
  .hover-tags { display: none; } /* タッチ主体の幅ではツールチップを出さない */
}
