/* Familjehubb – gemensam design (Mejselfix design system, mx-shell-v3) */
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans+Condensed:wght@700;900&family=Fira+Sans:wght@400;500&family=Fira+Mono&display=swap');

:root {
  --mx-yellow: #FFCC01;
  --mx-black: #090909;
  --mx-white: #F5F5F0;
  --bg: #090909;
  --surface: #111111;
  --surface-2: #181818;
  --line: #2a2a2a;
  --text: #F5F5F0;
  --muted: #a3a39c;
  --accent: #FFCC01;
  --on-accent: #090909;
  --danger: #ff5a4f;
  --ok: #5fd068;
  --orange: #ff8a1f;
  --shadow: 4px 4px 0 var(--accent);
  --shadow-sm: 2px 2px 0 var(--accent);
  --font-heading: 'Fira Sans Condensed', sans-serif;
  --font-body: 'Fira Sans', sans-serif;
  --font-mono: 'Fira Mono', monospace;
  --sidebar-w: 240px;
  --footer-h: 64px;
}
:root[data-theme="light"] {
  --bg: #F5F5F0;
  --surface: #ffffff;
  --surface-2: #ecece6;
  --line: #d4d4cc;
  --text: #090909;
  --muted: #5c5c56;
  --shadow: 4px 4px 0 var(--mx-black);
  --shadow-sm: 2px 2px 0 var(--mx-black);
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0 !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  display: flex; overflow: hidden;
}
a { color: inherit; }
h1, h2, h3, .heading { font-family: var(--font-heading); font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Sidomeny ---------- */
.hub-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--mx-black); color: var(--mx-white);
  border-right: 2px solid var(--accent); display: flex; flex-direction: column;
  transition: margin-left .25s ease; z-index: 50; overflow-y: auto;
}
.hub-sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
.hub-brand { padding: 20px 16px; border-bottom: 2px solid var(--accent); font-family: var(--font-heading); font-weight: 900; font-size: 22px; letter-spacing: .08em; }
.hub-brand span { color: var(--accent); }
.hub-brand small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 11px; letter-spacing: .2em; color: #a3a39c; }
.hub-nav { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.hub-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px;
  text-decoration: none; font-family: var(--font-heading); font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; border: 2px solid #2a2a2a; color: var(--mx-white);
}
.hub-nav a:hover { border-color: var(--accent); }
.hub-nav a.active { background: var(--accent); color: var(--mx-black); border-color: var(--accent); }
.nav-badge { font-family: var(--font-mono); font-size: 12px; background: var(--danger); color: #fff; padding: 0 6px; }
.nav-badge[hidden] { display: none; }
.hub-nav a.active .nav-badge { background: var(--mx-black); color: var(--accent); }
.hub-sidebar-foot { margin-top: auto; padding: 16px; font-family: var(--font-mono); font-size: 11px; color: #a3a39c; border-top: 2px solid #2a2a2a; }

/* ---------- Huvudyta ---------- */
.hub-main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }
.hub-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px;
  background: var(--mx-black); color: var(--mx-white); border-bottom: 2px solid var(--accent); flex-shrink: 0;
}
.hub-topbar h1 { font-size: 22px; }
.hub-topbar .left, .hub-topbar .right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hub-status { font-family: var(--font-mono); font-size: 12px; color: #a3a39c; }
.hub-content > * { flex-shrink: 0; }
.hub-content { flex: 1; overflow-y: auto; padding: 24px; padding-bottom: calc(var(--footer-h) + 24px); display: flex; flex-direction: column; gap: 24px; }

/* Timer-knapp i toppmenyn */
.hub-tmr {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
  font-family: var(--font-mono); font-size: 13px; color: var(--mx-black); background: var(--accent);
  border: 2px solid var(--accent); padding: 4px 8px;
}
.hub-tmr b { font-weight: 500; }
.hub-tmr.ring { background: var(--danger); border-color: var(--danger); color: #fff; animation: tmr-blink .7s steps(2) infinite; }
.hub-tmr[hidden] { display: none !important; }
@keyframes tmr-blink { 50% { background: var(--mx-black); color: var(--accent); } }
@media (max-width: 800px) { .hub-tmr .nm { display: none; } }

/* ---------- Varningsbanner (SMHI): gul text på svart, rullar ---------- */
.hub-alert {
  display: flex; align-items: stretch; flex-shrink: 0; cursor: pointer; overflow: hidden;
  background: #000; color: var(--mx-yellow); border-bottom: 2px solid var(--mx-yellow);
  font-family: var(--font-heading); font-weight: 700; letter-spacing: .04em; font-size: 16px; line-height: 1;
}
.hub-alert[hidden] { display: none !important; }
.hub-alert:focus-visible { outline: 3px solid var(--mx-yellow); outline-offset: -3px; }
.ha-tag {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 9px 12px;
  background: var(--mx-yellow); color: #000; font-weight: 900; text-transform: uppercase;
}
.hub-alert[data-level="RED"] .ha-tag { background: var(--danger); color: #fff; animation: ha-pulse 1s steps(2) infinite; }
.hub-alert[data-level="ORANGE"] .ha-tag { background: var(--orange); }
@keyframes ha-pulse { 50% { background: #000; color: var(--danger); } }
.ha-track { flex: 1; min-width: 0; overflow: hidden; display: flex; align-items: center;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.ha-move { display: flex; width: max-content; animation: ha-scroll var(--ha-dur, 30s) linear infinite; will-change: transform; }
.hub-alert:hover .ha-move, .hub-alert:focus .ha-move { animation-play-state: paused; }
.ha-run { display: flex; align-items: center; white-space: nowrap; padding-right: 0; }
.ha-item { padding: 9px 0 9px 22px; }
.ha-item b { font-weight: 900; text-transform: uppercase; }
.ha-item.lv-red b { color: #ff7a70; }
.ha-item.lv-orange b { color: var(--orange); }
.ha-sep { padding-left: 22px; }
@keyframes ha-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .ha-move { animation: none; } .ha-run + .ha-run { display: none; } .ha-track { overflow-x: auto; }
}

/* ---------- Komponenter ---------- */
.card { background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
:root[data-theme="light"] .card { border-color: var(--mx-black); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { font-family: var(--font-heading); font-weight: 900; font-size: 18px; text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.small { font-size: 13px; }

.btn {
  background: var(--accent); color: var(--on-accent); border: 2px solid var(--mx-black);
  font-family: var(--font-heading); font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 16px; cursor: pointer; box-shadow: 3px 3px 0 var(--mx-black); font-size: 14px;
  transition: transform .1s, box-shadow .1s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
:root:not([data-theme="light"]) .btn { box-shadow: 3px 3px 0 var(--mx-white); }
.btn:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--mx-black); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-ghost { background: transparent; color: var(--text); border: 2px solid var(--line); box-shadow: none !important; }
.btn-ghost:hover { border-color: var(--accent); transform: none; }
.btn-danger { background: var(--danger); color: #fff; }
.icon-btn { width: 40px; height: 40px; justify-content: center; padding: 0; font-size: 18px; }

.input, textarea.input, select.input {
  width: 100%; background: var(--surface-2); color: var(--text); border: 2px solid var(--line);
  padding: 10px 12px; font: inherit; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-transform: uppercase; }

.tag { display: inline-block; font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line); color: var(--muted); }
.tag.hot { background: var(--accent); color: var(--mx-black); border-color: var(--accent); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.warn { border-color: var(--danger); color: var(--danger); }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; z-index: 300; padding: 16px; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 24px; position: relative; animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close { position: absolute; top: 12px; right: 12px; }

/* ---------- Toast ---------- */
.hub-toast { position: fixed; right: 20px; bottom: calc(var(--footer-h) + 16px); background: var(--accent); color: var(--mx-black); font-family: var(--font-heading); font-weight: 700; text-transform: uppercase; padding: 10px 16px; border: 2px solid var(--mx-black); box-shadow: 4px 4px 0 var(--mx-black); z-index: 600; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; }
.hub-toast.show { opacity: 1; transform: none; }
.hub-toast.error { background: var(--danger); color: #fff; }

/* ---------- Ringöverlägg (timer/alarm klart) ---------- */
.hub-ring { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; padding: 16px; }
.hub-ring[hidden] { display: none !important; }
.hr-box { width: min(94vw, 34rem); max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.hr-item {
  background: var(--mx-yellow); color: var(--mx-black); border: 3px solid var(--mx-black); box-shadow: 8px 8px 0 var(--mx-white);
  padding: 20px; display: flex; flex-direction: column; gap: 8px; animation: hr-glow 1s steps(2) infinite;
}
/* Bara rubriken skakar – knapparna står still så de är lätta att träffa */
.hr-name { animation: hr-shake .45s ease-in-out infinite alternate; transform-origin: left center; }
@keyframes hr-shake { from { transform: rotate(-1.5deg); } to { transform: rotate(1.5deg); } }
@keyframes hr-glow { 50% { box-shadow: 8px 8px 0 var(--danger); } }
.hr-kind { font-family: var(--font-mono); font-size: 14px; text-transform: uppercase; letter-spacing: .1em; }
.hr-name { font-family: var(--font-heading); font-weight: 900; text-transform: uppercase; font-size: clamp(30px, 7vw, 64px); line-height: 1; overflow-wrap: anywhere; }
.hr-links { font-family: var(--font-mono); font-size: 14px; }
.hr-act { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.hr-act .btn { font-size: 20px; padding: 12px 20px; background: var(--mx-black); color: var(--mx-yellow); border-color: var(--mx-black); box-shadow: none; }
.hr-act .btn-ghost { background: transparent; color: var(--mx-black); border-color: var(--mx-black); }
.hr-foot { font-family: var(--font-mono); font-size: 12px; color: #a3a39c; text-align: center; }
@media (prefers-reduced-motion: reduce) { .hr-item, .hr-name { animation: none; } }

/* ---------- Mediaspelare ---------- */
.hub-radio {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--footer-h); z-index: 200;
  background: var(--mx-black); color: var(--mx-white); border-top: 2px solid var(--accent);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  transition: transform .25s ease;
}
.hub-radio [hidden] { display: none !important; }
.hub-radio.is-hidden { transform: translateY(110%); pointer-events: none; }
.hub-radio .rbtn { background: var(--accent); color: var(--mx-black); border: 2px solid var(--accent); width: 42px; height: 42px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hub-radio .rbtn.ghost { background: transparent; color: var(--mx-white); border-color: #2a2a2a; }
.hub-radio .rbtn.ghost:hover { border-color: var(--accent); }
.hub-radio .rinfo { min-width: 0; flex: 1; }
.hub-radio .rname { font-family: var(--font-heading); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-radio .rsub { font-size: 12px; color: #a3a39c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-radio input[type=range] { width: 110px; accent-color: #FFCC01; }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 22px; width: 26px; opacity: .25; flex-shrink: 0; }
.eq.on { opacity: 1; }
.eq i { width: 5px; background: var(--accent); height: 4px; }
.eq.on i { animation: eq .8s ease-in-out infinite alternate; }
.eq.on i:nth-child(2) { animation-delay: .2s; } .eq.on i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { to { height: 22px; } }

/* Flik när spelaren är dold */
.hub-player-tab {
  position: fixed; right: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 210;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--mx-black); color: var(--accent); border: 2px solid var(--accent); box-shadow: 3px 3px 0 var(--accent);
  font-family: var(--font-heading); font-weight: 900; font-size: 15px; padding: 6px 10px;
}
.hub-player-tab[hidden] { display: none !important; }
.hub-player-tab .eq { height: 16px; width: 20px; }
.hub-player-tab .eq i { width: 4px; }
@keyframes eq-s { to { height: 16px; } }
.hub-player-tab .eq.on i { animation-name: eq-s; }

/* Panel ovanför spelaren: MX Radio, Spotify, låtlista */
.hub-player-panel {
  position: fixed; right: 0; bottom: var(--footer-h); z-index: 190; width: min(100vw, 30rem); height: min(72vh, 40rem);
  background: var(--mx-black); color: var(--mx-white); border: 2px solid var(--accent); border-bottom: 0;
  display: flex; flex-direction: column; transform: translateY(calc(100% + var(--footer-h) + 20px)); transition: transform .25s ease;
  box-shadow: -4px -4px 0 rgba(255, 204, 1, .35);
}
.hub-player-panel.open { transform: none; }
.pp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 14px; border-bottom: 2px solid #2a2a2a; }
.pp-head b { font-family: var(--font-heading); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.pp-act { display: flex; gap: 8px; align-items: center; }
.pp-act .btn-ghost { color: var(--mx-white); border-color: #2a2a2a; }
.pp-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.pp-frame { flex: 1; display: flex; min-height: 0; }
.pp-frame iframe { flex: 1; width: 100%; border: 0; background: #000; }
.pp-info { padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; color: #a3a39c; }
.pp-info a { color: var(--accent); }
.pp-tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 12px 0; }
.pp-tools .input { flex: 1 1 10rem; padding: 7px 10px; background: #181818; color: var(--mx-white); border-color: #2a2a2a; }
.pp-tools .btn { font-size: 13px; padding: 6px 10px; }
.pp-tools .btn-ghost { color: var(--mx-white); border-color: #2a2a2a; }
.pp-tracks { list-style: none; padding: 0 6px 10px; }
.pp-tracks button {
  width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #222; color: var(--mx-white);
  font: inherit; padding: 9px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.pp-tracks button:hover { background: #181818; }
.pp-tracks button.cur { color: var(--accent); }
.pp-tracks small { font-family: var(--font-mono); font-size: 11px; color: #8a8a84; }
.pp-empty { padding: 12px 8px; color: #a3a39c; font-size: 13px; }

@media (max-width: 800px) {
  .hub-sidebar { position: fixed; top: 0; bottom: 0; left: 0; }
  .hub-sidebar:not(.open) { margin-left: calc(-1 * var(--sidebar-w)); }
  .hub-content { padding: 16px; padding-bottom: calc(var(--footer-h) + 16px); }
  .hub-radio { gap: 8px; padding: 0 10px; }
  .hub-radio input[type=range], .hub-radio #r-mute { display: none !important; }
  .hub-radio .rbtn { width: 38px; height: 38px; }
  .hub-status { display: none; }
  .hub-player-panel { width: 100vw; height: min(70vh, 34rem); }
  .hub-alert { font-size: 14px; }
}
@media (max-width: 420px) {
  .hub-radio .eq { display: none; }
  .hub-topbar { padding-left: 10px; padding-right: 10px; }
  .hub-topbar .right { gap: 6px; }
}
/* Memo i helskärm (mobil liggande): göm även banner och spelarflik */
@media (orientation: landscape) and (max-height: 560px) {
  body[data-page="memo"] .hub-player-tab, body[data-page="memo"] .hub-alert, body[data-page="memo"] .hub-player-panel { display: none !important; }
}
/* 4K / TV */
@media (min-width: 2200px) {
  .hub-alert { font-size: 26px; }
  .ha-tag { padding: 14px 18px; }
  .ha-item { padding: 14px 0 14px 32px; }
  .hub-tmr { font-size: 20px; padding: 8px 12px; }
  .hub-player-panel { width: 44rem; }
  .hub-player-tab { font-size: 22px; padding: 10px 16px; }
}
