/* Blessed Raven — symbol sandbox (native game engine) */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root,
[data-theme="dark"] {
  --bg: #0a0a0c;
  --fg: #f2f0ea;
  --muted: rgba(242, 240, 234, 0.45);
  --accent: #e11d2e;
  --panel: rgba(18, 18, 22, 0.92);
  --panel-border: rgba(242, 240, 234, 0.12);
  --btn: rgba(242, 240, 234, 0.08);
  --btn-on: rgba(225, 29, 46, 0.35);
  --hit: rgba(242, 240, 234, 0.08);
  --hit-stroke: rgba(242, 240, 234, 0.55);
  --label-stroke: rgba(10, 10, 12, 0.92);
  --sigil-filter: invert(1) contrast(1.05);
  --fallback-filter: invert(1);
  --vb-w: 923.86;
  --vb-h: 886.31;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f7f5f0;
  --fg: #121212;
  --muted: rgba(18, 18, 18, 0.45);
  --accent: #c41020;
  --panel: rgba(255, 253, 248, 0.94);
  --panel-border: rgba(18, 18, 18, 0.12);
  --btn: rgba(18, 18, 18, 0.06);
  --btn-on: rgba(196, 16, 32, 0.22);
  --hit: rgba(18, 18, 18, 0.06);
  --hit-stroke: rgba(18, 18, 18, 0.5);
  --label-stroke: rgba(255, 255, 255, 0.92);
  --sigil-filter: none;
  --fallback-filter: none;
  color-scheme: light;
}

[data-theme="vibe"],
[data-theme="vibe-dark"] {
  --bg: #050508;
  --fg: #f2f0ea;
  --muted: rgba(242, 240, 234, 0.5);
  --accent: #ff2d55;
  --panel: rgba(10, 8, 18, 0.92);
  --panel-border: rgba(255, 45, 85, 0.28);
  --btn: rgba(255, 255, 255, 0.07);
  --btn-on: rgba(255, 45, 85, 0.4);
  --hit: rgba(242, 240, 234, 0.08);
  --hit-stroke: rgba(242, 240, 234, 0.55);
  --label-stroke: rgba(10, 10, 12, 0.92);
  --sigil-filter: invert(1) contrast(1.05);
  --fallback-filter: invert(1);
  color-scheme: dark;
}

[data-theme="vibe-light"] {
  --bg: #f7f5f0;
  --fg: #121212;
  --muted: rgba(18, 18, 18, 0.45);
  --accent: #ff2d55;
  --panel: rgba(255, 253, 248, 0.94);
  --panel-border: rgba(255, 45, 85, 0.25);
  --btn: rgba(18, 18, 18, 0.06);
  --btn-on: rgba(255, 45, 85, 0.22);
  --hit: rgba(18, 18, 18, 0.06);
  --hit-stroke: rgba(18, 18, 18, 0.5);
  --label-stroke: rgba(255, 255, 255, 0.92);
  --sigil-filter: none;
  --fallback-filter: none;
  color-scheme: light;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background-color 280ms ease, color 280ms ease;
}

body {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--btn);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

button:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

button[aria-pressed="true"],
button[aria-selected="true"],
button.is-on {
  background: var(--btn-on);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

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

/* —— Header —— */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  z-index: 20;
  position: relative;
}

.brand {
  font-weight: 750;
  letter-spacing: 0.08em;
  text-decoration: none;
  font-size: 0.92rem;
}

.top-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem 0.85rem;
}

