/* base.css — リセットと要素の既定スタイル
   値はすべて tokens.css の CSS変数から取る。HEX を直接書かない。
   参照: docs/design/TYPOGRAPHY.md / COLOR.md / prototypes/index.html */

/* ボーダー幅は tokens.json に定義がない。
   docs/design/LAYOUT.md §6 の規定値（プロトタイプ実装値と同一）を
   名前付き定数としてここで宣言する。 */
:root {
}

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

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

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-body);
  line-height: var(--line-height-body);
  letter-spacing: var(--letter-spacing-body);
}

/* --bp-md: 900px。メディアクエリでは CSS変数を使えないため実値を書く */
@media (min-width: 900px) {
  body {
    font-size: var(--font-size-body-desktop);
  }
}

/* --- 見出し ------------------------------------------------------------ */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: inherit;
  overflow-wrap: break-word;
}

h1 {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-h1);
  line-height: var(--line-height-h1);
  letter-spacing: var(--letter-spacing-h1);
}

/* h2 は左に Primary のボーダー1本のみ。背景ベタ塗りを使わない
   （TYPOGRAPHY.md §3） */
h2 {
  margin: var(--space-7) 0 var(--space-4);
  padding-left: var(--space-3);
  border-left: var(--border-width-emphasis) solid var(--color-primary-600);
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-h2);
  line-height: var(--line-height-h2);
  letter-spacing: var(--letter-spacing-h2);
}

h3 {
  margin: var(--space-6) 0 var(--space-3);
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-h3);
  line-height: var(--line-height-h3);
  letter-spacing: var(--letter-spacing-h3);
}

h4 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-h4);
  line-height: var(--line-height-h4);
  letter-spacing: var(--letter-spacing-h4);
}

h5,
h6 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-h4);
  line-height: var(--line-height-h4);
}

@media (min-width: 900px) {
  h1 {
    font-size: var(--font-size-h1-desktop);
  }

  h2 {
    font-size: var(--font-size-h2-desktop);
  }

  h3 {
    font-size: var(--font-size-h3-desktop);
  }

  h4 {
    font-size: var(--font-size-h4-desktop);
  }
}

/* --- テキスト ---------------------------------------------------------- */

p {
  margin: 0 0 var(--space-4);
  overflow-wrap: break-word;
}

ul,
ol {
  margin: 0 0 var(--space-4);
  padding-left: 1.4em;
}

li {
  margin-bottom: var(--space-2);
}

dl {
  margin: 0 0 var(--space-4);
}

dd {
  margin: 0;
}

strong,
b {
  font-weight: var(--font-weight-h4);
}

/* 強調のマーカーは --color-primary-50 のみ（TYPOGRAPHY.md §5） */
mark {
  background-color: var(--color-primary-50);
  color: inherit;
}

small {
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: var(--font-size-body-sm);
}

pre {
  overflow-x: auto;
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
}

blockquote {
  margin: 0 0 var(--space-5);
  padding-left: var(--space-4);
  border-left: var(--border-width-accent) solid var(--color-border-strong);
  color: var(--color-text-secondary);
}

hr {
  height: 0;
  margin: var(--space-6) 0;
  border: 0;
  border-top: var(--border-width) solid var(--color-border);
}

/* --- リンク ------------------------------------------------------------ */

a {
  color: var(--color-primary-500);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-primary-700);
}

/* フォーカスは全インタラクティブ要素で可視にする（ACCESSIBILITY.md §3） */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
details:focus-visible,
[tabindex]:focus-visible,
[contenteditable]:focus-visible {
  outline: 2px solid var(--color-primary-700);
  outline-offset: 2px;
}

/* --- メディア ---------------------------------------------------------- */

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

figure {
  margin: 0 0 var(--space-5);
}

figcaption {
  margin-top: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
}

/* --- 表の既定 ---------------------------------------------------------- */

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--font-size-table);
  line-height: var(--line-height-table);
}

caption {
  padding: var(--space-3) var(--space-3) var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
  text-align: left;
}

th,
td {
  padding: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
  text-align: left;
}

thead th {
  background-color: var(--color-surface-alt);
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-h4);
}

/* --- フォーム ---------------------------------------------------------- */

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

label {
  display: block;
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-h4);
}

button {
  cursor: pointer;
}

[aria-disabled="true"],
button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* --- 折りたたみ -------------------------------------------------------- */

summary {
  cursor: pointer;
  font-weight: var(--font-weight-h4);
}
