/* ==========================================================================
   KINTARO_ portfolio — style.css
   デザイントークンは :root に集約(spec §3)。トークン外の色・フォントは使わない。
   ========================================================================== */

:root {
  --base: #FFFFFF;
  --surface: #F7F8FA;
  --ink: #0B0E12;
  --muted: #667077;
  --grid: #EBEEF1;
  --accent: #00A36C;
  --accent-dim: #007A50;
  --code-bg: #0F1418;

  --font-sans: "IBM Plex Sans JP", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --header-h: 64px;
  --container: 1080px;
  --radius: 12px;
  --shadow: 0 10px 28px rgba(11, 14, 18, 0.07);
}

/* ---------- reset / base ---------- */

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.9;
  color: var(--ink);
  background: var(--base);
  opacity: 1;
  transition: opacity 0.15s ease;
}

/* ページ遷移フェード(spec §4.1 / §6) */
body.is-leaving { opacity: 0; }

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

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

ul, ol { list-style: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent-dim);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: var(--base); }

h1, h2, h3, h4 { letter-spacing: 0.04em; line-height: 1.5; font-weight: 700; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- layout ---------- */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.section { padding: 96px 0; }
.section--surface { background: var(--surface); }
.section--tight { padding: 64px 0; }

.sec-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--accent-dim);
  margin-bottom: 12px;
}

.sec-title {
  font-size: clamp(22px, 3.4vw, 30px);
  margin-bottom: 16px;
}

.sec-lead { color: var(--muted); max-width: 640px; }

/* ---------- 方眼グリッド背景(spec §3.3) ---------- */

.grid-bg { position: relative; }
.grid-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.5;
}
.grid-bg > * { position: relative; }

/* ---------- 読了プログレスバー ---------- */

.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 300;
}

/* ---------- ヘッダー ---------- */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--grid);
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }

/* ロゴ末尾 `_` の点滅カーソル(spec §6) */
.logo-caret {
  color: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.site-nav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.site-nav a {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--accent-dim);
}

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 26px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.btn:hover { text-decoration: none; }

.btn--primary { background: var(--accent); color: var(--base); }
.btn--primary:hover { background: var(--accent-dim); }

.btn--ghost {
  background: var(--base);
  border-color: var(--grid);
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-dim); }

.btn--sm { min-height: 44px; padding: 8px 18px; font-size: 14px; }

/* ---------- Hero(index) ---------- */

.hero {
  padding: calc(var(--header-h) + 96px) 0 72px;
  background: var(--base);
  overflow: hidden;
}

/* 方眼グリッドがゆっくり流れる(heroのみ) */
@keyframes gridDrift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 32px 32px, 32px 32px; }
}
.hero.grid-bg::before { animation: gridDrift 10s linear infinite; }

/* フローティングチップ(CHANGELOGの断片・装飾) */
.hero-chips {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
@keyframes floatY {
  from { transform: translateY(-7px); }
  to   { transform: translateY(9px); }
}
@keyframes chipIn {
  from { opacity: 0; }
}
.chip {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--base);
  border: 1px solid var(--grid);
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  animation: chipIn 0.8s ease backwards, floatY 7s ease-in-out infinite alternate;
}
.chip.c1 { top: 24%; right: 13%; animation-delay: 0.5s, 0s; }
.chip.c2 { top: 42%; right: 5%;  animation-delay: 0.8s, -2.2s; }
.chip.c3 { top: 60%; right: 16%; animation-delay: 1.1s, -4.4s; }
.chip.c4 {
  top: 73%; right: 7%;
  animation-delay: 1.4s, -5.6s;
  color: var(--accent-dim);
  border-color: var(--accent);
}
.chip.c4::before { content: "● "; color: var(--accent); }
@media (max-width: 1099px) { .hero-chips { display: none; } }

