/* style.css — ハイパー鋼材表 構造設計ツールシリーズ 青テーマ */

/* === CSS Custom Properties === */
:root {
  --blue-dark:   #1a4a7a;
  --blue-mid:    #2d6fa5;
  --blue-accent: #4a90d9;
  --blue-light:  #daeaf7;
  --blue-pale:   #f0f7fd;
  --text-primary:   #1a2332;
  --text-secondary: #4a5568;
  --text-muted:     #8a9aac;
  --border:         #c0d4e8;
  --white:          #ffffff;
  --bg-page:        #f2f5f8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius:    8px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", "Yu Gothic", sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.6;
}

a { color: var(--blue-dark); text-decoration: none; }
a:hover { color: var(--blue-accent); text-decoration: underline; }

/* === Site Header === */
.site-header {
  background: var(--blue-dark);
  color: var(--white);
}
.site-header__inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-header__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.site-header__lab {
  display: inline-block;
  background: var(--blue-accent);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 4px;
  flex-shrink: 0;
}
.site-header__super {
  display: block;
  font-size: 11px;
  opacity: 0.72;
  line-height: 1.3;
}
.site-header__name {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

/* ヘッダー右端のボタン群（言語切替・使い方） */
.site-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-header__doc-link {
  font-family: inherit;
  cursor: pointer;
  color: var(--white);
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 5px;
  padding: 4px 13px;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.15s;
}
.site-header__doc-link:hover {
  background: rgba(255,255,255,0.26);
  color: var(--white);
  text-decoration: none;
}

/* === Site Nav (ツール切替タブ) === */
.site-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.site-nav__inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.site-nav__link {
  display: inline-block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.site-nav__link:hover {
  color: var(--blue-dark);
  text-decoration: none;
}
.site-nav__link--active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue-accent);
  font-weight: 700;
}

/* === Main === */
.main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* === AdSense === */
.ad-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2px;
  letter-spacing: 0.06em;
}

/* ①テーブル直下・レスポンシブ横長 */
.ad-bottom {
  text-align: center;
}

/* ②右サイドバー 300×600（1360px以上のみ表示） */
.ad-side { display: none; }

@media (min-width: 1360px) {
  .layout--ads {
    display: grid;
    grid-template-columns: minmax(0, 1000px) 300px;
    gap: 16px;
    justify-content: center;
  }
  .layout--ads .main {
    max-width: none;
    margin: 0;
    min-width: 0;
  }
  .layout--ads .ad-side {
    display: block;
    position: sticky;
    top: 16px;
    align-self: start;
    width: 300px;
    padding-top: 24px; /* .main の上パディングと揃える */
  }
}

/* === Cards === */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card--collapsible { overflow: visible; }

.card__header {
  background: var(--blue-dark);
  color: var(--white);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.card__header--flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__header__count {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
  letter-spacing: 0;
}

/* details/summary で折りたたみ可能なカードヘッダー */
.card__header--summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.card__header--summary::-webkit-details-marker { display: none; }
.card__header--summary::before {
  content: "▶";
  font-size: 9px;
  transition: transform 0.15s;
  display: inline-block;
  opacity: 0.8;
}
details[open] .card__header--summary::before { transform: rotate(90deg); }

.card__body { padding: 16px 20px; }
.card__body--compact { padding: 12px 16px; }
.card__body--nopad { padding: 0; }

/* === 鋼種選択ボタン群 === */
.steel-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.steel-nav__break { width: 100%; height: 0; }

.steel-nav__btn {
  display: inline-block;
  padding: 5px 12px;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--blue-dark);
  background: var(--blue-pale);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.steel-nav__btn:hover {
  background: var(--blue-light);
  color: var(--blue-dark);
  text-decoration: none;
}
.steel-nav__btn--active {
  background: var(--blue-dark);
  color: var(--white);
  border-color: var(--blue-dark);
}

/* === 必要断面係数 計算フォーム === */
.zx-form__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-start;
}
.zx-form__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zx-form__group--wide { flex: 1 1 100%; }
.zx-form__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.zx-result {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--blue-pale);
  border: 1px solid var(--blue-light);
  border-left: 3px solid var(--blue-accent);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ナビバー内の文字サイズ切替を右端に寄せる */
.site-nav__inner .font-size-ctrl { margin-left: auto; }

/* === テーブルツールバー === */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--blue-pale);
  border-bottom: 1px solid var(--border);
}
.table-note {
  color: var(--text-muted);
  font-size: 11px;
}
.font-size-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* === ボタン === */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 18px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn--primary {
  background: var(--blue-dark);
  color: var(--white);
}
.btn--primary:hover:not(:disabled) { background: var(--blue-mid); color: var(--white); text-decoration: none; }

.btn--ghost {
  background: transparent;
  color: var(--blue-dark);
  border: 1px solid var(--border);
}
.btn--ghost:hover:not(:disabled) { background: var(--blue-pale); text-decoration: none; }

/* 文字サイズ切替の小ボタン */
.btn--xs {
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn--xs.active, .btn--xs:hover {
  background: var(--blue-dark);
  color: var(--white);
  border-color: var(--blue-dark);
}

/* === フォームフィールド === */
.field {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 9px;
  border: 1px solid #b0c8e0;
  border-radius: 4px;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus {
  outline: none;
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.18);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* === データテーブル === */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#kozaiTableWrap {
  font-size: 18px;   /* JS で上書きされる基準値 */
}

#kozaiTableWrap table {
  width: 100%;
  border-collapse: collapse;
}

