/* Japanese Cutlery: A Practical Guide — stylesheet
   Quiet, flat documentation-site feel per DESIGN-BRIEF.md.
   Hierarchy via weight and space, not size. Single sans family + Noto Sans JP fallback. */

:root {
  --bg: #f7f5f1;
  --surface: #f1eee8;
  --surface-2: #ece7de;
  --border: #ddd7cd;
  --text: #2b2621;
  --text-muted: #6b625a;
  --text-faint: #9b9186;
  --accent: #2f5964;
  --accent-hover: #1f3f47;
  --diagram-primary: #3d3833;
  --diagram-secondary: #b3aaa0;

  --font-body: "General Sans", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --measure: 720px;
  --radius: 4px;
}

[data-theme="dark"] {
  --bg: #1c1a17;
  --surface: #232019;
  --surface-2: #2a261f;
  --border: #3a352c;
  --text: #e8e4dd;
  --text-muted: #a39a8f;
  --text-faint: #746b60;
  --accent: #7fb3bd;
  --accent-hover: #9dc7cf;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5em 1em;
  z-index: 200;
}
.skip-link:focus { left: 0.5em; top: 0.5em; }

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

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
}
.site-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.site-title:hover { color: var(--accent); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-wrap { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
#site-search {
  width: 100%;
  padding: 0.5em 0.75em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
#site-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 60;
}
.search-result-item { display: block; padding: 0.6em 0.8em; border-bottom: 1px solid var(--border); text-decoration: none; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item:focus { background: var(--surface-2); }
.search-result-page { display: block; font-size: 0.75rem; color: var(--text-faint); margin-bottom: 0.1em; }
.search-result-heading { display: block; font-weight: 600; color: var(--text); font-size: 0.92rem; }
.search-result-snippet { display: block; font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15em; }
.search-empty { padding: 0.8em; color: var(--text-muted); font-size: 0.88rem; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

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

.layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 220px;
  gap: 2rem;
  padding: 0 1.25rem;
  align-items: start;
}

.sidenav-wrap { position: sticky; top: 65px; max-height: calc(100vh - 80px); overflow-y: auto; padding: 1.5rem 0; }

.sidenav a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35em 0.5em;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.sidenav > a { font-weight: 600; color: var(--text); margin-bottom: 0.75em; }
.sidenav a:hover { background: var(--surface); color: var(--text); }
.sidenav a.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }

.nav-group { margin-bottom: 1.1em; }
.nav-group-title {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 0.35em 0.5em 0.2em;
  font-weight: 600;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; }

.content { min-width: 0; padding: 2rem 0 4rem; }
.content article { max-width: var(--measure); }

.content h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 0 0 0.9em; }
.content h2 { font-size: 1.4rem; font-weight: 600; margin: 2em 0 0.6em; padding-top: 0.4em; border-top: 1px solid var(--border); }
.content article > h2:first-child { border-top: none; padding-top: 0; }
.content h3 { font-size: 1.15rem; font-weight: 600; margin: 1.6em 0 0.5em; }
.content h4 { font-size: 1rem; font-weight: 600; margin: 1.4em 0 0.4em; color: var(--text); }
.content p { margin: 0 0 1em; }
.content ul, .content ol { margin: 0 0 1em; padding-left: 1.4em; }
.content li { margin-bottom: 0.35em; }
.content .entry-lead { margin-bottom: 1.1em; }

.content code {
  background: var(--surface-2);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-size: 0.88em;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
.content pre {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 1em;
  overflow-x: auto;
}
.content blockquote {
  border-left: 3px solid var(--border);
  margin: 0 0 1em;
  padding-left: 1em;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ toc */

.page-toc { position: sticky; top: 65px; max-height: calc(100vh - 80px); overflow-y: auto; padding: 1.5rem 0; font-size: 0.85rem; }
.page-toc-title { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; margin-bottom: 0.5em; }
.page-toc ul { list-style: none; margin: 0; padding: 0; }
.page-toc li { margin: 0; }
.page-toc a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.28em 0 0.28em 0.7em;
  border-left: 2px solid transparent;
}
.page-toc a.toc-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.page-toc a:hover { color: var(--text); }
.page-toc li.toc-l3 a { padding-left: 1.3em; font-size: 0.94em; }

/* --------------------------------------------------------------- tables */

.table-wrap { margin: 1.4em 0; }
.table-filter { margin-bottom: 0.5em; }
.table-filter input {
  width: 100%;
  max-width: 320px;
  padding: 0.45em 0.7em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
}
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

table.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}
table.data-table th, table.data-table td {
  padding: 0.55em 0.8em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: normal;
}
table.data-table th {
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  position: relative;
  white-space: nowrap;
}
table.data-table th:hover { color: var(--accent); }
table.data-table th[aria-sort="ascending"]::after { content: " \\25B2"; font-size: 0.7em; }
table.data-table th[aria-sort="descending"]::after { content: " \\25BC"; font-size: 0.7em; }
table.data-table tbody tr:hover { background: var(--surface); }
table.data-table tbody tr.row-hidden { display: none; }

/* -------------------------------------------------------------- diagrams */

figure.diagram {
  margin: 1.8em 0;
  padding: 1.2em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
figure.diagram img { max-width: 100%; height: auto; }
figure.diagram figcaption {
  margin-top: 0.7em;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: left;
}

/* -------------------------------------------------------------- footer */

.page-footer { margin-top: 3em; padding-top: 1.5em; border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--text-muted); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .page-toc { display: none; }
}

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .layout { grid-template-columns: 1fr; padding: 0 1rem; }
  .sidenav-wrap {
    position: fixed;
    top: 57px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 40;
    padding: 1rem 1.25rem;
    transform: translateY(-110%);
    transition: transform 0.18s ease;
    overflow-y: auto;
  }
  .sidenav-wrap.open { transform: translateY(0); }
  .search-wrap { max-width: none; }
  .content { padding: 1.5rem 0 3rem; }
  .content h1 { font-size: 1.6rem; }
}

/* --------------------------------------------------------- print toolbar */

.print-toolbar {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.print-toolbar button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  margin-right: 1em;
}
.print-toolbar button:hover { background: var(--accent-hover); }
.print-main { max-width: var(--measure); margin: 0 auto; padding: 2rem 1.25rem 5rem; }
.print-page { margin-bottom: 2.5em; }
.print-main h1 { font-size: 2.2rem; margin-bottom: 1em; }
.print-main h2 { font-size: 1.5rem; margin: 1.6em 0 0.6em; border-top: 1px solid var(--border); padding-top: 0.6em; }
.print-main section.print-page:first-of-type h2 { border-top: none; padding-top: 0; }
.print-main h3 { font-size: 1.15rem; margin: 1.3em 0 0.5em; }
.print-main h4 { font-size: 1rem; margin: 1.1em 0 0.4em; }
.print-main table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 0.9rem; }
.print-main th, .print-main td { border: 1px solid var(--border); padding: 0.4em 0.6em; text-align: left; }
.print-main th { background: var(--surface); }