/* サービスティッカー(hero下部・流れる帯) */
.ticker {
  margin-top: 72px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
@keyframes tickerMove {
  to { transform: translateX(-50%); }
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: tickerMove 30s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  margin-right: 44px;
}
.ticker-sep {
  color: var(--accent);
  font-size: 8px;
  vertical-align: 2px;
  margin-right: 44px;
}

.hero-label {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 20px;
}
.hero-label .prompt { color: var(--accent); }

.hero-title {
  font-size: clamp(30px, 6vw, 56px);
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 24px;
}

/* タイピング演出: ghost が高さを確保し、live を重ねて表示(レイアウトシフト防止) */
.type-wrap { position: relative; display: block; }
.type-ghost { visibility: hidden; }
.type-live { position: absolute; inset: 0; }

.type-caret {
  display: inline-block;
  width: 0.08em;
  min-width: 3px;
  height: 1em;
  margin-left: 0.06em;
  background: var(--accent);
  vertical-align: -0.12em;
}
.type-caret.is-blink { animation: blink 1s steps(1) infinite; }

.hero-sub {
  color: var(--muted);
  max-width: 600px;
  margin-bottom: 36px;
}

.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- 数字バンド(index) ---------- */

.stats {
  border-top: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  background: var(--base);
  padding: 56px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 32px 16px;
  text-align: center;
}

.stat-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
}
.stat-unit {
  font-size: 0.5em;
  font-weight: 500;
  margin-left: 2px;
  color: var(--muted);
}
.stat-label {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- ターミナル風 STATUS ブロック(index・唯一の暗色) ---------- */

.terminal {
  background: var(--code-bg);
  border-radius: var(--radius);
  max-width: 640px;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(102, 112, 119, 0.35); /* --muted 由来 */
}
.terminal-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.55;
}
.terminal-name {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.terminal-lines {
  padding: 22px 24px 26px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 2.1;
  color: var(--base);
}
.t-line { white-space: pre-wrap; word-break: break-word; }
.t-prompt { color: var(--accent); font-weight: 600; }

/* JSでタイピング中: まだ番が来ていない行は不可視(no-JS時は全文表示) */
.terminal-lines.is-typing .t-line:not(.is-on) { visibility: hidden; }

.t-caret {
  display: none;
  width: 8px; height: 1em;
  background: var(--accent);
  vertical-align: -0.15em;
}
.t-line.is-active .t-caret { display: inline-block; }
.terminal-lines.is-done .t-line:last-child .t-caret {
  display: inline-block;
  animation: blink 1s steps(1) infinite;
}

.terminal-caption {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-top: 20px;
}

/* ---------- カード共通 ---------- */

.card {
  background: var(--base);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.cards-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.cards-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.sec-more { margin-top: 32px; text-align: center; }
.sec-more a {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-dim);
}

/* ---------- 実績カード(works / indexハイライト) ---------- */

.work-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.work-cat {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--muted);
  border: 1px solid var(--grid);
  border-radius: 999px;
  padding: 3px 12px;
  white-space: nowrap;
}

.badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-dim);
  white-space: nowrap;
}
.badge-dot { color: var(--accent); margin-right: 4px; }

/* LIVEバッジの鼓動(「動いている」証) */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.badge-dot { animation: pulse 2.4s ease-in-out infinite; }

.work-title { font-size: 19px; margin-bottom: 12px; }

.work-items { margin-bottom: 18px; }
.work-items li {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
}
.work-items li + li { margin-top: 8px; }
.work-items li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--font-mono);
}

.work-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 6px;
  padding: 2px 10px;
}

/* ---------- worksフィルタ ---------- */

.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 40px;
}
.filter-btn {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--base);
  border: 1px solid var(--grid);
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 18px;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent-dim); }
.filter-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--base);
}

.works-grid { transition: opacity 0.2s ease; }
.works-grid.is-fading { opacity: 0; }

/* ---------- CHANGELOG(story・シグネチャー spec §3.4) ---------- */

.changelog {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding-left: 44px;
}
/* ベースの縦ライン */
.changelog::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--grid);
}
/* スクロールで伸びる緑ライン */
.cl-line {
  position: absolute;
  left: 11px;
  top: 4px;
  width: 2px;
  height: 0;
  background: var(--accent);
  max-height: calc(100% - 8px);
}

.cl-entry { position: relative; padding-bottom: 56px; }
.cl-entry:last-child { padding-bottom: 0; }

.cl-dot {
  position: absolute;
  left: -39px;
  top: 8px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--base);
  border: 2px solid var(--grid);
  transition: border-color 0.4s ease, background 0.4s ease;
}

.cl-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.cl-ver {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  transition: color 0.4s ease;
}
.cl-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 1px 8px;
  transition: color 0.4s ease, border-color 0.4s ease;
}

.cl-title { font-size: 19px; margin-bottom: 8px; }
.cl-body { font-size: 15px; color: var(--muted); max-width: 560px; }

