/* 羽田マルチビュー — 放送局マルチビューワー (モニターウォール + UMD + タリー) 様式
 * カラートークンは realtimeearth.com 本体 (styles.css) と共有:
 *   --bg #0a0e1a / --bg-card #131826 / --text #e8eaed / --muted #9aa0a6 / --accent #4fc3f7 / --border #2a3142
 */

:root {
  --bg: #0a0e1a;
  --bg-card: #131826;
  --bg-deep: #060912;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --accent: #4fc3f7;
  --border: #2a3142;
  --live: #ff3b3b;
  --tally: #ff3b3b;
  --pin: #ffc94f;
  --font-body: 'IBM Plex Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background:
    radial-gradient(1100px 500px at 75% -10%, rgba(79, 195, 247, 0.07), transparent 60%),
    radial-gradient(800px 600px at -10% 110%, rgba(79, 195, 247, 0.05), transparent 55%),
    var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
}

/* 走査線テクスチャ — モニターウォールの空気感 (操作を妨げない) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
  z-index: 1;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand .rt { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.14em; font-size: 0.66rem; color: var(--accent); text-transform: uppercase; }
.brand h1 { font-size: 0.92rem; font-weight: 700; letter-spacing: 0.02em; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--live);
  border-radius: 999px;
  padding: 0.15em 0.7em;
}
.live-pill::before {
  content: '';
  width: 0.45em; height: 0.45em; border-radius: 50%;
  background: #fff;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

.topbar-spacer { flex: 1; }

#clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.clock-label { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.18em; color: var(--text-muted); margin-right: 0.4rem; }

.btn-subscribe {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  background: #ff0033;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.32em 0.9em;
  border-radius: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-subscribe:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(255, 0, 51, 0.35); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  padding: 0.3em 0.75em;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- intro strip (SEO テキスト) ---------- */

.intro {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  padding: 0.35rem 1.25rem 0;
  max-width: 1900px;
  margin: 0 auto;
}
.intro p { font-size: 0.78rem; color: var(--text-muted); }
/* SEO 全文は DOM に残し、表示は 1 行に truncate */
.intro p:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.intro strong { color: var(--text); font-weight: 500; }
#data-status { flex: none; }

#data-status {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
#data-status[data-ok='1'] { color: #7ed99a; }

/* ---------- wall ---------- */

.wall {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0.8rem 1.25rem 1.4rem;
  max-width: 1900px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: rise 0.5s ease both;
  animation-delay: var(--stagger, 0ms);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.tile--hero { grid-column: span 2; grid-row: span 2; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.tile--audio { border-color: var(--tally); box-shadow: 0 0 0 1px var(--tally), 0 0 22px rgba(255, 59, 59, 0.25); }
.tile--pinned .ub-pin { color: var(--pin); }

/* media 領域: iframe / thumb / card のみを置く。UI を被せない */
.tile-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  min-height: 200px; /* RMF: player viewport ≥200px */
}
.tile-media > iframe,
.tile-media > div:not(.card) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- thumb (player 未生成 — overlay 可) ---------- */

.thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: #000;
  cursor: pointer;
  display: block;
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.82;
  transition: opacity 0.2s ease, transform 0.35s ease;
}
.thumb:hover img { opacity: 1; transform: scale(1.025); }

.play-ring {
  position: absolute;
  top: 50%; left: 50%;
  translate: -50% -50%;
  width: 64px; height: 64px; /* 再生起動サムネイル ≥120×70px はタイル全体で担保 */
  border-radius: 50%;
  background: rgba(6, 9, 18, 0.72);
  border: 1px solid rgba(79, 195, 247, 0.6);
  display: grid;
  place-items: center;
  transition: transform 0.18s ease, background 0.18s ease;
}
.thumb:hover .play-ring { transform: translate(0, 0) scale(1.12); background: rgba(6, 9, 18, 0.9); }
.play-ring svg { width: 26px; height: 26px; fill: var(--accent); margin-left: 3px; }

.thumb-hint {
  position: absolute;
  right: 10px; bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: rgba(232, 234, 237, 0.85);
  background: rgba(6, 9, 18, 0.6);
  padding: 0.2em 0.6em;
  border-radius: 3px;
}
.thumb-blank { position: absolute; inset: 0; background: linear-gradient(135deg, #0d1322, #131826); }

/* ---------- cards (standby / offline / cooldown) ---------- */

.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, #0d1322, #0a0e1a);
}
.card p { font-size: 0.86rem; }
.card small, .card .off-note { font-size: 0.72rem; color: var(--text-muted); }
.card a { color: var(--accent); font-size: 0.76rem; text-decoration: none; border-bottom: 1px dotted; }
.card-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  background: rgba(79, 195, 247, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 0.5em 1.1em;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.card-switch:hover { background: rgba(79, 195, 247, 0.22); }
.card-switch svg { width: 14px; height: 14px; fill: currentColor; }
.off-title { font-family: var(--font-mono); letter-spacing: 0.12em; color: var(--text-muted); }

.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--live); animation: blink 1.6s infinite; }

