/* Icon ring + center focus dock (KW Organizer modules) */

.organizer-constellation {
  position: relative;
  margin-top: 0;
  --orbit-radius-y: 41%;
  --orbit-spoke-trim: 1.75rem; /* icon radius — outer end stops at node edge */
  background: transparent;
  overflow: visible;
}

.organizer-constellation__layout,
.organizer-constellation__ring,
.organizer-constellation__orbit {
  background: transparent;
  overflow: visible;
}

/* Less dead space between filter pills and the orbit */
.apps--organizer .section-panel__inner {
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

.apps--organizer .categories--inline + .organizer-constellation {
  margin-top: 0;
}

/* Inline filters sit flush — responsive section rhythm must not re-add padding */
#apps .categories.categories--inline {
  padding-block: 0;
  margin-block: 0;
}

.organizer-constellation__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.55;
  z-index: 0;
}

.organizer-constellation__layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.organizer-constellation__ring {
  position: relative;
  width: 100%;
  max-width: min(100%, 1120px);
  min-height: 280px;
  margin-inline: auto;
}

/* Center hub: copy floats on the orbit — no card chrome; keep below spoke lines */
.organizer-constellation__dock {
  width: auto;
  max-width: min(88%, 22rem);
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  pointer-events: none;
  transition: transform var(--dur-base) var(--ease-out);
}

.organizer-constellation__dock--active {
  box-shadow: none;
}

.organizer-constellation__dock--drop-target {
  transform: scale(1.03);
}

.organizer-constellation__dock-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.organizer-constellation__dock--active .organizer-constellation__dock-hint {
  display: none;
}

.organizer-constellation__dock--drop-target .organizer-constellation__detail-inner {
  filter: drop-shadow(0 0 18px rgba(124, 58, 237, 0.35));
}

.organizer-constellation__detail[hidden] {
  display: none;
}

.organizer-constellation__detail-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  pointer-events: auto;
  animation: constellation-detail-in 0.22s var(--ease-out);
}

@keyframes constellation-detail-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.organizer-constellation__detail-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(
    145deg,
    var(--node-accent-from, #7c3aed),
    var(--node-accent-to, #22d3ee)
  );
  box-shadow: 0 10px 28px var(--node-accent-glow, rgba(124, 58, 237, 0.35));
}

.organizer-constellation__detail-icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
}

.organizer-constellation__detail-badge {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent-end);
}

.organizer-constellation__detail-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
  color: var(--color-text-primary);
}

.organizer-constellation__detail-desc {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  max-width: 36ch;
  line-height: 1.45;
}

.organizer-constellation__detail-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--color-text-subtle);
}

.organizer-constellation__detail-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.75rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.organizer-constellation__detail-meta span:last-child {
  color: var(--color-accent-end);
  font-weight: 600;
}

.organizer-constellation__detail-link {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent-end);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.organizer-constellation__detail-link:hover,
.organizer-constellation__detail-link:focus-visible {
  color: var(--color-text-primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.organizer-constellation__empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem 1rem;
}

/* Icon nodes */
.module-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: grab;
  background: linear-gradient(
    145deg,
    var(--node-accent-from, rgba(124, 58, 237, 0.95)),
    var(--node-accent-to, rgba(34, 211, 238, 0.75))
  );
  box-shadow:
    0 8px 24px var(--node-accent-glow, rgba(124, 58, 237, 0.35)),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  z-index: 2;
  transition:
    opacity var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    filter var(--dur-base) var(--ease-out),
    outline-color var(--dur-base) var(--ease-out);
  touch-action: none;
  pointer-events: auto;
}

/* Scroll-reveal must not override orbit anchoring */
.organizer-constellation__ring .module-node.reveal,
.organizer-constellation__ring .module-node.reveal.is-visible {
  transform: translate(-50%, -50%);
  opacity: 1;
}

.module-node:active {
  cursor: grabbing;
}

.module-node__icon svg {
  width: 1.35rem;
  height: 1.35rem;
  color: #fff;
}

.module-node__label {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  font-size: 0.65rem;
  white-space: nowrap;
  color: var(--color-text-muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.module-node:hover .module-node__label,
.module-node:focus-visible .module-node__label,
.module-node--active .module-node__label {
  opacity: 1;
}

.module-node:hover,
.module-node:focus-visible,
.module-node--active {
  z-index: 10;
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 32px var(--node-accent-glow, rgba(34, 211, 238, 0.45));
  filter: brightness(1.08);
}

.module-node--active {
  outline: 2px solid var(--node-accent-to, var(--color-accent-end));
  outline-offset: 3px;
}

.module-node.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.6);
  filter: blur(3px);
}

