/* Lull shared shell: theme tokens, control bar, auto-hide.
   Pieces read colours from these tokens (via Lull.color) so dark mode just works. */

:root {
  --ink: #1c1b19;
  --muted: #6f6d67;
  --line: #d8d5cd;
  --paper: #faf9f6;
  --panel: #f1efe9;
  --bar: rgba(250, 249, 246, 0.88);
  --hover: #ffffff;
  --outline: #c9c6bd;        /* faint structure lines on canvas */
  --outline-strong: #b9b6ad; /* container edges on canvas */
  --edge: #ffffff;           /* highlight lines over colour fills */
  --fill-l: 54%;             /* lightness for generated hsl() colours */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece9e1;
    --muted: #9a978f;
    --line: #3a3833;
    --paper: #161512;
    --panel: #1f1e1a;
    --bar: rgba(22, 21, 18, 0.85);
    --hover: #26251f;
    --outline: #34322d;
    --outline-strong: #4a4842;
    --edge: rgba(255, 255, 255, 0.55);
    --fill-l: 58%;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #ece9e1;
  --muted: #9a978f;
  --line: #3a3833;
  --paper: #161512;
  --panel: #1f1e1a;
  --bar: rgba(22, 21, 18, 0.85);
  --hover: #26251f;
  --outline: #34322d;
  --outline-strong: #4a4842;
  --edge: rgba(255, 255, 255, 0.55);
  --fill-l: 58%;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Full-viewport piece layout */
body.lull-piece {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* --- Control bar --- */
.lull-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px 14px;
  flex-wrap: wrap;
  justify-content: center;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--bar);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.6s ease;
  z-index: 10;
}

/* keeps related controls (e.g. a label and its slider) on the same line when the bar wraps */
.lull-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lull-bar .lull-sep {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}

.lull-bar button {
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.lull-bar button:hover { background: var(--hover); }
.lull-bar button:active { transform: scale(0.98); }
.lull-bar button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.lull-bar button[aria-pressed="true"] { background: var(--hover); border-color: var(--muted); }

.lull-bar button.lull-icon {
  padding: 6px;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
}
.lull-bar button.lull-icon svg { width: 18px; height: 18px; }

.lull-bar label { font-size: 13px; color: var(--muted); }
.lull-bar input[type=range] { width: 120px; accent-color: var(--ink); }

/* --- Toast (e.g. "Link copied"), just above the bar --- */
.lull-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 8px);
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 11;
}
.lull-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Auto-hide when idle, and screensaver mode --- */
.lull-idle .lull-bar,
.lull-screensaver .lull-bar {
  opacity: 0;
  pointer-events: none;
}
.lull-idle, .lull-idle *,
.lull-screensaver, .lull-screensaver * { cursor: none !important; }

@media (prefers-reduced-motion: reduce) {
  .lull-bar, .lull-toast { transition: none; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* separators just dangle once the bar wraps onto several lines */
@media (max-width: 560px) {
  .lull-bar .lull-sep { display: none; }
}
