/* Twitch widget: a unified panel with three manageable cards (info / actions /
   chat). Sections carry data-system-card so they hide/reorder like System cards.
   Rendered into .twitch-widget-mount by streaming-page.js. */
.twitch-panel { display: flex; }
.twitch-widget-mount { width: 100%; height: 100%; display: flex; min-height: 0; border-radius: inherit; }

.twitch-wrap {
  position: relative;
  width: 100%; height: 100%; min-height: 0; box-sizing: border-box;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 11px;
  overflow: hidden; border-radius: inherit;
  /* Twitch-purple ambience (#9146FF) — top-right glow + faint bottom wash */
  background:
    radial-gradient(125% 95% at 100% -12%, rgba(145,70,255,0.20), transparent 55%),
    radial-gradient(100% 70% at 0% 112%, rgba(145,70,255,0.08), transparent 60%);
}
/* Big, faded Twitch logo watermark — modern brand presence behind the content
   (the cards are semi-transparent, so it reads through subtly). */
.twitch-wrap::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 52%; max-width: 260px; aspect-ratio: 1 / 1;
  background: url('/public/images/twitch/twitch-logo.png') center / contain no-repeat;
  opacity: 0.07; pointer-events: none; z-index: 0;
}
.twitch-head, .twitch-cards { position: relative; z-index: 1; }