.module-node--dragging {
  opacity: 0.35;
  transform: translate(-50%, -50%) scale(0.9);
}

.module-node__drag-ghost {
  position: fixed;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: linear-gradient(
    145deg,
    var(--node-accent-from, #7c3aed),
    var(--node-accent-to, #22d3ee)
  );
  box-shadow: 0 16px 40px var(--node-accent-glow, rgba(124, 58, 237, 0.5));
  transform: translate(-50%, -50%);
}

.module-node__drag-ghost svg {
  width: 1.5rem;
  height: 1.5rem;
  color: #fff;
}

/* Mobile: horizontal icon rail + dock */
@media (max-width: 900px) {
  #apps .categories--inline .category-pills {
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }

  #apps .categories--inline .category-pills::-webkit-scrollbar {
    display: none;
  }

  .organizer-constellation__layout {
    gap: 1rem;
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  #organizer-modules {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .organizer-constellation__ring {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.65rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding: 0.35rem 0 0.5rem;
    min-height: auto;
    width: 100%;
    max-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-inline: calc(-1 * var(--space-page-x));
    padding-inline: max(var(--space-page-x), env(safe-area-inset-left, 0px))
      max(var(--space-page-x), env(safe-area-inset-right, 0px));
    -webkit-mask-image: linear-gradient(
      to right,
      transparent 0%,
      #000 10%,
      #000 90%,
      transparent 100%
    );
    mask-image: linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
  }

  .organizer-constellation__ring::-webkit-scrollbar {
    display: none;
  }

  .organizer-constellation__ring .module-node {
    touch-action: pan-x;
    cursor: pointer;
  }

  .module-node {
    position: relative;
    left: auto !important;
    top: auto !important;
    transform: none;
    flex: 0 0 auto;
    scroll-snap-align: center;
    animation: none;
    width: auto;
    min-width: 4.75rem;
    height: auto;
    min-height: 4.75rem;
    padding: 0.7rem 0.55rem 0.5rem;
    border-radius: 18px;
    flex-direction: column;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .module-node:active {
    cursor: pointer;
  }

  .module-node:hover,
  .module-node:focus-visible,
  .module-node--active {
    transform: none;
    filter: brightness(1.08);
  }

  .module-node--active {
    outline: 2px solid var(--node-accent-to, var(--color-accent-end));
    outline-offset: 2px;
    box-shadow:
      0 10px 28px var(--node-accent-glow, rgba(34, 211, 238, 0.35)),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }

  .module-node.is-hidden {
    display: none;
  }

  .module-node__icon svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  .module-node__label {
    opacity: 1;
    position: static;
    transform: none;
    display: block;
    margin-top: 0;
    font-size: 0.62rem;
    letter-spacing: 0.02em;
    color: var(--color-text-primary);
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .organizer-constellation__dock {
    width: 100%;
    max-width: none;
    padding: 0;
    background: transparent;
    pointer-events: auto;
  }

  .organizer-constellation__detail {
    width: 100%;
  }

  .organizer-constellation__detail-inner {
    width: 100%;
    padding: 1rem 0.95rem 0.9rem;
    gap: 0.4rem;
    border-radius: 16px;
    border: 1px solid rgba(124, 58, 237, 0.28);
    background: linear-gradient(
      165deg,
      rgba(14, 16, 24, 0.94) 0%,
      rgba(26, 20, 40, 0.88) 100%
    );
    box-shadow:
      0 10px 32px rgba(0, 0, 0, 0.32),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .organizer-constellation__dock--active .organizer-constellation__detail-inner {
    border-color: color-mix(in srgb, var(--node-accent-from, #7c3aed) 55%, transparent);
    box-shadow:
      0 12px 36px rgba(0, 0, 0, 0.38),
      0 0 0 1px color-mix(in srgb, var(--node-accent-to, #22d3ee) 25%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  .organizer-constellation__detail-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.1rem;
  }

  .organizer-constellation__detail-icon svg {
    width: 24px;
    height: 24px;
  }

  .organizer-constellation__detail-title {
    font-size: 1.2rem;
  }

  .organizer-constellation__detail-desc {
    font-size: 0.85rem;
    max-width: none;
    line-height: 1.4;
  }

  .organizer-constellation__detail-meta {
    margin-top: 0.2rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    width: 100%;
  }

  .organizer-constellation__detail-link {
    margin-top: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
    border: 1px solid rgba(34, 211, 238, 0.28);
    background: rgba(34, 211, 238, 0.08);
    text-decoration: none;
  }

  .organizer-constellation__detail-link:hover,
  .organizer-constellation__detail-link:focus-visible {
    text-decoration: none;
    background: rgba(34, 211, 238, 0.14);
  }

  .organizer-constellation__dock--active {
    box-shadow: none;
  }

  .organizer-constellation__canvas {
    display: none;
  }

  .organizer-constellation__orbit {
    display: none;
  }
}

@media (min-width: 901px) {
  .organizer-constellation__ring {
    min-height: min(52vh, 520px);
    aspect-ratio: 1.12 / 1;
    max-height: 640px;
  }

  .organizer-constellation__layout {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .organizer-constellation__dock {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    width: auto;
    max-width: min(88%, 22rem);
  }

  .organizer-constellation__dock-hint {
    position: relative;
    z-index: 2;
    pointer-events: none;
  }

  .organizer-constellation__dock--drop-target {
    transform: translate(-50%, -50%) scale(1.03);
  }

  .organizer-constellation__detail-inner {
    position: relative;
    isolation: isolate;
    padding: 1rem 1.5rem 0.85rem;
  }

  .organizer-constellation__detail-inner::before {
    content: "";
    position: absolute;
    inset: -0.85rem -1.5rem;
    border-radius: 50%;
    background: radial-gradient(
      ellipse 88% 92% at 50% 50%,
      rgba(8, 10, 18, 0.9) 0%,
      rgba(8, 10, 18, 0.72) 40%,
      rgba(8, 10, 18, 0.28) 68%,
      transparent 78%
    );
    box-shadow: 0 0 52px 32px rgba(0, 0, 0, 0.48);
    z-index: -1;
    pointer-events: none;
  }

  .organizer-constellation__orbit {
    position: absolute;
    inset: 0;
    animation: constellation-orbit 360s linear infinite;
  }

  .organizer-constellation__arm {
    position: absolute;
    inset: 0;
    transform: rotate(var(--orbit-angle, 0deg));
    transform-origin: 50% 50%;
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out);
  }

  .organizer-constellation__arm:has(.module-node.is-hidden) {
    opacity: 0;
    pointer-events: none;
  }

  .organizer-constellation__spoke {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1.5px;
    height: var(--orbit-radius-y);
    transform: translate(-50%, -100%);
    transform-origin: 50% 100%;
    border-radius: 1px;
    background: linear-gradient(
      to top,
      var(--spoke-accent-end, rgba(34, 211, 238, 0.85)) 0%,
      var(--spoke-accent-mid, rgba(124, 58, 237, 0.55)) 42%,
      var(--spoke-accent-base, rgba(124, 58, 237, 0.15)) 78%,
      transparent 100%
    );
    background-size: 100% 100%;
    box-shadow: 0 0 10px var(--node-accent-glow, rgba(34, 211, 238, 0.15));
    animation: spoke-flow 3.5s ease-in-out infinite;
    animation-delay: var(--spoke-delay, 0s);
    pointer-events: none;
    z-index: 2;
  }

  .organizer-constellation__arm .module-node {
    left: 50%;
    top: calc(50% - var(--orbit-radius-y));
    z-index: 4;
  }

  .module-node__label {
    display: none;
  }
}

@keyframes constellation-orbit {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spoke-flow {
  0%,
  100% {
    background-position: 0 100%;
    opacity: 0.55;
    filter: brightness(0.95);
  }
  50% {
    background-position: 0 0%;
    opacity: 1;
    filter: brightness(1.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .organizer-constellation__orbit {
    animation: none !important;
  }

  .organizer-constellation__spoke {
    animation: none !important;
    opacity: 0.55;
  }

  .module-node {
    animation: none !important;
  }

  .organizer-constellation__dock--drop-target {
    transform: translate(-50%, -50%);
  }

  .organizer-constellation__detail-inner {
    animation: none;
  }
}
