/* ============================================================
   Kips Template — Core CSS (reset + tokens + base)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--kt-font-ui);
  color: var(--kt-text-1);
  background: var(--kt-surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
img, svg, canvas, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--kt-accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* Universal design tokens (theme-agnostic) */
:root {
  --kt-font-ui: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --kt-font-display: "Inter", "SF Pro Display", system-ui, sans-serif;
  --kt-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Geometry */
  --kt-radius-xs: 4px;
  --kt-radius-sm: 8px;
  --kt-radius-md: 12px;
  --kt-radius-lg: 18px;
  --kt-radius-xl: 24px;
  --kt-radius-pill: 999px;

  /* Spacing scale */
  --kt-s-1: 4px;
  --kt-s-2: 8px;
  --kt-s-3: 12px;
  --kt-s-4: 16px;
  --kt-s-5: 20px;
  --kt-s-6: 24px;
  --kt-s-7: 32px;
  --kt-s-8: 40px;

  /* Z-index */
  --kt-z-base: 0;
  --kt-z-stage: 5;
  --kt-z-sidepanel: 20;
  --kt-z-topbar: 40;
  --kt-z-bottombar: 40;
  --kt-z-floatmenu: 55;
  --kt-z-perfhud: 60;
  --kt-z-toaster: 70;
  --kt-z-sheet: 80;
  --kt-z-modal: 90;
  --kt-z-boot: 999;

  /* Motion */
  --kt-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --kt-ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --kt-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --kt-dur-1: 120ms;
  --kt-dur-2: 180ms;
  --kt-dur-3: 240ms;
  --kt-dur-4: 360ms;

  /* Brand accent (constant across themes) */
  --kt-brand-1: #5B6BFF;       /* primary indigo */
  --kt-brand-2: #C24BFF;       /* magenta */
  --kt-brand-3: #FF6BB8;       /* pink (gradient end accent) */
  --kt-brand-grad: linear-gradient(135deg, var(--kt-brand-1) 0%, var(--kt-brand-2) 60%, var(--kt-brand-3) 100%);
  --kt-brand-grad-soft: linear-gradient(135deg, rgba(91,107,255,.12), rgba(255,107,184,.12));
  --kt-snap: #FF2D7B;          /* magenta smart-guide color */
  --kt-glow: 0 0 0 1px rgba(91,107,255,.18), 0 6px 24px rgba(91,107,255,.22);

  /* Sizes */
  --kt-topbar-h: 56px;
  --kt-bottombar-h: 64px;
  --kt-sidepanel-w: 360px;
  --kt-sidepanel-w-md: 320px;
  --kt-handle: 12px;
  --kt-handle-rot-offset: 32px;
}

/* Larger touch targets on coarse pointers (mobile/tablet) */
@media (pointer: coarse) {
  :root {
    --kt-handle: 16px;
    --kt-handle-rot-offset: 40px;
    --kt-bottombar-h: 72px;
  }
}

/* Default (Stellar light) is set in theme-stellar.css; theme switch via [data-theme] */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.kips-noscript {
  display: grid; place-items: center; min-height: 100dvh; padding: 24px; text-align: center;
}

/* Boot splash */
.kips-boot {
  position: fixed; inset: 0; z-index: var(--kt-z-boot);
  display: grid; place-items: center; gap: 14px; padding: 24px;
  background: var(--kt-surface-0); color: var(--kt-text-1);
  transition: opacity var(--kt-dur-4) var(--kt-ease-out);
}
.kips-boot[data-fade] { opacity: 0; pointer-events: none; }
.kips-boot__mark {
  position: relative; width: 64px; height: 64px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  transform: rotate(-12deg);
}
.kips-boot__chip {
  border-radius: 8px;
  background: var(--kt-brand-grad);
  animation: kt-boot-pulse 1.4s var(--kt-ease-out) infinite;
}
.kips-boot__chip:nth-child(2) { animation-delay: .15s; }
.kips-boot__chip:nth-child(3) { animation-delay: .30s; }
.kips-boot__chip:nth-child(4) { animation-delay: .45s; }
@keyframes kt-boot-pulse {
  0%, 100% { transform: scale(.7); opacity: .55; }
  50%      { transform: scale(1);  opacity: 1; }
}
.kips-boot__brand {
  font-family: var(--kt-font-display); font-weight: 700; letter-spacing: 0.16em;
  font-size: 18px;
}
.kips-boot__tag { color: var(--kt-text-2); font-size: 13px; letter-spacing: .04em; }

/* Hide app until ready */
.kips-app[hidden] { display: none; }



/* ------------------------------------------------------------
   Accessibility — global skip link
   ------------------------------------------------------------
   Hidden off-screen until it receives keyboard focus, at which
   point it becomes a high-contrast landing strip in the top-left
   corner. Lets keyboard / screen-reader users jump past the
   topbar straight into the main content. Required for WCAG
   2.4.1 "Bypass Blocks".
*/
.kips-skiplink {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 1000;
}
.kips-skiplink:focus,
.kips-skiplink:focus-visible {
  position: fixed;
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
  padding: 10px 14px;
  background: var(--kt-brand-1, #5B6BFF);
  color: #FFFFFF;
  border-radius: 8px;
  font: 600 14px/1 var(--kt-font-ui, system-ui, sans-serif);
  text-decoration: none;
  box-shadow: 0 8px 22px -10px rgba(91, 107, 255, 0.6);
  outline: 2px solid #FFFFFF;
  outline-offset: 2px;
}

/* Honor the user's reduced-motion preference globally so any animation
   defined in animations.css is muted to a single quick fade. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visually hidden helper for screen-reader-only labels */
.kips-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
