/**
 * MobiDaS Tutorial - Design System
 * "Refined Scientific" aesthetic for thesis artefact
 *
 * Typography: DM Serif Display (headings) + DM Sans (body)
 * Color System: Deep teal primary, warm off-white background, orange accent
 */

/* ═══════════════════════════════════════════════════════════════════════════
   GOOGLE FONTS IMPORT
   ═══════════════════════════════════════════════════════════════════════════ */

@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,600;0,9..40,700;1,9..40,400;1,9..40,500&family=DM+Serif+Display:ital@0;1&display=swap');

/* ═══════════════════════════════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─────────────────────────────────────────────────────────────────────────
     COLOR SYSTEM
     ───────────────────────────────────────────────────────────────────────── */

  /* Primary Colors */
  --color-primary: #0f4c75;
  --color-primary-light: #3282b8;
  --color-primary-dark: #0a3a5c;
  --color-primary-50: rgba(15, 76, 117, 0.05);
  --color-primary-100: rgba(15, 76, 117, 0.1);
  --color-primary-200: rgba(15, 76, 117, 0.2);

  /* Accent Colors */
  --color-accent: #e85d04;
  --color-accent-light: #f48c42;
  --color-accent-dark: #c44d00;
  --color-accent-50: rgba(232, 93, 4, 0.05);
  --color-accent-100: rgba(232, 93, 4, 0.1);

  /* Background Colors */
  --color-bg: #f7f4ef;
  --color-bg-warm: #faf8f5;
  --color-bg-cool: #f0f4f8;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;

  /* Text Colors */
  --color-text: #1a1a2e;
  --color-text-secondary: #4a4a68;
  --color-text-muted: #6b7280;
  --color-text-inverse: #ffffff;

  /* Semantic Colors */
  --color-success: #059669;
  --color-success-light: #d1fae5;
  --color-success-dark: #047857;

  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-warning-dark: #b45309;

  --color-error: #dc2626;
  --color-error-light: #fee2e2;
  --color-error-dark: #b91c1c;

  --color-info: #0284c7;
  --color-info-light: #e0f2fe;
  --color-info-dark: #0369a1;

  /* Border Colors */
  --color-border: #e5e2dc;
  --color-border-light: #f0ede8;
  --color-border-dark: #d1cec8;

  /* ─────────────────────────────────────────────────────────────────────────
     TYPOGRAPHY
     ───────────────────────────────────────────────────────────────────────── */

  /* Font Families */
  --font-heading: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

  /* Font Sizes - Using fluid typography */
  --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 */
  --text-5xl: 3rem;        /* 48px */

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Letter Spacing */
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;

  /* ─────────────────────────────────────────────────────────────────────────
     SPACING SCALE - More generous for breathable design
     ───────────────────────────────────────────────────────────────────────── */

  --space-0: 0;
  --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 */
  --space-24: 6rem;        /* 96px */
  --space-32: 8rem;        /* 128px */

  /* Spacing aliases for components */
  --spacing-1: var(--space-1);
  --spacing-2: var(--space-2);
  --spacing-3: var(--space-3);
  --spacing-4: var(--space-4);
  --spacing-5: var(--space-5);
  --spacing-6: var(--space-6);
  --spacing-8: var(--space-8);
  --spacing-10: var(--space-10);
  --spacing-12: var(--space-12);
  --spacing-16: var(--space-16);
  --spacing-20: var(--space-20);
  --spacing-24: var(--space-24);
  --spacing-32: var(--space-32);

  /* ─────────────────────────────────────────────────────────────────────────
     LAYOUT
     ───────────────────────────────────────────────────────────────────────── */

  --navbar-height: 64px;
  --sidebar-width: 280px;
  --sidebar-width-collapsed: 64px;
  --content-max-width: 800px;
  --content-wide-max-width: 1200px;
  --container-padding: var(--space-6);

  /* ─────────────────────────────────────────────────────────────────────────
     BORDERS & RADII
     ───────────────────────────────────────────────────────────────────────── */

  --radius-none: 0;
  --radius-sm: 0.25rem;    /* 4px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-2xl: 1.5rem;    /* 24px */
  --radius-full: 9999px;

  --border-width: 1px;
  --border-width-2: 2px;
  --border-width-4: 4px;

  /* ─────────────────────────────────────────────────────────────────────────
     SHADOWS
     ───────────────────────────────────────────────────────────────────────── */

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
  --shadow-none: none;

  /* Colored shadows for elevated elements */
  --shadow-primary: 0 4px 14px -3px rgba(15, 76, 117, 0.25);
  --shadow-accent: 0 4px 14px -3px rgba(232, 93, 4, 0.25);

  /* ─────────────────────────────────────────────────────────────────────────
     TRANSITIONS
     ───────────────────────────────────────────────────────────────────────── */

  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 500ms ease;

  /* Specific transitions */
  --transition-colors: color 200ms ease, background-color 200ms ease, border-color 200ms ease;
  --transition-transform: transform 200ms ease;
  --transition-opacity: opacity 200ms ease;
  --transition-shadow: box-shadow 200ms ease;
  --transition-all: all 200ms ease;

  /* ─────────────────────────────────────────────────────────────────────────
     Z-INDEX SCALE
     ───────────────────────────────────────────────────────────────────────── */

  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
  --z-toast: 800;

  /* ─────────────────────────────────────────────────────────────────────────
     FOCUS RING (Accessibility)
     ───────────────────────────────────────────────────────────────────────── */

  --focus-ring-color: var(--color-primary);
  --focus-ring-width: 3px;
  --focus-ring-offset: 2px;
  --focus-ring: 0 0 0 var(--focus-ring-offset) var(--color-bg),
                0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BASE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

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

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

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

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

