/* ============================================================================
   BASE STYLES - Global typography, fonts, resets, and mobile fixes
   ============================================================================
   This file provides:
   - @font-face declarations (Inter typeface family)
   - Global typography classes
   - Mobile/responsive resets
   - HTML/body baseline styles
*/

/* ──────────────────────────────────────────────────────
   FONT DECLARATIONS - Inter Typeface
   ─────────────────────────────────────────────────────– */

/* Light - For elegant, airy body text */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

/* Regular - Primary body text weight */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Regular Italic */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* Medium - Secondary headings */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* Medium Italic */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-MediumItalic.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

/* SemiBold - Primary headings */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* SemiBold Italic */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-SemiBoldItalic.woff2') format('woff2');
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}

/* Bold - Hero headings */
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ──────────────────────────────────────────────────────
   GLOBAL RESETS & HTML BASELINE
   ────────────────────────────────────────────────────── */

html {
  scroll-behavior: smooth;
  /* Ensure consistent font sizing across all browsers */
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background-color: var(--bg-page);
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  margin: 0;
  padding: 0;
}

/* Ensure app container has proper background */
#app-layout-container {
  background-color: var(--bg-page);
  min-height: 100vh;
}

/* Page content container */
#page-content {
  background-color: var(--bg-page);
}

/* ──────────────────────────────────────────────────────
   TYPOGRAPHY UTILITY CLASSES
   ────────────────────────────────────────────────────── */

/* Base text class */
.dmc-text {
  font-family: var(--font-family);
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Text size variants */
.dmc-text--body {
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
  font-weight: 400;
}

.dmc-text--caption {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  font-weight: 400;
  color: var(--text-dimmed);
}

.dmc-text--small {
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
  font-weight: 400;
}

.dmc-text--large {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-lg);
  font-weight: 400;
}

/* Heading class base */
.dmc-title {
  font-family: var(--font-family-heading);
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--text-primary);
  margin: 0;
  font-weight: 700;
}

