/*
 * PlexusVerse / GoHostie theme contract
 *
 * Semantic roles are shared by every product surface. PlexusVerse owns the
 * indigo/violet platform identity; GoHostie green is the customer-facing
 * accent. Consumers should use these roles instead of raw palette values.
 */
:root,
[data-theme="light"] {
  color-scheme: light;

  --pv-color-indigo: #5967e8;
  --pv-color-violet: #8859db;
  --gohostie-color-green: #138461;
  --gohostie-color-green-hover: #0d6f50;

  --hsn-color-brand: var(--pv-color-indigo);
  --hsn-color-brand-hover: #4653cb;
  --hsn-color-accent: var(--gohostie-color-green);
  --hsn-color-accent-hover: #0d6f50;
  --hsn-color-focus: #5967e8;
  --hsn-color-canvas: #f6f7fb;
  --hsn-color-canvas-subtle: #fbfbfe;
  --hsn-color-surface: #ffffff;
  --hsn-color-surface-elevated: #ffffff;
  --hsn-color-surface-muted: #eef1f7;
  --hsn-color-surface-translucent: rgb(255 255 255 / 90%);
  --hsn-color-border: #d7ddea;
  --hsn-color-border-strong: #aeb8cf;
  --hsn-color-text: #17213b;
  --hsn-color-text-muted: #5e6881;
  --hsn-color-text-subtle: #7a8398;
  --hsn-color-inverse-text: #ffffff;
  --hsn-color-code: #4653cb;
  --hsn-color-overlay: rgb(25 29 48 / 48%);
  --hsn-gradient-brand: linear-gradient(
    135deg,
    var(--pv-color-indigo),
    var(--pv-color-violet)
  );
  --hsn-gradient-canvas:
    radial-gradient(circle at 78% 3%, rgb(136 89 219 / 12%), transparent 30rem),
    radial-gradient(circle at 8% 20%, rgb(89 103 232 / 9%), transparent 25rem),
    var(--hsn-color-canvas);
  --hsn-shadow-sm: 0 8px 24px rgb(47 56 98 / 7%);
  --hsn-shadow-md: 0 18px 55px rgb(47 56 98 / 11%);

  --hsn-space-xs: 0.25rem;
  --hsn-space-sm: 0.5rem;
  --hsn-space-md: 1rem;
  --hsn-space-lg: 1.5rem;
  --hsn-space-xl: 2rem;
  --hsn-space-xxl: 3rem;

  --hsn-radius-sm: 0.25rem;
  --hsn-radius-md: 0.5rem;
  --hsn-radius-lg: 0.75rem;
  --hsn-radius-pill: 999px;

  --hsn-status-neutral-bg: #e2e8f0;
  --hsn-status-neutral-fg: #334155;
  --hsn-status-info-bg: #dbeafe;
  --hsn-status-info-fg: #1e3a8a;
  --hsn-status-success-bg: #dcfce7;
  --hsn-status-success-fg: #14532d;
  --hsn-status-warning-bg: #fef3c7;
  --hsn-status-warning-fg: #78350f;
  --hsn-status-danger-bg: #fee2e2;
  --hsn-status-danger-fg: #7f1d1d;

  --hsn-focus-ring: 0 0 0 3px rgb(89 103 232 / 30%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --pv-color-indigo: #929cff;
    --pv-color-violet: #b58aff;
    --gohostie-color-green: #65e6ae;
    --gohostie-color-green-hover: #8cf0c4;

    --hsn-color-brand: var(--pv-color-indigo);
    --hsn-color-brand-hover: #b1b8ff;
    --hsn-color-accent: var(--gohostie-color-green);
    --hsn-color-accent-hover: #8cf0c4;
    --hsn-color-focus: #9ea7ff;
    --hsn-color-canvas: #0e1018;
    --hsn-color-canvas-subtle: #121520;
    --hsn-color-surface: #181b26;
    --hsn-color-surface-elevated: #222634;
    --hsn-color-surface-muted: #202432;
    --hsn-color-surface-translucent: rgb(24 27 38 / 92%);
    --hsn-color-border: #3a4154;
    --hsn-color-border-strong: #596177;
    --hsn-color-text: #f4f6fb;
    --hsn-color-text-muted: #b7bed0;
    --hsn-color-text-subtle: #929aaf;
    --hsn-color-inverse-text: #10131d;
    --hsn-color-code: #b7bdff;
    --hsn-color-overlay: rgb(3 5 10 / 68%);
    --hsn-gradient-canvas:
      radial-gradient(circle at 78% 3%, rgb(136 89 219 / 18%), transparent 30rem),
      radial-gradient(circle at 8% 20%, rgb(89 103 232 / 14%), transparent 25rem),
      var(--hsn-color-canvas);
    --hsn-shadow-sm: 0 8px 24px rgb(0 0 0 / 24%);
    --hsn-shadow-md: 0 18px 55px rgb(0 0 0 / 34%);

    --hsn-status-neutral-bg: #303646;
    --hsn-status-neutral-fg: #e0e4ee;
    --hsn-status-info-bg: #242f61;
    --hsn-status-info-fg: #d8dcff;
    --hsn-status-success-bg: #143c31;
    --hsn-status-success-fg: #a8f3d2;
    --hsn-status-warning-bg: #493716;
    --hsn-status-warning-fg: #ffe2a0;
    --hsn-status-danger-bg: #4d252d;
    --hsn-status-danger-fg: #ffc4ca;

    --hsn-focus-ring: 0 0 0 3px rgb(158 167 255 / 38%);
  }
}

