/* ============================================================
 * LINE Webhook Design System — TALK
 *   「言葉が、ふきだしになって届く」
 *   白い面に、LINE のグリーン。角はまるく、動きはぽんっと弾むように。
 *   （LINE の雰囲気に寄せたオリジナルのデザインです。LINE のロゴや画面そのものは使いません）
 * ============================================================ */

:root {
  color-scheme: light;

  /* --- Surfaces --- */
  --bg: #f3f5f4;
  --bg-deep: #e9eeeb;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #eef2f0;
  --line: #e3e8e5;
  --line-strong: #d1d9d5;

  /* --- Ink (text) --- */
  --ink: #111814;
  --ink-soft: #343d38;
  --ink-mute: #66706b;
  --ink-faint: #99a29d;

  /* --- LINE green & signals --- */
  --green: #06c755;            /* LINE のブランドカラー（面・アイコン・主ボタン） */
  --green-strong: #05b04b;     /* 押したとき・ホバー */
  --green-ink: #03843a;        /* 白地の上の緑の文字（コントラスト 4.5 以上） */
  --green-soft: #e6f8ee;
  --green-softer: #f2fbf6;
  --bubble-out: #a6e69a;       /* 自分（ボット）が送ったふきだし */
  --talk-bg: #cddbec;          /* トークルームの背景 */

  --blue: #1e6fd9;
  --blue-soft: #e8f1fd;
  --amber: #ffb020;
  --amber-ink: #8a5800;
  --amber-soft: #fff4dd;
  --red: #f23b4f;
  --red-ink: #c21f33;
  --red-soft: #fdebed;
  --violet: #7a5cfa;
  --violet-ink: #5a3ed6;
  --violet-soft: #f0ecff;

  --accent: var(--green);
  --accent-ink: #ffffff;
  --danger: var(--red-ink);
  --selection: rgba(6, 199, 85, 0.24);
  --selection-ink: var(--ink);

  /* 以前の名前（コンポーネントの CSS のため、新しい色の別名として残す） */
  --signal: var(--green);
  --signal-deep: var(--green-strong);
  --cyan: var(--blue);
  --coral: var(--red);
  --night-0: #ffffff;
  --night-1: var(--surface-2);
  --night-2: var(--surface-3);
  --night-3: var(--line);
  --bg-soft: var(--surface-2);
  --bg-elev: var(--surface);
  --glass: var(--surface);
  --glass-strong: var(--surface);
  --glass-border: var(--line);
  --glass-border-strong: var(--line-strong);
  --glass-highlight: transparent;
  --glass-blur: 0px;
  --rule: var(--line-strong);
  --rule-soft: var(--line);
  --gradient-signal: linear-gradient(135deg, #19d36a 0%, #06c755 55%, #04b04f 100%);
  --gradient-signal-soft: linear-gradient(135deg, var(--green-soft), var(--green-softer));
  --gradient-hairline: linear-gradient(var(--line), var(--line));
  --glow-signal: 0 6px 18px -6px rgba(6, 199, 85, 0.55);
  --glow-cyan: 0 0 0 4px rgba(6, 199, 85, 0.16);

  --color-primary: var(--green);
  --color-primary-dark: var(--green-strong);
  --color-secondary: var(--ink-soft);
  --color-success: var(--green-ink);
  --color-danger: var(--red-ink);
  --color-warning: var(--amber-ink);
  --color-info: var(--blue);
  --color-light: var(--surface-2);
  --color-dark: var(--ink);
  --color-text: var(--ink);
  --color-text-muted: var(--ink-mute);
  --color-background: var(--bg);
  --color-border: var(--line);

  /* --- Typography --- */
  --font-sans: "LINE Seed JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  --font-display: var(--font-sans);
  --font-serif: var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-family-sans-serif: var(--font-sans);

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
  --fs-3xl: clamp(2.1rem, 1.4rem + 3vw, 3.5rem);
  --fs-4xl: clamp(2.6rem, 1.2rem + 6vw, 6rem);

  --font-size-base: 16px;
  --font-size-lg: var(--fs-lg);
  --font-size-sm: var(--fs-sm);
  --font-weight-normal: 400;
  --font-weight-bold: 700;
  --line-height-base: 1.8;
  --tracking-tight: 0.01em;
  --tracking-wide: 0.08em;

  /* --- Spacing --- */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 1rem;
  --s-4: 1.5rem;
  --s-5: 2.5rem;
  --s-6: 4rem;
  --s-7: 6rem;
  --spacing-1: var(--s-1);
  --spacing-2: var(--s-2);
  --spacing-3: var(--s-3);
  --spacing-4: var(--s-4);
  --spacing-5: var(--s-5);

  /* --- Geometry（まるく、やわらかく） --- */
  --rule-width: 1px;
  --rule-width-bold: 2px;
  --radius-0: 0;
  --radius-1: 10px;
  --radius-2: 14px;
  --radius-3: 20px;
  --radius-pill: 999px;
  --border-width: var(--rule-width);
  --border-radius: var(--radius-2);
  --border-radius-sm: var(--radius-1);
  --border-radius-lg: var(--radius-3);

  /* --- Depth --- */
  --shadow-sm: 0 1px 2px rgba(17, 24, 20, 0.06);
  --shadow: 0 1px 2px rgba(17, 24, 20, 0.04), 0 10px 28px -12px rgba(17, 24, 20, 0.14);
  --shadow-lg: 0 2px 6px rgba(17, 24, 20, 0.04), 0 28px 64px -24px rgba(17, 24, 20, 0.26);

  /* --- Motion（ぽんっと弾む） --- */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-1: 140ms;
  --dur-2: 240ms;
  --dur-3: 480ms;
}

/* ============================================================
 * Reset / base
 * ============================================================ */

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

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-color: var(--bg);
  scrollbar-color: #c4ccc8 transparent;
  scrollbar-width: thin;
}

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  letter-spacing: 0.02em;
  color: var(--ink);
  background-color: var(--bg);
  overflow-x: hidden;
  isolation: isolate;
}