/* Heading size variants - Using CSS variables from Mantine */
.dmc-title--h1 {
  font-size: var(--mantine-h1-font-size, 2.125rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.dmc-title--h2 {
  font-size: var(--mantine-h2-font-size, 1.625rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.025em;
}

.dmc-title--h3 {
  font-size: var(--mantine-h3-font-size, 1.375rem);
  font-weight: 700;
  line-height: 1.4;
}

.dmc-title--h4 {
  font-size: var(--mantine-h4-font-size, 1.125rem);
  font-weight: 700;
  line-height: 1.45;
}

.dmc-title--h5 {
  font-size: var(--mantine-h5-font-size, 1rem);
  font-weight: 700;
  line-height: 1.5;
}

.dmc-title--h6 {
  font-size: var(--mantine-h6-font-size, 0.875rem);
  font-weight: 700;
  line-height: 1.55;
}

/* Semantic text color variants */
.dmc-text--muted,
.dmc-text--dimmed {
  color: var(--text-dimmed) !important;
}

.dmc-text--primary {
  color: var(--color-primary) !important;
}

.dmc-text--error {
  color: var(--color-error-custom) !important;
}

.dmc-text--success {
  color: var(--color-success) !important;
}

.dmc-text--warning {
  color: var(--color-warning) !important;
}

/* Heading semantic colors */
.dmc-title--muted,
.dmc-title--dimmed {
  color: var(--text-dimmed) !important;
}

.dmc-title--primary {
  color: var(--color-primary) !important;
}

.dmc-title--center {
  text-align: center;
}

/* ──────────────────────────────────────────────────────
   TEXT UTILITY CLASSES
   ────────────────────────────────────────────────────– */

.text-uppercase {
  text-transform: uppercase !important;
  letter-spacing: 0.05em;
}

.text-center {
  text-align: center !important;
}

.text-left {
  text-align: left !important;
}

.text-right {
  text-align: right !important;
}

/* ──────────────────────────────────────────────────────
   MOBILE / RESPONSIVE FIXES
   ────────────────────────────────────────────────────– */

/* Mobile Header - Keep header fixed and visible */
@media (max-width: 768px) {
  /* Force page content responsive on mobile */
  #page-content {
    margin-left: 0 !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  /* Prevent iOS scroll interference */
  body {
    -webkit-overflow-scrolling: touch !important;
  }

  html,
  body {
    overflow-x: hidden !important;
  }

  /* Prevent iOS auto-zoom on focus */
  input,
  select,
  textarea,
  .mantine-input,
  .mantine-Input-input,
  .mantine-MultiSelect-input,
  [data-mantine-component="MultiSelect"] input {
    font-size: 16px !important;
  }

  /* Natural flow for explorer filters (no internal scroll) */
  #explorer-filters-container {
    max-height: none !important;
    overflow-y: visible !important;
    padding-right: 0 !important;
  }
}

/* Desktop header visibility at sidebar breakpoint */
@media (max-width: 990px) {
  .desktop-header-element {
    display: none !important;
  }
}

@media (min-width: 991px) {
  .desktop-header-element {
    display: flex !important;
  }
}

/* MOBILE CARD OPTIMIZATION */
@media (max-width: 768px) {
  /* Compact DMC Cards on mobile */
  .mantine-Card-root {
    padding: 8px !important;
    margin-bottom: 8px !important;
  }

  .mantine-Card-root .mantine-Stack-root {
    gap: 4px !important;
  }

  .mantine-Card-root .mantine-Group-root {
    gap: 8px !important;
    margin: 0 !important;
    flex-wrap: wrap !important;
  }

  /* Compact KPI values */
  .mantine-Card-root .mantine-Text-root[style*="fontSize: 2rem"] {
    font-size: 1.5rem !important;
    line-height: 1.2 !important;
  }

  /* Compact titles */
  .mantine-Card-root .mantine-Text-root[style*="textTransform: uppercase"] {
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
    margin-bottom: 2px !important;
  }

  /* Compact buttons */
  .mantine-Card-root .mantine-Button-root {
    font-size: 0.75rem !important;
    padding: 4px 8px !important;
    min-width: auto !important;
  }

  /* Compact borders */
  .mantine-Card-root .mantine-Box-root[style*="borderLeft"] {
    padding-left: 8px !important;
  }

  /* Container padding */
  .mantine-Container-root:not(.explorer-page) {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  /* SimpleGrid gaps */
  .mantine-SimpleGrid-root {
    gap: 8px !important;
  }

  /* Page content padding */
  #page-content {
    padding: 8px !important;
  }

  /* Section header spacing */
  .mantine-Title-root {
    margin-bottom: 8px !important;
  }

  /* Reduce Grid spacing */
  .mantine-Grid-root {
    margin: 0 !important;
  }

  .mantine-GridCol-root {
    padding: 4px !important;
  }

  /* Project cards on home page */
  .project-cards-container .mantine-Card-root {
    height: auto !important;
    max-height: none !important;
  }
}

/* Extra small mobile (< 480px) */
@media (max-width: 480px) {
  .mantine-Card-root {
    padding: 6px !important;
    margin-bottom: 6px !important;
  }

  .mantine-Card-root .mantine-Text-root[style*="fontSize: 2rem"] {
    font-size: 1.3rem !important;
  }

  .mantine-Card-root .mantine-Group-root {
    gap: 0.25rem !important;
    row-gap: 0.25rem !important;
  }
}

/* Prevent horizontal scrolling on mobile */
@media (max-width: 768px) {
  body,
  html {
    overflow-x: hidden !important;
    width: 100% !important;
  }

  #page-content {
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .mantine-Container-root {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* Large screens - optimize layout */
@media (min-width: 900px) {
  .mantine-Container-root {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }

  .mantine-Grid-col {
    padding: 1rem !important;
  }
}

/* Responsive grid for KPI cards */
@media (max-width: 640px) {
  [style*="cols="] .mantine-Grid-col {
    max-width: 50% !important;
    padding: 0.35rem !important;
  }
}
