/* ==========================================================================
   壁紙カタログ(/wallpaper)専用スタイル。色・書体・角丸は style.css のトークンを使う。
   (2026-10-23追加。docs/plans/2026-10-23_壁紙カタログ追加計画.md)
   ========================================================================== */

/* カタログの一覧(入口) */
.wp-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.wp-cat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 22px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-trust);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wp-cat-card:focus-visible,
.wp-card:focus-visible {
  outline: 3px solid var(--color-trust);
  outline-offset: 2px;
}

.wp-cat-card:hover,
.wp-cat-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.wp-cat-name {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-heading);
}

.wp-cat-ed {
  font-size: var(--fs-2sm);
  line-height: 1.5;
}

.wp-cat-lead {
  font-size: 0.88rem;
  line-height: 1.7;
}

.wp-cat-n {
  margin-top: auto;
  padding-top: 8px;
  font-size: var(--fs-sm);
  color: var(--color-trust);
  font-weight: 700;
}

/* 絞り込みと件数 */
.wp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 20px;
}

.wp-search-label {
  font-weight: 700;
  font-size: var(--fs-md);
}

.wp-search {
  flex: 1 1 280px;
  width: auto;
  max-width: 480px;
  padding: 10px 12px;
  border: 1px solid #8C8270;
  border-radius: var(--radius);
  background: var(--color-white);
  font-size: var(--fs-base);
  font-family: inherit;
  color: var(--color-text);
}

.wp-count {
  margin: 0;
  font-size: var(--fs-md);
}

/* 壁紙の格子 */
.wp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.wp-card {
  display: block;
  width: 100%;
  padding: 0;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  color: var(--color-text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wp-card:hover,
.wp-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.wp-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--color-bg-alt);
}

.wp-card-no {
  display: block;
  padding: 8px 6px;
  font-size: var(--fs-md2);
  font-weight: 700;
  word-break: break-all;
}

.wp-more {
  margin-top: 24px;
  text-align: center;
}

/* .btn の display が hidden 属性を上書きしないようにする */
.wp-more [hidden],
.wp-dialog-actions [hidden],
.wp-dialog-desc[hidden] {
  display: none !important;
}

.wp-empty {
  grid-column: 1 / -1;
  padding: 24px 0;
}

/* 詳細(ダイアログ) */
.wp-dialog {
  width: min(94vw, 760px);
  max-height: 90vh;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
  overflow: auto;
}

.wp-dialog::backdrop {
  background: rgba(44, 74, 82, 0.6);
}

.wp-dialog-inner {
  position: relative;
  padding: 28px 24px 24px;
}

.wp-dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--color-white);
  color: var(--color-heading);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.wp-dialog-cat {
  margin: 0 0 4px;
  font-size: var(--fs-sm);
  color: var(--color-trust);
  font-weight: 700;
}

.wp-dialog h2 {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  color: var(--color-heading);
  font-size: 1.5rem;
  word-break: break-all;
}

.wp-dialog-desc {
  margin: 0 0 16px;
  line-height: 1.9;
  font-size: var(--fs-md2);
}

.wp-dialog-section {
  margin: 20px 0 8px;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--color-heading);
}

.wp-dialog-imgs {
  display: grid;
  gap: 10px;
}

.wp-dialog-imgs img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius);
  background: var(--color-bg-alt);
}

/* 施工事例の写真(押すとチップに切り替わる) */
.wp-flip {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.wp-flip-tag {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--color-trust);
  color: var(--color-white);
  font-size: var(--fs-2sm);
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.wp-flip:focus-visible {
  outline: 3px solid var(--color-trust);
  outline-offset: 2px;
}

.wp-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.wp-dialog-actions .btn {
  flex: 1 1 220px;
  text-align: center;
}

@media (max-width: 768px) {
  .wp-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
  }

  .wp-dialog-inner {
    padding: 24px 16px 20px;
  }
}

