Files
rangerhq-tuner/src/popup/popup.css
T
ranger d0d5e76abe feat(v0.5.0-prep): manual theme toggle (Phase 2)
Adds an Auto / Dark / Light radio group to the Options page that
overrides the OS `prefers-color-scheme` setting. Stored in
chrome.storage.local under tuner.theme. Defaults to Auto.

Architecture:
- src/lib/theme.js (new, ~55 lines) — getTheme/setTheme/applyTheme/initTheme
  helpers. applyTheme sets/removes `data-theme` attribute on <html>;
  initTheme reads storage + applies.
- popup.js + newtab.js + options.js: call initTheme() FIRST in their
  init() so the theme paints before anything else. All three also
  listen for chrome.storage.onChanged on the THEME_KEY and live-apply
  changes — pick Light in Options, popup + newtab flip instantly.
- options.html: new 'Appearance' card with 3 radio buttons (Auto/Dark/
  Light) above the existing Playback card.
- options.css: styled radio group (pill-shaped, accent border on
  :checked, hover state). Plus the Auto/Dark/Light CSS overrides
  themselves.
- popup.css, newtab.css, options.css: each gets html[data-theme=light]
  and html[data-theme=dark] blocks that override :root vars. Attribute
  selector specificity beats both :root and the @media :root, so the
  manual override wins when set.

UX:
- Default = Auto (follows OS via existing @media block)
- Pick Dark → overrides OS, forces dark palette
- Pick Light → overrides OS, forces light palette
- Selection persists across reloads, syncs across all three surfaces

7 files, ~150 lines added. No new permissions, no new dependencies.

Bundled with v0.4.1-prep back-link + Phase 1 OS-follow light mode for
the v0.5.0 release.
2026-06-10 00:13:07 +01:00

402 lines
9.7 KiB
CSS

