/*
 * base.css
 * Global reset and design foundations only.
 */

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

:root {
  /* Backgrounds */
  --color-bg: #f5f1eb;
  --color-surface: #fdfaf5;
  --color-surface-alt: #ede8de;

  /* Borders */
  --color-border: #d6ceba;
  --color-border-focus: #2c3e6b;

  /* Text */
  --color-text-primary: #1a1a2e;
  --color-text-secondary: #5c5748;
  --color-text-muted: #9e9485;
  --color-text-on-accent: #ffffff;

  /* Accent */
  --color-accent: #c8860a;
  --color-accent-hover: #a36e08;
  --color-accent-light: #fdf0d5;

  /* Semantic */
  --color-danger: #c0392b;
  --color-danger-hover: #a93226;
  --color-danger-light: #fdedec;
  --color-success: #1e7e50;
  --color-success-light: #e8f5ee;
  --color-warning: #e67e22;
  --color-warning-light: #fef5e7;

  /* Study Card */
  --color-card-front: #fdfaf5;
  --color-card-back: #2c3e6b;
  --color-card-back-text: #fdfaf5;

  /* Overlays */
  --color-overlay: rgba(26, 26, 46, 0.5);

  /* Typography */
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.375rem;
  --text-xl: 1.75rem;
  --text-2xl: 2.25rem;
  --text-3xl: 3rem;

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-loose: 1.8;

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

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;
  --space-10: 4rem;
  --space-12: 5rem;

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

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(26, 26, 46, 0.06), 0 1px 2px rgba(26, 26, 46, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 26, 46, 0.08), 0 2px 4px rgba(26, 26, 46, 0.04);
  --shadow-lg: 0 10px 30px rgba(26, 26, 46, 0.12), 0 4px 8px rgba(26, 26, 46, 0.06);
  --shadow-card: 0 2px 8px rgba(26, 26, 46, 0.1);
  --shadow-modal: 0 20px 60px rgba(26, 26, 46, 0.2), 0 8px 20px rgba(26, 26, 46, 0.1);

  /* Layering */
  --z-base: 10;
  --z-sidebar: 100;
  --z-modal: 1000;
  --z-toast: 1100;

  /* Component sizing */
  --border-strong: 4px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a2e;
    --color-surface: #22223b;
    --color-surface-alt: #16213e;
    --color-border: #4a4a6b;
    --color-border-focus: #8ea2d6;
    --color-text-primary: #f0ede6;
    --color-text-secondary: #c9c3b7;
    --color-text-muted: #a49d90;
    --color-text-on-accent: #fdfaf5;
    --color-accent: #8a5d08;
    --color-accent-hover: #744d06;
    --color-accent-light: #3d2a00;
    --color-success: #2b9b65;
    --color-warning: #f09a3f;
    --color-danger: #d65a4d;
    --color-card-back: #30457a;
    --color-card-back-text: #f7f3eb;

    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  --color-bg: #f5f1eb;
  --color-surface: #fdfaf5;
  --color-surface-alt: #ede8de;
  --color-border: #d6ceba;
  --color-text-primary: #1a1a2e;
  --color-text-secondary: #5c5748;
  --color-text-muted: #9e9485;
  --color-accent-light: #fdf0d5;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --color-bg: #1a1a2e;
  --color-surface: #22223b;
  --color-surface-alt: #16213e;
  --color-border: #4a4a6b;
  --color-border-focus: #8ea2d6;
  --color-text-primary: #f0ede6;
  --color-text-secondary: #c9c3b7;
  --color-text-muted: #a49d90;
  --color-text-on-accent: #fdfaf5;
  --color-accent: #8a5d08;
  --color-accent-hover: #744d06;
  --color-accent-light: #3d2a00;
  --color-success: #2b9b65;
  --color-warning: #f09a3f;
  --color-danger: #d65a4d;
  --color-card-back: #30457a;
  --color-card-back-text: #f7f3eb;

  color-scheme: dark;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.has-mobile-sidebar-open {
  overflow: hidden;
}

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

p,
li,
blockquote {
  color: var(--color-text-secondary);
  font-family: var(--font-body);
}

button,
input,
select,
textarea,
label {
  font-family: var(--font-ui);
}

code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
}

.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;
}

@media (max-width: 767px) {
  :root {
    --text-lg: clamp(1.2rem, 4vw, 1.35rem);
    --text-xl: clamp(1.4rem, 5vw, 1.7rem);
    --text-2xl: clamp(1.8rem, 7vw, 2.1rem);
  }
}
