/*
  ============================================================================
  VEYRA CORE: the single design system
  ============================================================================

  Loaded first by every page: marketing, auth, and the application.

  Before this file there were three stylesheets each defining its own palette
  under its own names (--ink / --app-bg / --auth-bg all meant "the dark
  ground"). They had already drifted apart (the app's surface was #111a2e
  while the marketing site's was #0e1729) and nothing made that visible.

  Now there is one vocabulary. The surface stylesheets alias these tokens
  rather than restating hex values, so the three surfaces cannot drift again.

  Structure:
    1. Primitives  : raw ramps. Never referenced by components directly.
    2. Roles       : what a colour is FOR. Components use only these.
    3. Scales      : space, type, radius, shadow, motion.
    4. Reset
    5. Primitives  : button, input, table, badge, card, states.

  Ground switching: roles default to the dark ground (the application).
  A light section opts in with [data-ground="paper"].
*/

/* ==========================================================================
   1. PRIMITIVES
   ========================================================================== */

:root {
  /* --- Veyra blue. One hue, evenly stepped, from the logo's cyan-blue. ---
     The 500 step is the lightest that clears 4.5:1 on paper; 300 is the
     interactive step on the dark ground. Nothing here is a gradient. */
  --v-brand-50:  #eef6fc;
  --v-brand-100: #d3e9f7;
  --v-brand-200: #a8d5ef;
  --v-brand-300: #72bce4;
  --v-brand-400: #3ea2d3;
  --v-brand-500: #1b87bd;
  --v-brand-600: #146a99;
  --v-brand-700: #13537a;
  --v-brand-800: #143f5c;
  --v-brand-900: #122b3d;

  /* --- Neutrals, biased toward the brand hue so greys read as chosen
         rather than inherited. 950 is the established Veyra ink. --- */
  --v-ink-950: #0a1020;
  --v-ink-900: #0d1423;
  --v-ink-850: #111a2c;
  --v-ink-800: #162138;
  --v-ink-700: #1f2c47;
  --v-ink-600: #2b3a58;
  --v-ink-500: #46587c;
  --v-ink-400: #6b7d9f;
  --v-ink-300: #94a3bd;
  --v-ink-200: #bfc9da;
  --v-ink-100: #dee5ef;
  --v-ink-50:  #f2f5fa;

  /* --- Warm paper, for the marketing site's light ground. --- */
  --v-paper-0: #ffffff;
  --v-paper-1: #faf8f4;
  --v-paper-2: #f2eee7;
  --v-paper-3: #e6e0d6;
  --v-paper-line: #ddd6ca;

  /* --- Status. Two steps each: one legible on paper, one on ink. --- */
  --v-green-ink:   #4ecfa0;
  --v-green-paper: #1a7a5e;
  --v-amber-ink:   #e8b04b;
  --v-amber-paper: #8a5d0f;
  --v-red-ink:     #f0857d;
  --v-red-paper:   #a83a33;
}

/* ==========================================================================
   2. ROLES: the only colours components may use
   ========================================================================== */

:root,
[data-ground='ink'] {
  --bg: var(--v-ink-950);
  --surface: var(--v-ink-850);
  --surface-raised: var(--v-ink-800);
  --surface-sunken: var(--v-ink-900);

  --text: #eaf0fa;
  --text-secondary: var(--v-ink-300);
  --text-tertiary: var(--v-ink-400);
  --text-inverse: var(--v-ink-950);

  --border: rgba(148, 175, 214, 0.16);
  --border-strong: rgba(148, 175, 214, 0.3);

  --accent: var(--v-brand-300);
  --accent-hover: var(--v-brand-200);
  --accent-quiet: rgba(114, 188, 228, 0.12);
  --accent-contrast: var(--v-ink-950);

  --success: var(--v-green-ink);
  --success-quiet: rgba(78, 207, 160, 0.13);
  --warning: var(--v-amber-ink);
  --warning-quiet: rgba(232, 176, 75, 0.14);
  --danger: var(--v-red-ink);
  --danger-quiet: rgba(240, 133, 125, 0.14);
  --info: var(--v-brand-300);
  --info-quiet: rgba(114, 188, 228, 0.12);

  --shadow-sm: 0 1px 2px rgba(3, 8, 20, 0.4);
  --shadow-md: 0 8px 24px rgba(3, 8, 20, 0.38);
  --shadow-lg: 0 24px 60px rgba(3, 8, 20, 0.5);

  color-scheme: dark;
}

