/*
  AI Lab - スタイルシート
  デザイン方針: 「テンプレート的ではない、少し手の込んだAIをイメージしたデザイン」
  - ニューラルネットワーク風のグラデーション + グリッド装飾
  - アクセントカラーはエレクトリックバイオレット×シアンの2色グラデーション
  - 見出しは等幅フォントを混ぜて「コード・AI」感を出す
  - ダーク固定(2026-11-03変更): 以前は :root (light) と @media (prefers-color-scheme: dark) で
    ライト/ダークを切替していたが、progress-tracker-dashboardでのデザイン設計相談(モックアップ
    https://claude.ai/artifact/2ktTwDujNahY5CWo4jYePY の project/Main.dc.html)で確定した配色は
    ダーク固定の1系統のみだったため、ライト用トークンを廃止し :root に直接ダーク値を定義する方式に統一。
    OS側がライトモード設定でも常にこのダーク配色で表示される。
  - ヘッダー/ナビは position: sticky; top: 0; でスクロール時も固定
*/

:root {
  /* ===== 配色トークン(2026-11-03更新: モックアップのダーク配色に統一) ===== */
  --color-bg: #0a0a10;
  --color-bg-elevated: #14141f94;
  --color-text: #f2f2f5;
  --color-text-muted: #9a9fc3;
  --color-border: #262b45;
  /* アクセント1(紫)。モックアップでは #7c8cff と #8b5cf6 の2候補が提示されたが、
     既存のグラデーション相手である --color-accent-2 (#22d3ee シアン) との明度バランスが
     より取りやすい #7c8cff を採用した(#8b5cf6は彩度が高く沈んだ背景色#0A0A10上で
     やや重く見えたため見送り。判断理由をここに明記)。 */
  --color-accent-1: #7c8cff; /* violet */
  --color-accent-2: #22d3ee; /* cyan */
  --color-accent-gradient: linear-gradient(120deg, var(--color-accent-1), var(--color-accent-2));
  --color-card-bg: #151830;
  --color-header-bg: rgba(10, 10, 16, 0.72);
  --color-like-active: #f472b6;
  --shadow-soft: 0 10px 40px -14px rgba(0, 0, 0, 0.6);

  /* ===== フォント =====
     見出し(--font-display)は変更なし。本文(--font-body)は今回新規追加。
     以前は body 全体が --font-display (Space Grotesk) 指定のみで、本文用フォントの変数が
     存在しなかった。モックアップで本文に Inter の指定があったため、新たに --font-body を
     追加し、body の地の文に適用。見出し要素(h1〜h6)は従来通り --font-display を明示指定して
     Space Grotesk を維持する(判断理由: 見出しと本文を分けるのがモックアップの意図であり、
     既存の「見出しに等幅/ディスプレイ系フォントを使ってAI感を出す」方針とも矛盾しないため)。 */
  --font-display: "Space Grotesk", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-body: "Inter", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --radius-lg: 18px;
  --radius-md: 12px;

  /* ===== スペーシングトークン(2026-11-03追加) =====
     既存コードで実際に使われていたrem値(0.3〜0.9rem/1.4〜1.6rem/2.4rem/4rem付近)に
     近い5段階に整理した。既存の見た目を変えないことを優先し、厳密な等比数列にはしていない。 */
  --space-xs: 0.4rem;
  --space-sm: 0.8rem;
  --space-md: 1.4rem;
  --space-lg: 2.4rem;
  --space-xl: 4rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.7;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 10% 0%, rgba(124, 140, 255, 0.12), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(34, 211, 238, 0.12), transparent 40%);
  background-attachment: fixed;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
}

/* ===== フォーカス表示(アクセシビリティ、2026-11-03追加) =====
   :focus ではなく :focus-visible を使うことで、マウスクリック時には表示されず、
   キーボード操作(Tabキー移動)時のみアクセントカラーのフォーカスリングを表示する。 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent-2);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

/* ===== Header / Nav (sticky) ===== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  gap: var(--space-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--color-text);
}

.brand__mark {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 8px;
  background: var(--color-accent-gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--shadow-soft);
}

.brand__gradient-text {
  background: var(--color-accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  gap: var(--space-md);
  font-size: 0.95rem;
}

.nav a {
  color: var(--color-text-muted);
  font-weight: 500;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a.is-active {
  color: var(--color-text);
  text-decoration: none;
  border-bottom-color: var(--color-accent-2);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 1.2rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

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

.page-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-xl);
}

.section-title {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.section-subtitle {
  color: var(--color-text-muted);
  margin-top: 0;
  margin-bottom: 2rem;
}

/* ===== Hero (index.html) ===== */

.hero {
  position: relative;
  padding: 4.5rem 2rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-card-bg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--color-border);
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    repeating-linear-gradient(45deg, rgba(124, 140, 255, 0.12) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(-45deg, rgba(34, 211, 238, 0.1) 0 1px, transparent 1px 42px);
  z-index: -2;
  animation: drift 40s linear infinite;
}

.hero::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -140px;
  top: -140px;
  border-radius: 50%;
  background: var(--color-accent-gradient);
  filter: blur(80px);
  opacity: 0.35;
  z-index: -1;
}

@keyframes drift {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(42px, 42px);
  }
}

