/* Quiet Search デザインシステム（§13）。Clean / Quiet / Searchable / Private。
   初期はライトモード標準。ダークモードは Phase 2 以降。 */

:root {
  --bg: #f8f8f7;
  --surface: #ffffff;
  --text: #1f1f1f;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --success: #16a34a;
  --warning: #f59e0b;
  --error: #dc2626;

  --max-width: 1120px;
  --pad-x: 16px;
  --gap-card: 16px;
  --gap-section: 32px;

  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-tag: 999px;
  --radius-modal: 20px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.04);

  --fz-h1: 28px;
  --fz-h2: 22px;
  --fz-h3: 18px;
  --fz-body: 15px;
  --fz-note: 13px;
  --fz-tag: 12px;
}

* { box-sizing: border-box; }

/* hidden 属性を常に優先（.overlay/.hide-screen の display 指定に負けないように） */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--fz-body);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

/* モバイルファースト: 既定は狭幅向け。横幅・余白は min-width で広げる。 */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  /* 下部固定ナビ + iPhone ホームインジケータ分を確保 */
  padding: 20px var(--pad-x) calc(84px + env(safe-area-inset-bottom));
}

/* --- ヘッダー（モバイルファースト: 2段。上段ロゴ+操作、下段に全幅検索） --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 10px var(--pad-x);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.logo { display: inline-flex; align-items: center; flex-shrink: 0; }
.logo-img { display: block; height: 30px; width: auto; }
/* 検索は上段から折り返して全幅（モバイル） */
.header-search { order: 3; flex-basis: 100%; }
.header-search input,
.hero-search input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg);
  font-size: 16px; /* iOSのフォーカス時ズーム防止のため16px固定 */
}
.header-actions { display: flex; gap: 8px; margin-left: auto; }

/* --- ボタン --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fz-body);
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.92; background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-chip { padding: 8px 14px; border-radius: var(--radius-tag); font-size: var(--fz-note); }
/* プライバシーモード ON は塗り（保護中を直感的に示す）／ OFF はアウトライン */
#privacy-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#privacy-toggle[aria-pressed="true"]:hover { background: var(--accent); opacity: 0.92; }
#privacy-toggle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.btn-cta { width: 100%; margin-top: 8px; color: var(--accent); border-color: var(--accent); }
.btn-cta:hover { background: rgba(37, 99, 235, 0.06); }
.btn-large { padding: 12px 18px; font-size: var(--fz-h3); }

/* --- ヒーロー（トップ） --- */
.hero { text-align: center; padding: 24px 0 var(--gap-section); }
.hero-copy { font-size: var(--fz-h1); margin: 0 0 8px; }
.hero-sub { color: var(--text-sub); margin: 0 0 20px; }
.hero-search { display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.hero-search input { flex: 1; }

/* --- サービス説明（トップ） --- */
.intro { max-width: 820px; margin: 0 auto; text-align: center; }
.intro-title { font-size: var(--fz-h2); margin: 0 0 8px; }
.intro-lead { color: var(--text-sub); margin: 0 auto 20px; max-width: 720px; }
.intro-points {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-card);
  text-align: left;
}
.intro-point {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.intro-point h3 { font-size: var(--fz-h3); margin: 0 0 6px; }
.intro-point p { font-size: var(--fz-note); color: var(--text-sub); margin: 0; }
.intro-links { margin: 20px 0 0; font-size: var(--fz-note); color: var(--text-sub); }
.intro-links a { color: var(--accent); }
@media (max-width: 640px) {
  .intro-points { grid-template-columns: 1fr; }
}

/* --- カテゴリ説明文（各カテゴリトップ） --- */
.category-intro {
  max-width: 760px;
  margin: 0 0 var(--gap-section);
  color: var(--text-sub);
  font-size: var(--fz-note);
  line-height: 1.7;
}

/* --- カテゴリナビ（動画/同人/ブックス） --- */
.category-nav {
  display: flex;
  gap: 8px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px var(--pad-x) 0;
  flex-wrap: wrap;
}
.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-tag);
  background: var(--surface);
  color: var(--text-sub);
  font-size: var(--fz-note);
}
.cat-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cat-soon {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-tag);
  background: var(--bg);
  color: var(--text-sub);
  border: 1px solid var(--border);
}
.cat-tab.active .cat-soon { color: var(--text-sub); }
.search-tabs { padding-left: 0; padding-right: 0; margin-bottom: 16px; }

