/* Sakurai game-feel — shared by /renovation and /sandbox.
   Grab cursor, press squash, action pill, dual-contrast ripple,
   shutter flash, help sheet, 50% split detent, reduced motion. */

#rv-canvas,
#sandbox-canvas {
  cursor: grab;
  touch-action: none;
}

.is-grabbing {
  cursor: grabbing !important;
}

.is-grabbing #rv-canvas,
.is-grabbing #sandbox-canvas,
#rv-canvas.is-grabbing,
#sandbox-canvas.is-grabbing {
  cursor: grabbing !important;
}

/* #120 tactile squash: crisp press, short springy hover */
button,
[role="tab"],
[role="button"],
.rv-split-handle {
  transition:
    transform 90ms cubic-bezier(0.18, 0.84, 0.32, 1.08),
    filter 110ms ease,
    background-color 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

button:hover,
[role="tab"]:hover,
[role="button"]:hover {
  filter: brightness(1.045);
}

button:active,
[role="tab"]:active,
[role="button"]:active,
.gf-pressed {
  transform: scale(0.965);
}

/* #252 top-center action pill (clears topbar + /renovation viewbar + /sandbox compass cleanly) */
.gf-hud-pill {
  position: fixed;
  top: 108px;
  left: 50%;
  z-index: 1600;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 440px);
  margin: 0;
  padding: 6px 12px 6px 6px;
  pointer-events: none;
  color: var(--rv-text, #e8edf5);
  font: 600 13px/1.2 var(--rv-font, "Inter Variable", "Noto Sans SC Variable", "Segoe UI", sans-serif);
  letter-spacing: 0.01em;
  background: rgba(12, 16, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.96);
}

.gf-hud-pill.is-on {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: gf-pill-in 140ms cubic-bezier(0.16, 0.84, 0.28, 1.12) both;
}

.gf-hud-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  color: #06211e;
  background: linear-gradient(180deg, var(--rv-teal, #2dd4bf), #0f766e);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.72);
  font-size: 13px;
}

.gf-hud-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gf-hud-kbd,
.gf-help-card kbd {
  display: inline-flex;
  align-items: center;
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  color: #f8f1e4;
  background: rgba(255, 255, 255, 0.06);
  font: 650 11px/1.4 var(--rv-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}

@keyframes gf-pill-in {
  0% { opacity: 0; transform: translate(-50%, -8px) scale(0.94); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* #130 bright core + dark rim so the ring reads on day and night */
.gf-ripple {
  position: fixed;
  z-index: 1550;
  width: 18px;
  height: 18px;
  margin: 0;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 252, 245, 0.95);
  box-shadow:
    0 0 0 1.5px rgba(0, 0, 0, 0.78),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  transform: translate(-50%, -50%) scale(0.35);
  animation: gf-ripple 240ms cubic-bezier(0.16, 0.7, 0.2, 1) forwards;
}

.gf-ripple.is-gold {
  border-color: rgba(255, 214, 140, 0.98);
  box-shadow:
    0 0 0 1.5px rgba(40, 22, 0, 0.82),
    0 0 12px rgba(245, 158, 11, 0.45);
}

.gf-ripple.is-warn {
  border-color: rgba(255, 196, 186, 0.96);
  box-shadow:
    0 0 0 1.5px rgba(40, 0, 0, 0.8),
    0 0 12px rgba(248, 113, 113, 0.4);
}

@keyframes gf-ripple {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.35); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(8); }
}

/* #221 contrast flash: bright core, dark vignette, never a white wash */
.gf-flash {
  position: fixed;
  inset: 0;
  z-index: 1700;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 250, 240, 0.55) 0%, rgba(255, 244, 220, 0.16) 26%, rgba(255, 255, 255, 0) 48%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.42) 100%);
}

.gf-flash.is-on {
  animation: gf-flash 140ms ease-out both;
}

@keyframes gf-flash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

/* #227 help + #055 motion / sfx switches */
.gf-help-modal {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: grid;
  place-items: center;
  padding: 22px 16px;
}

.gf-help-modal[hidden] {
  display: none !important;
}

.gf-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 12, 0.52);
}

