/* ============================================================
   ai.kitemir.jp BBS site.css
   侘び寂び基調・読みやすさ優先・シニア閲覧者を意識した行間
   モバイルファーストのレスポンシブ対応
   ============================================================ */

:root {
  --bg:       #fafaf7;
  --paper:    #ffffff;
  --ink:      #1a1a1a;
  --sub:      #595959;
  --muted:    #8a8a8a;
  --rule:     #e5e5e1;
  --accent:   #1F3864;
  --ai-bg:    #F0F6FF;
  --ai-rule:  #4A90E2;
  --quote-bg: #f5f1e8;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Yu Gothic Medium", "Yu Gothic",
               "Meiryo", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;     /* iOSの自動拡大抑止 */
}
body { overflow-x: hidden; }          /* 横スクロール防止 */

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 880px; }

/* --- Hero --- */
.hero { border-bottom: 1px solid var(--rule); }
.hero h1 { letter-spacing: 0.04em; }
.hero__logo {
  display: inline-block;
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

/* --- Header brand logo --- */
.brand-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  padding: 2px;
}
.navbar-brand { padding-top: 0; padding-bottom: 0; }
.navbar-brand span { font-size: 1.05rem; }
@media (max-width: 480px) {
  .brand-logo { width: 40px; height: 40px; }
  .navbar-brand span { font-size: .95rem; }
}

/* --- ナビ折り返し防止・コンパクト化 --- */
.navbar .nav-link {
  white-space: nowrap;
  padding-left: .55rem;
  padding-right: .55rem;
}
.navbar .nav-item form.d-inline { display: inline-flex !important; }
.nav-logout {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: .4rem .55rem !important;
  color: #6c757d;
}
.nav-logout:hover { color: var(--accent); }
.nav-logout svg { display: block; }

/* --- カードのホバー --- */
.hover-lift { transition: transform .15s ease, box-shadow .15s ease; }
.hover-lift:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.06); }

/* --- 投稿 --- */
.post {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 12px;
  word-wrap: break-word;
  overflow-wrap: anywhere;            /* 長いURLでも折り返す */
}
.post__head {
  font-size: 0.92rem;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--rule);
  flex-wrap: wrap;                    /* スマホで折り返し */
  gap: 4px;
}
.post__body {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.85;
}
.post__body img,
.post__body iframe { max-width: 100%; height: auto; }
.post__body .quote {
  display: block;
  background: var(--quote-bg);
  border-left: 4px solid #cdb88a;
  padding: 4px 12px;
  margin: 6px 0;
  color: var(--sub);
}
.post__actions form { margin-left: 4px; }

/* --- ツリーの縦線 --- */
.post-tree { position: relative; }
.post-tree::before {
  content: '';
  position: absolute;
  left: -12px; top: 0; bottom: 0;
  width: 2px; background: var(--rule);
}

/* --- AI 投稿 --- */
.post--ai {
  background: var(--ai-bg);
  border-left: 4px solid var(--ai-rule);
}

/* --- AI タイピングインジケータ (チャット風) --- */
.ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--ai-bg);
  border: 1px solid #c9dcf3;
  border-left: 4px solid var(--ai-rule);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  color: #2E5395;
  font-size: 0.95rem;
}
.ai-typing__avatar { font-size: 1.3rem; }
.ai-typing__text   { font-weight: 500; }
.ai-typing__dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}
.ai-typing__dots span {
  width: 6px;
  height: 6px;
  background: var(--ai-rule);
  border-radius: 50%;
  animation: ai-typing-bounce 1.2s infinite ease-in-out;
}
.ai-typing__dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing__dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .3; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* --- 新着投稿のフェードイン (AJAX で追加された時) --- */
.post-fade-in {
  animation: post-fade-in 0.6s ease-out;
}
@keyframes post-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- 動画リンク集 --- */
.video-group__name {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
  margin-bottom: 8px;
  color: var(--accent);
}
.video-card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  height: 100%;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.video-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
  border-color: #c9d6e8;
}
.video-card__thumb {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.video-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease;
}
.video-card:hover .video-card__thumb img { transform: scale(1.04); }

