/* Syamantak brand: the shared design system for syamantak.in, ai.syamantak.in and retirement.syamantak.in.
   Canonical copy lives in in.smtk/src/brand.css; siblings get it via scripts/sync-brand.sh. Edit it there only.

   Plain CSS (no Tailwind), so the vanilla retirement app can use it too. Tailwind repos map these into utilities
   with brand-tailwind.css. Tokens are --sk-* so they never collide with a site's own variables.

   One knob per product: override the seven --sk-brand* palette values on :root, after this file. Every ground and
   semantic token below follows them. Neutrals, ink and the earned red are fixed across the family. */

@layer base {
  :root {
    /* Product accent palette (default: Research Indigo, syamantak.in and ai.syamantak.in). */
    --sk-brand: #4b45e0;
    --sk-brand-well: #3f3ac4;
    --sk-brand-deep: #2b2a8c;
    --sk-brand-pale: #c9c8ff;
    --sk-brand-mist: #e4e5ff;
    --sk-brand-haze: #d4d5ff;
    --sk-brand-red: #ffd0cc; /* the earned red, readable on a --sk-brand ground */
    --sk-concrete: #a8a7a3; /* categorical chart tone; fixed across the family */

    --sk-font-sans: "Hind", "Helvetica Neue", Arial, sans-serif;
    --sk-font-display: "Archivo Variable", "Helvetica Neue", Arial, sans-serif;

    /* Paper ground (default). */
    --sk-canvas: #ffffff;
    --sk-surface: #ffffff;
    --sk-elevated: #ffffff;
    --sk-well: #efeeeb;
    --sk-hover: rgb(17 17 17 / 0.05);
    --sk-track: rgb(17 17 17 / 0.12);
    --sk-line: rgb(17 17 17 / 0.16);
    --sk-line-strong: #111111;
    --sk-fg: #111111;
    --sk-muted: #3d3d3d;
    --sk-subtle: #595959;

    /* accent = fills, on-accent = text on those fills, accent-hi = accent-coloured text. */
    --sk-accent-lo: var(--sk-brand-deep);
    --sk-accent: var(--sk-brand);
    --sk-accent-hi: var(--sk-brand);
    --sk-on-accent: #ffffff;

    /* One earned red: --sk-down is the only hue, for rejections, losses and "Act". Gains, warnings and
       notes are ink; meaning comes from words, signs and stamp form, never from green or amber. */
    --sk-up: #111111;
    --sk-down: #a10012;
    --sk-warn: #111111;
    --sk-info: #3d3d3d;
  }

  /* The canvas behind the page is ink, so the footer's fractional last pixel (and macOS overscroll past it) blends
     ink with ink instead of showing a white hairline. The body itself stays paper. */
  html {
    background: #111111;
    color: var(--sk-fg);
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
    -webkit-font-smoothing: antialiased;
    color-scheme: light;
  }
  body {
    background: var(--sk-canvas);
    font-family: var(--sk-font-sans);
    overflow-x: clip; /* backstop: nothing may widen the page on phones. clip, not hidden, so position: sticky keeps working */
  }
  h1, h2, h3, h4 {
    font-family: var(--sk-font-display);
    font-stretch: 112%;
    letter-spacing: -0.01em;
    line-height: 1.04;
    text-wrap: balance;
  }
  ::selection { background: var(--sk-accent-lo); color: #fff; }
  :focus-visible { outline: 3px solid var(--sk-fg); outline-offset: 3px; }
  summary { cursor: pointer; list-style: none; }
  summary::-webkit-details-marker { display: none; }
}

@layer components {
  /* Grounds. Each owns a whole section, edge to edge, and re-points the same tokens so everything works on it. */
  .g-paper, .card {
    --sk-canvas: #ffffff;
    --sk-surface: #ffffff;
    --sk-elevated: #ffffff;
    --sk-well: #efeeeb;
    --sk-hover: rgb(17 17 17 / 0.05);
    --sk-track: rgb(17 17 17 / 0.12);
    --sk-line: rgb(17 17 17 / 0.16);
    --sk-line-strong: #111111;
    --sk-fg: #111111;
    --sk-muted: #3d3d3d;
    --sk-subtle: #595959;
    --sk-accent: var(--sk-brand);
    --sk-accent-hi: var(--sk-brand);
    --sk-on-accent: #ffffff;
    --sk-up: #111111;
    --sk-down: #a10012;
    --sk-warn: #111111;
    --sk-info: #3d3d3d;
    color: var(--sk-fg);
  }
  .g-concrete {
    --sk-canvas: #c9c8c4;
    --sk-well: #dcdbd7;
    --sk-hover: rgb(17 17 17 / 0.06);
    --sk-track: rgb(17 17 17 / 0.16);
    --sk-line: rgb(17 17 17 / 0.22);
    --sk-line-strong: #111111;
    --sk-fg: #111111;
    --sk-muted: #2b2b2b;
    --sk-subtle: #3a3a3a;
    --sk-accent: var(--sk-brand-deep);
    --sk-accent-hi: var(--sk-brand-deep);
    --sk-on-accent: #ffffff;
    --sk-up: #111111;
    --sk-down: #a10012;
    --sk-warn: #111111;
    --sk-info: #2b2b2b;
    color: var(--sk-fg);
  }
  /* The brand ground. Named for syamantak.in's indigo; it follows each product's --sk-brand. */
  .g-indigo {
    --sk-canvas: var(--sk-brand);
    --sk-well: var(--sk-brand-well);
    --sk-hover: rgb(255 255 255 / 0.1);
    --sk-track: rgb(255 255 255 / 0.25);
    --sk-line: rgb(255 255 255 / 0.3);
    --sk-line-strong: #ffffff;
    --sk-fg: #ffffff;
    --sk-muted: var(--sk-brand-mist);
    --sk-subtle: var(--sk-brand-haze);
    --sk-accent: #ffffff;
    --sk-accent-hi: #ffffff;
    --sk-on-accent: var(--sk-brand-deep);
    --sk-up: #ffffff;
    --sk-down: var(--sk-brand-red);
    --sk-warn: #ffffff;
    --sk-info: var(--sk-brand-mist);
    color: var(--sk-fg);
  }
  .g-ink {
    --sk-canvas: #111111;
    --sk-well: #1f1f1f;
    --sk-hover: rgb(255 255 255 / 0.08);
    --sk-track: rgb(255 255 255 / 0.2);
    --sk-line: rgb(255 255 255 / 0.2);
    --sk-line-strong: #f2f2f0;
    --sk-fg: #f2f2f0;
    --sk-muted: #c9c8c4;
    --sk-subtle: #a8a7a3;
    --sk-accent: #ffffff;
    --sk-accent-hi: var(--sk-brand-pale);
    --sk-on-accent: #111111;
    --sk-up: #f2f2f0;
    --sk-down: #ff8a80;
    --sk-warn: #f2f2f0;
    --sk-info: #c9c8c4;
    color: var(--sk-fg);
  }
  /* Night: the ink ground for a whole page (apps set data-theme="dark" on <html>) or a single section (.g-night).
     Canvas is #1a1a1a so long sessions are softer than the marketing site's #111 ink; same rule as .g-ink: one red,
     gains and warnings are ink. A product that keeps market colours overrides --sk-up/down/warn itself.
     On a themed page the paper sheets (.card, .g-paper) follow the theme too. */
  .g-night, [data-theme='dark'], [data-theme='dark'] .card, [data-theme='dark'] .g-paper {
    color-scheme: dark;
    --sk-canvas: #1a1a1a;
    --sk-surface: #1a1a1a;
    --sk-elevated: #1a1a1a;
    --sk-well: #111111;
    --sk-hover: rgb(255 255 255 / 0.08);
    --sk-track: rgb(255 255 255 / 0.2);
    --sk-line: rgb(255 255 255 / 0.18);
    --sk-line-strong: #f2f2f0;
    --sk-fg: #f2f2f0;
    --sk-muted: #c9c8c4;
    --sk-subtle: #a8a7a3;
    --sk-accent-lo: var(--sk-brand-pale);
    --sk-accent: var(--sk-brand-pale);
    --sk-accent-hi: var(--sk-brand-pale);
    --sk-on-accent: #111111;
    --sk-up: #f2f2f0;
    --sk-down: #ff8a80;
    --sk-warn: #f2f2f0;
    --sk-info: #c9c8c4;
    color: var(--sk-fg);
  }
  .g-paper, .g-concrete, .g-indigo, .g-ink, .g-night { background: var(--sk-canvas); }
  .g-indigo :focus-visible, .g-ink :focus-visible, .g-night :focus-visible, [data-theme='dark'] :focus-visible { outline-color: #fff; }

  /* A paper sheet with a 2px ink border, square, flat. It re-points to paper tokens on any ground. */
  .card {
    position: relative;
    background: #ffffff;
    border: 2px solid #111111;
  }

  /* The wordmark as a stencil, so it takes the palette: accent-hi on its ground, the S is the cut-out and shows the
     ground. Needs /wordmark-mask.svg (sync-brand copies it). Set a height; the width follows. */
  .wordmark {
    display: block;
    height: 1rem;
    aspect-ratio: 1050 / 140;
    background: var(--sk-accent-hi);
    -webkit-mask: url(/wordmark-mask.svg) center / contain no-repeat;
    mask: url(/wordmark-mask.svg) center / contain no-repeat;
  }

  /* Figures: Archivo, tabular. */
  .num { font-family: var(--sk-font-display); font-variant-numeric: tabular-nums; font-stretch: 100%; }

  input[type="range"] { accent-color: var(--sk-accent); width: 100%; }
}

/* Shared controls. Tokens only, so every ground re-points them. Apps wrap these classes; they do not redraw them.
   Reduced motion is handled once, at the foot of this file. */
@layer components {
  /* A control's fill is the surface, except on indigo and ink, where --sk-surface stays white while --sk-fg turns
     white: there the fill is the ground itself, so text and fill never match. */
  .g-indigo, .g-ink { --sk-control-bg: var(--sk-canvas); }
  .g-paper, .g-concrete, .g-night, [data-theme='dark'], .card { --sk-control-bg: var(--sk-surface); }

  /* Switch. A native checkbox (visually hidden) followed by the slider, so it works with no script:
       <label class="sk-switch"><input type="checkbox"><span class="sk-switch-slider"></span></label>
     A script app may use <button class="sk-switch" role="switch" aria-checked="true"> around the same slider.
     Size follows --sk-switch-w, --sk-switch-h and --sk-switch-inset (the gap round the thumb); an app may set them
     (retirement runs 100 x 47 to match its other controls) and nothing else about the geometry. */
  .sk-switch {
    --sk-switch-w: 64px;
    --sk-switch-h: 36px;
    --sk-switch-inset: 4px;
    --sk-switch-edge: var(--sk-line); /* the off edge; an app may make it stronger */
    --sk-switch-tint: 12%; /* how much accent the on track takes */
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: var(--sk-switch-w);
    height: var(--sk-switch-h);
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .sk-switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
  .sk-switch-slider {
    position: absolute;
    inset: 0;
    background: var(--sk-control-bg, var(--sk-surface));
    box-shadow: inset 0 0 0 1px var(--sk-switch-edge);
    transition: background-color 200ms ease, box-shadow 200ms ease;
  }
  .sk-switch-slider::before {
    content: "";
    position: absolute;
    top: var(--sk-switch-inset);
    left: var(--sk-switch-inset);
    width: calc(var(--sk-switch-h) - 2 * var(--sk-switch-inset));
    height: calc(var(--sk-switch-h) - 2 * var(--sk-switch-inset));
    background: var(--sk-accent);
    transition: transform 200ms ease;
  }
  .sk-switch input:checked + .sk-switch-slider,
  .sk-switch[aria-checked="true"] .sk-switch-slider {
    background: color-mix(in oklab, var(--sk-accent) var(--sk-switch-tint), var(--sk-control-bg, var(--sk-surface)));
    box-shadow: inset 0 0 0 1px var(--sk-accent);
  }
  .sk-switch input:checked + .sk-switch-slider::before,
  .sk-switch[aria-checked="true"] .sk-switch-slider::before {
    transform: translateX(calc(var(--sk-switch-w) - var(--sk-switch-h)));
  }
  /* Hover changes the track as well as the edge: an app whose off edge is already ink would otherwise show nothing. */
  .sk-switch:hover input:enabled + .sk-switch-slider,
  .sk-switch:enabled:hover .sk-switch-slider {
    background: color-mix(in oklab, var(--sk-fg) 6%, var(--sk-control-bg, var(--sk-surface)));
    box-shadow: inset 0 0 0 1px var(--sk-fg);
  }
  .sk-switch:hover input:enabled:checked + .sk-switch-slider,
  .sk-switch:enabled:hover[aria-checked="true"] .sk-switch-slider {
    background: color-mix(in oklab, var(--sk-accent) calc(var(--sk-switch-tint) + 8%), var(--sk-control-bg, var(--sk-surface)));
    box-shadow: inset 0 0 0 1px var(--sk-accent-lo);
  }
  .sk-switch input:focus-visible + .sk-switch-slider,
  .sk-switch:focus-visible .sk-switch-slider { outline: 3px solid color-mix(in oklab, var(--sk-accent) 30%, transparent); outline-offset: 0; }
  .sk-switch:focus-visible { outline: 0; }
  .sk-switch input:disabled + .sk-switch-slider,
  .sk-switch:disabled .sk-switch-slider { opacity: 0.5; cursor: not-allowed; }
  .sk-switch:has(input:disabled), .sk-switch:disabled { cursor: not-allowed; }

  /* Data table: <table class="sk-table">. Every column is left-aligned, header and body, whatever it holds.
     .sk-table--dense is for a table that sits inside a form or card and needs shorter rows. */
  .sk-table { width: 100%; border-collapse: collapse; }
  .sk-table thead tr { height: 2.75rem; }
  .sk-table th, .sk-table td { padding: 0.5rem 0.75rem; text-align: left; vertical-align: middle; }
  .sk-table tbody th { font-weight: 400; }
  .sk-table thead th {
    font-family: var(--sk-font-display);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--sk-muted);
    border-bottom: 2px solid var(--sk-line-strong);
  }
  .sk-table tbody tr {
    height: 3.25rem;
    border-bottom: 1px solid var(--sk-line);
    transition: background-color 120ms ease-out;
  }
  .sk-table tbody tr:last-child { border-bottom: 0; }
  .sk-table tbody tr:hover,
  .sk-table tbody tr:focus-within { background-color: var(--sk-hover); }
  /* A message that spans the table (nothing to show) is a message, not a column. */
  .sk-table tbody td[colspan] { padding-block: 2rem; text-align: center; }
  .sk-table tbody tr:has(> td[colspan]):hover { background-color: transparent; }
  .sk-table--dense tbody tr { height: 2.5rem; }
  .sk-table--dense thead tr { height: 2.25rem; }

  /* Buttons that sit beside a primary one: ink outline, and on hover a solid fill (a tint would vanish on a
     hovered table row, which is already tinted). Size and padding stay with the app. */
  .sk-btn, .sk-btn-danger, .sk-btn-success {
    --sk-btn-edge: var(--sk-btn-rest-edge, var(--sk-line-strong)); /* an app may set --sk-btn-rest-edge */
    border: 1px solid var(--sk-btn-edge);
    background: var(--sk-control-bg, var(--sk-surface));
    color: var(--sk-fg);
    cursor: pointer;
    transition: background-color 120ms ease-out, color 120ms ease-out;
  }
  .sk-btn-danger { border-color: var(--sk-down); color: var(--sk-down); }
  .sk-btn-success { border-color: var(--sk-up); color: var(--sk-up); }
  .sk-btn:enabled:hover { --sk-btn-edge: var(--sk-fg); background: var(--sk-fg); color: var(--sk-canvas); }
  .sk-btn-danger:enabled:hover { background: var(--sk-down); color: var(--sk-canvas); }
  .sk-btn-success:enabled:hover { background: var(--sk-up); color: var(--sk-canvas); }
  a.sk-btn:hover { --sk-btn-edge: var(--sk-fg); background: var(--sk-fg); color: var(--sk-canvas); }
  /* Text inside a button follows the button on hover. An app's own child colour rules must not fight this: give a
     quieter line opacity, not a colour. */
  .sk-btn:enabled:hover :where(span, svg), .sk-btn-danger:enabled:hover :where(span, svg), .sk-btn-success:enabled:hover :where(span, svg) { color: inherit; }
  .sk-btn:disabled, .sk-btn-danger:disabled, .sk-btn-success:disabled { opacity: 0.5; cursor: not-allowed; }

  /* Input, select, textarea: the edge darkens to ink on hover, accent edge and ring on focus. */
  .sk-input {
    border: 1px solid var(--sk-line);
    background: var(--sk-control-bg, var(--sk-surface));
    color: var(--sk-fg);
    outline: 0;
    transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
  }
  .sk-input:enabled:hover { border-color: var(--sk-fg); }
  .sk-input:enabled:focus { border-color: var(--sk-accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--sk-accent) 10%, transparent); }
  .sk-input:disabled { opacity: 0.5; cursor: not-allowed; }

  /* A checkbox that stays a checkbox. */
  .sk-check:enabled:hover { outline: 2px solid var(--sk-fg); outline-offset: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
