/* Discovery — デザインシステム
   catnose流: メイン1色+無彩色 / 引き算 / 余白で区切る / z-indexは変数一元管理
   変数は役割ベースで命名しダークモードを最初から織り込む */

:root {
  /* 面：FANZA参考の明るい配色（背景は真っ白より少しトーンを落として長時間でも疲れにくく） */
  --bg: #f3f3f6;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --surface-hover: #ececf1;
  --border: #e2e2e8;
  --border-soft: #ededf1;

  /* 文字 */
  --text: #17171c;
  --text-muted: #63636d;
  --text-faint: #9797a1;

  /* アクセントはFANZA基調の赤1色。強調は本当に必要な1箇所だけに使う */
  --accent: #e60044;
  --accent-strong: #c80039;
  --accent-weak: #fde3ec;
  --on-accent: #ffffff;
  --danger: #d63b2f;

  /* 形 */
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(20, 20, 30, 0.06);
  --maxw: 920px;

  /* レイヤー（横断レイヤーだけ z-index を使う。それ以外は 1 まで） */
  --z-header: 100;
  --z-overlay: 200;
  --z-toast: 300;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: light;
}

/* 既定は明るいFANZA配色。夜間閲覧向けに prefers-color-scheme: dark でダークへ切替 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121013;
    --bg-elevated: #1b171b;
    --bg-card: #1e1a1f;
    --surface-hover: #262029;
    --border: #302935;
    --border-soft: #241f28;
    --text: #f3eef2;
    --text-muted: #a89fa8;
    --text-faint: #6f6672;
    --accent: #ff3d70;
    --accent-strong: #ff5c86;
    --accent-weak: #3a1622;
    --on-accent: #1a0a10;
    --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.02);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  transition: background 180ms var(--ease), border-color 180ms var(--ease),
    transform 120ms var(--ease), opacity 180ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn--lg { padding: 14px 26px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--soft { background: var(--bg-elevated); border-color: var(--border); }
.btn--soft:hover { background: var(--surface-hover); }
.btn--ghost { border-color: var(--border); color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn svg { width: 18px; height: 18px; stroke-width: 2; }

/* ---- 年齢確認ゲート ---- */
.agegate {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%, var(--accent-weak) 0%, var(--bg) 62%);
}
.agegate[hidden] { display: none; }
.agegate__panel {
  width: 100%;
  max-width: 420px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 28px 28px;
  animation: rise 320ms var(--ease);
}
.agegate__mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-weak);
}
.agegate__title { margin: 0 0 12px; font-size: 22px; letter-spacing: 0.04em; }
.agegate__lead { margin: 0 0 26px; color: var(--text-muted); font-size: 15px; }
.agegate__actions { display: grid; gap: 10px; }
.agegate__note {
  margin: 22px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-faint);
}

/* ---- アプリバー ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 28px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.appbar[hidden] { display: none; }
.appbar__brand { display: inline-flex; align-items: center; gap: 10px; }
.appbar__logo {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: radial-gradient(circle at 32% 30%, var(--accent-strong), var(--accent) 60%, #7d2f43);
}
.appbar__name { font-weight: 700; letter-spacing: 0.06em; font-size: 17px; }
.appbar__nav { display: flex; gap: 4px; margin-left: auto; }
.appbar__nav a {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text-muted);
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.appbar__nav a:hover { color: var(--text); background: var(--surface-hover); }
.appbar__nav a[aria-current="page"] { color: var(--text); background: var(--bg-elevated); }

/* ---- レイアウト ---- */
.app { display: block; }
.app[hidden] { display: none; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 28px) 64px; }

.page-head { margin: 8px 0 26px; }
.page-head__eyebrow {
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 6px;
}
.page-head__title { margin: 0; font-size: clamp(22px, 5vw, 28px); letter-spacing: 0.02em; }
.page-head__sub { margin: 8px 0 0; color: var(--text-muted); font-size: 14.5px; max-width: 60ch; }