[data-ground='paper'] {
  --bg: var(--v-paper-1);
  --surface: var(--v-paper-0);
  --surface-raised: var(--v-paper-0);
  --surface-sunken: var(--v-paper-2);

  --text: #141b2b;
  --text-secondary: #4e5a6e;
  --text-tertiary: #6d788c;
  --text-inverse: var(--v-paper-0);

  --border: var(--v-paper-line);
  --border-strong: var(--v-paper-3);

  --accent: var(--v-brand-500);
  --accent-hover: var(--v-brand-600);
  --accent-quiet: var(--v-brand-50);
  --accent-contrast: #ffffff;

  --success: var(--v-green-paper);
  --success-quiet: #e3f2ec;
  --warning: var(--v-amber-paper);
  --warning-quiet: #f7efdc;
  --danger: var(--v-red-paper);
  --danger-quiet: #f8e7e5;
  --info: var(--v-brand-500);
  --info-quiet: var(--v-brand-50);

  --shadow-sm: 0 1px 2px rgba(20, 27, 43, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 27, 43, 0.07);
  --shadow-lg: 0 24px 60px rgba(20, 27, 43, 0.1);

  color-scheme: light;
}

/* ==========================================================================
   3. SCALES
   ========================================================================== */

:root {
  /*
    Type. IBM Plex Sans and IBM Plex Mono, one superfamily, two faces.

    Chosen over Inter because Inter is the default of every AI-generated
    interface and carries no identity. Plex was drawn for technical and
    industrial work: it has real character in the a, g and Q, its figures are
    even, and its mono is a true sibling rather than a borrowed face. For a
    product about SKUs, counts and supplier references that is the right
    voice, and it is not a font anyone reaches for to look fashionable.
  */
  --font-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system,
    'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas,
    monospace;

  /* A single scale. Every size on the site is one of these. */
  --text-2xs: 0.6875rem; /* 11px, table micro-labels only */
  --text-xs: 0.75rem;    /* 12px, meta and captions */
  --text-sm: 0.8125rem;  /* 13px, dense UI and table cells */
  --text-base: 0.9375rem;/* 15px, app body */
  --text-md: 1rem;       /* 16px, marketing body */
  --text-lg: 1.125rem;   /* 18px, lead paragraphs */
  --text-xl: 1.375rem;   /* 22px, card titles */
  --text-2xl: 1.75rem;   /* 28px, section headings */
  --text-3xl: 2.25rem;   /* 36px, page titles */
  --text-4xl: 3rem;      /* 48px, display */
  --text-5xl: 4rem;      /* 64px, hero */

  --leading-tight: 1.15;
  --leading-snug: 1.35;
  --leading-normal: 1.6;

  --tracking-display: -0.03em;
  --tracking-heading: -0.018em;
  --tracking-normal: 0;
  --tracking-label: 0.08em;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* Space: a 4px base. Nothing on the site uses an off-scale value. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;

  /*
    Radius, by role rather than by taste. Controls are softer than containers
    so that a button reads as pressable and a panel reads as structural,
    the opposite of stamping one radius on everything.
  */
  --radius-control: 6px;
  --radius-panel: 10px;
  --radius-pill: 999px;

  /* Motion. Short, and only for state changes. */
  --ease: cubic-bezier(0.2, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;

  /* Layout */
  --container: 1180px;
  --container-narrow: 720px;

  --z-header: 40;
  --z-dropdown: 60;
  --z-modal: 80;
  --z-toast: 100;
}

/* ==========================================================================
   4. RESET
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-20);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}

p { margin: 0; }

a {
  color: inherit;
  text-decoration: none;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* One focus treatment everywhere. Visible on both grounds, never removed. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection {
  background: var(--accent-quiet);
  color: var(--text);
}

/* Respect the system setting rather than animating regardless. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   5. SHARED PRIMITIVES
   ========================================================================== */

/* --- utility ------------------------------------------------------------ */

.v-shell {
  width: min(var(--container), calc(100% - var(--space-8)));
  margin-inline: auto;
}

.v-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/*
  Skip link. Present on every page. Hidden until focused, then it is a real
  control at the top of the viewport.
*/
.v-skip {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-4);
  background: var(--v-ink-950);
  color: #ffffff;
  font-weight: var(--weight-semibold);
  border: 1px solid var(--v-brand-300);
  border-radius: var(--radius-control);
  transition: top var(--duration-fast) var(--ease);
}