/* ── Header ─────────────────────────────────────────────────────── */
.twitch-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex: 0 0 auto; min-width: 0;
}
.twitch-brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.twitch-logo { font-size: 0.92rem; font-weight: 900; letter-spacing: 0.01em; color: #9146ff; flex: 0 0 auto; }
.twitch-channel {
  font-size: 0.86rem; font-weight: 800; color: var(--text, #e7e9ee);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.twitch-status-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.62rem; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase;
  color: #9aa3a0; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.09);
}
.twitch-status-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: #870000; flex: 0 0 auto; }
.twitch-status-pill.live { color: var(--color-danger); background: var(--danger-bg); border-color: rgba(var(--danger-rgb),0.38); }
.twitch-status-pill.live .twitch-status-dot { background: #e0245e; }
/* Compositor-only ripple — shared `live-ripple` keyframe in styles/global.css
   (an animated box-shadow would tick the main thread every frame, GitHub #99). */
.twitch-status-pill.live .twitch-status-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: rgba(224,36,94,0.45);
  animation: live-ripple 2s ease-in-out infinite;
  will-change: transform, opacity; pointer-events: none;
}
/* Paused while a frosted overlay covers the dashboard (see backgroundfx.css overlay-frozen). */
body.overlay-frozen .twitch-status-pill.live .twitch-status-dot::after { animation-play-state: paused; }

/* "Twitch account not linked" call-to-action — a full-width tap target that
   opens Settings → Streaming, so the OFFLINE/— state explains itself. */
.twitch-notice {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin: 2px 0 4px; padding: 8px 11px; border-radius: 10px; cursor: pointer;
  text-align: left; font: inherit; font-size: 0.8rem; font-weight: 700;
  color: rgb(var(--accent-rgb)); background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.30);
  transition: background 0.15s ease;
}
/* `display: flex` above outranks the UA `[hidden]{display:none}` rule, so the
   notice would stay visible even when connected — restore hiding explicitly. */
.twitch-notice[hidden] { display: none; }
.twitch-notice:hover { background: rgba(var(--accent-rgb), 0.18); }
.twitch-notice-ico { display: inline-flex; flex: 0 0 auto; }
.twitch-notice-ico svg { width: 16px; height: 16px; }
.twitch-notice-txt { flex: 1 1 auto; min-width: 0; }

/* ── Cards (flex column so card `order` from DashboardLayout.css works) ── */
.twitch-cards { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.twitch-card {
  position: relative; min-width: 0;
  border-radius: 14px; padding: 12px 14px;
  background: rgba(255,255,255,0.028);
  border: 1px solid rgba(255,255,255,0.07);
}
.twitch-card-label {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-dim, #8b91a1); margin-bottom: 9px;
}

/* ── Info card ──────────────────────────────────────────────────── */
.twitch-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.twitch-viewers { display: flex; align-items: baseline; gap: 7px; }
.twitch-viewers-num {
  font-size: 2.1rem; font-weight: 900; line-height: 1; color: #fff;
  font-variant-numeric: tabular-nums;
}
.twitch-viewers-label { font-size: 0.8rem; font-weight: 700; color: var(--text-dim, #8b91a1); }
.twitch-info-game { font-size: 0.84rem; font-weight: 800; color: #c9b8ff; }
.twitch-info-title {
  font-size: 0.76rem; opacity: 0.55;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.twitch-info-offline, .twitch-info-notice {
  display: flex; align-items: center; gap: 9px;
  font-size: 0.88rem; font-weight: 700; color: var(--text-dim, #a18b8b); padding: 2px 0;
}
.twitch-info-ico { display: inline-flex; opacity: 0.7; }
.twitch-info-ico svg { width: 20px; height: 20px; }

/* ── Actions card ───────────────────────────────────────────────── */
/* The actions are content-heavy (quick row + 4 fields + 2 selects); left to grow
   they crush the chat below to a couple of lines. So the card keeps its natural
   height on a tall tile but yields when space is tight — it shrinks and scrolls
   its own controls internally instead of eating the chat's minimum. */
.twitch-card--actions { flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
/* Stacks three sections: a quick one-tap row, text fields, and select rows. */
.twitch-actions { display: flex; flex-direction: column; min-width: 0; }
.twitch-act-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* Text-field rows (set title/category, send chat, shoutout). */
.twitch-fields { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.twitch-field { display: flex; gap: 6px; align-items: center; min-width: 0; }
.twitch-field-input {
  flex: 1 1 auto; min-width: 0; min-height: 36px; padding: 0 11px;
  border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--text, #e7e9ee);
  background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.12);
}
.twitch-field-input::placeholder { color: var(--text-dim, #8b91a1); opacity: 0.85; }
.twitch-field-input:focus { outline: none; border-color: rgba(145,70,255,0.6); background: rgba(0,0,0,0.36); }
.twitch-field-send { flex: 0 0 auto; width: 40px; padding: 0; justify-content: center; }
/* Labelled select rows (chat mode, ad break + its duration). */
.twitch-selrow { margin-top: 9px; gap: 14px; }
.twitch-act-grp { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.twitch-act-grp-lbl {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim, #8b91a1);
}
.twitch-needs-live.is-idle { opacity: 0.45; }
.twitch-act-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 13px; border-radius: 10px; cursor: pointer;
  font-size: 12px; font-weight: 800; color: var(--text, #e7e9ee);
  border: 1px solid rgba(145,70,255,0.4); background: rgba(145,70,255,0.16);
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.06s ease;
}
.twitch-act-btn:hover:not(:disabled) { background: rgba(145,70,255,0.28); border-color: rgba(145,70,255,0.6); }
.twitch-act-btn:active:not(:disabled) { transform: translateY(1px); }
.twitch-act-btn:disabled { cursor: default; }
.twitch-act-btn.ok { border-color: rgba(34,197,94,0.55); background: rgba(34,197,94,0.2); }
.twitch-act-btn.err { border-color: rgba(239,68,68,0.55); background: rgba(239,68,68,0.2); }
.twitch-act-btn.is-idle { opacity: 0.45; }
.twitch-act-ico { display: inline-flex; }
.twitch-act-ico svg { width: 15px; height: 15px; }
/* Go live (green, inviting) → End stream (red) while streaming; mic muted = red. */
.twitch-act-primary { border-color: rgba(34,197,94,0.5); background: rgba(34,197,94,0.16); }
.twitch-act-primary:hover:not(:disabled) { background: rgba(34,197,94,0.27); border-color: rgba(34,197,94,0.7); }
.twitch-golive.is-live { border-color: rgba(var(--danger-rgb),0.55); background: var(--danger-bg); color: var(--color-danger); }
.twitch-golive.is-live:hover:not(:disabled) { background: rgba(239,68,68,0.3); }
.twitch-mic.is-muted { border-color: rgba(var(--danger-rgb),0.55); background: var(--danger-bg); color: var(--color-danger); }
.twitch-act-ad { display: inline-flex; gap: 6px; align-items: center; }
.twitch-act-len {
  min-height: 36px; padding: 0 9px; border-radius: 10px; cursor: pointer;
  font-size: 12px; font-weight: 800; color: var(--text, #e7e9ee);
  border: 1px solid rgba(255,255,255,0.14); background: rgba(0,0,0,0.28);
}
.twitch-act-len.is-idle { opacity: 0.45; }

/* ── OBS preview card ───────────────────────────────────────────── */
.twitch-preview {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 9px; overflow: hidden; background: rgba(0,0,0,0.42);
  display: flex; align-items: center; justify-content: center;
}
.twitch-preview-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.twitch-preview-img[hidden] { display: none; }   /* `display:block` would otherwise outrank [hidden] */
.twitch-preview-empty { font-size: 0.78rem; opacity: 0.4; font-weight: 600; text-align: center; padding: 8px; }

/* ── Chat card ──────────────────────────────────────────────────── */
/* No `min-height: 0` here on purpose: the card floors at its own content minimum
   (header + the chat-log's min-height), so the chat can never be squeezed below a
   clean, readable block. It still grows to take any spare height on a tall tile. */
.twitch-card--chat { flex: 1 1 auto; display: flex; flex-direction: column; }
/* Chat header: label + an expand/collapse toggle on the right. */
.twitch-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.twitch-card-head .twitch-card-label { margin-bottom: 0; }
.twitch-chat-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 28px; height: 28px; padding: 0; border-radius: 8px; cursor: pointer;
  color: var(--text-dim, #8b91a1);
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.09);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.twitch-chat-toggle:hover { background: rgba(145,70,255,0.18); color: #c9b8ff; border-color: rgba(145,70,255,0.4); }
.twitch-chat-toggle svg { width: 15px; height: 15px; }
/* Expanded chat takes over the tile, but the essential one-tap controls (Go live,
   Mute, Clip, Marker) stay pinned above it — only the wordy fields/select rows and
   the OBS preview step aside. Their own layout state (hide/order) is untouched when
   collapsed again. */
.twitch-wrap.chat-expanded .twitch-card--preview { display: none; }
.twitch-wrap.chat-expanded .twitch-card--actions { flex: 0 0 auto; overflow: visible; }
.twitch-wrap.chat-expanded .twitch-card--actions .twitch-card-label,
.twitch-wrap.chat-expanded .twitch-card--actions .twitch-fields,
.twitch-wrap.chat-expanded .twitch-card--actions .twitch-selrow { display: none; }
.twitch-wrap.chat-expanded .twitch-card--chat { flex: 1 1 auto; }
.twitch-chat-log {
  flex: 1 1 auto; width: 100%; min-height: 104px;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 3px; padding-right: 4px;
  font-size: 0.8rem; line-height: 1.4; scrollbar-width: thin;
}
.twitch-chat-line { word-break: break-word; }
.twitch-chat-user { font-weight: 800; color: #a970ff; }
.twitch-chat-text { color: var(--text, #e7e9ee); opacity: 0.92; }
.twitch-chat-empty {
  margin: auto; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px; text-align: center; opacity: 0.38; font-size: 0.8rem; font-weight: 600;
}
.twitch-chat-empty-ico svg { width: 26px; height: 26px; }

/* Emotes in the chat log, same treatment as the watching widget's. */
.twitch-emote { height: 1.6em; width: auto; vertical-align: middle; margin: -0.2em 1px 0; }
