/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@keyframes fade-out {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; display: none; }
}

.animate-fade-out {
  animation: fade-out 5s ease-out forwards;
}

/* DNCL Syntax Highlighting */
.dncl-line-num {
  color: #6b7280;
  user-select: none;
  margin-right: 0.75em;
  display: inline-block;
  min-width: 1.5em;
  text-align: right;
}

.dncl-keyword {
  color: #c084fc;
  font-weight: bold;
}

.dncl-loop {
  color: #60a5fa;
  font-weight: bold;
}

.dncl-io {
  color: #34d399;
  font-weight: bold;
}

.dncl-operator {
  color: #fb923c;
  font-weight: bold;
}

.dncl-number {
  color: #fbbf24;
}

.dncl-comment {
  color: #6b7280;
  font-style: italic;
}

/* ホーム（#1868）のコース列: スクロールバーを出さず「‹ ›」ボタンで送る（home_carousel_controller） */
.no-scrollbar {
  scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* 薄めの細いスクロールバー（カード・領域・オーバーレイ用） */
.thin-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(209, 213, 219, 0.6) transparent;
}
.thin-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.thin-scroll::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 9999px;
}
.thin-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(209, 213, 219, 0.6);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.thin-scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(156, 163, 175, 0.7);
  background-clip: padding-box;
}

/* ストリーミングカーソル点滅 */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.animate-blink {
  animation: blink 0.8s step-end infinite;
}

/* タイピングインジケーター 3点ドット */
@keyframes typing-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}
.typing-dot:nth-child(1) { animation: typing-dot 1.2s infinite 0s;    }
.typing-dot:nth-child(2) { animation: typing-dot 1.2s infinite 0.2s;  }
.typing-dot:nth-child(3) { animation: typing-dot 1.2s infinite 0.4s;  }

/* Pagy ページネーション - バリアフリー対応ボタン */
nav.pagy.series-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

nav.pagy.series-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 48px;
  padding: 0 16px;
  font-size: 16px;
  font-weight: 500;
  border-radius: 10px;
  color: #374151;
  background-color: #ffffff;
  border: 2px solid #e5e7eb;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}

nav.pagy.series-nav a:hover:not([aria-disabled="true"]) {
  background-color: #eef2ff;
  border-color: #818cf8;
  color: #4338ca;
}