/* three.js のふきだし（front_end/experience が挿入する） */
#lumen-field {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}

#lumen-field.is-ready {
  opacity: 1;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  /* 日本語を文節で折り返し、行の長さを揃える（対応ブラウザのみ） */
  word-break: auto-phrase;
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-3xl);
}

h2 {
  font-size: var(--fs-2xl);
}

h3 {
  font-size: var(--fs-xl);
}

h4 {
  font-size: var(--fs-lg);
}

p {
  color: var(--ink-soft);
  word-break: auto-phrase;
  text-wrap: pretty;
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}

/* 文中のリンク（クラスの無い a）だけ下線を出す。ボタン・カード・ナビは対象外 */
a:not([class]):hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

ul,
ol {
  list-style: none;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

hr {
  border: 0;
  height: 1px;
  background: var(--line);
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid rgba(6, 199, 85, 0.45);
  outline-offset: 2px;
  border-radius: 8px;
}

main {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  width: 100%;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
}

/* ============================================================
 * Layout helpers
 * ============================================================ */

.flex-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

.flex-grow {
  flex-grow: 1;
}

.text-gradient,
.text-green {
  color: var(--green);
}

.mono {
  font-family: var(--font-mono);
}

/* ============================================================
 * Brand — 緑の丸に、白いふきだし（入力中の 3 つの点）
 *   しるしの見た目は、ここだけで決める。ヘッダー（components/header の
 *   .header-logo-mark）と、ヘッダーの無い画面（管理者のログイン、メールの
 *   リンクから開く管理者の画面、エラー画面）の .talk-brand-mark が同じ規則を使う。
 *   <span class="talk-brand-mark" aria-hidden="true"><i></i></span>
 * ============================================================ */

.talk-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--ink);
}

a.talk-brand:hover {
  color: var(--ink);
}

.talk-brand-mark,
.header-logo-mark {
  position: relative;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 4px 10px -4px rgba(6, 199, 85, 0.7);
  transition: transform var(--dur-3) var(--ease-spring);
}

.talk-brand-mark i,
.header-logo-mark i {
  position: relative;
  width: 1.15rem;
  height: 0.85rem;
  margin-top: -0.1rem;
  border-radius: 0.42rem;
  background:
    radial-gradient(circle, var(--green) 0 1.3px, transparent 1.8px) 25% 50% / 0.3rem 0.3rem no-repeat,
    radial-gradient(circle, var(--green) 0 1.3px, transparent 1.8px) 50% 50% / 0.3rem 0.3rem no-repeat,
    radial-gradient(circle, var(--green) 0 1.3px, transparent 1.8px) 75% 50% / 0.3rem 0.3rem no-repeat,
    #ffffff;
}

.talk-brand-mark i::after,
.header-logo-mark i::after {
  content: "";
  position: absolute;
  left: 0.2rem;
  bottom: -0.17rem;
  width: 0.36rem;
  height: 0.36rem;
  background: #ffffff;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

a.talk-brand:hover .talk-brand-mark,
.header-logo:hover .header-logo-mark {
  transform: rotate(-8deg) scale(1.06);
}

/* ============================================================
 * Card — 白い面と、やわらかな影
 * ============================================================ */

.card,
.glass {
  position: relative;
  border-radius: var(--radius-3);
  border: 1px solid var(--line);
  background-color: var(--surface);
  box-shadow: var(--shadow);
}

/* ============================================================
 * Forms
 * ============================================================ */

.form-group {
  margin-bottom: var(--s-4);
}

.form-label {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.8rem 1rem;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--surface);
  background-clip: padding-box;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  transition:
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease);
}

