/* ------------------------------------------------------------------
   Scene: Excel sheets orbit one system in 3D (Three.js canvas), with
   DOM labels laid over it. Neutrals plus one accent; red is reserved
   for the "wrong" mark. Labels animate with transform and opacity only.
------------------------------------------------------------------- */

:root {
  --color-danger: #b8332a;
  --color-danger-soft: rgba(184, 51, 42, 0.1);
}

:root[data-theme="dark"] {
  --color-danger: #ff7a6e;
  --color-danger-soft: rgba(255, 122, 110, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-danger: #ff7a6e;
    --color-danger-soft: rgba(255, 122, 110, 0.14);
  }
}

/* .snap-section is a centred flex column; without this the container
   shrinks to its content width instead of filling the page. */
.snap-section:not(.hero) > .container { width: 100%; }

/* The scene is taller than one screen on laptops; let it scroll normally. */
#services.snap-section { scroll-snap-stop: normal; }

/* the section is one full screen: heading, then the stage edge to edge */
#services.snap-section { padding: 28px 0 0; justify-content: flex-start; }
#services .section-subtitle { margin-bottom: 20px; }
#services > .container { flex: none; }

.scene { margin-top: 0; }

/* ---------- stage: always deep space, whatever the page theme ---------- */

.scene-stage {
  --space: #05060f;
  --ink: #f2f5ff;
  --ink-dim: #a9b4d6;
  --edge: rgba(150, 170, 255, 0.28);
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: max(600px, calc(100svh - 150px));
  color: var(--ink);
  /* feather the top and bottom so deep space melts into the page */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 56px, #000 calc(100% - 56px), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 56px, #000 calc(100% - 56px), transparent 100%);
  background:
    radial-gradient(ellipse 60% 55% at 22% 30%, rgba(124, 58, 237, 0.30), transparent 70%),
    radial-gradient(ellipse 55% 50% at 80% 70%, rgba(14, 165, 233, 0.26), transparent 70%),
    radial-gradient(ellipse 40% 40% at 60% 12%, rgba(236, 72, 153, 0.16), transparent 70%),
    radial-gradient(ellipse 80% 80% at 50% 50%, #0b1030 0%, var(--space) 75%);
  overflow: hidden;
}

.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.scene-canvas:active { cursor: grabbing; }

.orb-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* status line and replay: big enough to read from across the room */
.scene-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 44px clamp(16px, 4vw, 48px) 0;
  pointer-events: none;
}

.scene-status {
  margin: 0;
  max-width: 46ch;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  font-weight: 600;
  line-height: 1.4;
  text-shadow: 0 2px 16px rgba(5, 6, 15, 0.9);
  text-wrap: balance;
}

.scene-replay {
  flex: none;
  pointer-events: auto;
  padding: 10px 20px;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--edge);
  border-radius: 999px;
}

.scene-replay:hover { background: rgba(255, 255, 255, 0.16); }

.scene-hint {
  position: absolute;
  right: clamp(16px, 4vw, 48px);
  bottom: 52px;
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.875rem;
  pointer-events: none;
}

/* ---------- labels: sit on top of each sheet ---------- */

