/* 米株マップ — 共通スタイル
 *
 * 外部フォント・外部CSS・外部JSは読み込まない(憲法B-8)。
 * 見た目はすべてこのファイルと、生成する自前のSVGで作る。
 *
 * 色の決め方:
 *   日本 = 温かい橙、米国 = 冷たい青。これはこのサイトの意味そのものなので、
 *   図でも文字でも一貫させる。UIの主色(リンク等)は青系にそろえ、
 *   橙は「日本側」を指すときだけに使う。
 */

:root {
  /* 面 */
  --bg: #f3f6fb;          /* ページの地。白のカードを浮かせるための薄い青灰 */
  --surface: #ffffff;     /* カードの面 */
  --surface-2: #eef3fc;   /* 少し沈めた面(表の見出し行など) */

  /* 文字 */
  --fg: #101a2c;
  --muted: #5a677d;
  --line: #dfe6f1;
  --line-soft: #eaeff8;

  /* 主色(UI)= 米国側の青と同系。橙は日本側の意味に取ってある */
  --accent: #1663d6;
  --accent-strong: #0f4bab;
  --accent-soft: #e5eeff;
  --on-accent: #ffffff;   /* 主色の上に置く字の色。暗い配色では主色が明るくなるので入れ替える */
  --ring: rgba(16, 26, 44, .08);

  /* 日米の対比 */
  --jp: #e2600c;
  --jp-soft: #fdeee2;
  --us: #1663d6;
  --us-soft: #e5eeff;

  /* 増減 */
  --up: #067a4e;
  --up-soft: #e2f5ec;
  --down: #c0341d;
  --down-soft: #fdeae6;

  --warn-bg: #fff8e6;
  --warn-line: #f2dfae;

  /* 影と角 */
  --shadow-sm: 0 1px 2px rgba(16, 26, 44, .06), 0 1px 3px rgba(16, 26, 44, .05);
  --shadow-md: 0 2px 4px rgba(16, 26, 44, .05), 0 8px 20px rgba(16, 26, 44, .07);
  --shadow-lg: 0 4px 8px rgba(16, 26, 44, .06), 0 16px 32px rgba(16, 26, 44, .10);
  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;

  --max: 58rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1220;
    --surface: #161e30;
    --surface-2: #1d2740;

    --fg: #e8ecf4;
    --muted: #9aa7bd;
    --line: #2a3550;
    --line-soft: #222c44;

    --accent: #6ea8ff;
    --accent-strong: #9cc4ff;
    --accent-soft: #1b2846;
    --on-accent: #0b1220;
    --ring: rgba(255, 255, 255, .10);

    --jp: #ff9450;
    --jp-soft: #33210f;
    --us: #6ea8ff;
    --us-soft: #1b2846;

    --up: #4fc78d;
    --up-soft: #12301f;
    --down: #ff8a70;
    --down-soft: #331812;

    --warn-bg: #2b2415;
    --warn-line: #4a3d1e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .25), 0 8px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, .3), 0 16px 32px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
               "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.85;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

main { max-width: var(--max); margin: 0 auto; padding: 0 1.1rem 5rem; }

/* --- ヘッダー --- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.8rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem 1.1rem;
  text-decoration: none;
  color: inherit;
}
/* 印は日米の対応表そのもの。青(米国)と橙(日本)の升目を組む */
.brand::before {
  content: "";
  flex: none;
  width: 26px; height: 26px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, var(--us) 0 50%, transparent 50% 100%),
    linear-gradient(315deg, var(--jp) 0 50%, transparent 50% 100%),
    var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--ring);
}
.brand-name {
  font-size: 1.16rem; font-weight: 800; letter-spacing: 0.01em; line-height: 1.3;
}
.brand-tag {
  display: block; font-size: 0.76rem; color: var(--muted); line-height: 1.4;
  letter-spacing: 0.01em;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 2rem 1.1rem 3rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.site-footer p { margin: 0.35rem 0; }

.crumbs { font-size: 0.8rem; color: var(--muted); margin: 0 0 1.1rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* --- 見出し --- */
h1 {
  font-size: 1.95rem; line-height: 1.4; margin: 0 0 1.1rem;
  font-weight: 800; letter-spacing: -0.02em; text-wrap: balance;
}
h2 {
  font-size: 1.28rem; font-weight: 800; letter-spacing: -0.015em;
  margin: 3rem 0 1.1rem; padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--line);
  display: flex; align-items: center; gap: 0.55rem;
}
h2::before {
  content: ""; flex: none;
  width: 6px; height: 1.05em; border-radius: 3px;
  background: var(--accent);
}
h3 { font-size: 1.02rem; font-weight: 700; margin: 1.8rem 0 0.4rem; letter-spacing: -0.01em; }

.lead p { font-size: 1.05rem; }
.lead p:first-child { font-size: 1.12rem; }
.note { font-size: 0.82rem; color: var(--muted); margin-top: 0.8rem; line-height: 1.75; }

/* --- カードの共通形 --- */
.anchor, .profile, .industry-card, .disclaimer, .searchbox input {
  border-radius: var(--r);
}

/* --- 日本のアンカー --- */
.anchors { display: grid; gap: 0.9rem; }
@media (min-width: 40rem) {
  .anchors { grid-template-columns: repeat(3, 1fr); }
}
.anchor {
  border: 1px solid var(--line);
  border-top: 3px solid var(--jp);
  padding: 1rem 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.anchor h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.anchor p { margin: 0; font-size: 0.88rem; line-height: 1.75; }
.to-us {
  margin-top: 0.7rem !important;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.84rem !important;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.65rem;
}
.to-us-label { color: var(--muted); }
/* 社名としるしは一組。改行で切り離されると、どの会社の濃さか読めなくなる */
.to-us a { text-decoration: none; font-weight: 700; white-space: nowrap; }
.to-us a:hover { text-decoration: underline; }

/* --- 表 --- */
.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
table { border-collapse: collapse; width: 100%; font-size: 0.89rem; min-width: 40rem; }
@media (max-width: 40rem) {
  .table-scroll::before {
    content: "→ 表は横にスクロールできます";
    display: block; font-size: 0.76rem; color: var(--muted);
    padding: 0.5rem 0.8rem 0;
  }
  .table-scroll.fits::before { content: none; }
}
table.compact { min-width: 0; font-size: 0.86rem; }
table.compact th, table.compact td { padding: 0.6rem 0.5rem; }
table.compact thead th { white-space: normal; }

th, td {
  border-bottom: 1px solid var(--line-soft);
  padding: 0.7rem 0.7rem; text-align: left; vertical-align: top;
}
thead th {
  background: var(--surface-2);
  font-size: 0.76rem; font-weight: 700; white-space: nowrap;
  color: var(--muted); letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:target { background: var(--accent-soft); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.ticker {
  font-weight: 700; font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  display: inline-block; padding: 0.1rem 0.45rem; border-radius: 5px;
  background: var(--us-soft); color: var(--accent-strong);
  letter-spacing: 0.02em;
}
.name-en { display: block; font-size: 0.75rem; color: var(--muted); line-height: 1.55; }
.match { white-space: nowrap; font-size: 0.83rem; }

/* 対応の濃さは記号だけだと弱い。色と面の強さで濃淡を出す */
.lv {
  display: inline-block; min-width: 1.5rem; text-align: center;
  font-weight: 700; font-size: 0.8rem; line-height: 1.5rem;
  border-radius: 999px; margin-left: 0.15rem;
}
.lv-a { background: var(--accent); color: var(--on-accent); }
.lv-b { background: var(--us-soft); color: var(--accent-strong);
        box-shadow: inset 0 0 0 1px var(--accent); }
.lv-c { background: var(--surface-2); color: var(--muted);
        box-shadow: inset 0 0 0 1px var(--line); }

/* 狭い画面では列の多い表を1社=1枚のカードに組み替える */
@media (max-width: 46rem) {
  .table-scroll.table-cards {
    overflow-x: visible; background: none; border: none;
    border-radius: 0; box-shadow: none;
  }
  .table-scroll.table-cards::before { content: none; }
  .table-cards table { display: block; min-width: 0; font-size: 0.9rem; }
  .table-cards thead { display: none; }
  .table-cards tbody { display: block; }
  .table-cards tr {
    display: block; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    padding: 0.3rem 0.9rem; margin-bottom: 0.9rem;
  }
  .table-cards tr:hover { background: var(--surface); }
  /* 見出しは絶対配置で左に置く。格子にすると社名と英語表記が離れてしまう */
  .table-cards td {
    display: block; position: relative; padding: 0.55rem 0 0.55rem 7rem;
    border-bottom: 1px solid var(--line-soft);
    text-align: left; white-space: normal;
  }
  .table-cards tr td:last-child { border-bottom: none; }
  .table-cards td::before {
    content: attr(data-label);
    position: absolute; left: 0; top: 0.55rem; width: 6.6rem;
    color: var(--muted); font-size: 0.72rem; line-height: 2.05;
  }
  .table-cards td.num { text-align: left; }
  .table-cards td .name-en { display: inline; margin-left: 0.4rem; }
}

/* --- 図(規模比較バー) --- */
.chart-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.2rem; margin-top: 0.5rem;
}
.chart { width: 100%; height: auto; display: block; }
.chart .label { font-size: 12.5px; fill: var(--fg); font-weight: 700; }
.chart .value { font-size: 11.5px; fill: var(--muted); font-weight: 700; }
.chart .bar { fill: var(--us); }
.chart .bar-jp { fill: var(--jp); }
.chart .sub { font-size: 10px; fill: var(--muted); }
/* 図は幅660の座標系を画面幅に縮めて表示する。狭い画面では字が潰れるので、
   座標系の側で大きくして、縮んだ結果が読める大きさになるようにする */
@media (max-width: 40rem) {
  .chart .label { font-size: 19px; }
  .chart .value { font-size: 18px; }
  .chart .sub { font-size: 16px; }
}

/* --- 内訳の色(隣り合う区画が見分けられるよう寒暖を交互に) --- */
:root {
  --cat1: #1663d6; --cat2: #e2600c; --cat3: #4d94f0;
  --cat4: #f0a35e; --cat5: #123c86; --cat6: #7c8aa3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cat1: #6ea8ff; --cat2: #ff9450; --cat3: #a9cbff;
    --cat4: #ffc396; --cat5: #cfe0ff; --cat6: #8b98af;
  }
}

/* --- 最新の決算 --- */
.quarter-head { margin: 0.2rem 0 0.7rem; font-size: 1.05rem; }
.quarter-head .name-en { display: inline; margin-left: 0.6rem; font-weight: 400; }
.up, .down, .flat {
  display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px;
  font-weight: 700; font-size: 0.82rem;
}
.up { color: var(--up); background: var(--up-soft); }
.down { color: var(--down); background: var(--down-soft); }
.flat { color: var(--muted); background: var(--surface-2); }

.filings { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.55rem; }
.filings li {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--shadow-sm);
  padding: 0.7rem 0.9rem 0.7rem 2.3rem;
  transition: box-shadow .15s, transform .15s;
}
.filings li:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.filings li::before {
  content: "↗"; position: absolute; left: 0.9rem; top: 0.7rem;
  color: var(--accent); font-weight: 700;
}
.filings a { text-decoration: none; font-weight: 700; }
.filings a:hover { text-decoration: underline; }
.filings .name-en { line-height: 1.5; }

/* --- 事業ポートフォリオ --- */
#portfolio { display: grid; gap: 1.2rem; }
@media (min-width: 62rem) {
  #portfolio { grid-template-columns: 1fr 1fr; }
  #portfolio > h2, #portfolio > .note { grid-column: 1 / -1; }
}
.portfolio-block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem 1.1rem;
}
.portfolio-block > h3 {
  font-size: 0.82rem; margin: 0; padding-bottom: 0.6rem;
  color: var(--muted); letter-spacing: 0.05em; font-weight: 700;
  border-bottom: 1px solid var(--line-soft);
}
.portfolio { display: grid; gap: 1rem; align-items: center; margin-top: 0.8rem; }
@media (min-width: 34rem) {
  .portfolio { grid-template-columns: 200px 1fr; gap: 1.5rem; }
}
@media (min-width: 62rem) {
  /* 二段組みでは図が窮屈になるので縦積みに戻す */
  .portfolio { grid-template-columns: 1fr; }
}
.donut { width: 200px; height: auto; justify-self: center; }
.slice-1 { fill: var(--cat1); stroke: var(--cat1); }
.slice-2 { fill: var(--cat2); stroke: var(--cat2); }
.slice-3 { fill: var(--cat3); stroke: var(--cat3); }
.slice-4 { fill: var(--cat4); stroke: var(--cat4); }
.slice-5 { fill: var(--cat5); stroke: var(--cat5); }
.slice-6 { fill: var(--cat6); stroke: var(--cat6); }
.legend { list-style: none; margin: 0; padding: 0; font-size: 0.86rem; }
.legend li {
  display: flex; align-items: baseline; gap: 0.55rem;
  padding: 0.42rem 0; border-bottom: 1px solid var(--line-soft);
}
.legend li:last-child { border-bottom: none; }
.swatch {
  width: 0.72rem; height: 0.72rem; border-radius: 3px; flex: none;
  transform: translateY(0.05rem);
}
.swatch-1 { background: var(--cat1); }
.swatch-2 { background: var(--cat2); }
.swatch-3 { background: var(--cat3); }
.swatch-4 { background: var(--cat4); }
.swatch-5 { background: var(--cat5); }
.swatch-6 { background: var(--cat6); }
.legend-name { flex: 1; }
.legend-value { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.legend-share { color: var(--muted); margin-left: 0.5rem; font-weight: 400; }

/* --- 企業個票 --- */
.profile {
  display: grid; grid-template-columns: auto 1fr; gap: 0.55rem 1.2rem;
  font-size: 0.9rem; margin: 0;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.profile dt { color: var(--muted); white-space: nowrap; font-size: 0.83rem; }
.profile dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; }
.profile .name-en { display: inline; margin-left: 0.4rem; font-weight: 400; }
.chart.trend .label { font-size: 11.5px; }
.chart.trend .value { font-size: 11.5px; fill: var(--fg); }
@media (max-width: 40rem) {
  .chart.trend .label { font-size: 19px; }
  .chart.trend .value { font-size: 19px; }
}
#business ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
#business li { margin: 0.3rem 0; font-size: 0.93rem; }

/* --- FAQ・基準日 --- */
#faq h3 {
  margin-top: 1.8rem; padding-left: 1.9rem; position: relative;
}
#faq h3::before {
  content: "Q"; position: absolute; left: 0; top: 0.1rem;
  width: 1.4rem; height: 1.4rem; line-height: 1.4rem; text-align: center;
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 0.78rem; font-weight: 700;
}
#faq p { margin-top: 0.3rem; }