/* --- トップのカテゴリカード（モバイルは3列・余白控えめ） --- */
.category-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.category-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
@media (min-width: 600px) {
  .category-cards { gap: var(--gap-card); }
  .category-card { gap: 6px; padding: 24px 16px; }
}
.category-card:hover { background: var(--bg); }
.category-card-label { font-size: var(--fz-h3); font-weight: 700; }
.category-card-sub { font-size: var(--fz-note); color: var(--text-sub); }

/* カード上のカテゴリラベル（§8.3 検索結果でカテゴリ判別） */
.cat-label {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-tag);
  background: rgba(31, 31, 31, 0.62);
  color: #fff;
}

/* --- セクション見出し --- */
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 16px;
}
.section-heading h2 { font-size: var(--fz-h2); margin: 0; }
.section-more { color: var(--accent); font-size: var(--fz-note); }
section { margin-bottom: var(--gap-section); }

/* --- 作品グリッド / カード（モバイルは2列固定、広幅で自動増） --- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-card);
}
@media (min-width: 600px) {
  .work-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
.work-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.work-thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-placeholder { width: 100%; height: 100%; background: var(--border); }
.thumb-cover { display: none; }
.work-title { font-size: var(--fz-body); margin: 10px 0 6px; line-height: 1.4; }
.work-title .title-masked { display: none; color: var(--text-sub); }
.work-meta { display: flex; gap: 8px; align-items: center; font-size: var(--fz-note); color: var(--text-sub); flex-wrap: wrap; }
.work-price { color: var(--text); font-weight: 600; }
.badge-sale {
  font-size: var(--fz-tag);
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius-tag);
  padding: 1px 8px;
}

/* --- カテゴリ内ガイドリンク（同人/ブックストップ） --- */
.category-guide {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: var(--gap-section);
}
.guide-link {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-tag);
  background: var(--surface); color: var(--accent); font-size: var(--fz-note);
}
.guide-link:hover { background: var(--bg); }

/* --- 作品詳細（共通ヘッダ + 販売先カード） --- */
.detail-head { max-width: 760px; margin: 0 auto var(--gap-section); }
.detail-title { font-size: var(--fz-h1); margin: 0 0 12px; }
.detail-title .title-masked { display: none; color: var(--text-sub); }
body.privacy-on .detail-title .title-normal { display: none; }
body.privacy-on .detail-title .title-masked { display: inline; }

/* 販売先（offer）カードのグリッド */
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap-card); }
.offer-card {
  border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow); padding: 14px;
}
.offer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.offer-provider { font-weight: 700; }
.offer-body { display: flex; gap: 12px; }
.offer-thumb { width: 96px; flex-shrink: 0; aspect-ratio: 3/2; border-radius: 8px; overflow: hidden; background: var(--bg); }
.offer-info { flex: 1; min-width: 0; }
.offer-title { margin: 0 0 6px; font-size: var(--fz-body); line-height: 1.4; }
.offer-title .title-masked { display: none; color: var(--text-sub); }
body.privacy-on .offer-title .title-normal { display: none; }
body.privacy-on .offer-title .title-masked { display: inline; }
.offer-price { margin: 0; display: flex; gap: 8px; align-items: baseline; }
.offer-fetched { margin: 8px 0 0; font-size: var(--fz-tag); color: var(--text-sub); }
.offer-card .btn-cta { margin-top: 10px; }

/* --- 旧 作品詳細（後方互換のため残置） --- */
.work-detail { display: grid; grid-template-columns: 1fr; gap: 20px; }
.detail-media { position: relative; border-radius: var(--radius-card); overflow: hidden; background: var(--bg); }
.detail-img { width: 100%; display: block; }
.detail-title { font-size: var(--fz-h1); }
.detail-title .title-masked { display: none; color: var(--text-sub); }
.detail-row { display: flex; gap: 12px; align-items: baseline; margin: 6px 0; }
.detail-label { min-width: 72px; font-size: var(--fz-note); color: var(--text-sub); flex-shrink: 0; }
.price-sale { font-weight: 700; color: var(--error); }
.price-original { text-decoration: line-through; color: var(--text-sub); font-size: var(--fz-note); }

/* --- プライバシーモード（body.privacy-on で出し分け, §8.2） --- */
body.privacy-on .thumb-img,
body.privacy-on .detail-img { filter: blur(18px); transform: scale(1.05); }
body.privacy-on .work-title .title-normal,
body.privacy-on .detail-title .title-normal { display: none; }
body.privacy-on .work-title .title-masked,
body.privacy-on .detail-title .title-masked { display: inline; }