/* RangerHQ Tuner popup — ~360x520, dark earthy palette echoing the
RangerHQ family brand (forest green + warm cream). Vanilla CSS,
no preprocessor, no build step. */
:root {
--bg: #0f1411;
--bg-soft: #1a221c;
--bg-row: #1f2823;
--bg-row-hi: #2a3530;
--fg: #e8e4d4;
--fg-muted: #97a094;
--accent: #6dbf7a; /* RangerHQ green */
--accent-dim: #2a7d3e;
--cream: #f4e9b7;
--danger: #c9685b;
--radius: 6px;
/* First-run hint pulse colour (RGB tuple — alpha applied in keyframes). */
--pulse-rgb: 109, 191, 122;
}
/* ──────────────────────────────────────────────────────────────────────
Light mode (v0.5.0) — auto-follows OS theme via prefers-color-scheme.
Flips backgrounds + foregrounds to a cream-leaning palette while
preserving the brand green as the accent. Every existing rule that
uses the var(--*) tokens keeps working unchanged.
────────────────────────────────────────────────────────────────────── */
/* Shared light palette block — used as a mixin by the @media (OS-follow)
rule below AND by the html[data-theme="light"] manual override. */
@media (prefers-color-scheme: light) {
:root {
--bg: #f6f4ed; /* cream-leaning off-white */
--bg-soft: #ece5d2; /* slightly darker for header bars */
--bg-row: #ddd6c0; /* hover background */
--bg-row-hi: #c8c0a8; /* active row background */
--fg: #2a2f28; /* dark forest-green-leaning text */
--fg-muted: #6a7064; /* muted secondary text */
--accent: #2a7d3e; /* darker brand green for primary contrast */
--accent-dim: #6dbf7a; /* lighter brand green for fills */
--cream: #b8861a; /* darker amber — readable on light bg */
--danger: #b53a2b; /* darker red — readable on light bg */
}
.tuner-state[data-state="playing"] { color: #fff; }
.tuner-state[data-state="buffering"] { color: #fff; }
.tuner-state[data-state="error"] { color: #fff; }
.btn-primary[aria-pressed="true"] { color: #fff; }
}
/* Manual override — force LIGHT palette regardless of OS. The attribute
selector beats both :root and the @media rule's :root on specificity. */
html[data-theme="light"] {
--bg: #f6f4ed; --bg-soft: #ece5d2; --bg-row: #ddd6c0; --bg-row-hi: #c8c0a8;
--fg: #2a2f28; --fg-muted: #6a7064; --accent: #2a7d3e; --accent-dim: #6dbf7a;
--cream: #b8861a; --danger: #b53a2b;
}
html[data-theme="light"] .tuner-state[data-state="playing"] { color: #fff; }
html[data-theme="light"] .tuner-state[data-state="buffering"] { color: #fff; }
html[data-theme="light"] .tuner-state[data-state="error"] { color: #fff; }
html[data-theme="light"] .btn-primary[aria-pressed="true"] { color: #fff; }
/* Manual override — force DARK palette regardless of OS. Overrides the
@media block when OS is light but user explicitly wants dark. */
html[data-theme="dark"] {
--bg: #0f1411; --bg-soft: #1a221c; --bg-row: #1f2823; --bg-row-hi: #2a3530;
--fg: #e8e4d4; --fg-muted: #97a094; --accent: #6dbf7a; --accent-dim: #2a7d3e;
--cream: #f4e9b7; --danger: #c9685b;
}
html[data-theme="dark"] .tuner-state[data-state="playing"] { color: var(--bg); }
html[data-theme="dark"] .tuner-state[data-state="buffering"] { color: var(--bg); }
html[data-theme="dark"] .tuner-state[data-state="error"] { color: var(--cream); }
html[data-theme="dark"] .btn-primary[aria-pressed="true"] { color: var(--bg); }
* { box-sizing: border-box; }
html, body {
margin: 0;
padding: 0;
width: 360px;
background: var(--bg);
color: var(--fg);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
font-size: 13px;
line-height: 1.4;
}
/* Header */
.tuner-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 12px;
background: var(--bg-soft);
border-bottom: 1px solid #000;
}
.tuner-brand {
display: flex;
align-items: center;
gap: 8px;
}
.tuner-brand h1 {
margin: 0;
font-size: 14px;
font-weight: 600;
letter-spacing: 0.2px;
}
.tuner-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 8px var(--accent);
}
.tuner-state {
font-size: 11px;
color: var(--fg-muted);
text-transform: uppercase;
letter-spacing: 0.5px;
padding: 2px 8px;
border-radius: 999px;
background: var(--bg-row);
}
.tuner-state[data-state="playing"] {
color: var(--bg);
background: var(--accent);
}
.tuner-state[data-state="buffering"] {
color: var(--bg);
background: var(--cream);
}
.tuner-state[data-state="error"] {
color: var(--cream);
background: var(--danger);
}
/* Now playing */
.now-playing {
padding: 10px 12px;
background: var(--bg-soft);
border-bottom: 1px solid #000;
}
.np-station {
font-weight: 600;
font-size: 13px;
}
.np-track {
font-size: 12px;
color: var(--fg-muted);
margin-top: 2px;
min-height: 1.4em;
}
/* Controls */
.controls {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 12px;
border-bottom: 1px solid #000;
}
.btn {
padding: 6px 14px;
font-size: 13px;
font-weight: 500;
border: 1px solid var(--accent-dim);
border-radius: var(--radius);
background: var(--bg-row);
color: var(--fg);
cursor: pointer;
}
.btn:hover:not(:disabled) {
background: var(--bg-row-hi);
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-primary {
background: var(--accent-dim);
}
.btn-primary[aria-pressed="true"] {
background: var(--accent);
color: var(--bg);
}
.vol-wrap {
display: flex;
align-items: center;
gap: 6px;
flex: 1;
}
.vol-label {
font-size: 11px;
color: var(--fg-muted);
}
#volume {
flex: 1;
accent-color: var(--accent);
}
/* Search */
.search-wrap {
display: block;
padding: 8px 12px 4px;
}
#search {
width: 100%;
padding: 6px 8px;
font-size: 12px;
background: var(--bg-row);
color: var(--fg);
border: 1px solid var(--bg-row-hi);
border-radius: var(--radius);
}
#search:focus {
outline: none;
border-color: var(--accent);
}
/* Station list */
.station-list {
margin: 0;
padding: 0;
list-style: none;
max-height: 280px;
overflow-y: auto;
}
.station-row {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px;
border-bottom: 1px solid var(--bg-soft);
cursor: pointer;
}
.station-row:hover {
background: var(--bg-row);
}
.station-row.is-active {
background: var(--bg-row-hi);
border-left: 3px solid var(--accent);
padding-left: 9px;
}
.station-art {
width: 28px;
height: 28px;
border-radius: 4px;
background: var(--bg-soft);
flex-shrink: 0;
object-fit: cover;
}
.station-meta {
flex: 1;
min-width: 0;
}
.station-name {
font-size: 12px;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.station-genre {
font-size: 10px;
color: var(--fg-muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.station-empty {
padding: 16px;
text-align: center;
color: var(--fg-muted);
font-size: 12px;
}
/* Nav — quick-link row above the footer */
.tuner-nav {
display: grid;
grid-template-columns: repeat(3, 1fr);
background: var(--bg-soft);
border-top: 1px solid #000;
gap: 1px;
}
.tuner-nav-btn {
background: var(--bg-soft);
color: var(--fg-muted);
border: 0;
padding: 8px 4px;
font: inherit;
font-size: 11px;
font-weight: 500;
cursor: pointer;
display: flex;
flex-direction: column;
align-items: center;
gap: 3px;
font-family: inherit;
}
.tuner-nav-btn:hover {
background: var(--bg-row);
color: var(--fg);
}
.tuner-nav-btn:active {
background: var(--bg-row-hi);
}
.tuner-nav-icon {
font-size: 14px;
line-height: 1;
color: var(--accent);
}
.tuner-nav-label {
letter-spacing: 0.3px;
}
/* Footer */
.tuner-footer {
padding: 6px 12px;
background: var(--bg-soft);
border-top: 1px solid var(--bg-row);
font-size: 10px;
color: var(--fg-muted);
text-align: center;
}
/* Scrollbar styling — subtle, on-brand */
.station-list::-webkit-scrollbar {
width: 6px;
}
.station-list::-webkit-scrollbar-thumb {
background: var(--bg-row-hi);
border-radius: 3px;
}
.station-list::-webkit-scrollbar-track {
background: transparent;
}
/* ──────────────────────────────────────────────────────────────────────
First-run UX hint (v0.4.0)
When body.is-first-run is set (no station picked), the station list
subtly pulses with an accent-green glow and the now-playing area gets
a bouncing ↓ arrow pointing the user at the list. Both removed the
moment a station is picked, so existing users never see them again.
────────────────────────────────────────────────────────────────────── */
@keyframes tuner-pulse-glow {
0%, 100% { box-shadow: 0 0 0 0 rgba(109, 191, 122, 0); }
50% { box-shadow: 0 0 0 4px rgba(109, 191, 122, 0.25); }
}
@keyframes tuner-bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(3px); }
}
body.is-first-run .stations {
animation: tuner-pulse-glow 2.4s ease-in-out infinite;
border-radius: 6px;
}
body.is-first-run .np-track {
color: var(--accent);
font-weight: 500;
}
body.is-first-run .np-track::after {
content: " ↓";
display: inline-block;
animation: tuner-bounce 1.8s ease-in-out infinite;
margin-left: 4px;
}