.asof {
  display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1.1rem;
  font-size: 0.88rem; margin: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 1rem 1.2rem;
}
.asof dt { color: var(--muted); white-space: nowrap; }
.asof dd { margin: 0; font-variant-numeric: tabular-nums; }

.disclaimer {
  margin-top: 1.6rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  font-size: 0.83rem;
}
.disclaimer p { margin: 0.3rem 0; }

/* --- 検索 --- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.searchbox { margin-top: 0.5rem; position: relative; }
.searchbox input {
  width: 100%; padding: 0.95rem 1rem 0.95rem 2.9rem; font-size: 1.02rem;
  font-family: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.searchbox::before {
  content: ""; position: absolute; left: 1.05rem; top: 50%;
  width: 15px; height: 15px; margin-top: -9px;
  border: 2px solid var(--muted); border-radius: 50%;
  pointer-events: none;
}
.searchbox::after {
  content: ""; position: absolute; left: 1.85rem; top: 50%;
  width: 7px; height: 2px; margin-top: 3px;
  background: var(--muted); border-radius: 2px;
  transform: rotate(45deg); pointer-events: none;
}
.searchbox input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm);
}
.searchbox input::placeholder { color: var(--muted); }

.results {
  list-style: none; margin: 0.7rem 0 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-md); overflow: hidden;
}
.results li { border-bottom: 1px solid var(--line-soft); }
.results li:last-child { border-bottom: none; }
.results a {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; text-decoration: none; color: var(--fg);
}
.results a:hover, .results a:focus { background: var(--accent-soft); }
.hit-name { font-weight: 700; color: var(--accent); }
.hit-tag {
  font-size: 0.75rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent-strong); background: var(--us-soft);
  padding: 0.05rem 0.4rem; border-radius: 5px;
}
.hit-kind { font-size: 0.78rem; color: var(--muted); margin-left: auto; }
.results .no-hit { padding: 0.8rem 1rem; font-size: 0.86rem; color: var(--muted); }

/* --- 業界カード --- */
.industry-grid { display: grid; gap: 0.9rem; margin-top: 0.5rem; }
@media (min-width: 34rem) {
  .industry-grid { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
}
.industry-card {
  display: block; padding: 1.05rem 1.15rem; text-decoration: none; color: var(--fg);
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s, border-color .15s;
  position: relative; overflow: hidden;
}
.industry-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--jp), var(--us));
}
.industry-card:hover, .industry-card:focus {
  box-shadow: var(--shadow-lg); transform: translateY(-2px);
  border-color: var(--accent);
}
.industry-name {
  display: block; font-size: 1.1rem; font-weight: 800; color: var(--accent);
  letter-spacing: -0.01em;
}
.industry-jp { display: block; font-size: 0.86rem; margin-top: 0.25rem; }
.industry-count {
  display: inline-block; font-size: 0.74rem; color: var(--muted); margin-top: 0.55rem;
  background: var(--surface-2); padding: 0.1rem 0.5rem; border-radius: 999px;
  font-weight: 700;
}

/* --- 予定の業界 --- */
.planned {
  list-style: none; margin: 0.4rem 0 1.4rem; padding: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden;
}
.planned li {
  display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap;
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--line-soft);
}
.planned li:last-child { border-bottom: none; }
.planned-name { font-weight: 700; min-width: 9rem; }
.planned-jp { font-size: 0.82rem; color: var(--muted); }

/* --- 散文ページ --- */
.prose {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.6rem 1.8rem;
}
.prose h3 { margin-top: 2rem; }
.prose h3:first-child { margin-top: 0.2rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: 0.35rem 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .industry-card:hover, .filings li:hover { transform: none; }
}
