/* =====================
   Theme Vars
===================== */
:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #6b7280;
  --link: #174ea6;
  --maxw: 72ch;
  --radius: 12px;
  --line: rgba(107,114,128,.35);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --link: #8ab4f8;
    --line: rgba(156,163,175,.35);
  }
}

/* =====================
   Base
===================== */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0; padding: 2rem 1rem 4rem;
  background: var(--bg); color: var(--fg);
  font: 1rem/1.75 system-ui,-apple-system,Segoe UI,Roboto,
        "Hiragino Kaku Gothic ProN","Noto Sans JP","Noto Sans Thai","Th Sarabun New",
        "Noto Sans CJK JP","Yu Gothic UI","YuGothic",sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--maxw); margin: 0 auto; }
header { margin-bottom: 2rem; }

h1, h2, h3 { line-height: 1.25; margin: 1.6rem 0 .8rem; }
h1 { font-size: clamp(1.6rem, 2.5vw + 1rem, 2.2rem); }
h2 { font-size: clamp(1.25rem, 1.5vw + .9rem, 1.5rem); }
p  { margin: .85rem 0; }
ul { margin: .5rem 0 0; padding-left: 1.2rem; }

.note { color: var(--muted); font-size: .95rem; text-indent: 1em; }
.migiyose { text-align: right; margin-top: 1.5rem; margin-left: 1.5rem; margin-bottom: 2.5rem; }
hr {
  border: 0; height: 1px;
  background: rgba(107,114,128,.30);
  background: color-mix(in oklab, var(--muted) 30%, transparent);
  margin: 2rem 0;
}

/* Skip link (a11y) */
.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  left: 1rem; top: 1rem; width: auto; height: auto;
  padding: .5rem .75rem; background: var(--fg); color: var(--bg); border-radius: var(--radius);
}

/* Main wrapper width (unify with --maxw) */
main { max-width: var(--maxw); margin: 2rem auto; padding: 0 1rem; }

/* =====================
   Header / Global Nav
===================== */
.logo { height: 42px; width: auto; display: block; }
.brand { margin-right: auto; display: flex; align-items: center; }

.site-nav { display: flex; align-items: center; gap: .5rem 1rem; font-size: .95rem; flex-wrap: wrap; }
.site-nav a { color: var(--link); text-decoration: none; padding: .25rem .5rem; border-radius: var(--radius); }
.site-nav a:hover, .site-nav a:focus { text-decoration: underline; }

.navcheck { position: absolute; left: -9999px; }
.hamburger { display: none; position: relative; width: 40px; height: 40px; cursor: pointer; }
.hamburger span, .hamburger::before, .hamburger::after {
  content: ""; position: absolute; left: 8px; right: 8px; height: 2px; background: var(--fg);
  transition: transform .2s ease, opacity .2s ease;
}
.hamburger span { top: 50%; transform: translateY(-50%); }
.hamburger::before { top: 12px; }
.hamburger::after  { bottom: 12px; }
.navcheck:checked + .hamburger::before { transform: translateY(10px) rotate(45deg); }
.navcheck:checked + .hamburger::after  { transform: translateY(-10px) rotate(-45deg); }
.navcheck:checked + .hamburger span    { opacity: 0; }

.nav-links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.nav-links a { padding: .25rem .5rem; }

@media (max-width: 720px) {
  .logo { height: 36px; }
  .hamburger { display: block; margin-left: auto; }
  .nav-links {
    display: none; flex-direction: column; width: 100%;
    border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
    padding: .5rem; margin-top: .5rem;
  }
  .navcheck:checked ~ .nav-links { display: flex; }
  .nav-links a { padding: .6rem .75rem; }
}

/* =====================
   Breadcrumb
===================== */
.breadcrumb { font-size: .9rem; color: #555; margin: 1rem 0; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .5em; padding: 0; margin: 0; }
.breadcrumb li { display: flex; align-items: center; }
.breadcrumb li + li::before { content: "›"; color: #999; margin: 0 .4em; }
.breadcrumb a { text-decoration: none; color: var(--link); transition: color .2s ease; }
.breadcrumb a:hover { color: #0d3c91; text-decoration: underline; }
.breadcrumb li[aria-current="page"] { color: #333; font-weight: 500; }

/* =====================
   TOC
===================== */
.toc {
  background: rgba(107,114,128,.10);
  background: color-mix(in oklab, var(--muted) 10%, transparent);
  padding: .72rem 1rem; border-radius: var(--radius);
}
.toc h2 { margin-top: .5rem; }
.toc ol { margin: .25rem 0 0; padding-left: 1.25rem; }
.toc li { margin: .2rem 0; }

/* =====================
   Section Lists
===================== */
.badge {
  display: inline-block;
  font-size: .75rem;
  padding: .1rem .5rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  margin-right: .5rem;
}
.link-list { list-style: none; margin: .25rem 0 1.25rem; padding: 0; }
.link-list li { display: grid; grid-template-columns: auto 1fr; gap: .4rem .6rem; align-items: start; margin: .35rem 0; }
.link-list a { text-decoration: none; color: var(--link); }
.link-list a:hover, .link-list a:focus { text-decoration: underline; }

/* =====================
   Back-to-top
===================== */
.back-to-top {
  position: fixed; bottom: 2rem; right: 2rem;
  display: inline-block; background: var(--link); color: #fff;
  padding: .6rem 1rem; border-radius: 9999px; text-decoration: none;
  font-size: .9rem; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  opacity: .85; transition: opacity .2s, transform .2s;
}
.back-to-top:hover { opacity: 1; transform: translateY(-2px); }
@media (max-height: 600px) { .back-to-top { display: none; } }
@media (prefers-color-scheme: dark) {
  .back-to-top { box-shadow: 0 2px 6px rgba(0,0,0,.6); }
}

/* =====================
   Footer
===================== */
.social-text { margin-top: .5rem; font-size: .95rem; text-align: center; }
.social-text a { color: var(--link); text-decoration: none; margin: 0 .25rem; }
.social-text a:hover, .social-text a:focus { text-decoration: underline; }

/* =====================
   Motion Preference
===================== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* =====================
   Print
===================== */
@media print {
  nav, footer, .back-to-top { display: none; }
  body { padding: 0; }
}

/* =====================
   Small screens
===================== */
@media (max-width: 480px) {
  body { padding: 1rem .875rem 2rem; }
  h1 { font-size: clamp(1.5rem, 6vw, 2rem); }
  h2 { font-size: clamp(1.1rem, 4.5vw, 1.3rem); }
}
