/* Cinderella — logo-matched dark theme
 *
 * ロゴの配色（金の鍵 = 行動、青い炎 = 魔法、紺の地）をトークン化。
 * 書体は同じ Garamond 系で 2 役: 見出し/ロゴ = Cormorant（ディスプレイ）、
 * UI 本文 = EB Garamond（読みやすい本文用）。暗号素材のみ等幅。
 * フォントはセルフホスト（外部リクエストはしない）。
 */

@font-face {
  font-family: "Cormorant";
  src: url("/fonts/Cormorant.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/EBGaramond.ttf") format("truetype");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* gold（鍵）・blue（炎）のランプ。テーマ不変。 */
  --gold-hi: #fcc36a;
  --gold: #e6b05c;
  --gold-deep: #c68f3c;
  --gold-glow: rgba(230, 176, 92, 0.3);
  --blue-hi: #8aa6e0;
  --blue: #3f64c4;
  --blue-deep: #1a4da9;
  --blue-glow: rgba(63, 100, 196, 0.3);
  --err: #ff6b6b;

  /* dark（既定）: 地・文字・アクセントの解決値。アクセント = 金。 */
  --bg: #0b1420;
  --bg-raise: #0f1b29;
  --surface: #13202f;
  --surface-2: #182840;
  --line: rgba(208, 222, 245, 0.09);
  --line-strong: rgba(208, 222, 245, 0.17);
  --fg: #eef2f8;
  --muted: #94a3b8;
  --faint: #6b7a90;
  --ash: #6c7689;

  --field-bg: #0f1b29;
  --field-shadow: none;

  --accent: var(--gold);
  --accent-deep: var(--gold-deep);
  --accent-glow: var(--gold-glow);
  --accent-cool: var(--blue-hi);
  --btn-text: #3c2c0d;
  --ok-fg: var(--gold-hi);
  --seg-bg: linear-gradient(180deg, rgba(230, 176, 92, 0.24), rgba(198, 143, 60, 0.18));
  --seg-fg: var(--gold-hi);
  --seg-ring: rgba(230, 176, 92, 0.38);
  --warn-border: rgba(230, 176, 92, 0.42);
  --warn-sheen: rgba(230, 176, 92, 0.12);
  --glow-warm: rgba(230, 176, 92, 0.15);
  --glow-cool: rgba(63, 100, 196, 0.2);
  --card-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.85);
  --card-sheen: rgba(208, 222, 245, 0.1);
  --selection: rgba(63, 100, 196, 0.4);

  --radius: 14px;
  --radius-sm: 9px;
  /* display = Cormorant（見出し/ロゴ）, body = EB Garamond（読みやすいUI本文） */
  --serif: "Cormorant", Georgia, "Times New Roman", ui-serif, serif;
  --body: "EB Garamond", Georgia, "Times New Roman", ui-serif, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo,
    monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 二温度のアンビエンス: 左から金の灯り、右から炎の青。 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(54% 40% at 18% -6%, var(--glow-warm), transparent 70%),
    radial-gradient(54% 42% at 92% 0%, var(--glow-cool), transparent 72%);
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: clamp(1.8rem, 5vw, 3rem) 1.25rem 2rem;
}

/* --- ロゴ + thesis --------------------------------------------------------- */

header {
  text-align: center;
}

.logo-mark {
  display: block;
  width: min(300px, 84%);
  height: auto;
  margin: 0 auto;
}

.lede {
  margin: 0.7rem auto 0;
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 38ch;
}

.lede b {
  color: var(--accent-cool);
  font-weight: 600;
}

/* gold（鍵）から blue（炎）へ流れる一本の線。header と card の境目。 */
.fuse {
  height: 1px;
  margin: 1.3rem 0 1.5rem;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--gold) 18%,
    var(--line-strong) 50%,
    var(--blue) 82%,
    transparent 100%
  );
  opacity: 0.85;
}

/* --- card ------------------------------------------------------------------ */

.card {
  text-align: left;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.3rem 1.5rem;
  box-shadow: 0 1px 0 var(--card-sheen) inset, var(--card-shadow);
}

.card + .card {
  margin-top: 1rem;
}

h2 {
  margin: 0 0 0.2rem;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0;
}

/* ラベルは本文（導入文）と同じ EB Garamond・通常字間で読みやすく。 */
.field-label {
  display: block;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 1.2rem 0 0.5rem;
}

.field-label:first-of-type {
  margin-top: 0;
}