.orb {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px 7px 8px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: rgba(10, 14, 36, 0.82);
  border: 1px solid var(--edge);
  border-radius: 10px;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.orb:hover,
.orb:focus-visible { border-color: #fff; background: rgba(20, 26, 60, 0.95); }

.orb.is-selected { border-color: var(--hue, #7aa2ff); box-shadow: 0 0 0 1px var(--hue, #7aa2ff); }

.orb:focus-visible,
.orb-core:focus-visible,
.scene-replay:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* the wrong mark, stamped on each sheet */
.orb-x {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #ff6b5e;
  background: rgba(255, 107, 94, 0.16);
  border: 2px solid #ff6b5e;
  border-radius: 8px;
  opacity: 0;
  transform: scale(1.9) rotate(-14deg);
  transition: transform 0.28s cubic-bezier(0.22, 0.8, 0.24, 1), opacity 0.18s ease;
}

.orb-x svg { width: 14px; height: 14px; }

.orb.is-stamped .orb-x {
  opacity: 1;
  transform: scale(1) rotate(-6deg);
}

.orb-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.orb-text strong {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.orb-text small {
  color: var(--ink-dim);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.3;
}

/* while still a pile a sheet shows its file name; once in orbit, only the title */
.orb-text small { display: none; }
.scene[data-state="chaos"] .orb:not(.orb-feat) .orb-text strong { display: none; }
.scene[data-state="chaos"] .orb:not(.orb-feat) .orb-text small { display: block; color: var(--ink); font-size: 1rem; }

.orb-card b {
  display: block;
  margin-bottom: 6px;
  color: var(--hue, #9fb4ff);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 500;
}

/* detail card, only on hover or keyboard focus */
.orb-card {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  width: 340px;
  padding: 14px 16px;
  color: #fff;
  font-size: 1rem;
  line-height: 1.6;
  white-space: normal;
  background: #0a0e24;
  border: 1px solid rgba(190, 205, 255, 0.55);
  border-radius: 10px;
  box-shadow: 0 0 0 4px rgba(5, 6, 15, 0.7), 0 16px 40px rgba(0, 0, 0, 0.7);
  transform: translateX(-50%);
}

.orb.is-low .orb-card { top: auto; bottom: calc(100% + 10px); }
.orb.is-edge-l .orb-card { left: 0; transform: none; }
.orb.is-edge-r .orb-card { left: auto; right: 0; transform: none; }

.orb:hover .orb-card,
.orb:focus-visible .orb-card { display: block; }

.scene[data-state="chaos"] .orb-card,
.scene[data-state="merging"] .orb-card { display: none !important; }

/* feature tags around the enlarged core */
.orb-feat {
  padding: 8px 18px;
  border-radius: 999px;
  border-color: var(--hue, var(--edge));
}

.orb-feat .orb-x { display: none; }

.orb-feat.is-selected {
  color: #05060f;
  background: var(--hue, #7aa2ff);
}

.orb-feat.is-selected .orb-card { color: #fff; }

/* the core's click target */
.orb-core {
  --r: 40px;
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  padding: 0;
  display: block;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
}

.orb-core:disabled { cursor: default; }

.orb-core-name {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  padding: 4px 16px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(10, 14, 36, 0.82);
  border: 1px solid var(--edge);
  border-radius: 999px;
}

/* zoomed in: the name moves inside the enlarged core */
.scene[data-state="core"] .orb-core-name {
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  color: #fff;
  font-size: 1.6rem;
  background: transparent;
  border: 0;
}

/* WebGL not available */
.scene[data-fallback="true"] .scene-stage::after {
  content: "3D is not available in this browser.";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-dim);
}

/* ---------- detail panel, glass over the bottom of the stage ---------- */

.scene-detail {
  position: absolute;
  left: 50%;
  bottom: 48px;
  z-index: 1500;
  width: min(760px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 14px 22px;
  text-align: center;
  background: rgba(8, 11, 30, 0.78);
  border: 1px solid var(--edge);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

.scene-detail[data-kind="hint"]:has(.scene-detail-text:empty) { display: none; }

.scene-detail-title {
  margin: 0 0 4px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
}

.scene-detail-title:empty { display: none; }

.scene-detail-text {
  margin: 0;
  color: var(--ink);
  font-size: 1.125rem;
  line-height: 1.55;
}

/* ---------- services list (kept from the old carousel, now plain) ---------- */

.offers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.offer {
  padding: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
}

.offer h3 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.45;
  text-wrap: balance;
}

.offer details { border-top: 1px solid var(--color-border); }

.offer summary {
  padding: 12px 0;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.offer summary::-webkit-details-marker { display: none; }

.offer summary::after {
  content: "+";
  flex: none;
  color: var(--color-text-muted);
  font-weight: 400;
}

.offer details[open] summary::after { content: "\2212"; }

.offer details p {
  margin: 0 0 12px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ---------- theme toggle ---------- */

.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .scene-stage { height: max(560px, calc(100svh - 130px)); }
  .orb-card { width: 260px; font-size: 0.9375rem; }
  .orb { padding: 5px 12px 5px 6px; gap: 8px; }
  .orb-text strong { font-size: 0.9375rem; }
  .orb-x { width: 22px; height: 22px; }
  .scene:not([data-state="chaos"]) .orb-x { display: none; }
  .scene-detail { bottom: 40px; padding: 10px 14px; }
  .scene-detail-text, .scene-detail-title { font-size: 1rem; }
  .scene-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .orb-x { transition: none; }
}
