/* カーネリアン 予約サイト: 「カウンターで渡される、手書きのお手紙」 (docs/DESIGN_VISUAL.md) */

:root {
  color-scheme: light dark;

  /* 色: 明るい表示 (水彩紙) */
  --sky: #DCE6F2;
  --paper: #FFFDF8;
  --paper-2: #F7F1E3;
  --field: #FFFFFF;
  --ink: #2F2A3D;
  --muted: #5C566B;
  --olive: #8A7A3C;
  --olive-faint: rgb(138 122 60 / 0.55);
  --carn: #B5401F;
  --carn-hover: #983318;
  --on-carn: #FFFDF8;
  --carn-tint: #FBE6DC;
  --flax: #4A5FC1;
  --err-bg: #F5EBDD;

  --ribbon-btn-bg: #FFFDF8;
  --ribbon-btn-text: #2F2A3D;
  --ink-shadow: rgb(47 42 61 / 0.28);
  --lamp: rgb(255 240 214 / 0.75);
  --lamp-edge: rgb(255 240 214 / 0);

  /* 書体 */
  --font-hand: "Klee One", "Yu Kyokasho", "UD Digi Kyokasho N-R", "Hiragino Maru Gothic ProN", "Yu Gothic", serif;
  --font-body: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sky: #191B2E;
    --paper: #2A2420;
    --paper-2: #342C26;
    --field: #211C19;
    --ink: #F3E9DA;
    --muted: #CBBEAE;
    --olive: #B9A35E;
    --olive-faint: rgb(185 163 94 / 0.6);
    --carn: #E0714F;
    --carn-hover: #EA8767;
    --on-carn: #191B2E;
    --carn-tint: #4A2A20;
    --flax: #9AA8F0;
    --err-bg: #3A302A;

    --ribbon-btn-bg: #191B2E;
    --ribbon-btn-text: #F3E9DA;
    --ink-shadow: rgb(0 0 0 / 0.5);
    --lamp: rgb(255 170 90 / 0.4);
    --lamp-edge: rgb(58 42 26 / 0);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--sky);
  background-image:
    radial-gradient(70vmax 46vmax at 10% 4%, rgb(255 255 255 / 0.55), transparent 70%),
    radial-gradient(56vmax 40vmax at 92% 26%, rgb(150 178 222 / 0.32), transparent 70%),
    radial-gradient(80vmax 50vmax at 22% 92%, rgb(255 255 255 / 0.42), transparent 70%),
    radial-gradient(46vmax 34vmax at 96% 88%, rgb(176 196 232 / 0.5), transparent 70%),
    url("/static/grain.png");
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, repeat;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;      /* 17px */
  line-height: 1.9;
  letter-spacing: 0.03em;
  line-break: strict;
  overflow-wrap: anywhere;
}
@media (prefers-color-scheme: dark) {
  body {
    background-image:
      radial-gradient(60vmax 40vmax at 50% -6%, rgb(70 52 40 / 0.5), transparent 70%),
      radial-gradient(60vmax 44vmax at 100% 70%, rgb(44 48 92 / 0.45), transparent 70%),
      url("/static/grain.png");
    background-repeat: no-repeat, no-repeat, repeat;
  }
}

img { max-width: 100%; height: auto; }
p { margin: 0 0 var(--s3); text-wrap: pretty; }
a { color: var(--flax); text-underline-offset: 4px; }

:focus-visible { outline: 3px solid var(--flax); outline-offset: 3px; }

.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 10;
  background: var(--paper); color: var(--ink);
  padding: var(--s2) var(--s3); border-radius: 8px;
}
.skip-link:focus { top: var(--s2); }

.page { max-width: 680px; margin: 0 auto; padding: 0 var(--s4) var(--s7); }

/* 見出し: 手書きの書体。文節で改行する */
h1, h2, h3, .step > legend, .greeting {
  font-family: var(--font-hand);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.5;
  word-break: auto-phrase;
  overflow-wrap: normal;
  text-wrap: balance;
}
h1 { font-size: 2.0625rem; margin: 0 0 var(--s3); }   /* 33px */
h2 { font-size: 1.6875rem; margin: 0 0 var(--s3); }   /* 27px */
h3 { font-size: 1.3125rem; margin: 0 0 var(--s2); }   /* 21px */

.hint { color: var(--muted); font-size: 0.9375rem; line-height: 1.8; margin: var(--s1) 0 var(--s3); }