.v-skip:focus {
  top: var(--space-3);
}

/* --- monospaced label --------------------------------------------------- */

/*
  The one recurring typographic device in Veyra: a small monospaced label
  above data. It is what makes a screen read as an instrument rather than a
  document, and it earns its place because the data below it is numeric.
*/
.v-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.v-num {
  font-variant-numeric: tabular-nums;
}

/* --- buttons ------------------------------------------------------------ */

/*
  Four variants, one geometry. Hover changes background or border, never
  only opacity, which reads as an element becoming disabled rather than
  responsive.
*/
.v-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px; /* touch target floor */
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.v-btn:disabled,
.v-btn[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: 0.5;
}

.v-btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.v-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.v-btn-secondary {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text);
}

.v-btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.v-btn-ghost {
  color: var(--text-secondary);
}

.v-btn-ghost:hover:not(:disabled) {
  background: var(--accent-quiet);
  color: var(--text);
}

.v-btn-danger {
  background: var(--danger-quiet);
  border-color: var(--danger);
  color: var(--danger);
}

.v-btn-sm {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

/* --- form controls ------------------------------------------------------ */

.v-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.v-field > label {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-secondary);
}

.v-input,
.v-select,
.v-textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text);
  font-size: var(--text-base);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

.v-input::placeholder {
  color: var(--text-tertiary);
}

.v-input:focus,
.v-select:focus,
.v-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}

.v-input[aria-invalid='true'] {
  border-color: var(--danger);
}

.v-field-error {
  font-size: var(--text-xs);
  color: var(--danger);
}

.v-field-error:empty {
  display: none;
}

.v-field-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* --- status badge ------------------------------------------------------- */

/*
  Status is encoded twice (a dot and a word) so it survives being read
  without colour, printed, or seen by someone with a colour deficiency.
*/
.v-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 3px var(--space-2);
  border-radius: var(--radius-control);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.v-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.v-badge-success { color: var(--success); background: var(--success-quiet); }
.v-badge-warning { color: var(--warning); background: var(--warning-quiet); }
.v-badge-danger  { color: var(--danger);  background: var(--danger-quiet); }
.v-badge-info    { color: var(--info);    background: var(--info-quiet); }
.v-badge-neutral { color: var(--text-secondary); background: var(--surface-raised); }

/* --- panel -------------------------------------------------------------- */

/*
  One container, three weights. Most content needs none of them: a hairline
  and space usually separates things better than a box does.
*/
.v-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

.v-panel-flush { padding: 0; }
.v-panel-pad { padding: var(--space-6); }
.v-panel-raised { box-shadow: var(--shadow-md); }

.v-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.v-panel-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

/* --- table -------------------------------------------------------------- */