/* --- 画面を隠す（§8.3） --- */
.hide-fab {
  position: fixed;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 40;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: var(--fz-note);
}
.hide-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hide-inner { text-align: center; color: var(--text-sub); }
.hide-logo { font-size: var(--fz-h2); color: var(--text); margin-bottom: 16px; }
.hide-muted { color: var(--text-sub); margin: 4px 0; }
.hide-inner .btn { margin-top: 20px; }

/* --- 年齢確認ゲート（§8.1） --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(248, 248, 247, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad-x);
}
.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  max-width: 420px;
  text-align: center;
}
.overlay-card h2 { font-size: var(--fz-h2); margin-top: 0; }
.age-q { font-weight: 600; }
.age-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

/* 年齢未確認時は本文を隠す */
body:not(.age-ok) #main-content,
body:not(.age-ok) .site-header,
body:not(.age-ok) .site-footer,
body:not(.age-ok) .bottom-nav,
body:not(.age-ok) .hide-fab { visibility: hidden; }

/* --- フッター --- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 40px var(--pad-x) 96px;
  color: var(--text-sub);
  font-size: var(--fz-note);
}
.footer-main {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 32px 24px;
}
.footer-brand { max-width: 320px; }
.footer-logo { display: inline-block; }
.footer-logo img { display: block; height: 32px; width: auto; }
.footer-tagline { margin: 12px 0 0; line-height: 1.7; }
.footer-col-title {
  font-size: var(--fz-note);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin: 0 0 8px; }
.footer-col a { color: var(--text-sub); }
.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  max-width: var(--max-width);
  margin: 32px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.pr-note { margin: 0 0 8px; line-height: 1.7; }
.pr-note.small { font-size: var(--fz-note); }
.dmm-credit { margin: 0 0 12px; }
.footer-copy { margin: 8px 0 0; }

@media (max-width: 760px) {
  .footer-main { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; max-width: none; }
}
@media (max-width: 420px) {
  .footer-main { grid-template-columns: 1fr; }
}

/* --- 下部ナビ（モバイル, §12.2） --- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  font-size: var(--fz-tag);
}
.bottom-nav a {
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 44px;
  padding: 4px 8px;
  text-align: center;
}

/* --- 汎用 --- */
.empty-state { color: var(--text-sub); text-align: center; padding: 40px 0; }
.more-wrap { text-align: center; margin-top: 24px; }
.settings-list { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.setting-item { display: flex; justify-content: space-between; align-items: center; }
.prose { max-width: 720px; color: var(--text-sub); }

/* --- 法務・ポリシーページ --- */
.legal { max-width: 760px; margin: 0 auto; color: var(--text); }
.legal-title { font-size: var(--fz-h1); margin: 0 0 20px; }
.legal h2 { font-size: var(--fz-h3); margin: 28px 0 8px; }
.legal p { margin: 8px 0; }
.legal ul { padding-left: 1.25em; margin: 8px 0; }
.legal li { margin: 4px 0; }
.legal a { color: var(--accent); }
.legal-updated { margin-top: 32px; color: var(--text-sub); font-size: var(--fz-note); }
.legal-note { color: var(--text-sub); font-size: var(--fz-note); }
.legal-dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 12px 0; }
.legal-dl dt { font-weight: 600; }
.legal-dl dd { margin: 0; color: var(--text-sub); }
@media (max-width: 560px) {
  .legal-dl { grid-template-columns: 1fr; gap: 2px; }
  .legal-dl dd { margin-bottom: 8px; }
}

/* --- お問い合わせフォーム --- */
.contact-form { max-width: 640px; display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row span { font-size: var(--fz-note); color: var(--text-sub); }
.form-row span em { color: var(--error); font-style: normal; font-size: 11px; margin-left: 4px; }
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-size: var(--fz-body);
  font-family: inherit;
}
.contact-form .btn { align-self: flex-start; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-success { background: rgba(22, 163, 74, 0.1); color: var(--success); padding: 12px 16px; border-radius: var(--radius-btn); }
.form-error { background: rgba(220, 38, 38, 0.08); color: var(--error); padding: 12px 16px; border-radius: var(--radius-btn); }

/* PC では下部ナビを隠してヘッダー中心に（§12.3） */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .work-detail { grid-template-columns: 360px 1fr; }
  .hide-fab { bottom: 24px; }
  .container { padding: var(--gap-section) var(--pad-x); }
  /* ヘッダーを1段に戻し、検索を中央でフレキシブルに */
  .site-header { flex-wrap: nowrap; }
  .header-search { order: 0; flex: 1; flex-basis: auto; }
  .logo-img { height: 36px; }
}