/* 通過したバージョンの点灯 */
.cl-entry.is-lit .cl-dot { border-color: var(--accent); background: var(--accent); }
.cl-entry.is-lit .cl-ver { color: var(--accent-dim); }
.cl-entry.is-lit .cl-label { color: var(--accent-dim); border-color: var(--accent); }

/* ---------- ページ見出し(下層ページ) ---------- */

.page-hero {
  padding: calc(var(--header-h) + 80px) 0 72px;
}
.page-title {
  font-size: clamp(26px, 4.6vw, 42px);
  line-height: 1.5;
  margin-bottom: 20px;
}
.page-lead { color: var(--muted); max-width: 680px; }

/* ---------- services ---------- */

.svc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.svc-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--accent-dim);
  margin-bottom: 10px;
}
.svc-title { font-size: 18px; margin-bottom: 8px; }
.svc-desc { font-size: 14px; color: var(--muted); }

.strengths {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.strength-title { font-size: 18px; margin-bottom: 8px; }
.strength-title .mono { color: var(--accent-dim); font-size: 13px; display: block; margin-bottom: 6px; }
.strength-body { font-size: 14px; color: var(--muted); }

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  counter-reset: step;
}
.step {
  background: var(--base);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 24px;
}
.step-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--accent-dim);
  margin-bottom: 10px;
}
.step-title { font-size: 17px; margin-bottom: 8px; }
.step-body { font-size: 14px; color: var(--muted); }

.faq { max-width: 720px; margin: 0 auto; display: grid; gap: 16px; }
.faq-item {
  background: var(--base);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.faq-q {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}
.faq-q .mono, .faq-a .mono {
  font-family: var(--font-mono);
  color: var(--accent-dim);
  margin-right: 10px;
}
.faq-a { font-size: 15px; color: var(--muted); }

/* ---------- CTAセクション ---------- */

.cta-section { text-align: center; }
.cta-title { font-size: clamp(22px, 3.4vw, 30px); margin-bottom: 14px; }
.cta-sub { color: var(--muted); margin-bottom: 32px; }
.cta-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- contact ---------- */

.contact-notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 24px;
  margin: 24px 0 40px;
}
.contact-notes li {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}
.contact-notes li::before { content: "✓ "; color: var(--accent); font-weight: 600; }

.trust {
  border-top: 1px solid var(--grid);
  margin-top: 72px;
  padding-top: 40px;
  text-align: center;
}
.trust p { font-size: 14px; color: var(--muted); }
.trust .mono { font-family: var(--font-mono); }

/* ---------- フッター ---------- */

.site-footer {
  border-top: 1px solid var(--grid);
  background: var(--base);
  padding: 56px 0 40px;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.footer-nav a {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  padding: 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.footer-nav a:hover { color: var(--ink); text-decoration: none; }
.footer-license {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.copyright {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- スクロール出現(.rv) ---------- */

/* JS有効時のみ隠す(プログレッシブエンハンスメント) */
.js .rv {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .rv.is-in { opacity: 1; transform: none; }

/* 時差表示ユーティリティ */
.js .rv.d1 { transition-delay: 0.08s; }
.js .rv.d2 { transition-delay: 0.16s; }
.js .rv.d3 { transition-delay: 0.24s; }

/* ---------- レスポンシブ ---------- */

@media (max-width: 960px) {
  .cards-3 { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .strengths { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
  .pc-only { display: none; }
  .section { padding: 72px 0; }
  .hero { padding: calc(var(--header-h) + 64px) 0 72px; }
  .page-hero { padding: calc(var(--header-h) + 56px) 0 56px; }

  .cards-3, .cards-2, .svc-grid, .steps { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .container, .header-inner { padding-left: 18px; padding-right: 18px; }

  .header-inner { gap: 8px; }
  .logo { font-size: 14px; }
  .site-nav { gap: 0; }
  .site-nav a { font-size: 12px; padding: 10px 6px; }
  .btn--sm.header-cta { min-height: 40px; padding: 6px 12px; font-size: 12px; border-radius: 8px; }

  .changelog { padding-left: 36px; }
  .cl-dot { left: -31px; }

  .terminal-lines { font-size: 12.5px; padding: 18px 16px 22px; }
}

/* ---------- reduced-motion: 全アニメーション無効(spec §6 必須) ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  body.is-leaving { opacity: 1; }
  .js .rv { opacity: 1; transform: none; }
  .logo-caret, .type-caret, .t-caret { animation: none !important; }
}
