/* ==========================================================================
   慟哭のISA ｜ Landing Page
   --------------------------------------------------------------------------
   1. Design tokens
   2. Reset / base
   3. Layout (cut / container)
   4. Typography
   5. Backgrounds & scrims
   6. Animations
   7. UI (header / CTA / purchase / footer)
   ========================================================================== */

/* ------------------------------------------------------------------ 1. Tokens */
:root {
  /* Color */
  --light: #f4f7f5;
  --sky: #c8dfea;
  --paper: #f7f4ec;
  --ink: #211e1d;
  --ink-soft: #4a4644;
  --night: #111a27;
  --night-text: #edf2f2;

  /* Font family */
  --font-mincho: 'Noto Serif JP', 'Yu Mincho', 'Hiragino Mincho ProN', serif;
  --font-gothic: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --font-isa: 'Cinzel', 'Noto Serif JP', serif;

  /* --------------------------------------------------------------
     Fluid type scale
     375px -> 1440px を 1 本の clamp で連続的に補間する。
     旧実装は 768px でモバイル用 clamp から PC 用 clamp へ切り替わり、
     38px -> 32px と縮む段差が出ていた。ブレークポイントは廃止。
     -------------------------------------------------------------- */
  /* 基準サイズ。最長行（CUT04 の 18 字）が、どの幅でも本文枠の
     88% 以内に収まるよう傾きを逆算した値。ブレークポイントは持たない。 */
  --fs-base:        clamp(0.875rem, 4.56vw - 1.07px, 2.625rem);  /* 14 -> 42 */
  --fs-copy:        var(--fs-base);
  --fs-copy-lg:     min(var(--fs-base) * 1.24, 3.25rem);  /* CUT02 / 上限 52 */
  --fs-copy-sm:     min(var(--fs-base) * 0.92, 1.875rem); /* CUT06 / 上限 30 */
  --fs-title-main:  clamp(4.25rem,  2.842rem + 6.009vw, 8.25rem);   /* 68 -> 132 */
  --fs-book-title:  clamp(1.75rem,  1.243rem + 1.502vw, 2.75rem);   /* 28 -> 44 */
  --fs-body:        clamp(0.9375rem, 0.884rem + 0.188vw, 1.0625rem);/* 15 -> 17 */
  --fs-ui:          clamp(0.875rem, 0.846rem + 0.094vw, 0.9375rem); /* 14 -> 15 */

  /* Line height */
  --lh-copy: 1.75;
  --lh-body: 1.9;

  /* Letter spacing（行末アキの光学補正に同じ値を padding-left で使う） */
  --ls-copy: 0.06em;
  --ls-title-sub: 0.3em;
  --ls-title-main: 0.02em;
  --logo-optical: -0.041em; /* 実測で決める。ISA の em 基準 */

  /* Spacing */
  --flow: clamp(1.75rem, 1.15rem + 2.6vw, 3.25rem);
  --gutter: clamp(1.25rem, 0.7rem + 2.3vw, 3rem);
  --cut-pad-y: clamp(4rem, 10svh, 7.5rem);
  --measure: 900px;
}

/* ------------------------------------------------------------------ 2. Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-gothic);
  background-color: var(--light);
  color: var(--ink);
  overflow-x: hidden;
  line-height: var(--lh-body);
  font-feature-settings: 'palt' 1; /* 日本語の詰め組み */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ------------------------------------------------------------------ 3. Layout */
.cut {
  position: relative;
  width: 100%;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--cut-pad-y) var(--gutter);
  overflow: hidden;
}

.copy-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  text-align: center;
}

/* 縦フローは margin-bottom ではなく隣接セレクタで作る。
   末尾要素に余白が残ると flex 中央揃えが上にズレるため。 */
.copy + .copy,
.title-logo + .copy {
  margin-top: var(--flow);
}

/* ------------------------------------------------------------------ 4. Typography */
.copy {
  font-family: var(--font-mincho);
  font-size: var(--fs-copy);
  font-weight: 400;
  line-height: var(--lh-copy);
  letter-spacing: var(--ls-copy);
  /* 改行位置は <br> と .nw で意図的に決めるので自動バランスは使わない */
  line-break: strict;
  word-break: normal;
  overflow-wrap: normal;
}

/* --- 行頭・行末の約物ぶら下げ ------------------------------------------
   Google Fonts 版 Noto Serif JP は palt/halt を持たないため、句読点や
   括弧は全角のまま。実測すると 。=0.67em / 、=0.70em / 」=0.65em の
   アキが字面の外側に残り、中央揃えの行が約 0.33em 左（行頭「なら右）に
   ずれて見える。<br> の直前・段落末など "必ず行末になる" 約物にだけ
   負マージンを与えて、字面基準で中央に揃える。
   ---------------------------------------------------------------------- */
.h-e { margin-right: -0.67em; }
.h-s { margin-left: -0.65em; }

.copy-container.large .copy {
  font-size: var(--fs-copy-lg);
}

/* 文節単位で折り返させるユニット。nowrap が無いと inline-block が
   内部で改行してしまい、行が崩れる。 */
.nw {
  display: inline-block;
  white-space: nowrap;
}

