/*
 * ADE ダウンロードサイト
 *
 * 見た目はアプリ本体（src/renderer/styles/tokens.css）にそろえる。
 *   - 無彩色の面と 1px の線。グラデーション・光彩・ぼかしの影は使わない
 *   - 角丸は 4〜8px。アクセントは青1色（リンク・推奨・フォーカスだけ）
 *   - アイコンは単色の細い線（stroke 1.5）
 * 色の値はアプリのトークン（Orca 由来、MIT）から写した。サイトは別に配信するので import はしない。
 *
 * テーマ: 既定は OS の設定（prefers-color-scheme）。ヘッダーの切り替えで
 * html[data-theme] を書き、localStorage に残す（app.js）。
 */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-chrome: #fafafa;
  --bg-panel: #ffffff;
  --bg-sunken: #f5f5f5;
  --surface-hover: #f5f5f5;
  --surface-active: #ebebeb;
  --primary: #171717;
  --primary-fg: #fafafa;
  --primary-hover: #333333;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #0a0a0a;
  --text-muted: #737373;
  --text-faint: rgb(24 24 27 / 56%);
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-wash: color-mix(in srgb, var(--accent) 8%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 40%, transparent);
  --warning: #a16207;
  --record: #ef4444;
  --shot-shadow: 0 1px 2px rgb(0 0 0 / 6%);

  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic UI', Meiryo, Ubuntu, system-ui, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, 'Cascadia Mono', Menlo, Consolas, 'DejaVu Sans Mono',
    'Noto Sans Mono CJK JP', monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --page: 1120px;
  --gutter: 24px;
  --header: 56px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0a0a0a;
    --bg-chrome: #0f0f0f;
    --bg-panel: #141414;
    --bg-sunken: #0f0f0f;
    --surface-hover: #1e1e1e;
    --surface-active: #262626;
    --primary: #e5e5e5;
    --primary-fg: #171717;
    --primary-hover: #ffffff;
    --border: rgb(255 255 255 / 9%);
    --border-strong: rgb(255 255 255 / 16%);
    --text: #fafafa;
    --text-muted: #a1a1a1;
    --text-faint: rgb(255 255 255 / 52%);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --warning: #eab308;
    --shot-shadow: none;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-chrome: #0f0f0f;
  --bg-panel: #141414;
  --bg-sunken: #0f0f0f;
  --surface-hover: #1e1e1e;
  --surface-active: #262626;
  --primary: #e5e5e5;
  --primary-fg: #171717;
  --primary-hover: #ffffff;
  --border: rgb(255 255 255 / 9%);
  --border-strong: rgb(255 255 255 / 16%);
  --text: #fafafa;
  --text-muted: #a1a1a1;
  --text-faint: rgb(255 255 255 / 52%);
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --warning: #eab308;
  --shot-shadow: none;
}

/* ── 土台 ──────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

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

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  margin: 0;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 8px;
  z-index: 100;
  background: var(--bg-panel);
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.wrap {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.muted {
  color: var(--text-muted);
}

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

.nw {
  white-space: nowrap;
}

/* ── ボタン ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-fg);
}

.btn-lg {
  height: 44px;
  padding: 0 18px;
  font-size: 15px;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-icon {
  width: 30px;
  padding: 0;
}

/* ── ヘッダー ──────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.2) blur(8px);
}

.site-header .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand img {
  width: 24px;
  height: 24px;
}

.site-nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
}

.site-nav a:hover,
.site-nav a[aria-current='page'] {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme='dark'] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme='dark'] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme='light']) .theme-toggle .icon-moon {
    display: none;
  }
}

/* ── ヒーロー ──────────────────────────────────────── */

.hero {
  padding: 88px 0 56px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 24px;
}

.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.hero h1 {
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.18;
  letter-spacing: -0.02em;
  word-break: auto-phrase;
}

.hero .lede {
  margin-top: 20px;
  max-width: 36em;
  color: var(--text-muted);
  font-size: 17px;
}

.hero-actions {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-meta {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}

.hero-meta [data-hero-meta]:empty {
  display: none;
}

/* ── スクリーンショット ─────────────────────────────── */

.shot {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-chrome);
  box-shadow: var(--shot-shadow);
}

.shot img {
  width: 100%;
}

.shot .shot-dark {
  display: none;
}

:root[data-theme='dark'] .shot .shot-dark {
  display: block;
}

:root[data-theme='dark'] .shot .shot-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .shot .shot-dark {
    display: block;
  }
  :root:not([data-theme='light']) .shot .shot-light {
    display: none;
  }
}

