/*
 * SidelineWorks canonical design foundation.
 *
 * Approved palette values come from docs/SIDELINEWORKS_UX_UI_OVERHAUL_SPEC.md.
 * Derived foreground and interaction values are operational accessibility
 * tokens; they are not additions to the approved brand palette.
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/Inter-roman-latin-ext-variable.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/Inter-roman-latin-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/SpaceGrotesk-roman-latin-ext-variable.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/SpaceGrotesk-roman-latin-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html:root {
  /* Approved brand colors. These do not change with the surface theme. */
  --slw-color-signal: #00E6C3;
  --slw-color-support: #10BFA6;
  --slw-color-violet: #7C8CFF;

  /* Approved participation status colors. */
  --slw-color-status-cleared: #22C55E;
  --slw-color-status-restricted: #F59E0B;
  --slw-color-status-out: #EF4444;

  /* Approved role accents. */
  --slw-color-role-at: #00E6C3;
  --slw-color-role-coach: #FFB020;
  --slw-color-role-parent: #A970FF;
  --slw-color-role-ad: #4D8DFF;
  --slw-color-role-account: #7C8CFF;

  /*
   * Accessible text on approved filled semantic colors. #070A14 reaches at
   * least WCAG AA contrast against every approved status and role accent.
   */
  --slw-color-ink-on-bright: #070A14;
  --slw-color-on-signal: var(--slw-color-ink-on-bright);
  --slw-color-on-support: var(--slw-color-ink-on-bright);
  --slw-color-on-violet: var(--slw-color-ink-on-bright);
  --slw-color-on-status-cleared: var(--slw-color-ink-on-bright);
  --slw-color-on-status-restricted: var(--slw-color-ink-on-bright);
  --slw-color-on-status-out: var(--slw-color-ink-on-bright);
  --slw-color-on-role-at: var(--slw-color-ink-on-bright);
  --slw-color-on-role-coach: var(--slw-color-ink-on-bright);
  --slw-color-on-role-parent: var(--slw-color-ink-on-bright);
  --slw-color-on-role-ad: var(--slw-color-ink-on-bright);
  --slw-color-on-role-account: var(--slw-color-ink-on-bright);

  /* Canonical type families. */
  --slw-font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;
  --slw-font-heading: "Space Grotesk", "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --slw-font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono",
    Consolas, monospace;

  /*
   * Operational motion scale. These are interaction defaults, not approved
   * brand palette or geometry values.
   */
  --slw-motion-duration-instant: 80ms;
  --slw-motion-duration-fast: 160ms;
  --slw-motion-duration-standard: 240ms;
  --slw-motion-duration-slow: 360ms;
  --slw-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --slw-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1.2);
  --slw-motion-distance: 8px;

  /* Compatibility aliases for existing dashboards. */
  --bg-deep: var(--slw-color-canvas);
  --bg-surface: var(--slw-color-surface);
  --bg-elevated: var(--slw-color-surface-raised);
  --bg-card: var(--slw-color-surface);
  --bg-hover: var(--slw-color-surface-hover);
  --bg-tertiary: var(--slw-color-surface-subtle);
  --text-primary: var(--slw-color-text);
  --text-secondary: var(--slw-color-text-muted);
  --text-muted: var(--slw-color-text-muted);
  --text-link: var(--slw-color-link);
  --border: var(--slw-color-border);
  --border-light: var(--slw-color-border-strong);
  --at-accent: var(--slw-color-role-at-foreground);
  --at-dim: rgba(0, 230, 195, 0.12);
  --coach-accent: var(--slw-color-role-coach-foreground);
  --coach-dim: rgba(255, 176, 32, 0.12);
  --parent-accent: var(--slw-color-role-parent-foreground);
  --parent-dim: rgba(169, 112, 255, 0.12);
  --parent-bg: rgba(169, 112, 255, 0.06);
  --ad-accent: var(--slw-color-role-ad-foreground);
  --ad-dim: rgba(77, 141, 255, 0.12);
  --account-accent: var(--slw-color-role-account-foreground);
  --account-dim: rgba(124, 140, 255, 0.12);
  --status-full: var(--slw-color-status-cleared-foreground);
  --status-cleared: var(--slw-color-status-cleared-foreground);
  --status-restricted: var(--slw-color-status-restricted-foreground);
  --status-out: var(--slw-color-status-out-foreground);
  --font-sans: var(--slw-font-body);
  --font-mono: var(--slw-font-mono);
}

