/* ===================================================================
   docs.css — Playwright/Docusaurus 風の3カラム ドキュメントサイト外装。
   site.css の デザイントークン (色 / タイポ / code / table / callout) を
   前提に、その後に読み込んで レイアウト系を上書き・追加する。
   =================================================================== */

/* --- manual theme toggle: system 既定 + data-theme で明示上書き --- */
:root[data-theme="light"] {
  --bg: #f5f3ef;  --bg-soft: #ffffff;
  --fg: #222222;  --fg-soft: #555555;  --fg-dim: #888888;
  --border: #e2e0e6;  --border-soft: #ecebf0;
  --accent: #4f47a3;  --accent-soft: rgba(79,71,163,0.08);  --accent-strong: #3a3380;
  --code-bg: #f3f2f7;  --code-fg: #2d2b3a;
  --warn-bg: #fff3e0;  --warn-fg: #7a4500;
  --shadow: 0 1px 3px rgba(0,0,0,0.07);
  --shadow-lg: 0 6px 20px rgba(70,60,120,0.12);
}
:root[data-theme="dark"] {
  --bg: #16151c;  --bg-soft: #1f1e26;
  --fg: #e8e7ee;  --fg-soft: #b8b6c8;  --fg-dim: #8a889c;
  --border: rgba(170,165,200,0.18);  --border-soft: rgba(170,165,200,0.10);
  --accent: #8a82d6;  --accent-soft: rgba(138,130,214,0.14);  --accent-strong: #a8a2e6;
  --code-bg: #25232e;  --code-fg: #d8d6e6;
  --warn-bg: #2a200c;  --warn-fg: #f0c95c;
  --shadow: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-lg: 0 6px 20px rgba(0,0,0,0.45);
}

html { scroll-padding-top: 72px; }
body.docs { background: var(--bg); }

/* =========================== top header =========================== */
.docs-header {
  position: sticky; top: 0; z-index: 60;
  height: 56px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.docs-header .brand {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; font-weight: 700; font-size: 16px;
  color: var(--fg); letter-spacing: -0.01em; white-space: nowrap;
}
.docs-header .brand img { width: 26px; height: 26px; border-radius: 6px; display: block; }
.docs-header .brand .brand-text { color: var(--fg); }
.docs-header .brand .brand-tag {
  font-size: 11px; font-weight: 600; color: var(--accent-strong);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 999px;
  letter-spacing: 0.02em;
}
.docs-header .spacer { flex: 1; }

.docs-search {
  position: relative; width: min(260px, 34vw);
}
.docs-search input {
  width: 100%; height: 34px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg);
  font-size: 13px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.docs-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.docs-search::before {
  content: ""; position: absolute; left: 10px; top: 50%;
  width: 14px; height: 14px; transform: translateY(-50%);
  background: var(--fg-dim);
  -webkit-mask: no-repeat center/contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  mask: no-repeat center/contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  pointer-events: none;
}

.docs-header .hlink {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--fg-soft); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 6px 10px; border-radius: 7px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.docs-header .hlink:hover { background: var(--accent-soft); color: var(--accent-strong); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--fg-soft); cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--accent-strong); border-color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

.hamburger { display: none; }

/* =========================== layout =========================== */
.docs-layout {
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr) 236px;
  max-width: 1440px; margin: 0 auto;
  align-items: start;
}