/* --- タイトルロゴ ---------------------------------------------------
   書影 (images/isa000.png) のロックアップに合わせる:
   ・「慟哭の」と「ISA」は "左端揃え" の 2 段組（中央揃えではない）
   ・カバー実測 …「慟哭の」の字面高 ≒ ISA の cap height の 0.38 倍
   ・2 段の間隔は ISA cap height の 0.15 倍程度と狭い
   ロゴ全体は inline-block にして、その塊ごと中央に置く。
   ------------------------------------------------------------------ */
.title-logo {
  display: inline-block;
  /* ロゴ内の寸法をすべて ISA の em で記述できるよう、
     親自身を ISA のサイズにしておく */
  font-size: var(--fs-title-main);
  font-family: var(--font-mincho);
  font-weight: 500;
  text-align: left;
  color: var(--ink);
  line-height: 1;
  margin-left: var(--logo-optical); /* 字面中心を光学的な中央へ */
}

.title-logo .sub {
  display: block;
  font-size: 0.303em; /* ISA の cap height に対し字面高 0.38 倍になる比率 */
  font-weight: 600;
  letter-spacing: var(--ls-title-sub);
  line-height: 1;
  /* Cinzel の I は左サイドベアリングを持つ。字面の左端を ISA に
     揃えるため実測値 0.14em ぶん送る。 */
  margin-left: 0.14em;
}

.title-logo .main {
  display: block;
  font-size: 1em;
  font-family: var(--font-isa);
  font-weight: 600;
  letter-spacing: var(--ls-title-main);
  line-height: 1;
  margin-top: 0.03em;
}

.text-light {
  color: var(--night-text);
}

/* ------------------------------------------------------------------ 5. Backgrounds */
.bg-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  transition: opacity 1s ease, background-color 1s ease;
}

.bg-isa011 {
  background-image: url('./images/isa011.png');
  background-size: cover;
  background-position: center;
}

.bg-isa010 {
  background-image: url('./images/isa010.png');
  background-size: cover;
  background-position: center;
}

.bg-light {
  background: radial-gradient(circle at center, #ffffff 0%, var(--light) 100%);
  opacity: 0.85;
}

.bg-dark {
  background-color: var(--night);
  transition: opacity 0.5s ease;
}

.bg-dark-static {
  background-color: var(--night);
}

.bg-fire {
  background: radial-gradient(circle at bottom, rgba(141, 98, 70, 0.18) 0%, transparent 60%);
}

.bg-pale-light {
  background: radial-gradient(circle at center, #ffffff 20%, var(--sky) 100%);
  opacity: 0.45;
}

.bg-light-return {
  background-color: var(--light);
  transition: opacity 1.5s ease;
}

/* 明るい写真の上にダーク文字を置くための可読性ヴェール。
   写真は残しつつ、文字が乗る中央だけを持ち上げる。 */
.bg-veil {
  z-index: 2;
  background: radial-gradient(
    ellipse 82% 62% at 50% 48%,
    rgba(247, 244, 236, 0.94) 0%,
    rgba(247, 244, 236, 0.72) 45%,
    rgba(247, 244, 236, 0.18) 72%,
    rgba(247, 244, 236, 0) 100%
  );
}

.bg-veil.soft {
  background: radial-gradient(
    ellipse 80% 58% at 50% 46%,
    rgba(255, 255, 255, 0.7) 0%,
    rgba(255, 255, 255, 0.38) 50%,
    rgba(255, 255, 255, 0) 82%
  );
}

/* ------------------------------------------------------------------ 6. Animations */
.js .fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.js .fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.delay-1 { transition-delay: 0.5s; }
.delay-2 { transition-delay: 1s; }

/* --- CUT01 オープニング --- */
/* absolute 配置でも中央に来るよう inset:0 + max-width をリセットし、
   文字幅の制限は内側の .copy-inner で担保する。 */
.opening-sentence,
.opening-title {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--cut-pad-y) var(--gutter);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  text-align: center;
  pointer-events: none;
}

.copy-inner {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
}

.opening-white-out {
  z-index: 3;
  animation: white-out 2s ease 3s forwards;
}

.opening-sentence {
  opacity: 0;
  animation: sentence-show 5s ease forwards;
}

.opening-title {
  opacity: 0;
  animation: title-show 2s ease 4.5s forwards;
}

@keyframes white-out {
  0%   { opacity: 0.85; }
  100% { opacity: 0.3; } /* 完全に消すと写真の情報量で文字が潰れるため残す */
}

@keyframes sentence-show {
  0%   { opacity: 0; transform: translateY(16px); }
  20%  { opacity: 1; transform: translateY(0); }
  70%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-16px); }
}

