/* わくわく素材 利用者サイト — design_handoff (docs/design) を hono/jsx + class ベースで再現 */

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-body);
  font: var(--text-body-font);
  letter-spacing: var(--tracking-body);
  transition:
    background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  color: var(--link-hover);
}
img {
  display: block;
  max-width: 100%;
}
button {
  font: var(--text-button);
  letter-spacing: var(--tracking-body);
  cursor: pointer;
}
:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: color-mix(in oklab, var(--bg-page) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.logo-type {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: var(--tracking-display);
  color: var(--text-body);
  white-space: nowrap;
}
.logo-type .accent {
  color: var(--accent);
}
.site-nav {
  display: flex;
  gap: var(--sp-1);
}
.site-nav a {
  font: var(--text-button);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  transition:
    background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--bg-well);
  color: var(--text-body);
}
.header-search {
  margin-left: auto;
  flex: 1;
  max-width: 420px;
  display: flex;
}
.header-search input {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-4);
  font: var(--text-body-font);
  color: var(--text-body);
  background: var(--surface-card);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.header-search input::placeholder {
  color: var(--text-faint);
}
.header-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: all var(--dur-base) var(--ease-out);
}
.icon-btn:hover {
  background: var(--bg-well);
  color: var(--text-body);
}
.icon-btn:active {
  transform: scale(0.94);
}
.theme-toggle .icon-sun {
  display: none;
}
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}
@media (max-width: 860px) {
  .site-header {
    padding: 0 var(--sp-4);
  }
  .site-nav {
    display: none;
  }
}

/* ---------- Hero ---------- */
.hero {
  background: var(--bg-subtle);
  padding: clamp(28px, 5vw, 56px) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}
.hero-inner {
  max-width: var(--page-max);
  margin: 0 auto;
}
.hero h1 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 4.5vw, 40px);
  line-height: 1.25;
  letter-spacing: var(--tracking-display);
}
.hero h1 .accent {
  color: var(--accent);
}
.hero p {
  margin: 0 0 var(--sp-5);
  max-width: 560px;
  color: var(--text-muted);
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: var(--text-caption);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--surface-card);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  transition: all var(--dur-base) var(--ease-out);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}
.chip[aria-current="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ---------- Content ---------- */
.content {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-7) var(--sp-6) var(--sp-9);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.section-head h2 {
  margin: 0;
  font: var(--text-h2);
  letter-spacing: var(--tracking-display);
}
.tabs {
  display: inline-flex;
  gap: var(--sp-1);
  background: var(--bg-well);
  padding: 4px;
  border-radius: var(--radius-full);
}
.tabs a {
  font: var(--text-button);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  transition: all var(--dur-base) var(--ease-out);
}
.tabs a[aria-current="page"] {
  background: var(--surface-card);
  color: var(--text-body);
  box-shadow: var(--shadow-card);
}

/* ---------- AssetCard grid ---------- */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-5);
}
.asset-card {
  display: block;
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--dur-base) var(--ease-out);
  color: var(--text-body);
}
.asset-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  color: var(--text-body);
}
/* 一覧タイルは比率に依らず正方形で揃える。素材は 16:9 / 9:16 / 1:1 / 4:3 が
   混在するため、cover で切り取らず contain で全体を見せる(余白は bg-well) */
.asset-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-well);
}
.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.badge-new {
  position: absolute;
  top: 10px;
  left: 10px;
  font: var(--text-caption);
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}
.dl-pill {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: var(--text-caption);
  font-weight: 700;
  background: oklch(0.2 0.02 40 / 0.55);
  color: #fff;
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}
.asset-body {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.asset-title {
  font: var(--text-h3);
}
.asset-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font: var(--text-caption);
  font-weight: 700;
  color: var(--text-faint);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font: var(--text-button);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  padding: 0 var(--sp-5);
  height: 40px;
  transition: all var(--dur-base) var(--ease-out);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-secondary {
  background: var(--surface-card);
  color: var(--text-body);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-well);
}
.btn-lg {
  height: 48px;
  padding: 0 var(--sp-6);
  font-size: 15px;
}

/* ---------- Detail page ---------- */
.detail-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--sp-6);
}
/* 詳細プレビューは素材の実比率。style 属性で aspect-ratio を上書きする
   (app/lib/aspect-ratio.ts のホワイトリスト経由)。ここの値はフォールバック */