/* 現在ページ */
nav.pagy.series-nav a[aria-current="page"] {
  background-color: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
  font-weight: 700;
  cursor: default;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

/* 無効状態（先頭/末尾の前へ・次へ） */
nav.pagy.series-nav a[aria-disabled="true"]:not([role="separator"]):not([aria-current="page"]) {
  color: #d1d5db;
  border-color: #f3f4f6;
  background-color: #f9fafb;
  cursor: not-allowed;
}

/* 省略記号（…） */
nav.pagy.series-nav a[role="separator"] {
  border: none;
  background: none;
  color: #9ca3af;
  min-width: 28px;
  padding: 0 4px;
  cursor: default;
}

/* 前へ / 次へ ボタン */
nav.pagy.series-nav a[rel="prev"],
nav.pagy.series-nav a[rel="next"] {
  min-width: 72px;
  font-weight: 600;
  color: #4f46e5;
  border-color: #c7d2fe;
}

nav.pagy.series-nav a[rel="prev"]:hover,
nav.pagy.series-nav a[rel="next"]:hover {
  background-color: #eef2ff;
  border-color: #4f46e5;
  color: #3730a3;
}

/* ===== LaTeX field editor (math_manual モデル解答 / 問題文) =====
   latex_field_controller.js + questions/form/_latex_field.html.erb とペア。 */

/* プレビュー（KaTeX レンダリング表示） */
.lf-preview {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  min-height: 2.5rem;
}
.lf-preview.is-empty::before {
  content: "（未入力）";
  color: #9ca3af;
}

/* エディタ枠（暗色背景で編集範囲・余白を明確化） */
.lf-editor {
  position: relative;
  border-radius: 0.5rem;
  background: #1e293b;            /* slate-800 */
  border: 1px solid #334155;      /* slate-700 */
  overflow: hidden;
}

/* textarea と背面ハイライトは完全に同じメトリクスで重ねる */
.lf-textarea,
.lf-highlight {
  margin: 0;
  border: 0;
  padding: 0.75rem 0.875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.lf-highlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  color: #e2e8f0;                 /* 既定（数式外）テキスト slate-200 */
}

.lf-textarea {
  position: relative;
  display: block;
  width: 100%;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #f8fafc;
  resize: vertical;
  outline: none;
}
.lf-textarea::placeholder {
  color: #64748b;
  -webkit-text-fill-color: #64748b;
}
.lf-textarea::selection {
  background: rgba(148, 163, 184, 0.35);
}

/* トークン配色 */
.lf-math  { color: #fcd34d; }                 /* 数式内テキスト amber-300 */
.lf-delim { color: #f472b6; font-weight: 600; } /* $ / $$ 区切り pink-400 */
.lf-cmd   { color: #c084fc; }                 /* \command purple-400 */
.lf-b0 { color: #60a5fa; }                    /* 対応括弧：深さ別レインボー */
.lf-b1 { color: #34d399; }
.lf-b2 { color: #fbbf24; }
.lf-b3 { color: #fb7185; }
.lf-b4 { color: #22d3ee; }
.lf-bad { color: #fca5a5; background: rgba(248, 113, 113, 0.2); } /* 余分な閉じ括弧 */

/* ===== TeX を見せない数式入力（#1649）=====
   math_field_controller.js + questions/form/_latex_field.html.erb（wysiwyg_enabled: true）とペア。
   散文はこの面で直接打ち、数式は .mf-block の不活性ブロックとして並ぶ。 */

/* 編集面。position: relative はパネルを絶対配置で重ねる土台（行のレイアウトを動かさない）。 */
.mf-surface {
  position: relative;
  min-height: 2.5rem;
  line-height: 2.1;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}
.mf-surface:focus-visible {
  border-color: #a855f7;              /* purple-500 */
  box-shadow: 0 0 0 1px #a855f7;
}
.mf-surface.is-empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

/* 数式ブロック。叩くとパネルが開く。 */
.mf-block {
  display: inline-block;
  padding: 0.05rem 0.3rem;
  margin: 0 0.1rem;
  border-radius: 0.25rem;
  background: #faf5ff;                /* purple-50 */
  border: 1px solid #e9d5ff;          /* purple-200 */
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
}
.mf-block:hover { border-color: #c084fc; }
/* $$…$$ 由来のディスプレイ数式は行を占有する（KaTeX の .katex-display は block）。 */
.mf-block--display { display: block; margin: 0.25rem 0; text-align: center; }
.mf-block:focus-visible { outline: 2px solid #a855f7; outline-offset: 1px; }
.mf-block--empty { color: #9ca3af; font-size: 0.8em; }
/* 編集中は占位表示。元の組版のままだと、パネルと欄のどちらが最新か分からなくなる。 */
.mf-block--editing {
  background: #fef3c7;                /* amber-100 */
  border-color: #fcd34d;
}
/* Backspace / Delete の 1 回目で選択された状態（2 回目で消える）。 */
.mf-block--armed {
  background: #fee2e2;                /* red-100 */
  border-color: #fca5a5;
}

/* 編集パネル。**絶対配置**でブロックの左に重ねる。 */
.mf-panel {
  position: absolute;
  z-index: 30;
  top: 0;
  right: calc(100% + 0.5rem);
  width: 20rem;                        /* 320px（採点ステップの狭い行でも欄幅に縛られない） */
}
/* 左に幅が足りないときは下へ回り込ませる（タブレット縦向き想定）。 */
.mf-panel--below {
  position: relative;
  right: auto;
  top: auto;
  width: 100%;
  margin-top: 0.5rem;
}
.mf-panel-body {
  background: #ffffff;
  border: 1px solid #e9d5ff;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px -12px rgba(88, 28, 135, 0.35);
  padding: 0.625rem 0.75rem;
}
.mf-panel-input {
  display: block;
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.375rem 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}
.mf-panel-input:focus {
  outline: none;
  border-color: #a855f7;
  box-shadow: 0 0 0 1px #a855f7;
}
.mf-panel-preview {
  min-height: 2rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  background: #faf5ff;
  font-size: 1rem;
  overflow-x: auto;
}

/* キーパッド。折り畳みは details/summary（タップで開ける）。 */
.mf-keypad-group { margin-top: 0.375rem; }
.mf-keypad-summary {
  font-size: 0.6875rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0.125rem 0;
  user-select: none;
}
.mf-keypad-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding-top: 0.25rem;
}
/* ボタンは「組版した見本（上）＋打鍵（下）」の 2 段。@s とだけ書かれても何が起きるか
   分からないので、Σ の姿を主役にして打鍵は覚書として小さく添える。 */
.mf-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.0625rem;
  min-width: 2.5rem;
  min-height: 2.75rem;                 /* タブレットの指で押せる大きさ */
  padding: 0.1875rem 0.375rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  background: #ffffff;
  color: #374151;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.1;
  cursor: pointer;
}
.mf-key:hover { border-color: #c084fc; color: #6b21a8; }
.mf-key:focus-visible { outline: 2px solid #a855f7; outline-offset: 1px; }
/* KaTeX の組版が入る段。行列や場合分けの見本が縦に伸びてもボタンが崩れないよう
   小さめに描き、はみ出しは切らずに縮める。 */
.mf-key-glyph {
  display: block;
  font-size: 0.9375rem;
  line-height: 1.15;
  max-width: 7rem;
}
.mf-key-glyph .katex { font-size: 1em; }
.mf-key-caption {
  display: block;
  font-size: 0.625rem;
  color: #9ca3af;
  letter-spacing: 0.01em;
}
.mf-key:hover .mf-key-caption { color: #a855f7; }


/*
 * 対外文書（/terms・/privacy）の本文。正本は docs/legal/*.md で、kramdown が生成した
 * 素の HTML（h2/h3/p/ul/ol/table/blockquote）に見出し・余白・罫線を与える。
 * Tailwind の typography プラグインは導入していないため（`prose` は何もしない）、
 * ここで明示的に組む。仕様: docs/plans/legal-documents-as-code.md D4
 */
.legal-doc {
  color: #374151; /* gray-700 */
  line-height: 1.9;
}
.legal-doc > *:first-child {
  margin-top: 0;
}
.legal-doc h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937; /* gray-800 */
  scroll-margin-top: 1rem; /* #copyright 等のアンカー着地位置 */
}
.legal-doc h3 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2937;
  scroll-margin-top: 1rem;
}
.legal-doc p,
.legal-doc ul,
.legal-doc ol {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}
.legal-doc ul,
.legal-doc ol {
  padding-left: 1.5rem;
}
.legal-doc ul { list-style: disc; }
.legal-doc ol { list-style: decimal; }
.legal-doc ol ol { list-style: lower-alpha; margin-top: 0.375rem; }
.legal-doc li { margin-top: 0.25rem; }
.legal-doc li > p { margin: 0.25rem 0; }
.legal-doc strong {
  font-weight: 600;
  color: #111827; /* gray-900 */
}
.legal-doc a {
  color: #2563eb; /* blue-600 */
  text-decoration: underline;
}
.legal-doc a:hover {
  color: #1d4ed8; /* blue-700 */
}
.legal-doc hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid #e5e7eb;
}
.legal-doc blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid #d1d5db; /* gray-300 */
  background: #f9fafb; /* gray-50 */
  color: #4b5563; /* gray-600 */
}
.legal-doc blockquote > *:first-child { margin-top: 0; }
.legal-doc blockquote > *:last-child { margin-bottom: 0; }

/* 委託先一覧などの表。狭い画面では表だけ横スクロールさせ、ページ本体は横に伸ばさない（#1579 と同じ方針）。 */
.legal-doc table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.legal-doc th,
.legal-doc td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.legal-doc thead th {
  background: #f9fafb;
  font-weight: 500;
  white-space: nowrap;
}