/* ---- 作品グリッド ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: clamp(12px, 2.4vw, 20px);
}
.grid--today { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.card {
  display: block;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 180ms var(--ease), border-color 180ms var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--border); }
.card__thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}
.card__thumb svg,
.card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.card__rank {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
  color: var(--accent-strong);
}
.card__body { padding: 11px 13px 14px; }
.card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- チップ（ジャンル） ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
}
.chip--on { color: var(--accent); background: var(--accent-weak); border-color: transparent; }

/* ---- 見つける（1枚ずつ判定） ---- */
.judge { max-width: 440px; margin: 0 auto; }
.judge__card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.judge__thumb { aspect-ratio: 3 / 4; }
.judge__thumb svg,
.judge__thumb img { width: 100%; height: 100%; object-fit: cover; }
.judge__body { padding: 18px 20px 20px; }
.judge__title { margin: 0 0 10px; font-size: 18px; line-height: 1.5; }
.judge__meta { margin: 0 0 14px; color: var(--text-muted); font-size: 13.5px; }
.judge__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.judge__progress {
  text-align: center;
  margin: 16px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ---- 作品詳細 ---- */
.detail { max-width: 760px; margin: 0 auto; }
.detail__hero {
  display: grid;
  grid-template-columns: minmax(0, 260px) 1fr;
  gap: clamp(18px, 4vw, 32px);
  align-items: start;
}
.detail__thumb { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border-soft); aspect-ratio: 3 / 4; }
.detail__thumb svg,
.detail__thumb img { width: 100%; height: 100%; object-fit: cover; }
.samples-grid svg,
.samples-grid img { width: 100%; height: 100%; object-fit: cover; }
.detail__title { margin: 0 0 14px; font-size: clamp(19px, 4vw, 24px); line-height: 1.5; }
.detail__facts { margin: 0 0 18px; display: grid; gap: 8px; }
.detail__fact { display: grid; grid-template-columns: 84px 1fr; gap: 12px; font-size: 14px; }
.detail__fact dt { color: var(--text-faint); }
.detail__fact dd { margin: 0; color: var(--text); }
.detail__cta { margin-top: 22px; display: grid; gap: 10px; }
.detail__price { font-size: 20px; font-weight: 700; }
.detail__samples { margin-top: 34px; }
.detail__samples h2 { font-size: 15px; color: var(--text-muted); margin: 0 0 12px; font-weight: 600; }
.samples-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.samples-grid > * { aspect-ratio: 16 / 10; border-radius: var(--radius-sm); overflow: hidden; }

@media (max-width: 560px) {
  .detail__hero { grid-template-columns: 1fr; }
  .detail__thumb { max-width: 240px; }
}

/* ---- 空状態 / ローディング ---- */
.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty__title { color: var(--text); font-size: 17px; margin: 0 0 8px; }
.empty p { margin: 0 auto 20px; max-width: 40ch; font-size: 14px; }

.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.skeleton {
  border-radius: var(--radius);
  aspect-ratio: 3 / 4.5;
  background: linear-gradient(100deg, var(--bg-card) 30%, var(--surface-hover) 50%, var(--bg-card) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s var(--ease) infinite;
}

/* ---- フッター ---- */
.foot {
  border-top: 1px solid var(--border-soft);
  padding: 26px clamp(16px, 4vw, 28px) 40px;
  max-width: var(--maxw);
  margin: 0 auto;
  color: var(--text-faint);
}
.foot[hidden] { display: none; }
.foot__links { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; font-size: 13px; }
.foot__links a:hover { color: var(--text); }
.foot__reset {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-faint);
  font-size: 13px;
}
.foot__reset:hover { color: var(--danger); }
.foot__copy { margin: 14px 0 0; font-size: 12px; }
.foot__credit { margin: 6px 0 0; font-size: 12px; }
.foot__credit a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.foot__credit a:hover { color: var(--text); }

/* ---- About ---- */
.prose { max-width: 640px; margin: 0 auto; }
.prose h2 { font-size: 17px; margin: 30px 0 10px; }
.prose p { color: var(--text-muted); font-size: 14.5px; margin: 0 0 14px; }
.prose ul { color: var(--text-muted); font-size: 14.5px; padding-left: 1.2em; }
.prose li { margin: 6px 0; }

/* ---- トースト ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: var(--z-toast);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  pointer-events: none;
}
.toast[hidden] { display: none; }
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- like ボタン（詳細・カード） ---- */
.likebtn { display: inline-flex; align-items: center; gap: 7px; }
.likebtn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.likebtn[aria-pressed="true"] svg { fill: var(--accent); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -220% 0; } }

/* モバイルは主要ナビをボトムタブバーに（親指到達域・HIG準拠）。上部バーはブランドのみ。 */
@media (max-width: 560px) {
  /* backdrop-filter は position:fixed の含有ブロックを作るため、モバイルの上部バーからは外す。
     これがないと下記のボトムナビが親バー基準に閉じ込められ画面上部に固定されてしまう。 */
  .appbar { gap: 10px; padding: 12px 16px; backdrop-filter: none; }
  .appbar__nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    z-index: var(--z-header);
    display: flex;
    gap: 0;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border-soft);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .appbar__nav a {
    flex: 1;
    text-align: center;
    font-size: 12.5px;
    padding: 9px 4px;
  }
  .foot { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .judge__actions { grid-template-columns: 1fr 1fr; }
  /* コア操作(いいね/次へ)を1画面に収めるため、判定サムネの高さを上限で抑える */
  .judge__thumb { max-height: 34vh; }
  .judge__body { padding: 14px 16px 16px; }
  .judge__title { font-size: 16px; margin-bottom: 8px; }
  .judge__actions { margin-top: 14px; }
  .page-head { margin: 2px 0 12px; }
  .page-head__sub { font-size: 13px; margin-top: 6px; }
  .wrap { padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
