/* 上高地小水力発電 Webシステム 共通スタイル */

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --text: #1c2730;
  --text-muted: #5b6b78;
  --border: #dde4ea;
  --accent: #0b7285;          /* 渓流の青緑 */
  --accent-strong: #095c6b;
  --accent-soft: #e3f4f6;
  --voltage: #2563eb;
  --current: #dc2626;
  --power: #059669;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 16px rgba(16, 32, 48, .06);
  --radius: 14px;
  --header-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f161c;
    --surface: #17212a;
    --surface-2: #1e2a34;
    --text: #e4ebf0;
    --text-muted: #9aabb8;
    --border: #2a3742;
    --accent: #3cc3d6;
    --accent-strong: #6fd6e4;
    --accent-soft: #15323a;
    --voltage: #60a5fa;
    --current: #f87171;
    --power: #34d399;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

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

[hidden] { display: none !important; }

html { scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: min(1080px, 100% - 32px); margin-inline: auto; }

/* ---- ヘッダー ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #2f9e44);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: .08em; line-height: 1.2; }
.brand span { line-height: 1.3; }

.nav { display: flex; gap: 4px; }
.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); }

@media (max-width: 640px) {
  /* スマホではロゴとナビを2段に */
  :root { --header-h: 92px; }
  .site-header .container { flex-direction: column; align-items: stretch; justify-content: center; gap: 2px; }
  .brand small { display: none; }
  .brand-mark { width: 24px; height: 24px; border-radius: 7px; font-size: 13px; }
  .nav { justify-content: space-between; }
  .nav a { padding: 4px 10px; font-size: 14px; }
}

/* ---- ヒーロー（トップ） ---- */
.hero {
  position: relative;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(8, 30, 40, .25) 0%, rgba(8, 30, 40, .72) 100%),
    url("../img/hero.jpg") center 35% / cover no-repeat;
  padding: clamp(72px, 14vw, 140px) 0 clamp(56px, 9vw, 96px);
}
.hero .eyebrow { margin: 0 0 8px; font-size: 14px; letter-spacing: .2em; opacity: .9; }
.hero h1 {
  margin: 0;
  font-size: clamp(30px, 5.2vw, 52px);
  line-height: 1.3;
  font-weight: 700;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .35);
}
.hero p.lead { max-width: 640px; margin: 16px 0 28px; font-size: clamp(15px, 1.8vw, 18px); opacity: .95; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- ページ見出し（トップ以外） ---- */
.page-head { padding: 40px 0 8px; }
.page-head h1 { margin: 0; font-size: clamp(24px, 3.6vw, 34px); line-height: 1.4; }
.page-head p { margin: 6px 0 0; color: var(--text-muted); }

main { padding-bottom: 64px; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .5); backdrop-filter: blur(4px); }
.btn-ghost:hover { background: rgba(255, 255, 255, .26); color: #fff; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }

/* ---- セクション・カード ---- */
.section { padding-top: 48px; }
.section > h2, .section-title {
  margin: 0 0 16px;
  font-size: 22px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section > h2::before, .section-title::before {
  content: "";
  width: 6px;
  height: 22px;
  border-radius: 3px;
  background: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h3 { margin: 0 0 8px; font-size: 17px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

.media-card { padding: 0; overflow: hidden; }
.media-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.media-card figcaption { padding: 12px 16px; font-size: 14px; color: var(--text-muted); }
.media-card figure { margin: 0; }
figure.media-card { margin: 0; }

.split { display: grid; gap: 24px; align-items: center; grid-template-columns: 1.2fr 1fr; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.split img { border-radius: 10px; width: 100%; }

/* ---- 数値カード ---- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.stat .label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--accent)); }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat .unit { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.stat.voltage { --dot: var(--voltage); }
.stat.current { --dot: var(--current); }
.stat.power { --dot: var(--power); }
.stat.energy { --dot: #f59f00; }

/* ---- 操作バー ---- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 20px 0 16px;
}
.toolbar .spacer { flex: 1; }
input[type="date"], select {
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
}
.notice.warn { background: color-mix(in srgb, #f59f00 16%, var(--surface)); }
.muted { color: var(--text-muted); }

/* ---- グラフ ---- */
.chart-card { padding: 16px 16px 8px; }
.chart-wrap { position: relative; height: clamp(320px, 52vw, 480px); }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* ---- 表 ---- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
table.data caption { text-align: left; font-weight: 700; padding-bottom: 8px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.data th { font-weight: 500; color: var(--text-muted); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- リンク一覧 ---- */
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.link-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.link-list a::after { content: "↗"; color: var(--text-muted); }
.link-list a:hover { border-color: var(--accent); }
.link-list small { display: block; color: var(--text-muted); font-size: 13px; }

/* ---- ライブカメラ ---- */
.viewer {
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.viewer img { width: 100%; aspect-ratio: 680 / 440; object-fit: cover; background: var(--surface-2); }
.viewer figcaption { padding: 10px 16px; font-size: 14px; color: var(--text-muted); }
.live-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 680px) minmax(0, 1fr);
  align-items: start;
}
.thumbs-panel { padding: 12px; max-height: 520px; overflow-y: auto; }
@media (max-width: 860px) {
  .live-layout { grid-template-columns: 1fr; }
  .thumbs-panel { max-height: none; }
}
.thumbs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.thumbs button {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
}
.thumbs button[aria-pressed="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; aspect-ratio: 680 / 440; object-fit: cover; }
.thumbs span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---- フッター ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 14px;
}
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.site-footer a { color: var(--text-muted); }