.video-card__platform {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .03em;
}
.video-card__duration {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,.8);
  color: #fff;
  font-size: .75rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: Consolas, monospace;
}
.video-card__play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  background: rgba(0,0,0,.6);
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
  transition: background .2s, transform .2s;
}
.video-card:hover .video-card__play {
  background: rgba(31,56,100,.9);
  transform: translate(-50%, -50%) scale(1.1);
}

.video-card__body { padding: 12px 14px; }
.video-card__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  margin: 0 0 4px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card__speaker {
  font-size: .85rem;
  color: var(--accent);
  margin: 0 0 4px;
  font-weight: 500;
}
.video-card__desc {
  font-size: .82rem;
  color: var(--sub);
  margin: 0 0 4px;
  line-height: 1.5;
}
.video-card__date {
  display: block;
  font-size: .75rem;
  color: var(--muted);
}

/* スマホ: 1 列に切り替え (Bootstrap col-md-4 が自動でこれを処理) */
@media (max-width: 767.98px) {
  .video-card__title    { font-size: .95rem; }
  .video-card__play     { width: 48px; height: 48px; font-size: 18px; }
}

/* --- 文献リンク集 --- */
.link-group {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 20px;
}
.link-group__name {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin-bottom: 12px;
  color: var(--accent);
}
.link-list { margin: 0; padding: 0; }
.link-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
}
.link-item:last-child { border-bottom: none; }
.link-item__title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
}
.link-item__title:hover { text-decoration: underline; }
.link-item__icon {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 4px;
}
.link-item__desc { margin-top: 2px; line-height: 1.6; }
.link-item__url {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
  font-family: Consolas, monospace;
}

/* ============================================================
   アクセス解析ダッシュボード (ダーク基調)
   ============================================================ */
