/* =============================================================================
 * Stryde SDK Skin — the platform's single source of truth for look & feel.
 *
 * Served at /sdk/stryde.css and (a) injected by the shell into every mounted
 * app iframe as the LAST stylesheet, and (b) linked at build time by each app.
 * Loaded last, it OVERRIDES an app's own CSS so every surface — in the shell or
 * standalone — reads as the superapp (req §6.5 / §18.3). Mirror of the canonical
 * design language in app/static/wiki.html. Bump SKIN_VERSION + the ?v= query and
 * the manifest design_system id ("stryde@N") together when this changes.
 *
 *   1. TOKENS      — re-assert the palette in BOTH naming schemes (superapp hex
 *                    + the apps' HSL-channel vars) so app token blocks lose.
 *   2. BASE        — unify the FONT (override the var the apps consume) + base
 *                    typography, links, selection, scrollbars, focus. Global +
 *                    automatic; intentionally light-touch so it never fights an
 *                    app's own good styling.
 *   3. COMPONENTS  — the canonical `.stryde-*` classes (the wiki treatment) that
 *                    apps + the design-system primitives OPT INTO. This is the
 *                    "right SDK": build with these and you're plug-and-play —
 *                    wiki-grade with zero per-app CSS.
 * ========================================================================== */

/* ---- 1. TOKENS ---------------------------------------------------------- */
:root,
html {
  /* superapp (hex) naming — used by the shell/wiki/admin surfaces */
  --violet: #8B5CF6;
  --azure: #6BA4FF;
  --teal: #14B8C8;
  --warn: #FB923C;
  --ok: #34d399;
  --bad: #f87171;
  --grad: linear-gradient(105deg, var(--violet), var(--azure));
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --ease: cubic-bezier(.22, .7, .2, 1);

  /* FONT override — the apps' Tailwind `font-sans` resolves to these vars, so
     redefining them (loaded last, equal specificity → wins) flips every app to
     the superapp typeface with no !important and no app rebuild. */
  --font-geist-sans: var(--sans);
  --font-geist-mono: var(--mono);

  /* apps' HSL-channel naming — consumed as hsl(var(--brand-violet)) etc. The
     apps already define these (matching values); we re-assert so they're present
     everywhere the skin loads. */
  --brand-violet: 258 90 66;
  --brand-azure: 217 100 71;
  --brand-teal: 187 82 43;
}

/* IMPORTANT: the skin does NOT redefine surface tokens (--bg, --bg-elev,
   --bg-soft, --ink*, --line*, --shadow, --hi, --glass). Each surface owns those:
   the Tailwind apps define them as HSL CHANNELS and read them via
   hsl(var(--bg-elev)); the shell/wiki/launcher define them as hex. If the skin
   forced one format it would break the other — e.g. hsl(<hex>) is invalid, which
   silently made every app card transparent. So we leave colour tokens alone and
   only contribute brand accents, the font, the glow, and the .stryde-* classes.
   `.stryde-*` rely on the host surface's own --bg-elev/--line/--shadow (hex on
   the shell/wiki, where they're used). */

html[dir="rtl"] {
  --sans: "SF Arabic", "Noto Naskh Arabic", "Geeza Pro", -apple-system, system-ui, sans-serif;
}

/* ---- 2. BASE ------------------------------------------------------------ */
html,
body {
  font-family: var(--sans) !important;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  /* Each surface owns its own background (apps via their globals, shell/wiki via
     their own CSS) — the skin only positions for the glow below. We do NOT set a
     background here: --bg differs in format per surface (hex vs HSL channels). */
  position: relative;
}
/* The wiki's signature ambient art glow (violet top-right, teal bottom-left),
   applied to EVERY app so the whole platform shares one atmosphere. Fixed,
   behind content, non-interactive. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 82% -8%, color-mix(in srgb, var(--violet) 11%, transparent), transparent 60%),
    radial-gradient(760px 420px at -5% 8%, color-mix(in srgb, var(--teal) 8%, transparent), transparent 55%);
}
button,
input,
select,
textarea {
  font-family: var(--sans) !important;
}
code,
pre,
kbd,
samp,
.mono,
[class*="mono"] {
  font-family: var(--mono) !important;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans) !important;
  letter-spacing: -.025em;
}
/* The wiki uses bold, tight display headings — match that so app titles read
   the same (apps often leave large headings at normal weight). */
h1, h2 {
  font-weight: 700 !important;
  letter-spacing: -.03em;
}
h3 {
  font-weight: 650 !important;
}
/* NOTE: we deliberately do NOT set a global `a { color }`. Cards, list rows and
   nav items are anchors, and a blanket link colour bleeds into their text
   (the "blue cards" bug). Apps colour their own prose links via `.stryde-link`
   or their own classes. */