/* ---------- 冒頭: ランプの灯りとあいさつ ---------- */
.hero { text-align: center; padding: var(--s6) 0 var(--s5); }
.hero-logo { position: relative; width: 150px; margin: 0 auto var(--s4); }
.hero-logo img { position: relative; display: block; width: 100%; height: auto; }
.hero-logo::before {
  content: ""; position: absolute; z-index: 0;
  left: 50%; top: 50%; width: 360px; height: 360px;
  margin: -180px 0 0 -180px;
  background: radial-gradient(closest-side, var(--lamp), var(--lamp-edge));
  pointer-events: none;
  animation: lamp-on 2.2s ease-out 0.2s both;
}
.hero-small { padding-top: var(--s5); }
.hero-small .hero-logo { margin-bottom: 0; width: 120px; }
.greeting { font-size: 1.875rem; margin: 0 0 var(--s2); }
.greeting-sub { max-width: 21em; margin: 0 auto var(--s3); font-size: 1rem; text-wrap: balance; }
.hero-event { color: var(--muted); font-size: 0.9375rem; margin: 0; }

@keyframes lamp-on { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ---------- 便箋 ---------- */
.letter {
  position: relative;
  background-color: var(--paper);
  background-image: url("/static/grain.png");
  border: 5px double var(--olive);
  border-radius: 28px 40px 30px 44px / 42px 30px 46px 32px;
  padding: var(--s5) 18px 96px;
  box-shadow: 0 1px 0 var(--ink-shadow), 0 18px 34px -18px var(--ink-shadow);
}
/* 亜麻の花は、便箋の角に 1 か所だけ */
.letter::after {
  content: ""; position: absolute; right: -6px; bottom: -8px;
  width: 132px; height: 114px; pointer-events: none;
  background: url("/static/flax.svg") no-repeat right bottom / contain;
}

.letter-intro { text-align: center; }
.letter-intro h2 { font-size: 1.5rem; }
.letter-intro .lead { text-align: left; }
.notes { text-align: left; margin: var(--s4) 0 0; padding-left: 1.3em; }
.notes li { margin-bottom: var(--s2); padding-left: 2px; text-wrap: pretty; }
.notes li::marker { color: var(--olive); }
.notes strong { font-weight: 700; }

/* 手順の区切りは、手描きの波線 */
.step, .letter-section + .letter-section, #empty { position: relative; }
.step::before, .letter-section + .letter-section::before, #empty::before {
  content: ""; display: block; height: 14px; margin: 0 0 var(--s4);
  background-color: var(--olive);
  -webkit-mask: url("/static/wave.svg") repeat-x center / 120px 14px;
          mask: url("/static/wave.svg") repeat-x center / 120px 14px;
}
.letter-section { padding-top: var(--s2); }
.letter-section + .letter-section { margin-top: var(--s5); }
#empty { margin-top: var(--s5); }

fieldset.step { border: 0; margin: var(--s5) 0 0; padding: 0; min-width: 0; }
.step > legend {
  padding: 0; margin: 0 0 var(--s3); float: left; width: 100%;
  display: flex; align-items: center; gap: var(--s3);
  font-size: 1.3125rem;
}
.step > legend + * { clear: both; }
.step-num {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; font-size: 1.125rem; line-height: 1;
  border: 2px solid var(--olive);
  border-radius: 52% 48% 55% 45% / 47% 55% 45% 53%;
  color: var(--ink);
}

/* ---------- 選ぶ部品 ---------- */
.choices { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
.choice { position: relative; display: block; }
.choice > input[type="radio"] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer; z-index: 1;
}
.choice-body {
  position: relative; display: block; min-height: 48px;
  border: 1.5px solid var(--olive);
  background-color: var(--field);
  color: var(--ink);
}
.choice-title { display: block; font-weight: 700; }
.choice-sub { display: block; font-size: 0.9375rem; color: var(--muted); line-height: 1.7; }

.choice:hover > input:not(:disabled) + .choice-body { border-color: var(--carn); }
.choice > input:checked + .choice-body {
  border-color: var(--carn); background-color: var(--carn-tint);
  box-shadow: inset 0 0 0 1px var(--carn);
}
.choice > input:focus-visible + .choice-body { outline: 3px solid var(--flax); outline-offset: 3px; }
.choice > input:disabled { cursor: not-allowed; }
.choice > input:disabled + .choice-body {
  background-color: transparent; border-style: dashed; border-color: var(--olive-faint); color: var(--muted);
}