.analytics {
  background: #0f1115;
  color: #e8ecf3;
  margin: -1rem -12px;
  padding: 1.5rem 16px;
  border-radius: 8px;
  min-height: 60vh;
}
.analytics .text-muted-soft { color: #8a8fa3; }

.ana-card {
  background: #1a1d26;
  border: 1px solid #2a2e3a;
  border-radius: 10px;
  padding: 18px 18px;
  height: 100%;
  position: relative;
}
.ana-card--full { padding: 18px 22px 22px; }
.ana-card__label { font-size: 0.78rem; color: #8a8fa3; margin-bottom: 8px; }
.ana-card__value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  letter-spacing: -.01em;
}
.ana-card__value span {
  font-size: 0.78rem;
  font-weight: 400;
  color: #8a8fa3;
  margin-left: 4px;
}
.ana-card__sub { font-size: 0.73rem; color: #8a8fa3; margin-top: 6px; }
.ana-card__title { font-size: 0.95rem; color: #e8ecf3; margin: 0; font-weight: 600; }
.ana-card__legend { color: #8a8fa3; }
.ana-card__legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* --- デバイスバー --- */
.ana-device-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: #2a2e3a;
  margin: 12px 0 10px;
}
.ana-device-bar .seg-d { background: #a48bf2; }
.ana-device-bar .seg-m { background: #4ec9f0; }
.ana-device-bar .seg-t { background: #ffc745; }
.ana-device-legend { font-size: 0.72rem; color: #8a8fa3; line-height: 1.7; }
.ana-device-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.ana-device-legend .dot-d { background: #a48bf2; }
.ana-device-legend .dot-m { background: #4ec9f0; }
.ana-device-legend .dot-t { background: #ffc745; }
.ana-device-legend span { margin-right: 8px; white-space: nowrap; }

/* --- タイムラインチャート --- */
.ana-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding: 10px 0 0;
  border-top: 1px dashed #2a2e3a;
}
.ana-chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.ana-chart__bars {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 1px;
}
.ana-chart__bar { width: 100%; min-height: 0; border-radius: 2px 2px 0 0; }
.ana-chart__bar.bar-pv { background: #a48bf2; }
.ana-chart__bar.bar-uv { background: #ffc745; }
.ana-chart__date { font-size: 0.65rem; color: #8a8fa3; margin-top: 4px; height: 14px; }

.ana-card__legend .dot-pv { background: #a48bf2; }
.ana-card__legend .dot-uv { background: #ffc745; }

/* --- テーブル --- */
.ana-table {
  width: 100%;
  font-size: 0.85rem;
  color: #cfd3df;
}
.ana-table th {
  font-weight: 500;
  color: #8a8fa3;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #2a2e3a;
  padding: 8px 10px;
}
.ana-table td {
  padding: 10px;
  border-bottom: 1px solid #20232c;
  vertical-align: middle;
}
.ana-table tr:last-child td { border-bottom: none; }
.ana-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: #fff; }
.ana-table__path,
.ana-table__host {
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
  max-width: 200px;
}

.bar-row {
  width: 100%;
  height: 6px;
  background: #2a2e3a;
  border-radius: 3px;
  overflow: hidden;
}
.bar-row__fill {
  height: 100%;
  background: linear-gradient(90deg, #a48bf2, #ffc745);
  border-radius: 3px;
}

@media (max-width: 768px) {
  .analytics { padding: 1rem 10px; }
  .ana-card__value { font-size: 1.4rem; }
  .ana-chart { height: 140px; }
  .ana-chart__date { font-size: 0.55rem; }
  .ana-table th, .ana-table td { padding: 6px 4px; font-size: 0.78rem; }
}

/* --- Bootstrap 上書き --- */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #163057; border-color: #163057; }
.navbar { box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.breadcrumb { background: transparent; padding-left: 0; flex-wrap: wrap; }

/* --- 表のレスポンシブ補助（管理画面など） --- */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table { word-break: break-word; }
.table td, .table th { vertical-align: middle; }

/* ============================================================
   モバイル (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  body { font-size: 15px; line-height: 1.75; }
  .container { padding-left: 12px; padding-right: 12px; }

  /* 投稿の余白を詰める */
  .post { padding: 12px 14px; }
  .post__head .post__actions { width: 100%; margin-top: 4px; }

  /* ナビ内の検索バーは縦に展開 */
  .navbar-collapse form[role="search"] { width: 100%; margin: .5rem 0; }
  .navbar-collapse form[role="search"] input { width: 100%; }

  /* ヒーロー縮小 */
  .hero { padding: 1rem 0 !important; }
  .hero h1 { font-size: 1.6rem !important; }
  .hero .lead { font-size: 1rem; }

  /* ツリーインデントを詰める（thread.php の inline style を上書き）*/
  .post-tree[style] { margin-left: 12px !important; }
  .post-tree .post-tree[style] { margin-left: 24px !important; }
  .post-tree .post-tree .post-tree[style] { margin-left: 36px !important; }
  .post-tree .post-tree .post-tree .post-tree[style] { margin-left: 48px !important; }

  /* 管理者表は横スクロール許容（強制）*/
  .table { font-size: 0.85rem; }
}

/* ============================================================
   小型スマホ (≤480px)
   ============================================================ */
@media (max-width: 480px) {
  .post { padding: 10px 12px; }
  .post__body { font-size: 0.95rem; }
  .breadcrumb { font-size: 0.8rem; }

  /* ボタンを少し大きく（タッチしやすく）*/
  .btn { padding: .45rem .85rem; }
  .btn-sm { padding: .35rem .6rem; }
}

/* ============================================================
   タッチデバイス: ホバー演出を抑制
   ============================================================ */
@media (hover: none) {
  .hover-lift:hover { transform: none; box-shadow: none; }
}

/* --- 印刷時 --- */
@media print {
  .navbar, footer, .post__actions, .post__reply { display: none !important; }
  .post { break-inside: avoid; border-color: #ccc; }
  body { background: #fff; }
}