.shot-caption {
  margin-top: 12px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── セクション ─────────────────────────────────────── */

.section {
  padding: 80px 0;
  border-top: 1px solid var(--border);
}

.section-head {
  max-width: 40em;
  margin-bottom: 40px;
}

.kicker {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.section h2 {
  font-size: clamp(24px, 3.4vw, 32px);
}

.section-head p:not(.kicker) {
  margin-top: 12px;
  color: var(--text-muted);
}

/* 3ステップ */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.steps li {
  padding: 24px;
  background: var(--bg-panel);
}

.steps li + li {
  border-left: 1px solid var(--border);
}

.step-no {
  display: block;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 16px;
}

.steps h3,
.features h3 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.steps p,
.features p {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

/* 機能 */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.features > div {
  background: var(--bg-panel);
  padding: 24px;
}

.features .icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

/* Agent に届くもの */
.handoff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.file {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  overflow: hidden;
}

.file-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-chrome);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.file pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.file pre .k {
  color: var(--text-muted);
}

.file pre .h {
  font-weight: 600;
}

.handoff-notes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.handoff-notes li {
  display: flex;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.handoff-notes .icon {
  margin-top: 4px;
  color: var(--text);
}

.handoff-notes strong {
  color: var(--text);
  font-weight: 500;
}

/* 対応 OS */
.os-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.os-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  padding: 20px;
}

.os-card h3,
.os-col h3 {
  flex-wrap: wrap;
}

.os-card h3 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.os-card ul {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 14px;
}

.os-card .status {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* 末尾の CTA */
.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  padding: 32px;
}

.cta h2 {
  font-size: 24px;
}

.cta p {
  margin-top: 6px;
  color: var(--text-muted);
}

.cta .hero-actions {
  margin-top: 0;
}

/* ── ダウンロードページ ─────────────────────────────── */

.page-head {
  padding: 64px 0 32px;
}

.page-head h1 {
  font-size: clamp(30px, 5vw, 44px);
}

.page-head p {
  margin-top: 12px;
  color: var(--text-muted);
  max-width: 40em;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  font-size: 14px;
  margin-bottom: 24px;
}

.notice[hidden] {
  display: none;
}

.notice .icon {
  margin-top: 3px;
  color: var(--accent);
}

.notice strong {
  font-weight: 600;
}

.notice p + p {
  margin-top: 4px;
  color: var(--text-muted);
}

.notice pre {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  overflow-x: auto;
  color: var(--text);
}

.latest-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 16px;
}

.latest-title h2 {
  font-size: 20px;
}

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

.os-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  overflow: hidden;
}

.os-col h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 12px;
  padding: 14px 16px;
}

.slot + .slot {
  border-top: 1px solid var(--border);
}

.slot-name {
  font-weight: 500;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  white-space: nowrap;
}

.slot-file {
  grid-column: 1 / -1;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-name {
  grid-row: 1;
  grid-column: 1;
}

.slot .btn,
.slot .unavailable {
  grid-row: 1;
  grid-column: 2;
}

.slot .unavailable {
  color: var(--text-faint);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-accent {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent);
}

.badge-warn {
  color: var(--warning);
}

.slot.is-recommended {
  background: var(--accent-wash);
}

.help {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* 全バージョン */
.versions {
  display: grid;
  gap: 12px;
}

.version {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
}

.version > summary {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 16px;
  cursor: pointer;
}

.version > summary::-webkit-details-marker {
  display: none;
}

.version > summary .chev {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 150ms var(--ease);
}

.version[open] > summary .chev {
  transform: rotate(90deg);
}

.version > summary:hover {
  background: var(--surface-hover);
  border-radius: var(--radius-lg);
}

.version-name {
  font-weight: 600;
  font-size: 15px;
}

.version-date {
  color: var(--text-muted);
  font-size: 13px;
}

.version-body {
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.version-body h4 {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.notes {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text);
  font-size: 14px;
}

.notes li + li {
  margin-top: 4px;
}

.files {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}

.files li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  min-width: 0;
}

.files .os {
  flex: none;
  width: 13em;
  white-space: nowrap;
  color: var(--text-muted);
}

.files a {
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.preview-mark {
  color: var(--warning);
}

.files .size {
  flex: none;
  color: var(--text-faint);
  font-size: 12px;
}

.version-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 13px;
}

.loading {
  color: var(--text-muted);
  font-size: 14px;
  padding: 16px 0;
}

/* ── フッター ──────────────────────────────────────── */

.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  background: var(--bg-chrome);
  padding: 48px 0 32px;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
}

.footer-grid h2 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
}

.footer-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.footer-grid a {
  color: var(--text-muted);
}

.footer-grid a:hover {
  color: var(--text);
}

.provider {
  margin-top: 12px;
}

.provider a {
  color: var(--text);
}

.footer-bottom {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── 狭い画面 ──────────────────────────────────────── */

@media (max-width: 900px) {
  .features,
  .os-grid,
  .slots {
    grid-template-columns: 1fr 1fr;
  }
  .handoff,
  .version-body {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }
  .site-nav {
    margin-right: 0;
  }
  .site-nav a:not(.nav-keep) {
    display: none;
  }
  .header-actions {
    margin-left: auto;
  }
  .header-actions .btn-label {
    display: none;
  }
  .hero {
    padding: 56px 0 40px;
  }
  .hero .lede {
    font-size: 16px;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .section {
    padding: 56px 0;
  }
  .steps,
  .features,
  .os-grid,
  .slots,
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .steps li + li {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .cta {
    padding: 24px;
  }
  .files li {
    flex-wrap: wrap;
    gap: 0 8px;
  }
  .files .os {
    width: 100%;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.shot-block {
  margin-bottom: 80px;
}

#latest {
  padding-bottom: 64px;
}

/* 404 */
.not-found {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 16px;
}

.not-found h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.not-found .hero-actions {
  margin-top: 24px;
  justify-content: center;
}
