/* Ubuoto — 心音の記念動画
   産院で受け取る記念品らしい、和モダンで上品な一枚ページ。
   フォントは明朝系（システム搭載）で統一する。 */

:root {
  --bg: #FAF6F1;
  --bg-deep: #F3EBE2;
  --card: #FFFFFF;
  --ink: #4A3E3B;
  --sub: #97867F;
  --hairline: #EBE0D8;
  --shadow: 0 10px 30px rgba(74, 62, 59, 0.10);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "BIZ UDMincho", "Noto Serif JP", serif;

  /* テーマ（さくら）。カーソル色は動画側の定数（#FF8C7A / #6BB5FF）と揃える */
  --accent: #E0827A;
  --accent-soft: #FBE9E6;
  --cursor: #FF8C7A;
}
body[data-theme="blue"] {
  --accent: #5C9CD6;
  --accent-soft: #E4EFF9;
  --cursor: #6BB5FF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 0%, #FFFDFB 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.view { min-height: 100vh; min-height: 100dvh; }

.sheet {
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px 48px;
}

/* --- 見出し・ブランド --- */

.brand {
  margin: 0;
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* トラッキングの右余りを補正 */
  font-weight: 500;
}

.masthead { padding: 18px 0 14px; }

.tagline {
  margin: 6px 0 0;
  text-align: center;
  color: var(--sub);
  font-size: 12.5px;
  letter-spacing: 0.18em;
}

.rule {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 18px auto;
  width: 72px;
}

/* --- 読み込み中 --- */

#view-loading {
  display: flex; align-items: center; justify-content: center;
}
.loading-mark { text-align: center; }
.pulse-dot {
  display: block;
  width: 14px; height: 14px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--accent);
  animation: heartbeat 1.15s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1);   opacity: .85; }
  14%       { transform: scale(1.5); opacity: 1;   }
  28%       { transform: scale(1);   opacity: .85; }
  42%       { transform: scale(1.3); opacity: 1;   }
}

/* --- 無効ページ --- */

#view-invalid .sheet { padding-top: 22vh; text-align: center; }
.invalid-title { font-size: 19px; font-weight: 600; margin: 22px 0 10px; }
.invalid-text  { color: var(--sub); font-size: 14px; margin: 0; }

/* --- プレビュー --- */

.preview-card {
  margin: 8px 0 26px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.canvas-wrap { position: relative; background: #201B1A; }

#preview {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.play-btn {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 253, 251, 0.88);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform .15s ease, opacity .3s ease;
}
.play-btn:active { transform: translate(-50%, -50%) scale(0.94); }
.play-btn.is-playing { opacity: 0; }
.canvas-wrap:hover .play-btn.is-playing,
.play-btn.is-playing:focus-visible { opacity: 1; }
.play-btn svg { width: 26px; height: 26px; fill: var(--accent); vertical-align: middle; }

.preview-caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 16px 12px;
  margin: 0;
  font-size: 12px;
  color: var(--sub);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.caption-note { font-size: 11px; }

/* --- フォーム --- */

.field { margin: 0 2px 22px; }

.field-label {
  display: block;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--sub);
  margin-bottom: 8px;
}

input[type="text"] {
  width: 100%;
  font-family: var(--serif);
  font-size: 16px; /* iOSのズーム防止に16px以上 */
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: #C4B8B1; }

.char-count {
  margin: 5px 4px 0 0;
  text-align: right;
  font-size: 11px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}

.field-note { margin: 8px 2px 0; font-size: 12px; color: var(--sub); }
.field-note.is-error { color: #C0554D; }

/* 写真ボタン */
.photo-btn {
  width: 100%;
  font-family: var(--serif);
  font-size: 14.5px;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--card);
  border: 1.5px dashed #D8C9BE;
  border-radius: 12px;
  padding: 20px 14px;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.photo-btn:active { background: var(--accent-soft); }
.photo-btn.has-photo {
  border-style: solid;
  border-color: var(--hairline);
  padding: 13px 14px;
  color: var(--sub);
}

/* 配色スウォッチ */
.swatches { display: flex; gap: 12px; }
.swatch {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--hairline);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.swatch-dot { width: 17px; height: 17px; border-radius: 50%; }
.swatch-pink .swatch-dot { background: #FF8C7A; }
.swatch-blue .swatch-dot { background: #6BB5FF; }
.swatch.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* --- CTA --- */

.cta-block { margin-top: 30px; }

.cta {
  display: block;
  width: 100%;
  font-family: var(--serif);
  font-size: 16.5px;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-align: center;
  color: #FFFDFB;
  background: var(--accent);
  border: none;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .15s ease, opacity .2s ease, background .3s ease;
  text-decoration: none;
}
.cta:active { transform: scale(0.985); }
.cta:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.cta-sub { display: block; font-size: 11.5px; letter-spacing: 0.12em; margin-top: 3px; opacity: .85; }
.cta-download { margin-top: 12px; }

.progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--sub);
  font-size: 13.5px;
  letter-spacing: 0.1em;
}
.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- フッター --- */

.page-foot {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  text-align: center;
  font-size: 11.5px;
  color: var(--sub);
  letter-spacing: 0.04em;
}
.page-foot p { margin: 0; }