[data-theme="dark"] {
  color-scheme: dark;

  --pv-color-indigo: #929cff;
  --pv-color-violet: #b58aff;
  --gohostie-color-green: #65e6ae;
  --gohostie-color-green-hover: #8cf0c4;

  --hsn-color-brand: var(--pv-color-indigo);
  --hsn-color-brand-hover: #b1b8ff;
  --hsn-color-accent: var(--gohostie-color-green);
  --hsn-color-accent-hover: #8cf0c4;
  --hsn-color-focus: #9ea7ff;
  --hsn-color-canvas: #0e1018;
  --hsn-color-canvas-subtle: #121520;
  --hsn-color-surface: #181b26;
  --hsn-color-surface-elevated: #222634;
  --hsn-color-surface-muted: #202432;
  --hsn-color-surface-translucent: rgb(24 27 38 / 92%);
  --hsn-color-border: #3a4154;
  --hsn-color-border-strong: #596177;
  --hsn-color-text: #f4f6fb;
  --hsn-color-text-muted: #b7bed0;
  --hsn-color-text-subtle: #929aaf;
  --hsn-color-inverse-text: #10131d;
  --hsn-color-code: #b7bdff;
  --hsn-color-overlay: rgb(3 5 10 / 68%);
  --hsn-gradient-canvas:
    radial-gradient(circle at 78% 3%, rgb(136 89 219 / 18%), transparent 30rem),
    radial-gradient(circle at 8% 20%, rgb(89 103 232 / 14%), transparent 25rem),
    var(--hsn-color-canvas);
  --hsn-shadow-sm: 0 8px 24px rgb(0 0 0 / 24%);
  --hsn-shadow-md: 0 18px 55px rgb(0 0 0 / 34%);

  --hsn-status-neutral-bg: #303646;
  --hsn-status-neutral-fg: #e0e4ee;
  --hsn-status-info-bg: #242f61;
  --hsn-status-info-fg: #d8dcff;
  --hsn-status-success-bg: #143c31;
  --hsn-status-success-fg: #a8f3d2;
  --hsn-status-warning-bg: #493716;
  --hsn-status-warning-fg: #ffe2a0;
  --hsn-status-danger-bg: #4d252d;
  --hsn-status-danger-fg: #ffc4ca;

  --hsn-focus-ring: 0 0 0 3px rgb(158 167 255 / 38%);
}

/*
 * Brand mode is independent of colour mode. PlexusVerse uses indigo for
 * platform actions. GoHostie uses green for its customer and reseller
 * surfaces while retaining the shared semantic and accessibility contract.
 */
[data-brand="gohostie"] {
  --hsn-color-brand: var(--gohostie-color-green);
  --hsn-color-brand-hover: var(--gohostie-color-green-hover);
  --hsn-color-accent: var(--gohostie-color-green);
  --hsn-color-accent-hover: var(--gohostie-color-green-hover);
  --hsn-color-focus: var(--gohostie-color-green);
  --hsn-gradient-brand: linear-gradient(
    135deg,
    var(--gohostie-color-green),
    var(--pv-color-indigo)
  );
  --hsn-focus-ring: 0 0 0 3px color-mix(
    in srgb,
    var(--gohostie-color-green) 34%,
    transparent
  );
}

/*
 * Shared appearance selector. The preference controller mounts this only on
 * platform chrome that opts in with data-theme-controls="true".
 */
.hsn-theme-control {
  position: fixed;
  z-index: 1000;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.3rem;
  border: 1px solid var(--hsn-color-border);
  border-radius: var(--hsn-radius-pill);
  color: var(--hsn-color-text);
  background: var(--hsn-color-surface-translucent);
  box-shadow: var(--hsn-shadow-md);
  backdrop-filter: blur(16px);
}

.hsn-theme-control-label {
  padding-inline: 0.55rem 0.35rem;
  color: var(--hsn-color-text-muted);
  font: 700 0.72rem/1 ui-sans-serif, system-ui, sans-serif;
}

.hsn-theme-control button {
  min-width: 2.75rem;
  min-height: 2rem;
  margin: 0;
  border: 1px solid transparent;
  border-radius: var(--hsn-radius-pill);
  padding: 0.35rem 0.55rem;
  color: var(--hsn-color-text-muted);
  background: transparent;
  box-shadow: none;
  font: 750 0.7rem/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.hsn-theme-control button:hover {
  border-color: var(--hsn-color-border);
  color: var(--hsn-color-text);
  background: var(--hsn-color-surface-muted);
}

.hsn-theme-control button[aria-pressed="true"] {
  border-color: var(--hsn-color-brand);
  color: var(--hsn-color-inverse-text);
  background: var(--hsn-color-brand);
}

.hsn-theme-control button:focus-visible {
  outline: 2px solid var(--hsn-color-focus);
  outline-offset: 2px;
  box-shadow: var(--hsn-focus-ring);
}

@media (max-width: 480px) {
  .hsn-theme-control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

@media print {
  .hsn-theme-control {
    display: none;
  }
}