.gf-help-card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(84vh, 780px);
  overflow: auto;
  padding: 18px 18px 16px;
  color: var(--rv-text, #e8edf5);
  font-family: var(--rv-font, "Inter Variable", "Noto Sans SC Variable", "Segoe UI", sans-serif);
  background: rgba(14, 18, 28, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.gf-help-modal.is-open .gf-help-card {
  animation: gf-help-in 160ms cubic-bezier(0.16, 0.84, 0.3, 1) both;
}

@keyframes gf-help-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.gf-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.gf-help-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.gf-help-x {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: inherit;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.gf-help-lead,
.gf-help-foot {
  margin: 0 0 12px;
  color: var(--rv-dim, rgba(232, 237, 245, 0.62));
  font-size: 12.5px;
  line-height: 1.45;
}

.gf-help-foot {
  margin: 12px 0 0;
}

.gf-help-group {
  margin-top: 12px;
}

.gf-help-group h3 {
  margin: 0 0 8px;
  color: var(--rv-gold-2, #ffb347);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gf-help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.gf-help-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.4;
}

.gf-help-keys {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  flex: 0 0 auto;
}

.gf-help-plus {
  opacity: 0.45;
  font-size: 11px;
}

.gf-help-prefs {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.gf-pref {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  color: inherit;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
}

.gf-pref-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gf-pref-copy strong {
  font-size: 13px;
  font-weight: 680;
}

.gf-pref-copy small {
  color: var(--rv-dim, rgba(232, 237, 245, 0.62));
  font-size: 11.5px;
  line-height: 1.4;
}

.gf-switch {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.gf-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f4f1ea;
  transition: transform 120ms cubic-bezier(0.16, 0.84, 0.3, 1);
}

.gf-pref.is-on .gf-switch {
  background: #0f766e;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.85);
}

.gf-pref.is-on .gf-switch-knob {
  transform: translateX(20px);
}

.gf-help-card :focus-visible {
  outline: 2px solid var(--rv-teal, #2dd4bf);
  outline-offset: 2px;
}

/* 50% magnetic split detent */
.rv-split-handle.is-detent {
  border-color: var(--rv-teal, #2dd4bf);
  box-shadow:
    0 0 0 3px rgba(45, 212, 191, 0.45),
    0 0 0 8px rgba(245, 158, 11, 0.32),
    0 4px 20px rgba(0, 0, 0, 0.5);
  transform: scale(1.08);
  animation: gf-detent 280ms cubic-bezier(0.16, 0.84, 0.2, 1);
}

@keyframes gf-detent {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1.08); }
}

@media (max-width: 640px) {
  .gf-help-grid {
    grid-template-columns: 1fr;
  }
}

/* Reduced motion: kill travel and pulses, keep the on/off state readable. */
html.gf-reduced-motion *,
html.gf-reduced-motion *::before,
html.gf-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

html.gf-reduced-motion .gf-hud-pill,
html.gf-reduced-motion .gf-ripple,
html.gf-reduced-motion .gf-flash,
html.gf-reduced-motion .gf-help-card,
html.gf-reduced-motion .rv-split-handle.is-detent,
html.gf-reduced-motion .gf-switch-knob {
  animation: none !important;
  transition: none !important;
}

html.gf-reduced-motion .gf-hud-pill.is-on {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

html.gf-reduced-motion .gf-flash.is-on {
  opacity: 0.78;
}

html.gf-reduced-motion .gf-ripple {
  display: none !important;
}

html.gf-reduced-motion .rv-split-handle.is-detent {
  transform: none;
  box-shadow:
    0 0 0 3px rgba(45, 212, 191, 0.7),
    0 0 0 6px rgba(245, 158, 11, 0.55);
}

html.gf-reduced-motion .gf-pref.is-on .gf-switch-knob {
  transform: translateX(20px);
}

@media (prefers-reduced-motion: reduce) {
  html:not([data-gf-motion="full"]) *,
  html:not([data-gf-motion="full"]) *::before,
  html:not([data-gf-motion="full"]) *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html:not([data-gf-motion="full"]) .gf-hud-pill,
  html:not([data-gf-motion="full"]) .gf-ripple,
  html:not([data-gf-motion="full"]) .gf-flash,
  html:not([data-gf-motion="full"]) .gf-help-card,
  html:not([data-gf-motion="full"]) .rv-split-handle.is-detent,
  html:not([data-gf-motion="full"]) .gf-switch-knob {
    animation: none !important;
    transition: none !important;
  }

  html:not([data-gf-motion="full"]) .gf-hud-pill.is-on {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  html:not([data-gf-motion="full"]) .gf-flash.is-on {
    opacity: 0.78;
  }

  html:not([data-gf-motion="full"]) .gf-ripple {
    display: none !important;
  }

  html:not([data-gf-motion="full"]) .rv-split-handle.is-detent {
    transform: none;
    box-shadow:
      0 0 0 3px rgba(45, 212, 191, 0.7),
      0 0 0 6px rgba(245, 158, 11, 0.55);
  }

  html:not([data-gf-motion="full"]) .gf-pref.is-on .gf-switch-knob {
    transform: translateX(20px);
  }
}
