/* 色・文字・角丸・余白はここだけで決める。見た目の差し替えはこの変数の書き換えで済ませる。 */
:root {
  color-scheme: light dark;

  --color-bg: #ffffff;
  --color-surface: #f5f5f7;
  --color-text: #1d1d1f;
  --color-text-secondary: #636366;
  --color-border: #d2d2d7;
  --color-accent: #1d1d1f;
  --color-accent-contrast: #ffffff;
  --color-notice-bg: #ececef;
  --color-notice-border: #8e8e93;

  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Segoe UI", "Noto Sans JP", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --content-width: 720px;
  --gutter: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0b0b0c;
    --color-surface: #1c1c1e;
    --color-text: #f5f5f7;
    --color-text-secondary: #a1a1a6;
    --color-border: #38383a;
    --color-accent: #f5f5f7;
    --color-accent-contrast: #0b0b0c;
    --color-notice-bg: #2c2c2e;
    --color-notice-border: #7c7c80;
  }
}

/* 言語の出し分け。lang.js が <html data-show> を決める。JS が無ければ両方出る。 */
html[data-show="ja"] [data-lang="en"],
html[data-show="en"] [data-lang="ja"] {
  display: none !important;
}

html:not([data-show]) span[data-lang="ja"]::after {
  content: " / ";
}

html:not([data-show]) .page > section[data-lang="en"] {
  margin-top: 4rem;
  padding-top: 3rem;
  border-top: 1px solid var(--color-border);
}

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

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.8;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  overflow-wrap: anywhere;
}

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

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

/* 文章 */
h1,
h2,
h3 {
  font-feature-settings: "palt";
  font-weight: 700;
  text-wrap: balance;
  word-break: auto-phrase;
}

h2 {
  margin: 3.25rem 0 1rem;
  font-size: clamp(1.5rem, 4.4vw, 1.875rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.25rem;
  line-height: 1.45;
}

p,
ul,
ol,
dl {
  margin: 0 0 1.25rem;
}

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

li {
  margin-bottom: 0.5rem;
}

strong {
  font-weight: 650;
}

hr {
  margin: 3rem 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

code {
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

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

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

/* ページの枠。ヘッダー・本文・フッターの左右は同じ位置にそろえる。 */
.site-header,
.page,
.site-footer {
  padding-left: max(var(--gutter), env(safe-area-inset-left), calc((100% - var(--content-width)) / 2));
  padding-right: max(var(--gutter), env(safe-area-inset-right), calc((100% - var(--content-width)) / 2));
}

.skip-link {
  position: absolute;
  top: -5rem;
  left: max(var(--gutter), env(safe-area-inset-left));
  z-index: 10;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-size: 0.9375rem;
  text-decoration: none;
}

.skip-link:focus {
  top: max(0.75rem, env(safe-area-inset-top));
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.site-header a {
  overflow-wrap: normal;
  white-space: nowrap;
}

.brand {
  margin-right: auto;
  color: var(--color-text);
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
}

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

.site-nav a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.lang-switch a {
  display: inline-block;
  padding: 0.2rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-size: 0.875rem;
  text-decoration: none;
}

.lang-switch a:hover {
  border-color: var(--color-text-secondary);
  text-decoration: none;
}

.page {
  flex: 1 0 auto;
  padding-top: clamp(2.5rem, 8vw, 5rem);
  padding-bottom: clamp(3rem, 10vw, 6rem);
}

/* #ja / #en で開いたとき、ヘッダーまで見える位置に着地させる */
.page > section[id] {
  scroll-margin-top: 10rem;
}

.page-title {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 2rem;
  color: var(--color-text-secondary);
  font-size: clamp(1.1875rem, 3.2vw, 1.375rem);
  line-height: 1.7;
  text-wrap: pretty;
  word-break: auto-phrase;
}

.meta {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  line-height: 1.7;
}

.card {
  margin: 1.5rem 0;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.card > :first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

.notice {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-notice-border);
  border-radius: var(--radius-md);
  background: var(--color-notice-bg);
}

.notice > :first-child {
  margin-top: 0;
}

.notice > :last-child {
  margin-bottom: 0;
}

.faq {
  margin: 0.75rem 0;
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.faq summary {
  position: relative;
  padding: 1rem 3.25rem 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 650;
  line-height: 1.6;
  cursor: pointer;
  list-style: none;
}

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

.faq summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1.35rem;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--color-text-secondary);
  border-bottom: 2px solid var(--color-text-secondary);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s ease;
}

.faq[open] summary::after {
  transform: translateY(-30%) rotate(-135deg);
}

.faq summary:focus-visible {
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

.faq-body {
  padding: 0 1.25rem 1.25rem;
}

.faq-body > :last-child {
  margin-bottom: 0;
}

.steps {
  margin: 1.25rem 0;
  padding-left: 1.75em;
}

.steps li {
  margin-bottom: 1rem;
  padding-left: 0.4em;
}

.steps li::marker {
  color: var(--color-text-secondary);
  font-weight: 700;
}

.contact {
  margin: 1.5rem 0;
  padding: 2rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  font-size: clamp(1.25rem, 5.4vw, 1.75rem);
  font-weight: 650;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}

.contact > * {
  margin: 0;
}

.contact > * + * {
  margin-top: 0.5rem;
}

.contact .meta {
  font-size: 0.875rem;
  font-weight: 400;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 1.6rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-weight: 650;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  overflow-wrap: normal;
}

.button:hover {
  text-decoration: none;
  opacity: 0.85;
}

.site-footer {
  padding-top: 2rem;
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  line-height: 1.7;
}

.site-footer p {
  margin: 0 0 0.5rem;
}

.site-footer a {
  color: var(--color-text-secondary);
}

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

.site-footer a + a {
  margin-left: 1.25rem;
}

/* トップと 404 の中央寄せ */
.hero {
  padding: clamp(2rem, 10vw, 5rem) 0;
  text-align: center;
}

.hero .page-title {
  letter-spacing: -0.03em;
}

.home .page-title {
  font-size: clamp(2.75rem, 14vw, 5rem);
}

.hero .tagline {
  margin: 0 0 1.25rem;
  font-size: clamp(1.375rem, 5.2vw, 2rem);
  font-weight: 650;
  line-height: 1.4;
  text-wrap: balance;
  word-break: auto-phrase;
}

.hero .lead {
  max-width: 34em;
  margin-left: auto;
  margin-right: auto;
}

.hero .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.5rem;
  margin: 2rem 0 0;
}

@media (max-width: 480px) {
  .site-header {
    gap: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .site-nav {
    gap: 0.75rem;
  }

  .lang-switch a {
    padding: 0.15rem 0.6rem;
    font-size: 0.8125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .faq summary::after {
    transition: none;
  }
}
