/* Hux Studio theme controls v120: shadcn-like neutrals with Hux red interaction states. */

:root {
  --hux-theme-rest-surface: #18181a;
  --hux-theme-rest-border: #3f3f43;
  --hux-theme-rest-icon: #e4e4e7;
  --hux-favorite-rest-surface: #111113;
  --hux-favorite-rest-border: #3f3f43;
  --hux-favorite-rest-icon: #d4d4d8;
  --hux-control-shadow: 0 1px 2px rgb(0 0 0 / 18%);
}

html[data-theme="light"] {
  --background: #f5f5f6;
  --foreground: #18181b;
  --card: #ffffff;
  --card-foreground: #18181b;
  --secondary: #f4f4f5;
  --secondary-foreground: #27272a;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #dedee2;
  --border-strong: #d4d4d8;
  --brand: #df3f43;
  --brand-strong: #c93035;
  --ring: #df3f43;
  --hux-theme-rest-surface: #f4f4f5;
  --hux-theme-rest-border: #d4d4d8;
  --hux-theme-rest-icon: #27272a;
  --hux-favorite-rest-surface: #ffffff;
  --hux-favorite-rest-border: #d4d4d8;
  --hux-favorite-rest-icon: #52525b;
  --hux-control-shadow: 0 1px 2px rgb(0 0 0 / 6%);
}

.theme-toggle {
  position: relative;
  isolation: isolate;
  overflow: visible;
}

.theme-toggle-icon {
  --ui-icon: url("./assets/icons/untitledui/sun.svg");
  position: relative;
  z-index: 1;
  width: 18px !important;
  height: 18px !important;
  color: var(--hux-theme-rest-icon);
}

html[data-theme="light"] .theme-toggle-icon {
  --ui-icon: url("./assets/icons/untitledui/moon-01.svg");
}

html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global {
  width: 64px;
  min-width: 64px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent !important;
  color: var(--hux-theme-rest-icon);
  box-shadow: none !important;
}

html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global::before {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 40px;
  height: 40px;
  border: 1px solid var(--hux-theme-rest-border);
  background: var(--hux-theme-rest-surface);
  box-shadow: var(--hux-control-shadow);
  content: "";
  transform: translate(-50%, -50%);
  transition:
    border-color 140ms ease,
    background-color 140ms cubic-bezier(0.33, 1, 0.68, 1),
    box-shadow 140ms ease;
}

html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global:is(:hover, :focus-visible) {
  border-left-color: var(--border) !important;
  background: transparent !important;
  color: var(--hux-interactive-inverse-text) !important;
  box-shadow: none !important;
}

html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global:is(:hover, :focus-visible)::before {
  border-color: var(--hux-interactive-border);
  background: var(--hux-interactive-inverse-surface);
  box-shadow: none;
}

html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global:is(:hover, :focus-visible) .theme-toggle-icon {
  color: var(--hux-interactive-inverse-text) !important;
}

html[data-theme] .auth-gate .theme-toggle.auth-gate-theme-toggle,
html[data-theme] .workspace-actions > .theme-toggle.theme-toggle-mobile {
  border-color: var(--hux-theme-rest-border) !important;
  background: var(--hux-theme-rest-surface) !important;
  color: var(--hux-theme-rest-icon) !important;
  box-shadow: var(--hux-control-shadow) !important;
}

html[data-theme] .auth-gate .theme-toggle.auth-gate-theme-toggle:is(:hover, :focus-visible),
html[data-theme] .workspace-actions > .theme-toggle.theme-toggle-mobile:is(:hover, :focus-visible) {
  border-color: var(--hux-interactive-border) !important;
  background: var(--hux-interactive-inverse-surface) !important;
  color: var(--hux-interactive-inverse-text) !important;
  box-shadow: none !important;
}

html[data-theme] .auth-gate .theme-toggle.auth-gate-theme-toggle:is(:hover, :focus-visible) :is(.theme-toggle-icon, [data-theme-label]),
html[data-theme] .workspace-actions > .theme-toggle.theme-toggle-mobile:is(:hover, :focus-visible) :is(.theme-toggle-icon, [data-theme-label]) {
  color: var(--hux-interactive-inverse-text) !important;
}

/* Card hover alone keeps the favorite control at rest. */
#asset-grid .skill-card > .favorite-btn:not(.active):not([aria-pressed="true"]),
#asset-grid .skill-card:hover > .favorite-btn:not(.active):not([aria-pressed="true"]),
#asset-grid .skill-card:focus-within > .favorite-btn:not(.active):not([aria-pressed="true"]) {
  border: 1px solid var(--hux-favorite-rest-border) !important;
  background: var(--hux-favorite-rest-surface) !important;
  color: var(--hux-favorite-rest-icon) !important;
  box-shadow: var(--hux-control-shadow) !important;
  transform: none !important;
}

/* Direct hover makes the action explicit; selection is communicated by the filled star. */
#asset-grid .skill-card > .favorite-btn:not(.active):not([aria-pressed="true"]):is(:hover, :focus-visible) {
  border-color: var(--hux-interactive-border) !important;
  background: var(--hux-interactive-inverse-surface) !important;
  color: var(--hux-interactive-inverse-text) !important;
  box-shadow: none !important;
}

#asset-grid .skill-card > .favorite-btn:not(.active):not([aria-pressed="true"]):is(:hover, :focus-visible) .ui-icon {
  color: var(--hux-interactive-inverse-text) !important;
  transform: none !important;
}

#asset-grid .skill-card > .favorite-btn.active,
#asset-grid .skill-card > .favorite-btn[aria-pressed="true"] {
  border-color: var(--brand) !important;
  background: var(--brand) !important;
  color: #ffffff !important;
  box-shadow: 0 1px 2px rgb(223 63 67 / 20%) !important;
}

#asset-grid .skill-card > .favorite-btn.active:is(:hover, :focus-visible),
#asset-grid .skill-card > .favorite-btn[aria-pressed="true"]:is(:hover, :focus-visible) {
  border-color: var(--brand-strong) !important;
  background: var(--brand-strong) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgb(201 48 53 / 22%) !important;
}

#asset-grid .skill-card > .favorite-btn.active .ui-icon,
#asset-grid .skill-card > .favorite-btn[aria-pressed="true"] .ui-icon {
  color: #ffffff !important;
  transform: none !important;
}

@media (max-width: 1020px) and (min-width: 721px) {
  html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global {
    width: 58px;
    min-width: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme] .topbar > .sidebar-footer > .theme-toggle.theme-toggle-global::before,
  .theme-toggle-icon,
  #asset-grid .skill-card > .favorite-btn {
    transition-duration: 0.01ms !important;
  }
}