/* 選んだしるし(丸。選ぶと中が塗られ、チェックが入る) */
.choice-body::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--olive); background-color: transparent;
}
.choice > input:checked + .choice-body::after {
  border-color: var(--carn); background-color: var(--carn);
  background-image: url("/static/check-light.svg"); background-size: 100% 100%; background-repeat: no-repeat;
}
@media (prefers-color-scheme: dark) {
  .choice > input:checked + .choice-body::after { background-image: url("/static/check-dark.svg"); }
}
.choice > input:disabled + .choice-body::after { border-color: var(--olive-faint); border-style: dashed; }

/* 日付と時間: 小さな紙の券 */
.dates, .slots { grid-template-columns: 1fr 1fr; }
@media (max-width: 349px) { .dates, .slots { grid-template-columns: 1fr; } }
.dates .choice-body, .slots .choice-body {
  padding: var(--s3) 6px var(--s3) 30px; text-align: center; letter-spacing: 0.01em;
  border-radius: 4px 12px 12px 4px;
}
.dates .choice-body::before, .slots .choice-body::before {
  content: ""; position: absolute; left: 25px; top: 8px; bottom: 8px;
  border-left: 2px dotted var(--olive-faint);
}
.dates .choice-body::after, .slots .choice-body::after { left: 4px; top: 50%; margin-top: -8px; }
.dates .choice-body { font-family: var(--font-hand); font-weight: 600; font-size: 1rem; }
.dates .choice-title { font-weight: 600; }
.slots .choice-title { font-weight: 500; }

/* カウンセラー: プロフィール帳の札 */
#counsellors .choice-body {
  padding: var(--s4) var(--s3) var(--s4) var(--s3);
  border-left: 10px double var(--olive);
  border-radius: 6px 16px 16px 6px;
}
#counsellors .choice-body::after { right: 12px; top: 14px; }
#counsellors .choice > input:checked + .choice-body { border-left-color: var(--carn); }
#counsellors .choice > input:disabled + .choice-body { border-left-color: var(--olive-faint); }
.cs-body { display: grid; grid-template-columns: 60px 1fr; gap: 4px var(--s3); align-items: start; }
.cs-img, .cs-mono {
  width: 60px; height: 60px; object-fit: cover;
  border: 2px solid var(--olive); border-radius: 10px 20px 10px 20px;
  background-color: var(--paper-2);
}
.cs-mono { display: flex; align-items: center; justify-content: center; font-family: var(--font-hand); font-weight: 600; font-size: 1.75rem; color: var(--ink); }
.cs-name { display: block; padding-right: 22px; font-family: var(--font-hand); font-weight: 600; font-size: 1.3125rem; line-height: 1.5; }
.cs-meta { display: block; font-size: 0.9375rem; color: var(--muted); line-height: 1.7; }
.cs-meta b { font-weight: 700; color: var(--ink); }
.cs-message { display: block; margin-top: var(--s2); font-family: var(--font-hand); font-weight: 600; font-size: 1rem; line-height: 1.85; color: var(--ink); }
.choice > input:disabled + .choice-body .cs-img { filter: grayscale(0.6); }
.choice > input:disabled + .choice-body .cs-name,
.choice > input:disabled + .choice-body .cs-message,
.choice > input:disabled + .choice-body .cs-meta b { color: var(--muted); }

/* ---------- 入力欄 ---------- */
.field { margin: 0 0 var(--s5); }
.field:last-child { margin-bottom: 0; }
.field > label:not(.check), .label { display: block; font-weight: 700; margin-bottom: var(--s1); }
.req, .opt {
  display: inline-block; margin-left: var(--s2); padding: 0 var(--s2);
  font-size: 0.8125rem; font-weight: 500; line-height: 1.6; letter-spacing: 0.02em;
  border-radius: 999px; vertical-align: 0.08em; color: var(--ink);
}
.req { border: 1px solid var(--olive); }
.opt { color: var(--muted); }
input[type="text"], input[type="url"], textarea {
  width: 100%; min-height: 48px; padding: var(--s3);
  font: inherit; letter-spacing: inherit; line-height: 1.7; color: var(--ink);
  background-color: var(--field);
  border: 1.5px solid var(--olive); border-radius: 10px 14px 10px 14px;
}
textarea {
  min-height: 12rem; resize: vertical; line-height: 2rem; padding-top: 8px;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(2rem - 1px), var(--olive-faint) calc(2rem - 1px), var(--olive-faint) 2rem);
  background-attachment: local; background-position: 0 8px; background-size: 100% 100%;
}
input[type="text"]:focus-visible, input[type="url"]:focus-visible, textarea:focus-visible { border-color: var(--flax); outline-offset: 1px; }
::placeholder { color: var(--muted); opacity: 1; }
.counter { text-align: right; font-size: 0.9375rem; color: var(--muted); margin-top: var(--s1); }
.counter.is-near { color: var(--ink); font-weight: 700; }

