/* Chit UI のドキュメントサイト。ビルドはしないので、ここが唯一のスタイルシート。 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-code: #f4f4f6;
  --text: #1c1d21;
  --text-soft: #565a63;
  --border: #e3e4e8;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --accent-text: #0b4bb3;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);

  --measure: 44rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --bg-soft: #1a1c22;
    --bg-code: #1d1f26;
    --text: #e8e9ed;
    --text-soft: #a3a7b3;
    --border: #2b2d36;
    --accent: #6ea8fe;
    --accent-soft: #1b2a45;
    --accent-text: #9cc3ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.5em 1em;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}

.site-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.site-header .brand span {
  color: var(--text-soft);
  font-weight: 400;
  font-size: 0.85rem;
  margin-left: 0.5em;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-left: auto;
  font-size: 0.95rem;
}

.site-header nav a {
  color: var(--text-soft);
  text-decoration: none;
}

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

/* --- レイアウト -------------------------------------------------------- */

main {
  padding: 0 1.5rem 6rem;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
}

.with-toc {
  display: grid;
  max-width: 64rem;
  margin: 0 auto;
  gap: 3rem;
  grid-template-columns: 15rem minmax(0, 1fr);
  align-items: start;
}

.toc {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding: 1rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.toc h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li + li {
  margin-top: 0.4rem;
}

.toc li.sub {
  padding-left: 1rem;
  font-size: 0.85rem;
}

.toc a {
  color: var(--text-soft);
  text-decoration: none;
}

.toc a:hover,
.toc a.active {
  color: var(--accent-text);
}

@media (max-width: 62rem) {
  .with-toc {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .toc {
    position: static;
    max-height: none;
    margin-bottom: 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-soft);
  }
}

/* --- 文章 -------------------------------------------------------------- */

h1 {
  margin: 2.5rem 0 1rem;
  font-size: 2rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

h2 {
  margin: 3.5rem 0 1rem;
  padding-top: 0.5rem;
  font-size: 1.4rem;
  line-height: 1.4;
}

h3 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.1rem;
}

h2 .anchor,
h3 .anchor {
  margin-left: 0.4em;
  color: var(--text-soft);
  font-weight: 400;
  opacity: 0;
  text-decoration: none;
}

h2:hover .anchor,
h3:hover .anchor,
.anchor:focus {
  opacity: 1;
}

p {
  margin: 1rem 0;
}

.lead {
  font-size: 1.15rem;
  color: var(--text-soft);
}

ul,
ol {
  padding-left: 1.4em;
}

li + li {
  margin-top: 0.35rem;
}

code {
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--bg-code);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}

pre {
  position: relative;
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-code);
  line-height: 1.7;
}

pre code {
  padding: 0;
  background: none;
  font-size: 0.85rem;
}

.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25em 0.7em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms;
}

pre:hover .copy,
.copy:focus-visible {
  opacity: 1;
}

.copy:hover {
  color: var(--text);
}

table {
  width: 100%;
  margin: 1.25rem 0;
  border-collapse: collapse;
  font-size: 0.925rem;
}

th,
td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-soft);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

td code {
  white-space: nowrap;
}

.scroll-x {
  overflow-x: auto;
}

.note {
  margin: 1.5rem 0;
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  font-size: 0.95rem;
}

.note p:first-child {
  margin-top: 0;
}

.note p:last-child {
  margin-bottom: 0;
}

/* --- トップ ------------------------------------------------------------ */

.hero {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 4rem 0 1rem;
}

.hero h1 {
  margin-top: 0;
  font-size: 2.6rem;
}

.hero .lead {
  max-width: 34rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.badges span {
  padding: 0.2em 0.7em;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0;
}

.button {
  padding: 0.6em 1.3em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--bg-soft);
}

.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  filter: brightness(1.08);
}

.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 2rem 0;
}

.card {
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

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

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

.playground {
  margin: 2rem 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

.playground h2 {
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 1.1rem;
}

.playground p {
  margin: 0 0 1rem;
  color: var(--text-soft);
  font-size: 0.925rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.controls button {
  padding: 0.4em 0.9em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.controls button:hover {
  background: var(--bg-soft);
}

.controls button[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.widget-status {
  margin-top: 1rem;
  color: var(--text-soft);
  font-size: 0.85rem;
}

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

.site-footer {
  padding: 2rem 1.5rem 4rem;
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}

/* 画面の隅で本物のウィジェットが動いているので、フッターの下に余白を置いて
   ランチャーが文章に重ならないようにする。 */
body {
  padding-bottom: 2rem;
}

@media (max-width: 40rem) {
  /* 狭い画面では、ナビゲーションを名前の下の 1 行にまとめる。右端で折り返すと
     最後の 1 つだけが次の行に取り残されて読みにくい。 */
  .site-header {
    gap: 0.25rem;
  }

  .site-header nav {
    width: 100%;
    margin-left: 0;
    gap: 0.9rem;
    font-size: 0.9rem;
  }

  main {
    padding: 0 1.25rem 5rem;
  }

  .hero {
    padding-top: 2.5rem;
  }

  .hero h1 {
    font-size: 2rem;
  }
}