/* Dark is the product default, including when no saved preference exists. */
html:root,
html:root[data-theme="dark"] {
  color-scheme: dark;
  --slw-color-canvas: #070A14;
  --slw-color-surface: #0D1326;
  --slw-color-text: #F7F8FC;
  --slw-color-text-primary: #F7F8FC;
  --slw-color-text-muted: #AEB6C9;

  /* Operational neutrals derived for boundaries and interaction states. */
  --slw-color-surface-raised: #131b33;
  --slw-color-surface-hover: #18213b;
  --slw-color-surface-subtle: rgba(247, 248, 252, 0.06);
  --slw-color-border: #2b354f;
  --slw-color-border-strong: #3a4665;
  --slw-color-link: var(--slw-color-signal);
  --slw-color-focus: var(--slw-color-signal);
  --slw-color-on-canvas: var(--slw-color-text);
  --slw-color-on-surface: var(--slw-color-text);

  /* Foregrounds for semantic text displayed on neutral surfaces. */
  --slw-color-status-cleared-foreground: var(--slw-color-status-cleared);
  --slw-color-status-restricted-foreground: var(--slw-color-status-restricted);
  --slw-color-status-out-foreground: var(--slw-color-status-out);
  --slw-color-role-at-foreground: var(--slw-color-role-at);
  --slw-color-role-coach-foreground: var(--slw-color-role-coach);
  --slw-color-role-parent-foreground: var(--slw-color-role-parent);
  --slw-color-role-ad-foreground: var(--slw-color-role-ad);
  --slw-color-role-account-foreground: var(--slw-color-role-account);
}

html:root[data-theme="sunlight"] {
  color-scheme: light;
  --slw-color-canvas: #F6F8FC;
  --slw-color-surface: #FFFFFF;
  --slw-color-text: #0D1326;
  --slw-color-text-primary: #0D1326;
  --slw-color-text-muted: #5F6B85;
  --slw-color-border: #D9DFEA;

  /* Operational neutrals derived for boundaries and interaction states. */
  --slw-color-surface-raised: #ffffff;
  --slw-color-surface-hover: #eef2f8;
  --slw-color-surface-subtle: rgba(13, 19, 38, 0.05);
  --slw-color-border-strong: #b8c1d2;
  --slw-color-link: #006f60;
  --slw-color-focus: #006f60;
  --slw-color-on-canvas: var(--slw-color-text);
  --slw-color-on-surface: var(--slw-color-text);

  /* Accessible semantic text colors for light neutral surfaces. */
  --slw-color-status-cleared-foreground: #137a37;
  --slw-color-status-restricted-foreground: #8a5300;
  --slw-color-status-out-foreground: #b91c1c;
  --slw-color-role-at-foreground: #006f60;
  --slw-color-role-coach-foreground: #875300;
  --slw-color-role-parent-foreground: #7440c2;
  --slw-color-role-ad-foreground: #355cc9;
  --slw-color-role-account-foreground: #4c5fc7;
}

:where(body, button, input, select, textarea) {
  font-family: var(--slw-font-body);
  font-optical-sizing: auto;
}

:where(h1, h2, h3, h4, h5, h6, [data-slw-heading]) {
  font-family: var(--slw-font-heading);
}

/* Approved raster branding always renders on its source-matched dark well. */
img[src*="/img/brand/sidelineworks-mark-ui-"] {
  background: #070A14;
  border-radius: 6px;
}

img[src*="/img/brand/sidelineworks-horizontal"] {
  background: #070A14;
  border-radius: 8px;
}

/*
 * Bounded theme control primitive. It participates in its parent's normal
 * flow and deliberately makes no positioning or surrounding layout choices.
 */
.slw-theme-toggle {
  display: inline-flex;
  min-inline-size: 44px;
  min-block-size: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--slw-color-border);
  border-radius: 12px;
  background: var(--slw-color-surface);
  color: var(--slw-color-text);
  font-family: var(--slw-font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color var(--slw-motion-duration-fast) var(--slw-motion-easing-standard),
    border-color var(--slw-motion-duration-fast) var(--slw-motion-easing-standard),
    color var(--slw-motion-duration-fast) var(--slw-motion-easing-standard);
}

.slw-theme-toggle--icon {
  inline-size: 44px;
  padding-inline: 0;
}

.slw-theme-toggle:hover {
  background: var(--slw-color-surface-hover);
  border-color: var(--slw-color-border-strong);
}

.slw-theme-toggle:focus-visible {
  outline: 2px solid var(--slw-color-focus);
  outline-offset: 2px;
}

.slw-theme-toggle[aria-pressed="true"] {
  border-color: var(--slw-color-focus);
}

.slw-theme-toggle:disabled,
.slw-theme-toggle[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
}

.slw-theme-toggle :where(svg, [data-slw-theme-icon]) {
  inline-size: 1.125rem;
  block-size: 1.125rem;
  flex: 0 0 auto;
}

@media (prefers-reduced-motion: reduce) {
  html:root {
    --slw-motion-duration-instant: 0.01ms;
    --slw-motion-duration-fast: 0.01ms;
    --slw-motion-duration-standard: 0.01ms;
    --slw-motion-duration-slow: 0.01ms;
    --slw-motion-easing-standard: linear;
    --slw-motion-easing-emphasized: linear;
    --slw-motion-distance: 0px;
  }

  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