.spinner {
  width: 26px; height: 26px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }

/* ---------- UMD bar (under-monitor display) ---------- */

.umd {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0.65rem;
  background: linear-gradient(180deg, #101626, #0c101d);
  border-top: 1px solid var(--border);
  min-height: 44px;
}

.tally {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3a4356;
  flex: none;
}
.tile--audio .tally { background: var(--tally); box-shadow: 0 0 8px var(--tally); }

.umd-text { min-width: 0; flex: 1; line-height: 1.25; }
.umd-text strong { display: block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; }
.umd-text span {
  display: block;
  font-size: 0.66rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-live {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--live);
  border: 1px solid color-mix(in srgb, var(--live) 55%, transparent);
  border-radius: 3px;
  padding: 0.1em 0.45em;
  flex: none;
}

.umd-actions { display: flex; gap: 0.15rem; flex: none; }

.ub {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.ub[hidden] { display: none; }
.ub:hover { color: var(--accent); background: rgba(79, 195, 247, 0.08); }
.ub svg { width: 15px; height: 15px; fill: currentColor; }
.tile--audio .ub-audio { color: var(--tally); }

/* ---------- picker dialog ---------- */

dialog#picker {
  margin: auto;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.1rem 0.9rem;
  width: min(480px, 92vw);
  max-height: 80vh;
}
dialog#picker::backdrop { background: rgba(4, 6, 12, 0.7); backdrop-filter: blur(2px); }
#picker h2 { font-size: 0.95rem; margin-bottom: 0.7rem; letter-spacing: 0.03em; }
#picker-list { list-style: none; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 56vh; }
#picker-list button {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: 'dot name note' 'dot view note';
  column-gap: 0.6rem;
  align-items: center;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
}
#picker-list button:hover:not(:disabled) { border-color: var(--accent); }
#picker-list button:disabled { opacity: 0.45; cursor: default; }
.dot { grid-area: dot; width: 8px; height: 8px; border-radius: 50%; }
.dot--on { background: var(--live); }
.dot--off { background: #3a4356; }
.dot--unknown { background: var(--pin); }
.pk-name { grid-area: name; font-size: 0.82rem; font-weight: 700; }
.pk-view { grid-area: view; font-size: 0.68rem; color: var(--text-muted); }
.pk-note { grid-area: note; font-family: var(--font-mono); font-size: 0.62rem; color: var(--text-muted); }
#picker-close { margin-top: 0.8rem; width: 100%; }

/* ---------- chat drawer ---------- */

#chat {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 0.8rem;
  gap: 0.6rem;
}
body.chat-open #chat { transform: translateX(0); }
#chat header { display: flex; justify-content: space-between; align-items: center; }
#chat h2 { font-size: 0.85rem; letter-spacing: 0.04em; }
#chat select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.4em 0.5em;
  font-family: inherit;
  font-size: 0.78rem;
}
#chat-frame { flex: 1; border-radius: 6px; overflow: hidden; background: var(--bg-deep); }
#chat-frame iframe { width: 100%; height: 100%; border: 0; }
.chat-note { font-size: 0.64rem; color: var(--text-muted); }

/* ---------- toast / footer ---------- */

#toast {
  position: fixed;
  left: 50%; bottom: 26px;
  translate: -50%;
  background: #1a2233;
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.55em 1.1em;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 50;
}
#toast.show { opacity: 1; }

footer {
  border-top: 1px solid var(--border);
  padding: 1.6rem 1.25rem 2.4rem;
  max-width: 1900px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}
footer h2 { font-size: 0.8rem; color: var(--text); letter-spacing: 0.04em; }
footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem 1.4rem; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.foot-legal { max-width: none; }

/* ---------- fit layout (JS がウィンドウ寸法から列数・タイルサイズを算出) ---------- */

.wall[data-fit] {
  grid-template-columns: repeat(var(--cols), var(--tilew));
  grid-auto-rows: var(--tileh);
  grid-auto-flow: dense;
  justify-content: center;
  align-content: start;
}
.wall[data-fit] .tile { height: 100%; }
.wall[data-fit] .tile--hero { grid-column: span 2; grid-row: span 2; }
.wall[data-fit] .tile-media { aspect-ratio: auto; flex: 1; min-height: 200px; }
.wall[data-fit] .umd { flex: none; }

/* ---------- breakpoints ---------- */

@media (max-width: 1280px) {
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile--hero { grid-column: span 2; grid-row: auto; }
  #chat { width: 300px; }
}

@media (max-width: 760px) {
  .wall { grid-template-columns: 1fr; gap: 12px; padding: 0.7rem 0.7rem 1.2rem; }
  .tile--hero { grid-column: auto; }
  .topbar { flex-wrap: wrap; gap: 0.5rem 0.8rem; padding: 0.6rem 0.8rem; }
  .clock-label { display: none; }
  #chat, #chat-toggle { display: none; } /* live chat embed はモバイル web 非対応 */
  .intro { padding: 0.7rem 0.8rem 0; }
}