.tag {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.themes.dash {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.vibe-wrap,
.motion-wrap,
.pin-wrap,
.zoom-wrap {
  position: relative;
  display: inline-flex;
}

.vibe-menu,
.motion-menu,
.pin-menu,
.zoom-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem;
  min-width: 9.5rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.85rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 40;
}

.vibe-menu button,
.motion-menu button,
.pin-menu button,
.zoom-menu button {
  width: 100%;
  text-align: left;
  border-radius: 0.65rem;
}

.top-reset {
  background: color-mix(in srgb, var(--accent) 18%, var(--btn));
}

/* —— Symbol lab panel —— */
.motion-panel {
  position: fixed;
  top: 4.1rem;
  right: 1rem;
  width: min(22rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 5.5rem);
  overflow: auto;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1.1rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.motion-panel-inner {
  padding: 0.95rem 1rem 1.1rem;
}

.motion-kicker {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.motion-label {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.motion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.motion-opt {
  border-radius: 0.7rem;
  padding: 0.32rem 0.62rem;
  font-size: 0.82rem;
}

.motion-speed-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.motion-speed-val {
  font-size: 0.78rem;
  color: var(--muted);
}

.motion-speed,
.colour-bar {
  width: 100%;
  accent-color: var(--accent);
}

.colour-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.colour-bar-swatch {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  flex: 0 0 auto;
}

.motion-hint {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.motion-hint a {
  color: var(--accent);
}

.motion-reset {
  margin-top: 0.75rem;
  width: 100%;
}

.motion-reset-danger {
  background: color-mix(in srgb, var(--accent) 22%, var(--btn));
}

.motion-sandbox {
  margin-top: 0.4rem;
  width: 100%;
}

/* —— Stage / sigil —— */
.landing {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
}

.mark {
  --mark-zoom: 1;
  position: relative;
  width: min(92vw, 92vh * (var(--vb-w) / var(--vb-h)));
  height: min(82vh, 92vw * (var(--vb-h) / var(--vb-w)));
  transform: scale(var(--mark-zoom));
  transform-origin: center center;
  transition: filter 320ms ease;
}

.mark-host,
.mark-host svg.sigil,
.hits {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mark-host svg.sigil {
  filter: var(--sigil-filter);
  overflow: visible;
}

html[data-line-any="on"] .mark-host svg.sigil {
  filter: none;
}

.sigil-fallback {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: var(--fallback-filter);
  display: block;
}

.mark-host svg.sigil .sym,
.mark-host svg.sigil .center,
.mark-host svg.sigil .sym-slot {
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform, filter, opacity;
}

.mark-host svg.sigil .sym.is-selected,
.mark-host svg.sigil .center.is-selected {
  outline: none;
}

.mark-host svg.sigil .sym.is-selected::after {
  /* SVG can't ::after — selection via aura/filter in JS */
}

.sym-shape-hit {
  fill: transparent !important;
  stroke: transparent !important;
  pointer-events: stroke;
  cursor: pointer;
}

.sym-shape-hit[data-hit-fill="1"] {
  pointer-events: all;
}

.sym-aura {
  stroke-width: 3.2;
  stroke-dasharray: 7 9;
  opacity: 0.9;
  animation: aura-spin 7s linear infinite;
}

@keyframes aura-spin {
  to {
    stroke-dashoffset: -64;
  }
}

.hits {
  pointer-events: none;
  z-index: 2;
}

.hits .hotspot {
  pointer-events: none;
}

.hits .hit {
  fill: transparent;
  stroke: transparent;
}

.hits .hit-label {
  fill: transparent;
  font-size: 0.01px;
}

html[data-pin="on"] .mark-host svg.sigil .sym,
html[data-pin="on"] .mark-host svg.sigil .center {
  cursor: grab;
  touch-action: none;
}

html[data-pin="on"] .mark-host svg.sigil .sym:active,
html[data-pin="on"] .mark-host svg.sigil .center:active {
  cursor: grabbing;
}

html[data-cloud-orbit="on"] .mark::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent);
  pointer-events: none;
  opacity: 0.55;
  animation: ring-breathe 4.5s ease-in-out infinite;
}

@keyframes ring-breathe {
  0%,
  100% {
    transform: scale(0.98);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.02);
    opacity: 0.65;
  }
}

/* Vibe neon on whole mark */
[data-theme="vibe"] .mark.is-ready,
[data-theme="vibe-dark"] .mark.is-ready,
[data-theme="vibe-light"] .mark.is-ready {
  animation: vibe-glow 9s linear infinite;
}

@keyframes vibe-glow {
  0% {
    filter: drop-shadow(0 0 10px hsl(0, 95%, 58%)) drop-shadow(0 0 28px hsl(20, 90%, 50%));
  }
  20% {
    filter: drop-shadow(0 0 10px hsl(70, 95%, 52%)) drop-shadow(0 0 28px hsl(100, 90%, 48%));
  }
  40% {
    filter: drop-shadow(0 0 10px hsl(160, 95%, 52%)) drop-shadow(0 0 28px hsl(190, 90%, 50%));
  }
  60% {
    filter: drop-shadow(0 0 10px hsl(220, 95%, 58%)) drop-shadow(0 0 28px hsl(250, 90%, 55%));
  }
  80% {
    filter: drop-shadow(0 0 10px hsl(300, 95%, 58%)) drop-shadow(0 0 28px hsl(330, 90%, 55%));
  }
  100% {
    filter: drop-shadow(0 0 10px hsl(360, 95%, 58%)) drop-shadow(0 0 28px hsl(20, 90%, 50%));
  }
}

html[data-sandbox-frame="on"] .brand::after {
  content: " · PLAY";
  color: var(--accent);
  letter-spacing: 0.12em;
  font-size: 0.75em;
}

.hint {
  position: absolute;
  bottom: 0.4rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

.soon {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* —— Site bar / footer —— */
.site-bar {
  position: fixed;
  left: 1rem;
  bottom: 2.4rem;
  z-index: 15;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
}

.site-bar-link {
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--btn);
  font-size: 0.85rem;
}

.foot {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  z-index: 10;
}

.foot a {
  color: var(--fg);
  text-decoration: none;
}

.foot a:hover {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

html[data-zoom-mode="on"] .mark {
  cursor: ns-resize;
}

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

@media (max-width: 720px) {
  .tag {
    display: none;
  }
  .motion-panel {
    top: auto;
    bottom: 4.5rem;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-height: 45dvh;
  }
  .hint {
    display: none;
  }
}