.form-control::placeholder {
  color: var(--ink-faint);
}

.form-control:hover {
  border-color: #b9c3be;
}

.form-control:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(6, 199, 85, 0.16);
}

.form-control:disabled {
  color: var(--ink-faint);
  background-color: var(--surface-2);
}

textarea.form-control {
  min-height: 140px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-mute) 50%), linear-gradient(135deg, var(--ink-mute) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--green);
}

.error-message {
  margin-top: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--red-ink);
}

/* ============================================================
 * Buttons — まるいピル。主ボタンは LINE のグリーン
 * ============================================================ */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.85rem 1.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  isolation: isolate;
  transform: translate3d(var(--magnet-x, 0), var(--magnet-y, 0), 0);
  transition:
    color var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-3) var(--ease-spring);
}

.btn:hover {
  border-color: #b9c3be;
  background-color: var(--surface-2);
}

.btn:focus-visible {
  outline: 3px solid rgba(6, 199, 85, 0.45);
  outline-offset: 2px;
}

.btn:active {
  transform: translate3d(var(--magnet-x, 0), calc(var(--magnet-y, 0px) + 1px), 0) scale(0.97);
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary,
.btn.btn-primary {
  color: #ffffff;
  background-color: var(--green);
  border-color: var(--green);
  box-shadow: 0 6px 16px -8px rgba(6, 199, 85, 0.75);
}

.btn-primary:hover,
.btn.btn-primary:hover {
  color: #ffffff;
  background-color: var(--green-strong);
  border-color: var(--green-strong);
  box-shadow: 0 10px 22px -10px rgba(6, 199, 85, 0.85);
}

.btn-secondary {
  color: var(--ink-soft);
  background-color: var(--surface-2);
  border-color: var(--line);
}

.btn-outline-primary {
  color: var(--green-ink);
  background-color: var(--surface);
  border-color: var(--green);
}

.btn-outline-primary:hover {
  color: var(--green-ink);
  background-color: var(--green-soft);
  border-color: var(--green);
}

.btn-lg {
  padding: 1.05rem 2rem;
  font-size: var(--fs-base);
}

.btn-sm {
  padding: 0.55rem 1rem;
  font-size: var(--fs-xs);
}

/* ============================================================
 * Chrome
 * ============================================================ */

.user-welcome {
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  color: var(--ink-mute);
}

footer,
.footer {
  position: relative;
  z-index: 1;
  padding: var(--s-5) var(--s-4);
  border-top: 1px solid var(--line);
  background-color: var(--surface);
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

footer p,
.footer p {
  color: inherit;
}

/* ============================================================
 * Keyframes
 * ============================================================ */

@keyframes lumen-breathe {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes lumen-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes lumen-pulse-ring {
  0% {
    opacity: 0.9;
    transform: scale(0.6);
  }
  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}

@keyframes lumen-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* 入力中の「…」（ふきだしの中で弾む 3 つの点） */
@keyframes talk-typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* 動きを減らす設定のときは、ほぼ静止画にする */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
 * Experience hooks (front_end/experience)
 * ============================================================ */

/* 演出の読み込み中は、これから現れる要素を隠しておく（experience/index.ts） */
html.lumen-booting [data-reveal],
html.lumen-booting [data-split] {
  opacity: 0;
}

/* 押したところから広がる光 */
.lumen-ripple {
  position: absolute;
  z-index: -1;
  width: 360px;
  height: 360px;
  margin: -180px 0 0 -180px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
}

.btn:not(.btn-primary) .lumen-ripple {
  background: radial-gradient(closest-side, rgba(6, 199, 85, 0.22), rgba(6, 199, 85, 0));
}

/* 操作の合図: ぽんっと弾けるふきだし（experience/pop.ts） */
.talk-pop {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2000;
  width: 0;
  height: 0;
  pointer-events: none;
}

.talk-pop i {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  translate: -50% -50%;
}

/* 見出しを行ごとに浮かび上がらせるマスク */
.lumen-split-line {
  padding-bottom: 0.1em;
  margin-bottom: -0.1em;
}

/* 画面遷移: やわらかく消える */
html.lumen-motion main,
html.lumen-motion header,
html.lumen-motion footer {
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}

html.lumen-leaving main,
html.lumen-leaving header,
html.lumen-leaving footer {
  opacity: 0;
  transform: translateY(-6px);
}

/* Lenis（慣性スクロール） */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}
