/* Visual language ported from clippinator's cute themes (src/style.css there):
   lilac/plum palettes, a hot-pink accent, Baloo 2, and the "pop" - an ink outline
   plus a hard offset shadow that buttons sink into when pressed. Plain CSS, no build step. */

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("baloo2-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("baloo2-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Cinzel (SIL OFL 1.1): an inscriptional serif standing in for Valheim's carved wordmark. Logo only. */
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("cinzel-latin.woff2") format("woff2");
}

/* ---------- tokens ----------
   The ramp keeps one meaning in both themes: 950 page, 900 panel, 800 control,
   700 hover, 600/500 faint text, 300-100 readable text. */
:root,
[data-theme="cute-dark"] {
  color-scheme: dark;
  --n-950: #16101f;
  --n-900: #1f1730;
  --n-800: #2b2040;
  --n-700: #3a2b55;
  --n-600: #6f6089;
  --n-500: #9083ab;
  --n-400: #b3a5cc;
  --n-300: #d5cbe8;
  --n-200: #ece5f8;
  --n-100: #fbf7ff;

  --accent-200: #ffe0ec;
  --accent-300: #ffa8c6;
  --accent-400: #ff7ea6;
  --accent-500: #fb5a90;
  --accent-600: #ef3f7d;

  --ok: #2fd6a6;
  --warn: #ffc466;
  --bad: #f74d79;

  /* Darker than the page rather than a light outline, which would read as a glow. */
  --ink: #090513;

  /* Valheim-style bronze for the logo: bright crown, dark band, a second highlight, dark foot. */
  --logo-metal: linear-gradient(180deg, #fbefcf 0%, #e3bf74 34%, #9a6d31 56%, #d7b170 76%, #6e4c22 100%);
  --logo-edge: #241405;
  --logo-shadow: drop-shadow(0 3px 4px rgb(0 0 0 / 0.45));
  --logo-dim: #bfa274;
}

[data-theme="cute-light"] {
  color-scheme: light;
  --n-950: #f6f2ff;
  --n-900: #fffdfa;
  --n-800: #efe6fd;
  --n-700: #ded0f6;
  --n-600: #a99ac4;
  --n-500: #8577a0;
  --n-400: #6a5a85;
  --n-300: #483a61;
  --n-200: #33244a;
  --n-100: #241832;

  --accent-200: #ffd9e7;
  --accent-300: #ff9cbd;
  --accent-400: #ff6f9c;
  --accent-500: #f43f85;
  --accent-600: #e02f74;

  --ok: #12a87e;
  --warn: #e09a2a;
  --bad: #e63a68;

  --ink: #241832;

  /* Deeper bronze so the metal keeps its contrast on the pale page. */
  --logo-metal: linear-gradient(180deg, #d9a752 0%, #a5732c 38%, #5e3d14 58%, #9c6c2a 78%, #4a2f0e 100%);
  --logo-edge: rgb(255 244 220 / 0.9);
  --logo-shadow: drop-shadow(0 2px 2px rgb(70 40 5 / 0.22));
  --logo-dim: #8a6a3b;
}

:root {
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.375rem;
  --pop-ring: 0 0 0 2px var(--ink);
  --pop-sm: var(--pop-ring), 3px 3px 0 var(--ink);
  --pop-lg: var(--pop-ring), 5px 5px 0 var(--ink);
  --glow: 0 0 18px -6px var(--accent-500);
  font-family: "Baloo 2", "Segoe UI Rounded", system-ui, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* Components set their own display, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--n-950);
  color: var(--n-200);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--n-600) var(--n-900);
}

/* ---------- layout ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Equal outer columns keep the logo on the true centre line whatever the controls' width. */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 2px solid var(--n-800);
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

/* ---------- logo ----------
   Styled after Valheim's wordmark rather than clippinator's: wide-tracked carved capitals in
   weathered bronze, with the smaller lines set like an inscription. Letter-spacing adds trailing
   space after the last glyph, so each line gets matching left padding to stay optically centred. */
.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  user-select: none;
  white-space: nowrap;
  font-family: "Cinzel", "Trajan Pro", Georgia, serif;
  text-transform: uppercase;
}

.logo-kicker {
  margin-bottom: 3px;
  padding-left: 0.4em;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: var(--logo-dim);
}

.logo-main {
  padding-left: 0.14em;
  font-size: 2.05rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  background: var(--logo-metal);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* A hard 1px edge reads as the bevel of carved metal, the soft one lifts it off the bar. */
  filter: drop-shadow(0 1px 0 var(--logo-edge)) var(--logo-shadow);
}

.logo-sub {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-top: 4px;
  padding-left: 0.45em;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.45em;
  color: var(--logo-dim);
}

.logo-sub::before,
.logo-sub::after {
  content: "";
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor);
}

.logo-sub::after {
  margin-left: -0.45em; /* cancel the trailing letter-spacing so both rules sit evenly */
  transform: scaleX(-1);
}

.spacer { flex: 1; }

main {
  flex: 1;
  overflow: auto;
  padding: 26px 22px 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 26px;
  align-content: start;
  align-items: start;
}