.v-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.v-table {
  width: 100%;
  border-collapse: collapse;
}

.v-table th,
.v-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.v-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.v-table tbody tr:last-child td {
  border-bottom: 0;
}

.v-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- states ------------------------------------------------------------- */

.v-empty {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--text-secondary);
}

.v-empty-title {
  margin-bottom: var(--space-2);
  font-size: var(--text-md);
  color: var(--text);
}

.v-empty-body {
  max-width: 46ch;
  margin-inline: auto;
  font-size: var(--text-sm);
}

.v-note {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
}

.v-note-success { border-left-color: var(--success); background: var(--success-quiet); }
.v-note-warning { border-left-color: var(--warning); background: var(--warning-quiet); }
.v-note-danger  { border-left-color: var(--danger);  background: var(--danger-quiet); }
.v-note-info    { border-left-color: var(--info);    background: var(--info-quiet); }

.v-note[hidden] { display: none; }

/* Loading: a quiet shimmer, not a spinner that implies failure when slow. */
.v-skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-raised) 0%,
    var(--surface) 50%,
    var(--surface-raised) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-control);
  animation: v-shimmer 1.4s linear infinite;
}

@keyframes v-shimmer {
  to { background-position: -200% 0; }
}

/* --- mobile disclosure menu --------------------------------------------- */

/*
  A real menu, not a shrunken desktop nav. The button is a 44px target, the
  panel is keyboard reachable, and aria-expanded tells assistive tech what
  happened.
*/
.v-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: none;
  color: var(--text);
  cursor: pointer;
}

.v-menu-btn span,
.v-menu-btn span::before,
.v-menu-btn span::after {
  display: block;
  width: 17px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--duration-base) var(--ease);
}

.v-menu-btn span::before,
.v-menu-btn span::after {
  content: '';
  position: relative;
}

.v-menu-btn span::before { top: -5.5px; }
.v-menu-btn span::after { top: 4px; }

.v-menu-btn[aria-expanded='true'] span {
  transform: rotate(45deg);
}

.v-menu-btn[aria-expanded='true'] span::before {
  transform: translateY(5.5px) rotate(-90deg);
}

.v-menu-btn[aria-expanded='true'] span::after {
  opacity: 0;
}

/* ==========================================================================
   6. COLLAPSIBLE NAVIGATION
   ==========================================================================
   Above the breakpoint the wrapper is `display: contents`, so it is invisible
   to layout and the header lays out exactly as it did before the mobile menu
   existed. Below it, the same element becomes a real panel.
   ========================================================================== */

.nav-collapse {
  display: contents;
}

@media (max-width: 900px) {
  .v-menu-btn {
    display: inline-flex;
    margin-left: auto;
    flex: none;
  }

  .nav-collapse {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: var(--z-dropdown);
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-3);
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }

  .nav-collapse.is-open {
    display: flex;
  }

  /* Every destination is a full-width, 44px-tall target. */
  .nav-collapse a,
  .nav-collapse .nav-login {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-control);
    font-size: var(--text-md);
  }

  .nav-collapse a:hover {
    background: var(--accent-quiet);
  }

  .nav-collapse .site-nav,
  .nav-collapse .app-nav,
  .nav-collapse .nav-actions,
  .nav-collapse .app-account {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: visible;
  }

  /* The primary action stays a button, separated by a rule from the links. */
  .nav-collapse .nav-actions {
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
  }

  .nav-collapse .nav-cta.button,
  .nav-collapse .btn {
    width: 100%;
    min-height: 44px;
  }

  .nav-collapse .app-account {
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
  }

  .nav-collapse .app-account-name {
    display: block;
    padding: 0 var(--space-3) var(--space-2);
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    max-width: none;
  }

  /* The header becomes the positioning context for the panel. */
  .site-header,
  .app-bar {
    position: sticky;
  }

  .site-header > .nav,
  .app-bar > .page {
    position: static;
  }
}
