/* ==========================================================================
   base.css
   Reset, design tokens (color/spacing/type/shadow), typography scale.
   No layout rules here — see layout.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. RESET
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

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

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

button {
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

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

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
}

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

/* --------------------------------------------------------------------------
   2. DESIGN TOKENS — LIGHT THEME (default)
   -------------------------------------------------------------------------- */
:root,
:root[data-theme="light"] {
  /* Neutral scale — warm-neutral grays, no chroma spikes */
  --neutral-0:   #ffffff;
  --neutral-50:  #f7f7f6;
  --neutral-100: #f0efed;
  --neutral-150: #e7e6e3;
  --neutral-200: #dcdad6;
  --neutral-300: #c3c1bc;
  --neutral-400: #9d9b95;
  --neutral-500: #7a7873;
  --neutral-600: #5c5a56;
  --neutral-700: #444341;
  --neutral-800: #2c2b2a;
  --neutral-900: #1a1918;
  --neutral-950: #0f0e0e;

  /* Single muted accent — soft graphite/slate, used sparingly */
  --accent-100: #e9e8e5;
  --accent-400: #8b877e;
  --accent-500: #6f6b62;
  --accent-600: #57534c;

  /* Semantic surface tokens */
  --color-bg-canvas:      var(--neutral-50);
  --color-bg-surface:     var(--neutral-0);
  --color-bg-surface-alt: var(--neutral-100);
  --color-bg-sunken:      var(--neutral-150);
  --color-bg-hover:       var(--neutral-100);
  --color-bg-active:      var(--neutral-150);
  --color-bg-selected:    var(--accent-100);

  /* Text */
  --color-text-primary:   var(--neutral-900);
  --color-text-secondary: var(--neutral-600);
  --color-text-muted:     var(--neutral-400);
  --color-text-inverse:   var(--neutral-0);
  --color-text-accent:    var(--accent-600);

  /* Borders / dividers */
  --color-border-subtle:  var(--neutral-150);
  --color-border-default: var(--neutral-200);
  --color-border-strong:  var(--neutral-300);

  /* Focus ring */
  --color-focus-ring: var(--neutral-900);

  /* Shadows — soft, neutral, no color tint */
  --shadow-sm: 0 1px 2px rgba(15, 14, 14, 0.06);
  --shadow-md: 0 2px 8px rgba(15, 14, 14, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 14, 14, 0.10);
  --shadow-inset: inset 0 0 0 1px rgba(15, 14, 14, 0.06);

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   3. DESIGN TOKENS — DARK THEME
   -------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  --neutral-0:   #0f0e0e;
  --neutral-50:  #161514;
  --neutral-100: #1d1c1b;
  --neutral-150: #242322;
  --neutral-200: #2d2c2a;
  --neutral-300: #403f3c;
  --neutral-400: #5c5a56;
  --neutral-500: #7a7873;
  --neutral-600: #9d9b95;
  --neutral-700: #c3c1bc;
  --neutral-800: #e7e6e3;
  --neutral-900: #f0efed;
  --neutral-950: #ffffff;

  --accent-100: #2a2925;
  --accent-400: #a9a49a;
  --accent-500: #c2bcb0;
  --accent-600: #d8d2c6;

  --color-bg-canvas:      var(--neutral-50);
  --color-bg-surface:     var(--neutral-100);
  --color-bg-surface-alt: var(--neutral-150);
  --color-bg-sunken:      var(--neutral-0);
  --color-bg-hover:       var(--neutral-150);
  --color-bg-active:      var(--neutral-200);
  --color-bg-selected:    var(--accent-100);

  --color-text-primary:   var(--neutral-900);
  --color-text-secondary: var(--neutral-600);
  --color-text-muted:     var(--neutral-500);
  --color-text-inverse:   var(--neutral-0);
  --color-text-accent:    var(--accent-600);

  --color-border-subtle:  var(--neutral-150);
  --color-border-default: var(--neutral-200);
  --color-border-strong:  var(--neutral-300);

  --color-focus-ring: var(--neutral-900);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.50);
  --shadow-inset: inset 0 0 0 1px rgba(255, 255, 255, 0.06);

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   4. TYPOGRAPHY SCALE
   -------------------------------------------------------------------------- */
:root {
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Inter", Helvetica, Arial, sans-serif;
  --font-family-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --font-size-xs:   0.75rem;   /* 12px */
  --font-size-sm:   0.875rem;  /* 14px */
  --font-size-base: 1rem;      /* 16px */
  --font-size-md:   1.125rem;  /* 18px */
  --font-size-lg:   1.375rem;  /* 22px */
  --font-size-xl:   1.75rem;   /* 28px */
  --font-size-2xl:  2.25rem;   /* 36px */

  --font-weight-regular:  400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

  --line-height-base:    1.5;
  --line-height-heading: 1.25;
  --line-height-tight:   1.1;
}

/* --------------------------------------------------------------------------
   5. ROOT LAYOUT VARIABLES
   (values consumed by layout.css; centralized here for easy tuning)
   -------------------------------------------------------------------------- */
:root {
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  --sidebar-width: 260px;
  --sidebar-width-collapsed: 64px;
  --toolbar-height: 56px;

  --drive-topbar-height: 56px;
  --drive-tabs-height: 48px;
  --drive-bottom-nav-height: 64px;
  --drive-fab-size: 56px;

  --breakpoint-mobile: 768px;
  --breakpoint-tablet: 1024px;

  --transition-theme: 150ms ease;
  --transition-base: 180ms ease;
  --transition-fast: 100ms ease;

  --z-sidebar: 10;
  --z-toolbar: 20;
  --z-drawer-backdrop: 40;
  --z-drawer-panel: 50;
  --z-fab: 30;
}

/* --------------------------------------------------------------------------
   6. ACCESSIBILITY HELPERS (base-level, generic ones live in utilities.css)
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: top var(--transition-base);
}

.skip-link:focus {
  top: var(--space-4);
}

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}