/* ═══════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════ */

/* Headings - More generous spacing for breathable design */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-normal);
  line-height: 1.2;
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: 1.25rem;
}

h1 {
  font-size: clamp(2.25rem, 5vw, var(--text-5xl));
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: clamp(1.875rem, 4vw, var(--text-4xl));
  letter-spacing: -0.01em;
  margin-bottom: 1.25rem;
}

h3 {
  font-size: clamp(1.5rem, 3vw, var(--text-2xl));
  margin-bottom: 1rem;
}

h4 {
  font-size: var(--text-xl);
  margin-bottom: 0.875rem;
}

h5 {
  font-size: var(--text-lg);
  margin-bottom: 0.75rem;
}

h6 {
  font-size: var(--text-base);
  font-family: var(--font-body);
  font-weight: var(--font-semibold);
  margin-bottom: 0.75rem;
}

/* Paragraphs - Generous spacing */
p {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

p:last-child {
  margin-bottom: 0;
}

/* Lead paragraph */
.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

/* Small text */
small, .small {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--color-primary-dark);
}

a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Strong & Emphasis */
strong, b {
  font-weight: var(--font-semibold);
}

em, i {
  font-style: italic;
}

/* Code */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--color-primary-50);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  background-color: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-4) 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* Blockquotes */
blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  border-left: var(--border-width-4) solid var(--color-primary);
  background-color: var(--color-primary-50);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote cite {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  font-style: normal;
  color: var(--color-text-muted);
}

/* Lists */
ul, ol {
  margin: var(--space-4) 0;
  padding-left: var(--space-6);
}

li {
  margin-bottom: var(--space-2);
}

li:last-child {
  margin-bottom: 0;
}

/* Definition Lists */
dl {
  margin: var(--space-4) 0;
}

dt {
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
}

dd {
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
}

/* Horizontal Rule */
hr {
  border: none;
  border-top: var(--border-width) solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════ */

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Colors */
.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

/* Font Weights */
.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

/* Display */
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }

/* Flexbox */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.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); }

/* Spacing */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* Width */
.w-full { width: 100%; }
.max-w-content { max-width: var(--content-max-width); }
.max-w-wide { max-width: var(--content-wide-max-width); }

/* Visibility */
.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;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: inherit;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

/*
 * Breakpoint system:
 * --breakpoint-sm: 640px
 * --breakpoint-md: 768px
 * --breakpoint-lg: 1024px
 * --breakpoint-xl: 1280px
 * --breakpoint-2xl: 1536px
 */

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0;
    --container-padding: var(--space-4);
  }

  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  h3 {
    font-size: var(--text-xl);
  }
}

@media (max-width: 640px) {
  :root {
    --container-padding: var(--space-3);
  }

  h1 {
    font-size: var(--text-2xl);
  }

  h2 {
    font-size: var(--text-xl);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  :root {
    --color-bg: #ffffff;
    --color-text: #000000;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

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

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  .no-print {
    display: none !important;
  }
}
