/* =========================================================
   麦の郷出版 オンラインショップ
   ========================================================= */

:root {
  --paper: #faf6ee;
  --surface: #fffdf8;
  --surface-2: #f3ecdd;
  --ink: #2b2620;
  --muted: #6b6257;
  --line: #e2d8c4;
  --accent: #9a6a14;
  --accent-strong: #7f560c;
  --accent-ink: #ffffff;
  --accent-soft: #f4e6c6;
  --green: #4a6b3a;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --shadow: 0 1px 2px rgb(60 45 20 / 0.06), 0 8px 24px rgb(60 45 20 / 0.08);
  --radius: 14px;
  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "BIZ UDPMincho", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1915;
    --surface: #24211c;
    --surface-2: #2d2923;
    --ink: #efe7d8;
    --muted: #b3a894;
    --line: #3d372e;
    --accent: #d9a441;
    --accent-strong: #e8b75a;
    --accent-ink: #1b1915;
    --accent-soft: #3a2f1b;
    --green: #9cc08a;
    --danger: #ff8a80;
    --danger-soft: #3b201d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1915;
  --surface: #24211c;
  --surface-2: #2d2923;
  --ink: #efe7d8;
  --muted: #b3a894;
  --line: #3d372e;
  --accent: #d9a441;
  --accent-strong: #e8b75a;
  --accent-ink: #1b1915;
  --accent-soft: #3a2f1b;
  --green: #9cc08a;
  --danger: #ff8a80;
  --danger-soft: #3b201d;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

img, svg { display: block; max-width: 100%; }
svg { fill: currentColor; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.4; margin: 0; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--surface); padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.sp-only { display: none; }
@media (max-width: 520px) { .sp-only { display: inline; } }

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand-name { font-family: var(--font-serif); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.06em; white-space: nowrap; }
.brand-tag { font-size: 0.8rem; color: var(--muted); white-space: nowrap; padding-left: 10px; border-left: 1px solid var(--line); }
@media (max-width: 420px) { .brand-tag { display: none; } }

.cart-button {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600;
}
.cart-button:hover { border-color: var(--accent); }
.cart-button svg { width: 20px; height: 20px; }
.cart-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 0.8rem; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}

.notice {
  background: var(--accent-soft); color: var(--ink);
  font-size: 0.875rem; line-height: 1.6; text-align: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}

/* ---------- ヒーロー ---------- */
.hero { padding: 56px 0 40px; }
.hero h1 { font-family: var(--font-serif); font-size: clamp(1.75rem, 4.5vw, 2.6rem); letter-spacing: 0.04em; }
.hero-lead { margin-top: 14px; color: var(--muted); max-width: 40em; }
.hero-points { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.hero-points li {
  display: inline-block;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 0.9rem; line-height: 1.6;
}
.hero-points strong { color: var(--accent-strong); margin-right: 10px; }
@media (max-width: 520px) { .hero-points li { border-radius: 14px; } }

/* ---------- 書籍一覧 ---------- */
.section-title {
  font-family: var(--font-serif); font-size: 1.4rem; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 14px; margin-bottom: 24px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.books { padding: 16px 0 56px; }
.book-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 24px;
}
@media (max-width: 520px) { .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; } }