.hero__eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--color-accent-2);
  margin: 0 0 0.8rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0 0 1rem;
  max-width: 24ch;
}

.hero p.lead {
  max-width: 48ch;
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

.hero__actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn--primary {
  background: var(--color-accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn--ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

/* ===== Profile summary ===== */

.profile-card {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-md);
  align-items: center;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-soft);
}

.profile-card__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.4rem;
}

.profile-card h2 {
  margin: 0 0 0.3rem;
  font-size: 1.15rem;
}

.profile-card p {
  margin: 0;
  color: var(--color-text-muted);
}

/* ===== Card grids (articles / portfolio) ===== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
}

.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--color-accent-2);
}

.card__thumb {
  width: 100%;
  height: 140px;
  border-radius: var(--radius-md);
  background: var(--color-accent-gradient);
  opacity: 0.85;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/*
  記事のアイキャッチ画像、2026-11-07方針決定:
  外部の画像生成AI(Gemini API)は無料枠が無い(aistudio.google.com/docs/pricingで確認、
  画像生成モデルは全てFree Tier「Not available」)ため、ルール9(永久無料)に反する。
  そのためポートフォリオと同系統の「グラデーション+テキスト」方式(CSSのみ、外部API不要)を
  AI技術記事のアイキャッチにも採用する。
*/
.card__thumb__label {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0 var(--space-sm);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--color-bg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.detail-thumb {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-lg);
  background: var(--color-accent-gradient);
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.detail-thumb__label {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0 var(--space-lg);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.35;
  color: var(--color-bg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.card__meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.card p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.empty-state {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  color: var(--color-text-muted);
}

/* ===== Detail page (article.html / work.html) ===== */

.detail-header {
  margin-bottom: 1.5rem;
}

.detail-header h1 {
  margin: 0.4rem 0;
}

.detail-body {
  white-space: pre-wrap;
  font-size: 1.02rem;
}

/* ===== Research feed (articles.html) ===== */

.research-feed-list {
  display: grid;
  gap: var(--space-sm);
}

.research-feed-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-card-bg);
}

.research-feed-item__cat {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-accent-1);
}

/* ===== Like / Comments ===== */

.like-area {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.8rem 0;
}

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-border);
  background: var(--color-card-bg);
  color: var(--color-text);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
}

.like-button[data-liked="true"] {
  background: var(--color-like-active);
  border-color: var(--color-like-active);
  color: #fff;
}

.comments-section {
  margin-top: 2.4rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.6rem;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}

.comment-form textarea {
  resize: vertical;
  min-height: 80px;
  padding: 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.comment-item {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
}

.comment-item__meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
}

/* ===== コメントの編集・削除・パスワード関連UI(2026-11-03追加) ===== */

.btn--small {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
}

.btn--danger {
  background: transparent;
  border-color: #ef4444;
  color: #ef4444;
}

.comment-item__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comment-item__password-notice {
  margin-top: 0.6rem;
}

.comment-item__password-display {
  font-size: 0.85rem;
  background: var(--color-bg);
  border: 1px dashed var(--color-accent-1);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.7rem;
}

.comment-item__password-change {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.comment-item__password-change-input,
.comment-item__password-input {
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
}

.comment-item__action-form-inner {
  margin-top: 0.6rem;
  padding: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comment-item__password-required {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-accent-1);
  margin: 0;
}

.comment-item__edit-text {
  resize: vertical;
  min-height: 60px;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font-family: inherit;
}

.comment-item__delete-confirm {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
}

.comment-item__form-actions {
  display: flex;
  gap: 0.5rem;
}

.comment-item__form-error,
.comment-item__password-change-error {
  font-size: 0.8rem;
  color: #ef4444;
  margin: 0;
}

/* ===== Footer ===== */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ===== Responsive (<=640px) =====
   ブレークポイントは640pxに統一(モックアップ側は760pxだったが、このリポジトリでは
   640pxで統一する方針に決定済み。新たに760px関連のコードは追加しない)。 */

@media (max-width: 640px) {
  .site-header__inner {
    padding: var(--space-sm) var(--space-md);
  }

  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.3rem;
    gap: 0.9rem;
    display: none;
  }

  .nav.is-open {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .hero {
    padding: 2.6rem 1.3rem;
  }

  .profile-card {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .page-shell {
    padding: 1.6rem 1.1rem 3rem;
  }
}

/* ===== draft.html(開発用記事作成ツール)専用スタイル、2026-11-07追加 ===== */
.draft-form {
  margin-bottom: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.draft-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.draft-field input,
.draft-field textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.7rem;
  resize: vertical;
}

.draft-field__hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.draft-preview-badge {
  display: inline-block;
  background: var(--color-accent-gradient);
  color: var(--color-bg);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  margin-bottom: var(--space-sm);
}

.sns-draft-preview {
  position: relative;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--color-card-bg);
}

.sns-draft-preview__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.5rem;
}

.sns-draft-preview__body {
  white-space: pre-wrap;
  color: var(--color-text);
}

.image-prompt-box {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--color-card-bg);
  margin-bottom: var(--space-md);
}

.image-prompt-box__label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.image-prompt-box__text {
  white-space: pre-wrap;
  color: var(--color-text);
  margin: 0 0 var(--space-sm);
}
