/*
 * Method Motion — サイト共通スタイル
 * トーンは /image-gallery と揃える（ダーク基調・Neue Haas Unica・微グレイン）。
 * 一覧は画像ではなくライブデモ（iframe）を並べるため、可変高マソンリーではなく
 * 固定アスペクト比（16:10）の均等グリッドにしてある。
 */

:root {
  --bg: #070809;
  --bg-soft: #0E0F12;
  --ink: #F4F5F6;
  --ink-dim: #9A9CA1;
  --ink-faint: #5B5E66;
  --line: rgba(255, 255, 255, .10);
  --line-soft: rgba(255, 255, 255, .05);
  --accent: #8A9AA6;
  --pad: clamp(16px, 4vw, 56px);
  --font: "neue-haas-unica", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0 }

[hidden] { display: none !important }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100%; overscroll-behavior-y: none }
a { color: inherit; text-decoration: none }
img { display: block; max-width: 100% }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer }
::selection { background: var(--accent); color: #06070A }

:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px }

/* ===== 背景（固定）===== */
.space-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 18% 6%, rgba(40, 58, 72, .28), transparent 55%),
    radial-gradient(90% 70% at 86% 92%, rgba(72, 48, 40, .20), transparent 55%),
    radial-gradient(140% 120% at 50% 50%, #0A0C10 0%, #070809 60%, #050607 100%);
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 1;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@media (max-width: 640px) {
  .grain { opacity: .03 }
}

.page { position: relative; z-index: 2 }

/* ===== ヘッダー ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 8, 9, .82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

/* サイト名の横に出す一言。狭い画面ではナビと競合するので出さない */
.header-tag {
  display: none;
  font-size: 11px;
  line-height: 1;
  letter-spacing: .02em;
  color: var(--ink-faint);
  white-space: nowrap;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

@media (min-width: 1000px) {
  .header-tag { display: block }
}

.wordmark {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wordmark em { font-style: normal; color: var(--ink-dim); font-weight: 400 }

.header-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--ink-dim);
  white-space: nowrap;
}

.header-nav a { transition: color .3s var(--ease) }
.header-nav a:hover { color: var(--ink) }

@media (max-width: 560px) {
  .wordmark { font-size: 12px; letter-spacing: .1em }
  .header-nav { gap: 14px; font-size: 11px; letter-spacing: .04em }
}

/* ===== 見出しブロック ===== */
.masthead {
  padding: clamp(40px, 8vw, 88px) var(--pad) clamp(20px, 3vw, 32px);
}

.masthead h1 {
  max-width: 11em;
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.06;
}

.masthead .lead {
  margin-top: 20px;
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: .01em;
  font-weight: 500;
  color: var(--ink);
  max-width: 40em;
}

.masthead .lead + p {
  margin-top: 12px;
}

.masthead p {
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-dim);
  max-width: 54ch;
}

@media (min-width: 900px) {
  .masthead .lead { font-size: 17px }
  .masthead p { font-size: 12.5px; max-width: 78em }
}

/* ===== 広告枠（image-gallery と同じ構成。中身は data/ads.json） ===== */
.ad {
  align-self: start;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(14, 15, 18, .6);
}

/* 幅が縮んでも height 属性(250px)が残って縦に潰れないように */
.ad img { height: auto; max-width: 100% }

.ad-label {
  display: block;
  margin-bottom: 10px;
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ad-placeholder {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* 詳細ページ：サイドと本文末尾 */
.ad--detail { margin: 28px 0 0 }

/* SP: 枠・背景なしで Sponsored 表記＋バナーは周囲と同じ幅 */
@media (max-width: 640px) {
  .ad {
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
  }
  .ad a img { width: 100% }
}

/* 一覧ページの追従広告（少しスクロールでフェードイン／×でセッション中は非表示） */
.ad-float {
  position: fixed;
  right: clamp(12px, 2vw, 26px);
  bottom: clamp(12px, 2vw, 26px);
  z-index: 40;
  max-width: min(320px, calc(100vw - 24px));
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .34s var(--ease), transform .34s var(--ease);
}

.ad-float.is-in { opacity: 1; transform: none }
.ad-float[hidden] { display: none }

/* SPの .ad は枠なしにしているので、追従枠では戻す */
.ad-float .ad {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(10, 11, 13, .94);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
}

.ad-float .ad img { max-width: 100% }

.ad-float-close {
  position: absolute;
  top: -11px;
  right: -11px;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--ink-dim);
  font: 400 15px/1 var(--font);
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

.ad-float-close:hover { color: var(--ink); border-color: var(--ink-faint) }

@media (max-width: 640px) {
  .ad-float { left: 12px; right: 12px; bottom: 12px; max-width: none }
  .ad-float .ad a img { width: 100% }
}

@media (prefers-reduced-motion: reduce) {
  .ad-float { transition: none }
}

/* ===== カテゴリフィルタ ===== */
.filter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 8, 9, .82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}

.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-scroll::-webkit-scrollbar { display: none }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-dim);
  white-space: nowrap;
  transition: color .25s var(--ease), border-color .25s var(--ease), background-color .25s var(--ease);
}

.chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, .22) }

.chip[aria-current="page"] {
  color: #06070A;
  background: var(--ink);
  border-color: var(--ink);
}

.chip .n { font-size: 10px; color: var(--ink-faint); font-variant-numeric: tabular-nums }
.chip[aria-current="page"] .n { color: rgba(6, 7, 10, .5) }

/* ===== デモグリッド ===== */
.grid {
  padding: clamp(20px, 3vw, 34px) var(--pad) clamp(60px, 10vw, 120px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
}

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; gap: 16px }
}

