/*
 * 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;
}

/* 薄めの細いスクロールバー（カード・領域・オーバーレイ用） */
.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); } /* 余分な閉じ括弧 */