.stryde-link {
  color: var(--azure);
}
::selection {
  background: rgba(139, 92, 246, .30);
  color: var(--ink);
}
:focus-visible {
  outline: 2.5px solid var(--teal);
  outline-offset: 2px;
  border-radius: 8px;
}
/* themed scrollbars — a quiet but pervasive "feel" tell */
* {
  scrollbar-color: var(--line) transparent;
}
*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
  background-clip: content-box;
}

/* ---- 3. CANONICAL COMPONENTS — the "right SDK" surface ------------------ *
 * Opt-in classes that ARE the wiki treatment (values mirror wiki.html). An app
 * that builds with these (or the @stryde/design-system primitives that map to
 * them) is plug-and-play — it looks like the superapp with no per-app CSS. We
 * deliberately DON'T blanket-override raw <input>/<button>/<table> anymore: that
 * fought apps that already style well. Apps adopt these explicitly instead. */

.stryde-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.stryde-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--violet) 40%, var(--line));
}
.stryde-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.stryde-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 12px;
}
.stryde-hero {
  font-size: clamp(32px, 6vw, 64px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.035em;
}
.stryde-grad,
.stryde-hero .g {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stryde-lead {
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 64ch;
}
.stryde-section { margin: 0 0 64px; }

.stryde-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: transform .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.stryde-btn:active { transform: translateY(.5px); }
.stryde-btn:disabled { opacity: .55; cursor: not-allowed; }
.stryde-btn-primary {
  background-image: var(--grad);
  color: #fff;
  box-shadow: 0 18px 44px -22px var(--violet);
}
.stryde-btn-primary:hover { transform: translateY(-1px); }
.stryde-btn-ghost {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--line);
}
.stryde-btn-ghost:hover { background: var(--bg-soft); }

.stryde-input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  padding: 11px 14px;
  font: inherit;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.stryde-input::placeholder { color: var(--ink-3); }
.stryde-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--violet) 55%, var(--line));
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .18);
}

.stryde-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.stryde-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.stryde-table th {
  text-align: start;
  color: var(--ink-3);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 12px 14px;
}
.stryde-table td { padding: 12px 14px; }
.stryde-table th,
.stryde-table td { border-bottom: 1px solid var(--line-2); }

.stryde-note {
  font-size: 15px;
  color: var(--ink-2);
  border-inline-start: 3px solid var(--teal);
  padding: 6px 0 6px 16px;
  background: linear-gradient(90deg, var(--hi), transparent);
  border-radius: 0 8px 8px 0;
}

/* Safe semantic element polish (no class needed). */
pre {
  background: color-mix(in srgb, var(--violet) 6%, var(--bg-elev));
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
}
:not(pre) > code {
  background: var(--line-2);
  border: 1px solid var(--line-2);
  padding: 2px 7px;
  border-radius: 7px;
  color: var(--teal);
}
hr {
  border: 0;
  border-top: 1px solid var(--line-2);
}

/* SIDE MENU (hex surfaces — shell/wiki). Mirror of the HSL version in
   stryde-tokens.css so the side-nav looks identical wherever it's used. Apps
   pick up the HSL version (loaded later); the shell/wiki use this. */
.stryde-side {
  display: flex; flex-direction: column; gap: 2px;
  inline-size: 248px; flex: none; padding: 16px 12px;
  background: var(--bg-soft); border-inline-end: 1px solid var(--line-2);
  min-block-size: 100dvh;
}
.stryde-side-brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px 14px;
  font-weight: 700; font-size: 16px; letter-spacing: -.02em;
  color: var(--ink); text-decoration: none;
}
.stryde-side-brand img { height: 26px; width: auto; border-radius: 6px; }
.stryde-side-section {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 12px 6px;
}
.stryde-side-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); font-size: 14.5px; font-weight: 550; text-decoration: none; cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.stryde-side-item:hover { background: var(--line-2); color: var(--ink); }
.stryde-side-item.active {
  background: color-mix(in srgb, var(--violet) 14%, transparent); color: var(--ink); font-weight: 650;
}
.stryde-side-icon {
  inline-size: 18px; block-size: 18px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* React Flow (neo-stryde / brainstorming) — bind its theme vars to ours so the
   canvas matches the platform. */
.react-flow {
  --xy-background-color: transparent;
  --xy-edge-stroke-default: var(--line);
  --xy-handle-background-color-default: var(--violet);
  --xy-handle-border-color-default: var(--bg-elev);
}