.tile {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  transition: border-color .3s var(--ease);
}

.tile:hover { border-color: var(--line) }

/* カード全体を詳細へのリンクにする。デモの上に透明なリンクを重ね、
   iframe はポインタを受け取らないようにする（どこを押しても詳細へ飛ぶ）。 */
.tile-link {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.tile-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg);
}

.tile-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s var(--ease);
}

.tile-frame iframe.is-loaded { opacity: 1 }

.tile-open {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: rgba(7, 8, 9, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .3s var(--ease), transform .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}

.tile:hover .tile-open, .tile:focus-within .tile-open { opacity: 1; transform: none }
.tile-open:hover { color: var(--ink); border-color: rgba(255, 255, 255, .3) }

.tile-caption {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  transition: background-color .3s var(--ease);
}

.tile-caption:hover { background: rgba(255, 255, 255, .03) }

.tile-no {
  font-size: 10px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

.tile-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .02em;
}

.tile-cat {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.grid-empty {
  padding: 80px var(--pad) 120px;
  color: var(--ink-faint);
  font-size: 13px;
  letter-spacing: .06em;
}

/* ===== 詳細ページ ===== */
.detail {
  padding: clamp(22px, 4vw, 44px) var(--pad) clamp(60px, 10vw, 120px);
  max-width: 1360px;
  margin: 0 auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  transition: color .3s var(--ease);
}

.back-link:hover { color: var(--ink) }

.detail-body {
  margin-top: 26px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}

@media (max-width: 980px) { .detail-body { grid-template-columns: minmax(0, 1fr) } }

.detail-figure {
  position: relative;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}

.detail-figure iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.stage-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.stage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  transition: color .25s var(--ease), border-color .25s var(--ease);
}

.stage-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, .3) }

.detail-side { position: sticky; top: calc(var(--header-h) + 24px) }
@media (max-width: 980px) { .detail-side { position: static } }

.detail-title {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.25;
}

.detail-title-ja {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-dim);
}

.detail-meta {
  margin-top: 20px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-dim);
}

.detail-meta div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.detail-meta dt { color: var(--ink-faint); letter-spacing: .08em; text-transform: uppercase; font-size: 10px }
.detail-meta dd { font-variant-numeric: tabular-nums }
.detail-meta dd a { border-bottom: 1px solid var(--line); transition: color .25s var(--ease) }
.detail-meta dd a:hover { color: var(--ink) }

.detail-tags { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 7px }

.detail-tags a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-dim);
  transition: color .25s var(--ease), border-color .25s var(--ease);
}

.detail-tags a:hover { color: var(--ink); border-color: rgba(255, 255, 255, .24) }

/* ===== 生成プロンプト ===== */
.prompt-box {
  margin-top: 26px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: rgba(14, 15, 18, .6);
}

.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.prompt-head .section-label { padding: 0; border: 0 }

.copy-btn {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  transition: color .25s var(--ease), border-color .25s var(--ease), background-color .25s var(--ease);
}

.copy-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, .3) }
.copy-btn.is-copied { color: #06070A; background: var(--ink); border-color: var(--ink) }

.prompt-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
}

.prompt-tab {
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-dim);
  transition: color .25s var(--ease), border-color .25s var(--ease), background-color .25s var(--ease);
}

.prompt-tab:hover { color: var(--ink) }

.prompt-tab.is-active {
  color: #06070A;
  background: var(--ink);
  border-color: var(--ink);
}

.prompt-text {
  max-height: 360px;
  overflow-y: auto;
  padding: 14px;
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== 参考リンク ===== */
.refs { margin-top: 22px }

.refs ul {
  margin-top: 12px;
  list-style: none;
  font-size: 12px;
  line-height: 2;
  color: var(--ink-dim);
}

.refs a {
  border-bottom: 1px solid var(--line);
  transition: color .25s var(--ease);
}

.refs a:hover { color: var(--ink) }

.license-note {
  margin-top: 18px;
  font-size: 11px;
  line-height: 1.8;
  color: var(--ink-faint);
}

.license-note a { color: var(--ink-dim); border-bottom: 1px solid var(--line) }

/* ===== 関連 ===== */
.related { margin-top: clamp(52px, 8vw, 96px) }

.section-label {
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.related .grid { padding: 22px 0 0 }

/* ===== About ===== */
.prose {
  padding: clamp(40px, 7vw, 80px) var(--pad) clamp(60px, 10vw, 120px);
  max-width: 720px;
}

.prose h1 { font-size: clamp(26px, 4vw, 40px); font-weight: 500; letter-spacing: -.02em }
.prose h2 { margin-top: 44px; font-size: 15px; font-weight: 600; letter-spacing: .02em }
.prose p { margin-top: 14px; font-size: 14px; line-height: 1.9; color: var(--ink-dim) }
.prose .ja { font-size: 13px; color: var(--ink-faint) }
.prose ul { margin-top: 14px; padding-left: 1.1em; font-size: 14px; line-height: 1.9; color: var(--ink-dim) }
.prose a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* ===== フッター ===== */
.site-footer {
  padding: clamp(36px, 5vw, 56px) var(--pad);
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 20px 40px;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-faint);
}

.footer-note {
  margin-top: 10px;
  max-width: 60ch;
  font-size: 11px;
  line-height: 1.9;
  color: var(--ink-faint);
}

.site-footer nav { display: flex; gap: 22px }
.site-footer a { transition: color .3s var(--ease) }
.site-footer a:hover { color: var(--ink) }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important }
}