#kozaiTableWrap th {
  background: var(--blue-pale);
  color: var(--text-secondary);
  font-size: 0.65em;
  font-weight: 700;
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

#kozaiTableWrap td {
  font-size: 0.75em;
  padding: 5px 10px;
  border-bottom: 1px solid var(--blue-light);
  border-right: 1px solid var(--blue-light);
  text-align: right;
  color: var(--text-primary);
}

/* No. 列（1行目または単独行のみ — data-row-2 には適用しない）*/
#kozaiTableWrap tr.data-row-1 td:nth-child(1),
#kozaiTableWrap tr.data-row-single td:nth-child(1) {
  text-align: center;
  background: #f4f8fc;
  font-size: 0.6em;
  color: var(--text-muted);
  width: 2em;
}

/* 呼び名 列（同上）*/
#kozaiTableWrap tr.data-row-1 td:nth-child(2),
#kozaiTableWrap tr.data-row-single td:nth-child(2) {
  text-align: left;
  padding-left: 12px;
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.72em;
}

#kozaiTableWrap tr:hover td { background: var(--blue-pale); }
#kozaiTableWrap tr.data-row-1:hover td:nth-child(1),
#kozaiTableWrap tr.data-row-single:hover td:nth-child(1) { background: #e8f0f8; }

/* 絞り込みヒット行 */
.row--highlight td { background: #fff8e1; }
.row--highlight:hover td { background: #fff0c0 !important; }

/* クリック選択行 */
#kozaiTableWrap tbody tr.row--selected td { background: #e9eefd; cursor: default; }
#kozaiTableWrap tbody tr.row--selected:hover td { background: #dce4fc; }

/* データ行はクリック可能と分かるようカーソルを変える */
#kozaiTableWrap tbody tr:not(.pagetop-row) { cursor: pointer; }

/* ページ上部リンク行（25行ごと）*/
.pagetop-row td {
  text-align: right;
  padding: 4px 12px;
  background: var(--blue-pale);
  font-size: 0.6em;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}
.pagetop-row a { color: var(--blue-mid); font-size: 1em; }

/* 絞り込みヒット値（太字・青色） */
.cell--match { font-weight: 700; color: var(--blue-dark); }

/* 2行構造（x軸 1行目 / y軸 2行目）*/
/* 1行目の下端：x軸とy軸の間を点線で区切る */
#kozaiTableWrap tbody tr.data-row-1 td:not([rowspan]) {
  border-bottom: 1px dashed #b0c8e0;
}
/* 2行目の下端：鋼材間の区切り（実線）*/
#kozaiTableWrap tbody tr.data-row-2 td {
  border-bottom: 1px solid var(--blue-light);
  padding-top: 3px;
  padding-bottom: 4px;
}
/* rowspan=2 のセル（No.・呼び名・H/B/t1… などスパン列）*/
#kozaiTableWrap tbody td[rowspan="2"] {
  vertical-align: middle;
  border-bottom: 1px solid var(--blue-light);
}

/* === 断面図モーダル === */
#drawModal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
#drawModal.open { display: flex; }
#drawModalBox {
  background: #fff;
  padding: 10px;
  position: relative;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
#drawModalClose {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 18px;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  color: var(--text-secondary);
}
#drawModalClose:hover { color: var(--text-primary); }
#drawImg {
  display: block;
  background: #000;   /* PNG読み込み中も黒地を維持 */
}

/* === 使い方モーダル === */
#helpModal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
#helpModal.open { display: flex; }

#helpModalBox {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#helpModalHead {
  background: var(--blue-dark);
  color: var(--white);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#helpModalClose {
  font-size: 16px;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  color: rgba(255,255,255,0.75);
  padding: 2px;
}
#helpModalClose:hover { color: var(--white); }

#helpModalBody {
  padding: 16px 20px 12px;
  overflow-y: auto;
}

#helpModalFoot {
  padding: 10px 20px 18px;
  text-align: center;
  flex-shrink: 0;
}

.help-list { margin: 0; }
.help-list dt {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-dark);
  margin-top: 12px;
}
.help-list dt:first-child { margin-top: 0; }
.help-list dd {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.help-hl {
  background: #fff8e1;
  border: 1px solid #f0e0a0;
  border-radius: 3px;
  padding: 0 5px;
  font-weight: 700;
  color: var(--text-primary);
}

/* === フッター === */
.site-footer {
  background: var(--blue-dark);
  color: rgba(255,255,255,0.65);
  text-align: center;
  padding: 20px 24px;
  font-size: 12px;
  margin-top: 16px;
}
.site-footer__inner { margin-bottom: 6px; }
.site-footer a { color: rgba(255,255,255,0.88); }
.site-footer a:hover { color: var(--white); text-decoration: underline; }
.site-footer__sep { margin: 0 10px; opacity: 0.35; }
.site-footer__copy { font-size: 11px; opacity: 0.45; }

/* === レスポンシブ === */
@media (max-width: 680px) {
  .site-header__inner { padding: 12px 16px; }
  .site-header__name  { font-size: 16px; }
  .main               { padding: 14px 12px; }
  .card__body         { padding: 14px 14px; }
  .table-toolbar      { flex-direction: column; align-items: flex-start; gap: 6px; }
  .zx-form__grid      { gap: 12px; }
  .input-row          { flex-wrap: wrap; }
}