.book-card { display: flex; flex-direction: column; gap: 14px; }
.cover-button { all: unset; cursor: pointer; display: block; border-radius: 4px 10px 10px 4px; }
.cover-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.cover-button .cover { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.cover-button:hover .cover { transform: translateY(-3px); box-shadow: var(--shadow), 0 14px 30px rgb(60 45 20 / 0.14); }

.book-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.book-title { font-family: var(--font-serif); font-size: 1.05rem; }
.link-button { all: unset; cursor: pointer; }
.link-button:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.link-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.book-sub, .book-author { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }
.book-price { margin-top: 6px; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.tax { font-size: 0.75rem; font-weight: 400; color: var(--muted); margin-left: 2px; }

.add-button {
  margin-top: auto; align-self: stretch;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--accent); color: var(--accent-strong); font-weight: 700;
}
.book-price + .add-button { margin-top: 12px; }
.add-button svg { width: 18px; height: 18px; }
.add-button:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- 表紙 ---------- */
.cover {
  position: relative; aspect-ratio: 1 / 1.414; width: 100%; overflow: hidden;
  border-radius: 3px 8px 8px 3px; box-shadow: var(--shadow); background: var(--surface-2);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover--placeholder {
  --cover: #7a5a2b;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 0.22) 0 4%, rgb(255 255 255 / 0.08) 4% 5.5%, transparent 5.5%),
    radial-gradient(120% 80% at 80% 0%, rgb(255 255 255 / 0.12), transparent 60%),
    var(--cover);
  color: #fbf4e4;
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: 1fr auto;
  padding: 10% 8% 7% 12%;
}
.cover-title {
  grid-column: 2; grid-row: 1;
  writing-mode: vertical-rl; font-family: var(--font-serif); font-weight: 700;
  font-size: clamp(1rem, 1.6vw + 0.4rem, 1.45rem); letter-spacing: 0.12em; line-height: 1.3;
  max-height: 100%; overflow: hidden;
}
.cover-sub {
  grid-column: 1; grid-row: 1; justify-self: end; margin-right: 10%;
  writing-mode: vertical-rl; font-family: var(--font-serif);
  font-size: 0.68rem; letter-spacing: 0.08em; opacity: 0.85; max-height: 80%; overflow: hidden;
}
.cover-publisher {
  grid-column: 1 / -1; grid-row: 2; justify-self: center;
  font-family: var(--font-serif); font-size: 0.7rem; letter-spacing: 0.3em;
  padding-top: 6px; border-top: 1px solid rgb(251 244 228 / 0.5);
}
.cover--thumb { width: 56px; flex: none; border-radius: 2px 5px 5px 2px; }
.cover--thumb.cover--placeholder { padding: 6px 4px; grid-template-rows: 1fr; }
.cover--thumb .cover-title { font-size: 0.55rem; letter-spacing: 0.04em; }
.cover--thumb .cover-sub, .cover--thumb .cover-publisher { display: none; }
.cover--detail { width: 100%; }
.cover--detail .cover-title { font-size: 1.6rem; }
.cover--detail .cover-sub { font-size: 0.8rem; }

/* ---------- お届け・お受け取り ---------- */
.info { padding: 16px 0 64px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.info-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 22px 24px;
}
.info-card h3 { font-size: 1.05rem; margin-bottom: 12px; color: var(--accent-strong); }
.info-card p + p { margin-top: 10px; }
.info-card p, .info-card dd { font-size: 0.92rem; }
.info-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.info-card dt { font-size: 0.8rem; color: var(--muted); padding-top: 2px; white-space: nowrap; }
.info-card dd { margin: 0; }

/* ---------- フッター ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 36px; font-size: 0.85rem; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--ink); }

/* ---------- ダイアログ共通 ---------- */
dialog { color: var(--ink); background: var(--surface); border: 0; padding: 0; }
dialog::backdrop { background: rgb(20 15 8 / 0.45); }

.icon-button {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover:not(:disabled) { border-color: var(--accent); }
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }

.primary-button {
  width: 100%; min-height: 52px; padding: 10px 20px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem;
}
.primary-button:hover:not(:disabled) { background: var(--accent-strong); }
.primary-button:disabled { opacity: 0.6; cursor: progress; }

.text-button { background: none; border: 0; padding: 4px 6px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 0.85rem; }
.text-button:hover { color: var(--danger); }

/* ---------- 書籍の詳細 ---------- */
.book-dialog {
  width: min(760px, 100% - 32px); max-height: min(90vh, 900px);
  border-radius: 18px; box-shadow: var(--shadow); overflow: auto;
}
.book-dialog-body { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 28px; padding: 32px; }
.book-detail { display: flex; flex-direction: column; gap: 4px; }
.detail-title { font-family: var(--font-serif); font-size: 1.5rem; padding-right: 36px; }
.detail-sub, .detail-author { color: var(--muted); font-size: 0.92rem; }
.detail-price { font-weight: 700; font-size: 1.3rem; margin-top: 8px; }
.detail-desc { margin-top: 12px; font-size: 0.95rem; }
.detail-meta { margin: 14px 0 20px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.85rem; }
.detail-meta dt { color: var(--muted); }
.detail-meta dd { margin: 0; }
.book-detail .primary-button { margin-top: auto; }
.dialog-close { position: absolute; top: 14px; right: 14px; }
@media (max-width: 600px) {
  .book-dialog-body { grid-template-columns: 1fr; padding: 24px 20px; gap: 20px; }
  .book-dialog-body .cover--detail { width: 52%; margin-inline: auto; }
}

/* ---------- カゴ（右からのパネル） ---------- */
.cart {
  margin: 0 0 0 auto; width: min(440px, 100vw); max-width: 100vw;
  height: 100dvh; max-height: 100dvh; border-left: 1px solid var(--line);
}
.cart[open] { animation: slide-in 0.22s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .cart[open] { animation: none; } }

.cart-inner { display: flex; flex-direction: column; height: 100%; }
.cart-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--line);
}
.cart-header h2 { font-size: 1.15rem; }
.cart-scroll { flex: 1; overflow-y: auto; padding: 8px 22px 20px; }
.cart-empty { color: var(--muted); padding: 32px 0; text-align: center; }

