/* Stilväxlaren – Ståhle Digital. Neutral, så att den inte konkurrerar med stilen.
   Allt är prefixat .stv / --stv- och påverkar inget annat på sidan. */

.stv, .stv * , .stv-cover { box-sizing: border-box; }

/* ---------------------------------------------------------------- täckning vid ankomst (första målningen) */
html.stv-arrive::before {
  content: var(--stv-cover-name, "");
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--stv-cover-bg, #0f0f10);
  color: var(--stv-cover-fg, #fff);
  font: 600 clamp(38px, 8vw, 112px) / 1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.04em;
  clip-path: inset(0 0 0 0);
  pointer-events: none;
}
html.stv-arrive[data-stv-font="thin"]::before { font-weight: 250; }
html.stv-arrive[data-stv-font="serif"]::before { font-family: "Iowan Old Style", Georgia, "Times New Roman", serif; font-weight: 400; font-style: italic; }
html.stv-reveal::before { clip-path: inset(0 0 100% 0); transition: clip-path 0.85s cubic-bezier(0.76, 0, 0.24, 1); }
html.stv-arrive-still::before { content: ""; }

/* ---------------------------------------------------------------- övergång ut */
.stv-cover {
  position: fixed;
  inset: 0;
  z-index: 2147483601;
  display: none;
  place-items: center;
  background: var(--stv-cover-bg, #0f0f10);
  color: var(--stv-cover-fg, #fff);
  font: 600 clamp(38px, 8vw, 112px) / 1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.04em;
  pointer-events: none;
  transition: clip-path 0.7s cubic-bezier(0.76, 0, 0.24, 1);
}
.stv-cover[data-font="thin"] { font-weight: 250; }
.stv-cover[data-font="serif"] { font-family: "Iowan Old Style", Georgia, "Times New Roman", serif; font-weight: 400; font-style: italic; }
.stv-cover.is-on { display: grid; }
.stv-cover span { opacity: 0; transform: translateY(16px); transition: opacity 0.35s 0.3s, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.25s; }
.stv-cover.is-full span { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- knapp och väljare */
.stv {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font: 500 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0;
  color: #f4f4f3;
  text-align: left;
  pointer-events: none; /* bara knapp och panel tar emot klick */
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
}
.stv > * { pointer-events: auto; }
.stv.is-tucked:not(.is-open) { transform: translateY(calc(100% + 24px)); opacity: 0; }
.stv.is-typing:not(.is-open) { opacity: 0; transform: translateY(calc(100% + 24px)); }

.stv-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(22, 22, 24, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.55);
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s, border-color 0.25s;
}
.stv-btn:hover { background: rgba(38, 38, 42, 0.9); border-color: rgba(255, 255, 255, 0.28); }
.stv-btn:focus-visible, .stv-opt:focus-visible, .stv-close:focus-visible, .stv-reset:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.6);
}
.stv-btn-swatch { display: inline-flex; }
.stv-btn-swatch i { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid rgba(22, 22, 24, 0.9); }
.stv-btn-swatch i + i { margin-left: -6px; }
.stv.is-open .stv-btn { background: #f4f4f3; color: #141416; border-color: #f4f4f3; }

.stv-panel {
  width: min(340px, calc(100vw - 28px));
  padding: 8px;
  border-radius: 20px;
  background: rgba(22, 22, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.7);
  transform-origin: 100% 100%;
  animation: stv-pop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.stv-panel[hidden] { display: none; }
@keyframes stv-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.stv-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 8px 12px; }
.stv-title { margin: 0; font-size: 13px; font-weight: 600; color: rgba(244, 244, 243, 0.72); letter-spacing: 0.02em; }
.stv-close {
  position: relative;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.stv-close:hover { background: rgba(255, 255, 255, 0.08); }
.stv-close span::before, .stv-close span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 1.5px;
  margin: -0.75px 0 0 -7px;
  background: currentColor;
  transform: rotate(45deg);
}
.stv-close span::after { transform: rotate(-45deg); }

.stv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.stv-opt {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 60px;
  padding: 6px 12px 6px 6px;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.2s;
}
.stv-opt:hover { background: rgba(255, 255, 255, 0.07); }
.stv-opt.is-current { background: rgba(255, 255, 255, 0.1); }
.stv-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--b);
  color: var(--f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  font: 600 17px/1 system-ui, sans-serif;
  letter-spacing: -0.03em;
}
.stv-thumb[data-font="thin"] { font-weight: 250; }
.stv-thumb[data-font="serif"] { font-family: "Iowan Old Style", Georgia, serif; font-weight: 400; font-style: italic; }
.stv-thumb i { position: absolute; left: 8px; right: 8px; bottom: 7px; height: 3px; border-radius: 2px; background: var(--a); }
.stv-opt-text { display: grid; gap: 1px; min-width: 0; }
.stv-opt-name { font-size: 15px; font-weight: 600; }
.stv-opt-desc { font-size: 12.5px; font-weight: 400; color: rgba(244, 244, 243, 0.66); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stv-opt-state { font-size: 11.5px; font-weight: 500; color: rgba(244, 244, 243, 0.72); }
.stv-opt.is-current .stv-opt-state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #7ee2a8; vertical-align: 1px; }

.stv-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; padding: 8px 6px 4px 12px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.stv-note { margin: 0; font-size: 12.5px; font-weight: 400; color: rgba(244, 244, 243, 0.7); }
.stv-reset {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: 500 12.5px/1 system-ui, sans-serif;
  cursor: pointer;
}
.stv-reset:hover:not([disabled]) { background: rgba(255, 255, 255, 0.08); }
.stv-reset[disabled] { opacity: 0.4; cursor: default; }

@media (max-width: 520px) {
  .stv { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
  .stv-btn { padding: 0 14px 0 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .stv, .stv-panel, .stv-cover, .stv-cover span { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .stv-btn, .stv-panel, .stv-opt.is-current { border: 1px solid CanvasText; }
}