@keyframes title-show {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ 7. UI */
.floating-header {
  position: fixed;
  top: 0;
  right: 0;
  /* 右端は本文と同じ --gutter に揃える（スマホで文字組の右辺と一直線になる） */
  padding: clamp(1.125rem, 2.6vw, 2.25rem) var(--gutter);
  /* inline-block のベースライン分だけ下がるのを避ける */
  display: flex;
  justify-content: flex-end;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.floating-header.visible {
  opacity: 1;
  pointer-events: auto;
}

/* CTA はボタンではなく「文字＋その下に走る一本線」。
   塗り・角丸・影を持たせると本文より強くなるので一切持たせない。 */
.cta-button {
  display: inline-block;
  text-decoration: none;
  font-family: var(--font-gothic);
  font-size: var(--fs-ui);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.5;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0 0 0.5em;
  border-bottom: 1px solid currentColor;
  white-space: nowrap;
  opacity: 0.72;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.cta-button:hover,
.cta-button:focus-visible {
  opacity: 1;
}

.header-cta {
  /* 暗いカットの上では文字色を反転させるだけ（塗りは置かない） */
  color: var(--ink);
}

body.on-dark .header-cta {
  color: var(--night-text);
}

/* 購入セクションを見ている間は、そこへ落とす導線自体が不要なので消す */
body.purchase-in-view .floating-header {
  opacity: 0;
  pointer-events: none;
}

/* --- 「下へ落ちる」シェブロン（モバイルのみ） --- */
/* 開き角 90 度の山ひとつ。線幅・色は CTA の下線と同じ言語に揃え、
   stroke を currentColor にしてあるので暗転カットでは自動で白に反転する。 */
.header-cta-arrow {
  display: none;
}

@media (max-width: 767px) {
  /* アイコン表示のときは下線を消す（矢印の着地線に見えてしまう） */
  .header-cta {
    border-bottom: 0;
    /* 見た目は 20×11 のアイコンのまま、当たり判定だけ 44px 以上に広げる */
    padding: 17px 12px;
    margin: -17px -12px;
    opacity: 0.82;
  }

  .header-cta-label {
    /* 読み上げには残し、視覚的にだけ隠す */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .header-cta-arrow {
    display: block;
  }
}

.primary-cta {
  margin-top: 0.5rem;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.primary-cta.is-pending {
  cursor: default;
  opacity: 0.72;
  user-select: none;
}

/* --- CUT10 購入 --- */
.purchase-cut {
  background-color: var(--light);
}

.purchase-container {
  /* ヘッダーのアンカーで落ちてきたとき、上端がぴったり詰まらないよう逃がす */
  scroll-margin-top: clamp(2.5rem, 6vh, 4.5rem);
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  gap: clamp(2rem, 4vw, 3.5rem);
}

.book-cover {
  width: min(70%, 300px);
  flex-shrink: 0;
}

.book-cover img {
  width: 100%;
  height: auto;
  box-shadow: 0 18px 40px rgba(17, 26, 39, 0.18);
}

.book-info {
  width: 100%;
  text-align: left;
}

.book-title {
  font-family: var(--font-mincho);
  font-size: var(--fs-book-title);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.04em;
  margin-bottom: 0.35em;
}

.author {
  font-family: var(--font-mincho);
  font-size: var(--fs-body);
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin-bottom: 1.75rem;
}

.synopsis {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-soft);
  margin-bottom: 1.75rem;
}

.book-meta {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 0.5rem 1rem;
  font-size: var(--fs-ui);
  line-height: 1.7;
  margin-bottom: 2rem;
  border-top: 1px solid rgba(33, 30, 29, 0.14);
  padding-top: 1.25rem;
}

.book-meta dt {
  color: #6b6663;
}

.cta-note {
  font-size: 0.75rem;
  color: #8a8481;
  text-align: left;
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .purchase-container {
    flex-direction: row;
    align-items: center;
  }
  .book-cover {
    width: 38%;
    max-width: 360px;
  }
  .book-info {
    width: 62%;
  }
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 2.5rem var(--gutter) calc(2.5rem + env(safe-area-inset-bottom, 0px));
  background-color: var(--paper);
  font-size: 0.75rem;
  line-height: 1.8;
  color: #6b6663;
}

.footer-links {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
}

.footer-links a {
  color: #6b6663;
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.amazon-associate {
  font-size: 0.6875rem;
  margin-top: 1rem;
}

@media (min-width: 768px) {
  footer {
    padding-bottom: 3rem;
  }
}

/* ------------------------------------------------------------------ Section tweaks */
/* CUT06: 断片を等間隔に。svh 固定だと小さい画面で溢れるため clamp。 */
.fragments-cut {
  gap: clamp(3rem, 12svh, 8rem);
}

.fragments-cut .copy {
  font-size: var(--fs-copy-sm);
}

.mt-title {
  margin-top: clamp(2.5rem, 6svh, 4.5rem);
}

/* ------------------------------------------------------------------ Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .cut {
    min-height: auto;
    padding-block: clamp(3.5rem, 8vw, 6rem);
  }
  .js .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .bg-layer,
  .cta-button {
    transition: none;
  }
  /* オープニングは重ねずに縦積みで見せる */
  .opening-cut {
    min-height: 100svh;
  }
  .opening-sentence,
  .opening-title {
    position: static;
    inset: auto;
    padding: 0;
    height: auto;
    opacity: 1;
    animation: none;
  }
  .opening-title {
    margin-top: var(--flow);
  }
  .opening-white-out {
    animation: none;
    opacity: 0.3;
  }
}