.check {
  display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer;
  padding: var(--s3) var(--s4); background-color: var(--field);
  border: 1.5px solid var(--olive); border-radius: 8px 16px 8px 16px;
}
.check input[type="checkbox"] { width: 1.5rem; height: 1.5rem; margin: 4px 0 0; flex: none; accent-color: var(--carn); cursor: pointer; }
.check-text { display: block; }
.check-title { display: block; font-weight: 700; }
.check-sub { display: block; font-size: 0.9375rem; color: var(--muted); line-height: 1.8; }
.check:has(input:checked) { border-color: var(--carn); background-color: var(--carn-tint); }
.check:has(input:focus-visible) { outline: 3px solid var(--flax); outline-offset: 3px; }
.reveal { margin-top: var(--s3); padding-left: var(--s3); border-left: 3px double var(--olive); }

.hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.field-error { color: var(--ink); font-weight: 700; font-size: 0.9375rem; margin-top: var(--s1); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: var(--s2) var(--s6);
  font: inherit; font-weight: 700; letter-spacing: 0.06em; text-decoration: none;
  border-radius: 999px; border: 2px solid var(--carn);
  background-color: var(--carn); color: var(--on-carn);
  cursor: pointer; transition: background-color 0.15s ease;
}
.btn:hover:not(:disabled) { background-color: var(--carn-hover); border-color: var(--carn-hover); color: var(--on-carn); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-quiet { background-color: transparent; color: var(--ink); border-color: var(--olive); }
.btn-quiet:hover:not(:disabled) { background-color: var(--paper-2); border-color: var(--olive); color: var(--ink); }
.btn-danger { background-color: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-danger:hover:not(:disabled) { background-color: var(--ink); border-color: var(--ink); color: var(--paper); filter: brightness(1.15); }
.btn-row { display: flex; gap: var(--s3); flex-wrap: wrap; }

/* ---------- 知らせ: インクの色の文字と、淡い地 ---------- */
.message {
  margin: 0 0 var(--s4); padding: var(--s3) var(--s4);
  background-color: var(--err-bg); color: var(--ink);
  border: 1.5px solid var(--olive); border-left-width: 6px; border-radius: 6px 14px 14px 6px;
}
.message:empty { display: none; }
.message-error { font-weight: 500; }

.loading { color: var(--muted); text-align: center; padding: var(--s6) 0; }
.loading-tall { min-height: 30rem; }  /* 個人ページのカードが入る分の高さ。入れ替えでずれにくくする */
.spinner {
  display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -0.2em; margin-right: var(--s2);
  border: 2px solid var(--olive-faint); border-top-color: var(--olive); border-radius: 50%;
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.submit-area { margin-top: var(--s6); }
.notice-strong {
  margin: 0 0 var(--s4); padding: var(--s3) var(--s4);
  background-color: var(--paper-2); border: 2px solid var(--olive); border-radius: 8px 16px 8px 16px;
}
.fine { color: var(--muted); font-size: 0.9375rem; text-align: center; margin: var(--s3) 0 0; }

/* ---------- 個人ページ ---------- */
.status-card { text-align: center; }
.status-badge {
  display: inline-block; margin-bottom: var(--s3); padding: 0 var(--s4);
  font-size: 0.9375rem; font-weight: 700; line-height: 1.9;
  border: 1.5px solid var(--olive); border-radius: 999px;
}
.status-card h1 { font-size: 1.75rem; }
.status-message { text-align: left; }
.dl { margin: var(--s4) 0 0; text-align: left; display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); align-items: baseline; }
.dl dt { color: var(--muted); font-size: 0.9375rem; }
.dl dd { margin: 0; font-weight: 700; }
.dl dd.code { font-family: var(--font-hand); font-weight: 600; font-size: 1.1875rem; letter-spacing: 0.1em; }
.letter-section h2 { font-size: 1.3125rem; }
.confirm-box { margin-top: var(--s4); padding: var(--s4); background-color: var(--paper-2); border: 2px solid var(--olive); border-radius: 8px 16px 8px 16px; }

/* 栞: カーネリアン色のリボン。ページの最上部に下がる */
.ribbon-wrap { display: none; position: relative; z-index: 2; max-width: 560px; margin: 0 auto; filter: drop-shadow(0 10px 10px var(--ink-shadow)); }
.ribbon {
  position: relative; text-align: center;
  padding: var(--s5) 20px 64px;
  background-color: var(--carn); color: var(--on-carn);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 30px), 0 100%);
}
html.is-new .ribbon-wrap { display: block; }
.ribbon::before {
  content: ""; position: absolute; inset: 9px 9px 42px; pointer-events: none;
  border: 1.5px dashed var(--on-carn); opacity: 0.55; border-radius: 4px;
}
.ribbon:focus-visible { outline: 3px solid var(--on-carn); outline-offset: -8px; }
.ribbon :focus-visible { outline-color: var(--on-carn); }
.ribbon h2 { font-size: 1.3125rem; margin: 0 0 var(--s3); }
.ph { display: inline-block; }
.ribbon-first { font-family: var(--font-hand); font-weight: 600; font-size: 1.1875rem; letter-spacing: 0.08em; margin: 0 0 var(--s1); }
.ribbon-why { font-weight: 700; margin: 0 0 var(--s4); }
.ribbon-hint { font-size: 0.9375rem; text-align: left; margin: var(--s3) 0 0; }
.ribbon-feedback { font-weight: 700; min-height: 1.9em; margin: var(--s2) 0 0; }
.btn-ribbon {
  min-height: 60px; font-size: 1.1875rem;
  background-color: var(--ribbon-btn-bg); color: var(--ribbon-btn-text); border-color: var(--ribbon-btn-bg);
}
.btn-ribbon:hover:not(:disabled) { background-color: var(--ribbon-btn-bg); border-color: var(--ribbon-btn-bg); color: var(--ribbon-btn-text); filter: brightness(1.12); }