.cart-lines { list-style: none; margin: 0; padding: 0; }
.cart-line { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.cart-line-body { flex: 1; min-width: 0; }
.cart-line-title { font-weight: 600; line-height: 1.5; }
.cart-line-price { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stepper .icon-button { width: 34px; height: 34px; }
.qty { min-width: 3em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.stepper .text-button { margin-left: auto; }

.fulfillment { border: 0; padding: 0; margin: 22px 0 0; }
.fulfillment legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  background: var(--surface);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 5px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.choice-body { display: flex; flex-direction: column; }
.choice-title { font-weight: 700; }
.choice-note { font-size: 0.82rem; color: var(--muted); line-height: 1.6; }

.pickup-fields { margin-top: 6px; padding: 14px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 12px; }
.field-help { font-size: 0.82rem; color: var(--muted); }
.field { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 600; }
.field input {
  height: 46px; padding: 0 12px; border-radius: 10px; font-weight: 400; font-size: 1rem;
  border: 1.5px solid var(--line); background: var(--surface);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }

.cart-footer { border-top: 1px solid var(--line); padding: 16px 22px calc(18px + env(safe-area-inset-bottom)); background: var(--surface); }
.totals { margin: 0 0 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 0; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); font-size: 0.9rem; }
.totals dd { margin: 0; text-align: right; padding-left: 12px; }
.totals .grand { font-weight: 700; font-size: 1.15rem; color: var(--ink); padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 4px; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 0.88rem; margin-bottom: 12px; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; font-size: 0.78rem; color: var(--muted); }
.secure-note svg { width: 14px; height: 14px; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 14px 12px 18px;
  box-shadow: var(--shadow); font-size: 0.9rem; transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-action {
  flex: none; border: 0; background: none; color: var(--accent-soft); font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 4px;
}
:root[data-theme="dark"] .toast-action { color: var(--accent-strong); }

/* ---------- 文章ページ（特商法・プライバシー・完了） ---------- */
.page { padding: 48px 0 72px; }
.page .wrap { max-width: 760px; }
.page h1 { font-family: var(--font-serif); font-size: clamp(1.5rem, 3.5vw, 2rem); margin-bottom: 24px; }
.page h2 { font-size: 1.1rem; margin: 32px 0 10px; }
.page p, .page li { font-size: 0.95rem; }
.page p + p { margin-top: 10px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.legal-table tr:last-child th, .legal-table tr:last-child td { border-bottom: 0; }
.legal-table th { width: 32%; background: var(--surface-2); font-weight: 600; }
@media (max-width: 600px) {
  .legal-table, .legal-table tbody, .legal-table tr, .legal-table th, .legal-table td { display: block; width: 100%; }
  .legal-table th { border-bottom: 0; padding-bottom: 4px; }
  .legal-table td { padding-top: 4px; }
}
.todo { background: var(--accent-soft); border-radius: 4px; padding: 0 4px; }
.done-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 28px; text-align: center; }
.done-card .brand-mark { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--accent); }
.done-card p { margin-top: 10px; }
.done-card .primary-button { display: inline-flex; align-items: center; justify-content: center; width: auto; margin-top: 24px; text-decoration: none; }
.page-note { margin-top: 32px !important; color: var(--muted); font-size: 0.85rem !important; }
@media (max-width: 520px) {
  .cart-footer { padding-top: 12px; }
  .totals { margin-bottom: 10px; }
  .totals dt, .totals dd { font-size: 0.85rem; }
  .totals .grand { font-size: 1.05rem; }
  .primary-button { min-height: 48px; }
}
