/**
 * tonegrid-base.css
 * ─────────────────
 * Layer 1: Design tokens (CSS custom properties), reset, typography.
 * These values are overridden at runtime by the /api/whitelabel/theme endpoint
 * injected via includes/theme-style.css.php.
 *
 * Usage: <link rel="stylesheet" href="/css/tonegrid-base.css">
 */

/* ═══════════════════════════════════════════════════════════════
   1. DESIGN TOKENS (safe fallback values)
═══════════════════════════════════════════════════════════════ */
:root {
  /* ── Brand palette (overridden by whitelabel theme) */
  --color-primary:       #6C3AEF;
  --color-primary-hover: #7e52f5;
  --color-primary-muted: rgba(108, 58, 239, 0.15);
  --color-secondary:     #1E1E2E;
  --color-accent:        #A78BFA;
  --color-text:          #F8F8F2;
  --color-text-muted:    #a0a0b8;
  --color-text-subtle:   #6b6b80;
  --color-bg:            #0F0F17;
  --color-surface:       #181825;
  --color-surface-alt:   #1E1E2E;
  --color-border:        rgba(255, 255, 255, 0.10);
  --color-border-strong: rgba(255, 255, 255, 0.18);
  --color-hover-bg:      rgba(255, 255, 255, 0.06);

  /* ── Semantic colours */
  --color-success:       #4ade80;
  --color-warning:       #facc15;
  --color-error:         #f87171;
  --color-info:          #60a5fa;

  /* ── Typography */
  --font-family:   "Aeonik", sans-serif;
  --font-mono:     "DM Mono", "Fira Code", Consolas, monospace;

  --text-xs:    0.75rem;    /* 12px */
  --text-sm:    0.875rem;   /* 14px */
  --text-base:  1rem;       /* 16px */
  --text-lg:    1.125rem;   /* 18px */
  --text-xl:    1.25rem;    /* 20px */
  --text-2xl:   1.5rem;     /* 24px */
  --text-3xl:   1.875rem;   /* 30px */
  --text-4xl:   2.25rem;    /* 36px */

  --font-regular: 400;
  --font-medium:  500;
  --font-bold:    700;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-loose:  1.75;

  /* ── Spacing scale */
  --space-1:   0.25rem;   /* 4px  */
  --space-2:   0.5rem;    /* 8px  */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-20:  5rem;      /* 80px */

  /* ── Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  20px;
  --radius-full: 9999px;

  /* ── Shadows */
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 10px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl:  0 20px 56px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 24px rgba(108, 58, 239, 0.35);

  /* ── Transitions */
  --transition-fast:   0.12s ease;
  --transition-normal: 0.22s ease;
  --transition-slow:   0.36s ease;

  /* ── Layout */
  --sidebar-width:    60px;
  --sidebar-expanded: 200px;
  --header-height:    60px;
  --content-max-w:    1200px;

  /* ── Z-index scale */
  --z-base:     0;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   900;
  --z-sidebar:  1000;
  --z-modal:    2000;
  --z-toast:    3000;
  --z-tooltip:  4000;
}


/* ═══════════════════════════════════════════════════════════════
   2. MODERN CSS RESET
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family:              var(--font-family);
  font-size:                16px;
  line-height:              var(--leading-normal);
  -webkit-text-size-adjust: 100%;
  tab-size:                 4;
  scroll-behavior:          smooth;
}

body {
  font-family:             var(--font-family);
  background:              var(--color-bg);
  color:                   var(--color-text);
  -webkit-font-smoothing:  antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering:          optimizeLegibility;
  overflow-x:              hidden;
  min-height:              100vh;
}

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

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

button {
  cursor:     pointer;
  background: none;
  border:     none;
  color:      inherit;
}

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

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing:  0;
  width:           100%;
}

h1, h2, h3, h4, h5, h6 {
  font-weight:   var(--font-bold);
  line-height:   var(--leading-tight);
  color:         var(--color-text);
}

p {
  line-height: var(--leading-normal);
  color:       var(--color-text-muted);
}

hr {
  border:     none;
  border-top: 1px solid var(--color-border);
  margin:     var(--space-4) 0;
}


/* ═══════════════════════════════════════════════════════════════
   3. TYPOGRAPHY UTILITIES
═══════════════════════════════════════════════════════════════ */
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.text-base   { font-size: var(--text-base); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.text-2xl    { font-size: var(--text-2xl); }
.text-3xl    { font-size: var(--text-3xl); }
.text-4xl    { font-size: var(--text-4xl); }

.text-primary  { color: var(--color-primary); }
.text-accent   { color: var(--color-accent); }
.text-muted    { color: var(--color-text-muted); }
.text-subtle   { color: var(--color-text-subtle); }
.text-success  { color: var(--color-success); }
.text-warning  { color: var(--color-warning); }
.text-error    { color: var(--color-error); }
.text-info     { color: var(--color-info); }

.font-regular  { font-weight: var(--font-regular); }
.font-medium   { font-weight: var(--font-medium); }
.font-bold     { font-weight: var(--font-bold); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

.truncate {
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}

.line-clamp-2 {
  display:            -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow:           hidden;
}

.mono { font-family: var(--font-mono); }


/* ═══════════════════════════════════════════════════════════════
   4. LAYOUT HELPERS
═══════════════════════════════════════════════════════════════ */
.flex              { display: flex; }
.flex-col          { display: flex; flex-direction: column; }
.flex-1            { flex: 1; }
.flex-none         { flex: none; }
.items-center      { align-items: center; }
.items-start       { align-items: flex-start; }
.items-end         { align-items: flex-end; }
.justify-between   { justify-content: space-between; }
.justify-center    { justify-content: center; }
.justify-end       { justify-content: flex-end; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.wrap   { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

.hidden   { display: none !important; }
.sr-only  {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.w-full   { width: 100%; }
.h-full   { height: 100%; }
.min-h-screen { min-height: 100vh; }

.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }
.pt-4 { padding-top: var(--space-4); }
.pb-4 { padding-bottom: var(--space-4); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

.m-0    { margin: 0; }
.mt-2   { margin-top: var(--space-2); }
.mt-4   { margin-top: var(--space-4); }
.mt-6   { margin-top: var(--space-6); }
.mb-2   { margin-bottom: var(--space-2); }
.mb-4   { margin-bottom: var(--space-4); }
.mb-6   { margin-bottom: var(--space-6); }
.mx-auto { margin-left: auto; margin-right: auto; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.inset-0  { inset: 0; }

.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }

.cursor-pointer { cursor: pointer; }
.select-none    { user-select: none; }

.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }


/* ═══════════════════════════════════════════════════════════════
   5. SCROLLBAR STYLING (Webkit)
═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background:    rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }


/* ═══════════════════════════════════════════════════════════════
   6. FOCUS / ACCESSIBILITY
═══════════════════════════════════════════════════════════════ */
:focus-visible {
  outline:        2px solid var(--color-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

input, input:focus, input:active, input:focus-visible {
  outline: none !important;
}

input::placeholder        { color: var(--color-text-subtle); font-weight: 300; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus { -webkit-text-fill-color: var(--color-text); transition: background-color 9999s ease; }


/* ═══════════════════════════════════════════════════════════════
   7. REDUCED MOTION
═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ═══════════════════════════════════════════════════════════════
   8. DM SANS FONT IMPORT (self-hosted fallback via Google Fonts)
═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');