/* --------------------------------------------------------------------------
   スマホ用: 1枚ずつ見る「カスケード」表示(js/wallpaper-cascade.js)
   スクロールの間、画面に留まる枠(.wpc-sticky)の中で、カードの束が進む
   -------------------------------------------------------------------------- */
.wpc-back { display: none; }

@media (max-width: 768px) {
  body:not(.wpc-on) .wpc-back { display: inline-flex; margin-left: auto; padding: 8px 14px; font-size: var(--fs-sm); }

  /* カスケードの間は、格子の一覧を隠す(注記と戻るリンクは残す) */
  body.wpc-on .wp-toolbar,
  body.wpc-on .wp-grid,
  body.wpc-on .wp-more { display: none; }

  .wpc {
    --wpc-bar: 76px;                 /* 画面下の固定CTAバーの高さ */
    --wpc-pane-h: calc(100vh - var(--header-height) - var(--wpc-bar));
    --wpc-bg-1: var(--color-bg-soft);
    --wpc-bg-2: var(--color-border-soft);
    --wpc-ink: var(--color-heading);
    --wpc-muted: rgba(92, 58, 36, 0.8);
    --wpc-line: rgba(92, 58, 36, 0.18);
    --wpc-accent: var(--color-trust);
    position: relative;
    padding: 0;
    height: calc(var(--wpc-pane-h) + var(--wpc-travel, 0px));
    background: var(--wpc-bg-2);
  }

  /* アドレスバーが出入りしても高さが変わらない単位を使う */
  @supports (height: 100svh) {
    .wpc { --wpc-pane-h: calc(100svh - var(--header-height) - var(--wpc-bar)); }
  }

  .wpc-sticky {
    position: sticky;
    top: var(--header-height);
    height: var(--wpc-pane-h);
    overflow: hidden;
    background: radial-gradient(130% 100% at 50% 12%, var(--wpc-bg-1) 0%, var(--wpc-bg-2) 78%);
    color: var(--wpc-ink);
    user-select: none;
    -webkit-user-select: none;
  }

  /* 3Dの舞台 */
  .wpc-stage {
    position: absolute;
    inset: 0;
    perspective: var(--persp, 1300px);
    perspective-origin: 50% 38%;
  }

  .wpc-deck {
    position: absolute;
    left: 46%;
    top: 65%;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
  }

  .wpc-card {
    position: absolute;
    width: var(--cw, 240px);
    height: var(--ch, 278px);
    left: calc(var(--cw, 240px) / -2);
    top: calc(var(--ch, 278px) / -2);
    transform-style: preserve-3d;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    cursor: pointer;
  }

  .wpc-face {
    position: absolute;
    inset: 0;
    border-radius: 22px;
    overflow: hidden;
    background: var(--color-text);
    box-shadow:
      0 2px 3px rgba(58, 51, 43, 0.12),
      0 22px 40px -18px rgba(58, 51, 43, 0.5),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  .wpc-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  /* 文字を読みやすくする影(下は品番、上は番号の札のため) */
  .wpc-scrim {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      linear-gradient(to top, rgba(30, 24, 18, 0.82) 0%, rgba(30, 24, 18, 0.32) 32%, rgba(30, 24, 18, 0) 58%),
      linear-gradient(to bottom, rgba(30, 24, 18, 0.3) 0%, rgba(30, 24, 18, 0) 22%);
  }

  /* カードの傾きに合わせた照り */
  .wpc-face::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0.2) 100%);
    opacity: var(--sheen, 0.5);
    mix-blend-mode: soft-light;
  }

  .wpc-body {
    position: absolute;
    inset: 0;
    z-index: 2;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--color-white);
  }

  .wpc-top { display: flex; align-items: center; justify-content: space-between; }

  .wpc-idx {
    font: 700 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
    letter-spacing: 0.1em;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(30, 24, 18, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.28);
  }

  .wpc-kicker {
    margin: 0 0 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: rgba(255, 255, 255, 0.78);
  }

  .wpc-no {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 7.4vw, 2.1rem);
    font-weight: 700;
    line-height: 1.05;
    color: var(--color-white);
    text-shadow: 0 1px 18px rgba(0, 0, 0, 0.25);
    word-break: break-all;
  }

  .wpc-meta {
    margin: 8px 0 0;
    font-size: var(--fs-xs);
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.82);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  /* 上の見出し */
  .wpc-hero {
    position: absolute;
    top: clamp(14px, 4vw, 26px);
    left: 0;
    right: 0;
    z-index: 5;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    pointer-events: none;            /* 見出しの後ろに来たカードも押せるように */
  }

  .wpc-cta { pointer-events: auto; }

  .wpc-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--wpc-muted);
  }

  .wpc-eyebrow::before,
  .wpc-eyebrow::after {
    content: "";
    width: 18px;
    height: 1px;
    background: currentColor;
    opacity: 0.6;
  }

  .wpc-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.45rem, 7.2vw, 2.2rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    color: var(--wpc-ink);
    text-wrap: balance;
  }

  .wpc-cta {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 16px 10px 20px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font: 700 0.85rem/1 var(--font-body);
    color: var(--color-white);
    background: var(--wpc-accent);
    box-shadow: 0 10px 24px -10px rgba(44, 74, 82, 0.7);
  }

  .wpc-cta:focus-visible,
  .wpc-tolist:focus-visible { outline: 2px solid var(--wpc-accent); outline-offset: 3px; }

  .wpc-cta-ico {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
  }

  .wpc-cta-ico svg { width: 13px; height: 13px; }

  /* 右端の進み具合(押す・なぞるで品番を選べる) */
  .wpc-rail {
    position: absolute;
    right: 6px;
    top: 65%;
    transform: translateY(-50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .wpc-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-heading);
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  .wpc-cur { font-size: 1.35rem; font-weight: 700; color: var(--wpc-ink); }
  .wpc-tot { margin-top: 3px; font-size: 0.68rem; font-weight: 700; color: var(--wpc-muted); }

  .wpc-track {
    position: relative;
    width: 36px;                       /* 指で押しやすい幅 */
    height: clamp(130px, 30vh, 240px);
    cursor: pointer;
    touch-action: none;
  }

  .wpc-track::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: var(--wpc-line);
    border-radius: 2px;
  }

  .wpc-fill {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 0;
    transform: translateX(-50%);
    border-radius: 2px;
    background: var(--wpc-accent);
  }

  .wpc-thumb {
    position: absolute;
    left: 50%;
    top: 0;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--wpc-accent);
    box-shadow: 0 0 0 4px rgba(44, 74, 82, 0.18);
  }

  .wpc-tolist {
    min-height: 44px;
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 6;
    padding: 8px 14px;
    border: 1px solid var(--wpc-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    font: 700 0.78rem/1 var(--font-body);
    color: var(--wpc-ink);
    cursor: pointer;
  }

  .wpc-hint {
    position: absolute;
    right: 14px;
    bottom: 18px;
    z-index: 6;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--wpc-muted);
    transition: opacity 0.4s ease;
  }

  .wpc-hint::after { content: " ↓"; }
  .wpc-hint.is-hidden { opacity: 0; }

  .wpc-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* カタログの一覧(入口)のカードの見本画像 */
.wp-cat-thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: var(--color-bg-alt);
}

/* 一覧の下の相談への道 */
.wp-consult-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0 32px;
}

/* 詳細の画面の「前へ」「次へ」 */
.wp-dialog-nav {
  display: flex;
  gap: 12px;
  margin: 0 40px 12px 0;
}

.wp-dialog-nav[hidden] {
  display: none;
}

.wp-dialog-nav .btn {
  flex: 1 1 0;
  padding: 10px 16px;
  font-size: var(--fs-md);
}

.wp-dialog-nav .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 詳細の画面の画像は、枠の縦横比を決めて、その中に収める */
.wp-dialog-imgs img,
.wp-flip img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

/* 一覧に戻るリンクを押しやすくする(2026-11-28) */
.mt-24 > a[href="/wallpaper"] { display: inline-flex; align-items: center; min-height: 44px; }