.detail-preview {
  aspect-ratio: 16 / 9;
  /* 9:16 は実比率のままだと縦 1200px 超になり画面を占有するので上限をかける。
     contain なので上限に当たった場合は左右に余白が出るだけで切れない */
  max-height: 70vh;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-well);
  /* 上限に当たると比率に応じて幅が縮むので中央に寄せる(縦長素材) */
  margin: 0 auto var(--sp-4);
}
.detail-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- 色調整スライダー(ColorAdjuster island) ----------
   フォーカスリングはグローバルの :focus-visible に乗せる(上書きしない)。
   値・色・radius はすべて既存トークン。独自値を足さないこと */
.color-controls {
  display: grid;
  gap: var(--sp-2);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  margin: 0 0 var(--sp-5);
}
.color-controls legend {
  font: var(--text-h3);
  color: var(--text-body);
  padding: 0 var(--sp-2);
}
.color-controls-actions {
  display: flex;
  justify-content: flex-end;
}
.color-slider {
  display: grid;
  grid-template-columns: 3.5em 1fr 4em;
  align-items: center;
  gap: var(--sp-3);
}
.color-slider label {
  font: var(--text-small);
  font-weight: 700;
  color: var(--text-muted);
}
.color-slider output {
  font: var(--text-small);
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.color-slider input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  /* トラックは 6px だが、タップ領域として 44px 確保する */
  height: 44px;
  background: transparent;
  cursor: pointer;
}
.color-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-well);
}
.color-slider input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-well);
}
.color-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  /* (トラック 6px - つまみ 20px) / 2 */
  margin-top: -7px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 2px solid var(--surface-card);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-base) var(--ease-out);
}
.color-slider input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 2px solid var(--surface-card);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-base) var(--ease-out);
}
.color-slider input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}
.color-slider input[type="range"]:active::-moz-range-thumb {
  transform: scale(1.15);
}
@media (width <= 480px) {
  .color-slider {
    grid-template-columns: 3.5em 1fr;
  }
  .color-slider output {
    grid-column: 2;
    text-align: left;
  }
}

.badge {
  display: inline-flex;
  font: var(--text-caption);
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--accent-2-soft);
  color: var(--tangerine-text);
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  font: var(--text-small);
  color: var(--text-muted);
  margin: var(--sp-3) 0;
}
.desc-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  font: var(--text-body-font);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}
.breadcrumb {
  font: var(--text-small);
  color: var(--text-faint);
  margin-bottom: var(--sp-4);
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
}
.breadcrumb li + li::before {
  content: "/";
  margin-right: var(--sp-2);
  color: var(--border-strong);
}

/* ---------- Download dialog ---------- */
dialog.dl-dialog {
  width: min(640px, calc(100vw - 32px));
  border: none;
  border-radius: var(--radius-xl);
  background: var(--surface-card);
  color: var(--text-body);
  box-shadow: var(--shadow-pop);
  padding: var(--sp-6);
}
dialog.dl-dialog::backdrop {
  background: oklch(0.25 0.03 40 / 0.35);
}
dialog.dl-dialog[open] {
  animation: pop-in var(--dur-slow) var(--ease-pop);
}
@keyframes pop-in {
  from {
    transform: scale(0.94) translateY(8px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.dl-dialog h2 {
  margin: 0 0 var(--sp-4);
  font: var(--text-h2);
  letter-spacing: var(--tracking-display);
}
.dl-stage {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.ad-slot {
  aspect-ratio: 300 / 250;
  max-width: 300px;
  margin: 0 auto;
  background: var(--bg-well);
  border-radius: var(--radius-md);
}
.dl-overlay {
  position: absolute;
  inset: 0;
  background: oklch(0.2 0.02 40 / 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: #fff;
  font: var(--text-small);
  font-weight: 700;
}
.progress {
  width: 60%;
  height: 6px;
  border-radius: var(--radius-full);
  background: oklch(1 0 0 / 0.25);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 1s linear;
}
.dl-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--sp-6);
  transform: translateX(-50%);
  background: var(--text-body);
  color: var(--bg-page);
  font: var(--text-button);
  padding: 12px 22px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--dur-slow) var(--ease-pop);
  z-index: 100;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: center;
  justify-content: space-between;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-6);
  font: var(--text-small);
  color: var(--text-faint);
}
.site-footer a {
  color: var(--text-muted);
}

/* ---------- Misc ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- View Transitions ---------- */
/* タブ・タグ切替などの同一オリジン MPA 遷移をクロスフェードにし、
   ページ全体の再描画によるちらつきを緩和する。非対応ブラウザは従来どおり。
   上の reduced-motion 対策は ::view-transition-* 疑似要素に届かないため、
   no-preference のときだけ有効化する */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}
