/* 見出し heading */

h1 {
  position: relative;
  width: fit-content;
  max-width: 100%;
  font-size: var(--text-xl);
  font-weight: bold;
  font-style: normal;
  line-height: 1.2;
  padding: 10px;
  background-color: var(--gray-tertiary);
  border-left: 4px solid var(--brand-secondary);
  margin-bottom: 20px;
}

h2 {
  position: relative;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand-secondary);
  width: fit-content;
  font-size: var(--text-xl);
  max-width: 100%;
  font-weight: bold;
  line-height: 1.2;
  margin-bottom: 20px;
}

h3,
h4,
h5,
h6 {
  position: relative;
  width: fit-content;
  max-width: 100%;
  font-size: var(--text-lg);
  font-weight: bold;
  line-height: 1.2;
  margin-bottom: 20px;
}

/* 段落 Paragraph */

p {
  max-width: 100%;
  font-size: var(--text-base);
  line-height: 2.2;
  margin-bottom: 20px;
}

/* リスト List */

ul,
ol {
  padding-left: 24px;
  margin: 20px 0;
  margin-bottom: 20px;
}

li>ul,
li>ol {
  margin-bottom: 0 !important;
}

ul li,
ol li {
  margin-bottom: 12px;
  position: relative;
  padding-left: 8px;
  line-height: 1.6;
}

ul li::marker,
ol li::marker {
  color: var(--text-primary);
  font-weight: bold;
}

ul li:last-child,
ol li:last-child {
  margin-bottom: 0;
}

/* 画像 Image */

img {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 20px 0;
  min-height: auto;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  vertical-align: bottom;
}

/* 水平線 Horizontal Rule */

hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--brand-secondary);
}

/* テーブル Table */

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  background: var(--gray-primary);
  margin-bottom: 20px;
  display: table;
  table-layout: fixed;
}

table thead,
table tbody {
  display: table-header-group;
  width: 100%;
}

table tbody {
  display: table-row-group;
}

table tr {
  display: table-row;
}

table th,
table td {
  border-right: 1px solid var(--border-primary);
  padding: 10px 8px;
  text-align: left;
  display: table-cell;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 0;
}

/* 左端・右端のセルには右ボーダーを表示しない */

table th:last-child,
table td:last-child {
  border-right: none;
}

table th {
  background: var(--gray-secondary);
  font-weight: bold;
}

table tr:nth-child(even) {
  background: var(--gray-secondary);
}

table>* {
  margin: 0 !important;
}

table small {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-top: 5px;
  display: block;
}

/* 1250px以下でテーブルに横スクロールを適用 */
@media (max-width: 1250px) {
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  table thead,
  table tbody,
  table tr {
    display: table;
    width: 100%;
  }

  table th,
  table td {
    min-width: 120px;
  }
}

/* 引用 Blockquote */

blockquote {
  margin: 0 0 20px 0;
  padding: 10px;
  background-color: var(--gray-secondary);
  border-left: 4px solid var(--brand-secondary);

  * {
    margin: 0;
  }
}

/* セクション Section */
section {
  margin: 30px 0px;
}

/* コード Code */

code {
  background-color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: var(--text-xs);
  line-height: 1.2;
  color: var(--gray-primary);
  font-weight: 200;
  display: inline-block;
}

/* コードブロック Preformatted Text */
pre {
  background-color: var(--text-primary);
  padding: 20px;
  border-radius: 4px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 20px;
  display: block;
  width: 100%;
  overflow-x: scroll;
}

pre code {
  padding: 0;
  display: block;
  min-width: 0;
  width: 100%;
  background-color: transparent;
  color: var(--text-primary);
}

/* キーボード入力 Keyboard Input */
kbd {
  background-color: var(--text-primary);
  color: var(--gray-primary);
  border: 1px solid var(--border-primary);
  border-bottom: 2px solid var(--gray-tertiary);
  border-radius: 3px;
  padding: 2px 6px;
  display: inline-block;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
  margin: 0 1px;
  white-space: nowrap;
  line-height: 1;

  &:active {
    transform: translateY(1px);
    border-bottom: 1px solid var(--gray-tertiary);
    box-shadow: none;
  }
}

/* フォーム Form */

input[type="submit"],
button[type="submit"] {
  appearance: none;
  background-color: var(--brand-secondary);
  border: none;
  cursor: pointer;
  outline: none;
  padding: 10px 15px;
  box-shadow: var(--shadow-md);
  border-radius: calc(infinity * 1px);
  transition: all 0.3s ease;
  width: auto;
  margin-bottom: 0;

  &:hover {
    transform: translateY(-2px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  }

  &:disabled {
    opacity: 0.3;
    transform: none;
    cursor: not-allowed;
  }
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-base);
  color: var(--text-secondary);
}

input,
textarea,
select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-primary);
  border-radius: 4px;
  font-size: var(--text-xs);
  transition: border 0.3s, box-shadow 0.3s;
  font-family: inherit;
  margin-bottom: 20px;
  box-sizing: border-box;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 2px rgba(77, 102, 62, 0.2);
  outline: none;
}

input:invalid,
textarea:invalid,
select:invalid {
  border-color: var(--status-error);
  box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.2);
}

/* テキストの小さい要素 Small Text */
small {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* 詳細 Details */
details {
  background-color: var(--gray-primary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
  margin-bottom: 20px;
}

summary {
  background-color: var(--brand-secondary);
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 500;
  color: var(--white);
  position: relative;
  list-style: none;
  outline: none;
  transition: background-color 0.2s ease;
}

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

summary::after {
  content: "▼";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.2s ease;
  font-size: 12px;
}

details[open] summary::after {
  transform: translateY(-50%) rotate(180deg);
}

@media (max-width: 1250px) {
  summary {
    padding-right: 25px;
  }
}

details>*:not(summary) {
  padding: 16px;
  margin: 0 20px 0 20px;
  color: var(--text-primary);
}

details p {
  margin: 0;
  line-height: 1.5;
}

/* ボタン button */

button {
  appearance: none;
  background-color: var(--brand-secondary);
  color: var(--gray-primary);
  border: none;
  cursor: pointer;
  outline: none;
  padding: 10px 15px;
  box-shadow: var(--shadow-md);
  border-radius: calc(infinity * 1px);
  transition: all 0.3s ease;

  &:hover {
    transform: translateY(-2px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  }

  &:disabled {
    opacity: 0.3;
    transform: none;
    cursor: not-allowed;
  }
}

/* フッター Footer */
footer {
  background-color: var(--gray-secondary);
  border-top: 3px solid var(--brand-secondary);
  padding: 40px 20px 20px 20px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.8;

  small {
    display: block;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-primary);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-xs);
  }
}