.field-label .opt {
  color: var(--ash);
  font-weight: 400;
  font-size: 0.85em;
}

/* --- 入力 ------------------------------------------------------------------ */

textarea,
input[type="text"] {
  width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.7rem 0.8rem;
  box-shadow: var(--field-shadow);
  transition: border-color 0.18s, box-shadow 0.18s;
}

textarea::placeholder,
input::placeholder {
  color: var(--faint);
}

/* 秘密はヒーロー。器としての存在感を持たせる。 */
.secret-input {
  min-height: 132px;
  resize: vertical;
  line-height: 1.5;
  padding-bottom: 1.6rem; /* カウンタ分の余白 */
}

.secret-wrap {
  position: relative;
}

/* 文字数カウンタ。入力欄の右下。 */
.counter {
  position: absolute;
  right: 12px;
  bottom: 9px;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--faint);
  pointer-events: none;
}

/* フォーカス時にアクセント色の灯りを帯びる。 */
textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- セグメント型コントロール（条件のダイヤル）--------------------------- */

.dials {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.dial {
  flex: 1;
  min-width: 0;
}

.segmented {
  display: flex;
  background: var(--field-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  box-shadow: var(--field-shadow);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 0.45rem 0.1rem;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.segmented label:hover {
  color: var(--fg);
}

.segmented input:checked + label {
  background: var(--seg-bg);
  color: var(--seg-fg);
  box-shadow: 0 0 0 1px var(--seg-ring) inset;
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- ボタン ---------------------------------------------------------------- */

.btn {
  display: block;
  width: 100%;
  margin-top: 1.4rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--body);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, filter 0.18s;
}

/* ロゴの鍵に合わせた金属的な金。上に光、下に深いアンバー。 */
.btn-primary {
  color: var(--btn-text);
  background: linear-gradient(
    180deg,
    #ffd98f 0%,
    var(--gold-hi) 28%,
    var(--gold) 64%,
    var(--gold-deep) 100%
  );
  box-shadow:
    0 8px 22px -10px var(--gold-glow),
    0 0 0 1px rgba(255, 214, 140, 0.5) inset,
    0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05) saturate(1.05);
  box-shadow:
    0 13px 30px -10px var(--gold-glow),
    0 0 0 1px rgba(255, 214, 140, 0.6) inset,
    0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line-strong);
}

.btn-ghost:hover {
  border-color: var(--muted);
  background: rgba(127, 127, 127, 0.06);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* --- 補助テキスト ---------------------------------------------------------- */

.reassure,
.note {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.9rem;
}

/* 「中身は見ていない」trust はアクセント色で示す。 */
.note.ok {
  color: var(--ok-fg);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

/* --- 共有リンク ------------------------------------------------------------ */

.linkbox {
  display: flex;
  gap: 0.5rem;
}

.linkbox input {
  font-size: 0.8rem;
}

.linkbox .btn {
  margin: 0;
  width: auto;
  white-space: nowrap;
  padding: 0 1.1rem;
  font-size: 1rem;
}

/* --- 受信・開封 ------------------------------------------------------------ */

/* 開封を促すカードはアクセントの縁取りで「まだ開いていない鍵」を示す。 */
.card.warn {
  border-color: var(--warn-border);
  box-shadow: 0 0 0 1px var(--warn-sheen) inset, var(--card-shadow);
}

/* 開封後の中身は ash 面に着地（消費済み）。 */
.secret {
  margin: 0.6rem 0 0;
  padding: 0.85rem 0.9rem;
  background: var(--field-bg);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--ash);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.passphrase-hint {
  color: var(--accent-deep);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

/* --- エラー ---------------------------------------------------------------- */

.card.error {
  border-color: rgba(255, 107, 107, 0.35);
}

.card.error h2 {
  color: var(--err);
}

/* --- footer ---------------------------------------------------------------- */

footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 1.6rem 1.25rem 1.4rem;
  font-family: var(--body);
  color: var(--faint);
  text-align: center;
  line-height: 1.5;
}

.foot-line {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.foot-meta {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
}

footer a {
  color: var(--accent-cool);
  text-decoration: none;
}

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

.foot-meta .sep {
  margin: 0 0.45rem;
  opacity: 0.5;
}

/* --- 状態 ------------------------------------------------------------------ */

.hidden {
  display: none !important;
}

::selection {
  background: var(--selection);
  color: var(--fg);
}

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

@media (max-width: 420px) {
  .dials {
    flex-direction: column;
    gap: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