.footer { text-align: center; margin-top: var(--s6); color: var(--muted); font-family: var(--font-hand); font-weight: 600; letter-spacing: 0.08em; }
.footer p { margin: 0; }
.footer a { font-family: var(--font-body); font-weight: 500; }

@media (min-width: 640px) {
  .page { padding-left: var(--s5); padding-right: var(--s5); }
  .hero-logo { width: 170px; }
  .hero-logo::before { width: 480px; height: 480px; margin: -240px 0 0 -240px; }
  .greeting { font-size: 2.0625rem; }
  .letter { padding: var(--s6) var(--s6) 110px; }
  .letter::after { width: 160px; height: 138px; right: -10px; bottom: -12px; }
  .letter-intro h2 { font-size: 1.6875rem; }
  .dates, .slots { grid-template-columns: repeat(3, 1fr); }
  .ribbon { padding-left: var(--s6); padding-right: var(--s6); }
  .ribbon h2 { font-size: 1.625rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 個人ページ: 控えのお願い(再訪のとき)、更新、読み込み失敗 */
.keep-note {
  margin: var(--s5) 0 0; padding: var(--s4); text-align: left;
  background-color: var(--carn-tint); color: var(--ink);
  border: 1.5px solid var(--carn); border-left-width: 6px; border-radius: 6px 16px 16px 6px;
}
.keep-note p { margin: 0 0 var(--s3); font-weight: 700; }
.keep-note .btn { width: 100%; }
.keep-note .keep-feedback { margin: var(--s2) 0 0; }
.keep-note .keep-feedback:empty { margin: 0; }
.refresh-row { margin: var(--s4) 0 0; }
.notice-retry { margin: calc(-1 * var(--s2)) 0 var(--s5); text-align: center; }
.step { scroll-margin-top: var(--s4); }

/* 読み込み中は奥の署名を見せない(入れ替えのずれを数えさせない) */
.footer-late { visibility: hidden; }
body.is-ready .footer-late { visibility: visible; }

/* 相談内容の扱い(箇条書き)と、公的な相談窓口のリンク */
.hint p { margin: 0 0 var(--s2); }
.privacy-list { margin: 0 0 var(--s2); padding-left: 1.3em; }
.privacy-list li { margin-bottom: var(--s1); }
.privacy-list li::marker { color: var(--olive); }
.notes a { display: block; margin-top: var(--s1); font-weight: 700; word-break: auto-phrase; }
.notes a.inline-link { display: inline; margin-top: 0; }