@media (max-width: 860px) {
  main { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- surfaces ---------- */
.card {
  background: var(--n-900);
  border-radius: var(--radius-xl);
  box-shadow: var(--pop-lg);
  padding: 22px 24px;
  min-width: 0;
}

.card h2 {
  margin: 0 0 2px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--n-100);
}

.muted { color: var(--n-500); }
.small { font-size: 0.85rem; }

/* ---------- hero ---------- */
.hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  /* Soft accent bloom in the corner; decoration only. */
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-500) 22%, transparent), transparent 70%);
  pointer-events: none;
}

.hero-title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
  font-weight: 800;
  color: var(--n-100);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 3px 12px 2px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--n-800);
  color: var(--n-300);
  box-shadow: var(--pop-ring);
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill[data-state="ready"] { color: var(--ok); }
.pill[data-state="busy"] { color: var(--accent-400); }
.pill[data-state="busy"]::before { animation: pulse 1s ease-in-out infinite; }
.pill[data-state="offline"] { color: var(--warn); }
.pill[data-state="error"] { color: var(--bad); }
.pill[data-state="setup"] { color: var(--n-400); }

@keyframes pulse {
  50% { transform: scale(0.5); opacity: 0.5; }
}

.update-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent-500) 14%, var(--n-800));
  box-shadow: var(--pop-ring);
  font-size: 0.9rem;
  color: var(--n-100);
}

.update-banner span { flex: 1; min-width: 0; }

.status-line:empty { display: none; }

.status-line {
  color: var(--n-400);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--n-800);
  box-shadow: var(--pop-ring);
  overflow: hidden;
  display: none;
}

.progress[data-on="true"] { display: block; }

.progress > span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-400), var(--accent-600));
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(260%); }
}

.log {
  margin: 0;
  padding: 10px 12px;
  max-height: 160px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: var(--n-950);
  box-shadow: var(--pop-ring);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--n-400);
  white-space: pre-wrap;
}

/* ---------- controls ---------- */
button,
input[type="text"],
input[type="url"] {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  background: var(--n-800);
  color: var(--n-200);
  font-weight: 700;
  box-shadow: var(--pop-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--n-700);
  box-shadow: var(--pop-sm), var(--glow);
}

/* Pressed, a button sinks into its own shadow by exactly the offset it loses. */
button:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: var(--pop-ring);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  background: var(--accent-500);
  color: #fff;
}

button.primary:hover:not(:disabled) { background: var(--accent-400); }

button.play {
  align-self: stretch;
  padding: 16px 24px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: var(--radius-xl);
  box-shadow: var(--pop-lg), 0 0 40px -12px var(--accent-500);
}

button.play:hover:not(:disabled) {
  box-shadow: var(--pop-lg), 0 0 46px -8px var(--accent-500);
}

button.play:active:not(:disabled) {
  transform: translate(5px, 5px);
  box-shadow: var(--pop-ring);
}

button.icon {
  padding: 7px 10px;
  line-height: 0;
}

button.link {
  background: none;
  box-shadow: none;
  padding: 0;
  color: var(--accent-400);
  font-weight: 600;
}

button.link:hover:not(:disabled) {
  background: none;
  box-shadow: none;
  text-decoration: underline;
}

button.link:active:not(:disabled) { transform: none; }

:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

/* Segmented switch: one control, so the outline belongs to the group. */
.seg {
  display: inline-flex;
  border-radius: var(--radius-lg);
  box-shadow: var(--pop-sm);
  overflow: hidden;
}

.seg button {
  border-radius: 0;
  box-shadow: none;
  padding: 6px 12px;
  background: var(--n-800);
  color: var(--n-500);
  line-height: 0;
}

.seg button[aria-pressed="true"] {
  background: var(--accent-500);
  color: #fff;
}

.seg button:hover:not(:disabled) { box-shadow: none; }
.seg button:active:not(:disabled) { transform: none; }

input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--n-800);
  color: var(--n-100);
  box-shadow: var(--pop-sm);
}

input::placeholder { color: var(--n-600); }

/* Round checkboxes, drawn by hand since border-radius alone is ignored once Chromium paints the control. */
input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  flex: none;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background-color: var(--n-950);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="checkbox"]:checked {
  background-color: var(--accent-500);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5'/%3E%3C/svg%3E");
  background-size: 74%;
  background-position: center;
  background-repeat: no-repeat;
}

input[type="checkbox"]:active { transform: scale(0.9); }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.55; }

/* ---------- extras list ---------- */
.extras {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.extra {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--n-800);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.extra:hover { background: var(--n-700); }
.extra strong { display: block; color: var(--n-100); font-weight: 700; }
.extra span { display: block; color: var(--n-500); font-size: 0.86rem; }

.empty {
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--n-700);
  color: var(--n-500);
  text-align: center;
  font-size: 0.9rem;
}

/* ---------- settings dialog ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(4px);
}

.dialog {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; color: var(--n-200); font-size: 0.92rem; }
.row { display: flex; gap: 10px; align-items: center; }
.actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  max-width: min(560px, calc(100% - 44px));
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  background: var(--n-900);
  color: var(--n-100);
  box-shadow: var(--pop-lg);
  transform: translate(-50%, 0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast[data-kind="error"] { border-left: 6px solid var(--bad); }
.toast[data-kind="ok"] { border-left: 6px solid var(--ok); }
.toast:not([data-show]) { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }

/* ---------- launch confetti ---------- */
.confetti {
  position: fixed;
  pointer-events: none;
  font-size: 12px;
  line-height: 1;
  z-index: 60;
  animation: burst 1s ease-out forwards;
}

@keyframes burst {
  0% { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