/* --- left sidebar --- */
.docs-sidebar {
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 20px 12px 40px 20px;
  border-right: 1px solid var(--border);
}
.sb-filter { position: relative; margin-bottom: 14px; }
.sb-filter input {
  width: 100%; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-soft); color: var(--fg); font-size: 12.5px; font-family: inherit;
}
.sb-filter input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.sb-group { margin-bottom: 18px; }
.sb-group > .sb-group-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--fg-dim);
  padding: 4px 10px; margin: 0 0 4px;
}
.sb-group ul { list-style: none; margin: 0; padding: 0; }
.sb-group li { margin: 1px 0; }
.sb-group a {
  display: block; padding: 6px 10px; border-radius: 7px;
  font-size: 13.5px; color: var(--fg-soft); text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.sb-group a:hover { background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; }
.sb-group a.active {
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 600; border-left-color: var(--accent);
}
.sb-empty { padding: 10px; color: var(--fg-dim); font-size: 12.5px; }

/* --- main content --- */
main.docs-main {
  max-width: none; margin: 0;
  padding: 30px 52px 72px;
  min-width: 0;
}
.docs-article { max-width: 800px; }
.docs-breadcrumb {
  font-size: 12.5px; color: var(--fg-dim); margin-bottom: 4px;
}
.docs-breadcrumb a { color: var(--fg-dim); }
.docs-article > h1:first-of-type,
.docs-article > h1 { margin-top: 0.2em; }
.docs-article h2 { scroll-margin-top: 72px; }
.docs-article h3 { scroll-margin-top: 72px; }
/* anchor link on hover */
.docs-article h2, .docs-article h3 { position: relative; }
.header-anchor {
  position: absolute; left: -0.9em; top: 0;
  opacity: 0; text-decoration: none; color: var(--fg-dim);
  transition: opacity 0.12s; padding-right: 0.3em;
}
.docs-article h2:hover .header-anchor,
.docs-article h3:hover .header-anchor { opacity: 1; }

.lead {
  font-size: 1.06rem; color: var(--fg-soft);
  margin: 0.2em 0 1.4em; line-height: 1.6;
}

/* --- prev / next pager --- */
.docs-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--border);
}
.docs-pager a {
  display: flex; flex-direction: column; gap: 3px;
  padding: 13px 16px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-soft); text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.docs-pager a:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); text-decoration: none; transform: translateY(-1px); }
.docs-pager a.next { text-align: right; align-items: flex-end; }
.docs-pager .dir { font-size: 11.5px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.docs-pager .ttl { font-size: 14px; font-weight: 600; color: var(--accent-strong); }
.docs-pager a.placeholder { visibility: hidden; }

.docs-foot {
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border);
  color: var(--fg-dim); font-size: 12.5px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.docs-foot a { color: var(--fg-soft); }

/* --- right "on this page" --- */
.docs-toc {
  position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
  padding: 30px 18px 40px 8px;
  font-size: 13px;
}
.docs-toc .toc-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--fg-dim); margin: 0 0 10px 12px;
}
.docs-toc ul { list-style: none; margin: 0; padding: 0; }
.docs-toc a {
  display: block; padding: 4px 12px; border-left: 2px solid var(--border);
  color: var(--fg-soft); text-decoration: none; line-height: 1.4;
  transition: color 0.12s, border-color 0.12s;
}
.docs-toc a.lvl-3 { padding-left: 24px; font-size: 12.5px; }
.docs-toc a:hover { color: var(--accent-strong); }
.docs-toc a.active { color: var(--accent-strong); border-left-color: var(--accent); font-weight: 600; }
.docs-toc.empty { display: none; }

/* keep site.css tables from stretching past content on wide screens */
.docs-article table { display: block; overflow-x: auto; }
@media (min-width: 720px) { .docs-article table { display: table; } }

/* =========================== responsive =========================== */
@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: 260px minmax(0,1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: minmax(0,1fr); }
  .hamburger { display: inline-grid; }
  main.docs-main { padding: 24px 22px 60px; }
  .docs-sidebar {
    position: fixed; top: 56px; left: 0; z-index: 55;
    width: 300px; max-width: 86vw;
    background: var(--bg);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .docs-sidebar.open { transform: translateX(0); }
  .sb-backdrop {
    display: none; position: fixed; inset: 56px 0 0 0; z-index: 54;
    background: rgba(0,0,0,0.4);
  }
  .sb-backdrop.show { display: block; }
  .docs-search { width: min(180px, 40vw); }
}
@media (max-width: 560px) {
  .docs-header .brand .brand-tag { display: none; }
  .docs-header .hlink.labelled span { display: none; }
  .docs-pager { grid-template-columns: 1fr; }
}
