/**
 * Typography System - Consolidated font definitions and sizing
 * All typography variables and styles in one place
 */

:root {
  /* Font Families */
  --font-primary: 'FoundersGrotesk', sans-serif;
  --font-secondary: 'Open Sans', sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
  
  /* Font Sizes - Desktop */
  --font-size-h1: clamp(4rem, 25vw, 15rem);
  --font-size-h2: 3rem;
  --font-size-h3: 1.25rem;
  --font-size-h4: 1.5rem;
  --font-size-h5: 1.25rem;
  --font-size-h6: 1.1rem;
  --font-size-body: 1rem;
  --font-size-small: 0.9rem;
  --font-size-tiny: 0.6rem;
  
  /* Font Sizes - Mobile */
  --mobile-font-size-h1: clamp(1.5rem, 15vw, 4rem);
  --mobile-font-size-h2: 1.5rem;
  --mobile-font-size-h3: 1rem;
  --mobile-font-size-h4: 1.1rem;
  --mobile-font-size-h5: 1rem;
  --mobile-font-size-h6: 0.9rem;
  --mobile-font-size-body: 0.9rem;
  --mobile-font-size-small: 0.8rem;
  --mobile-font-size-tiny: 0.6rem;
  
  /* Font Sizes - UI Elements */
  --popover-font-size: 0.9rem;
  --coords-hud-font-size: 1.2rem;
  --version-font-size: 0.6rem;
  --button-font-size: 2rem;
  --minimap-font-size: 0.7rem;
  
  /* Font Weights */
  --font-weight-light: 300;
  --font-weight-normal: normal;
  --font-weight-bold: bold;
  --font-weight-heavy: 900;
  
  /* Line Heights */
  --line-height-tight: 0.8;
  --line-height-normal: 1.2;
  --line-height-relaxed: 1.5;
  
  /* Letter Spacing */
  --letter-spacing-tight: -0.04em;
  --letter-spacing-normal: 0;
}

/* ========== Base Typography ========== */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: var(--line-height-normal);
}

h1 {
  font-family: var(--font-primary);
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-bold);
  line-height: 1;
  letter-spacing: var(--letter-spacing-tight);
  margin-block-start: 0;
  margin-block-end: 0;
}

h2 {
  font-family: var(--font-secondary);
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-light);
  letter-spacing: var(--letter-spacing-tight);
  margin-top: 4rem;
}

h3 {
  font-family: var(--font-secondary);
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-normal);
}

h4 {
  font-family: var(--font-secondary);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-normal);
  text-align: left;
}

h5 {
  font-family: var(--font-secondary);
  font-size: var(--font-size-h5);
  font-weight: var(--font-weight-normal);
  text-align: right;
}

h6 {
  font-family: var(--font-secondary);
  font-size: var(--font-size-h6);
  font-weight: var(--font-weight-normal);
}

body, p {
  font-family: var(--font-secondary);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-relaxed);
}

small {
  font-size: var(--font-size-small);
}

/* ========== Breadcrumb Typography ========== */
.section-breadcrumb {
  font-family: var(--font-primary);
  font-size: 0.8rem;
  font-weight: var(--font-weight-normal);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  opacity: 0.7;
}

/* ========== Grid Item Typography ========== */
.grid-item {
  font-family: var(--font-secondary);
}

.grid-item h1 {
  margin: 0;
  margin-bottom: -120px;
  padding-top: 10px;
  color: var(--text-primary);
  text-align: center;
  z-index: 2;
  white-space: nowrap;
  max-width: 100%;
}

.grid-item h2 {
  margin: 4rem 0 2rem 0;
  color: var(--text-primary);
  opacity: 0.8;
  text-align: center;
  z-index: 2;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 85%;
}

.grid-item h4 {
  text-align: left;
  width: 100%;
  max-width: 85%;
  margin: -0.75rem 0;
}

.grid-item h5 {
  text-align: right;
  width: 100%;
  max-width: 85%;
  margin: -0.75rem 0;
}

/* ========== UI Element Typography ========== */
.more-info-btn {
  font-size: var(--button-font-size);
  font-weight: var(--font-weight-bold);
}

.bsp-split-btn {
  font-size: 1.5rem;
}

.minimap-dot {
  font-size: var(--minimap-font-size);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-mono);
}

#coords-hud {
  font-family: var(--font-mono);
  font-size: var(--coords-hud-font-size);
}

#version-footer .version {
  font-size: var(--version-font-size);
  font-weight: var(--font-weight-normal);
  font-family: var(--font-mono);
}

#top-nav a {
  font-size: 1.5rem;
  font-family: var(--font-secondary);
}

.header-content h1 {
  font-family: var(--font-primary);
  font-size: 2rem;
  line-height: var(--line-height-normal);
  text-align: left;
  letter-spacing: var(--letter-spacing-tight);
}

.popover,
#minimap-popover {
  font-size: var(--popover-font-size);
}

/* ========== Video Background Typography ========== */
.grid-item:has(.section-video-bg) h1,
.grid-item:has(.section-video-bg) h2 {
  position: relative;
  z-index: 2;
  text-shadow: none;
  background: none;
  padding: 0;
  border-radius: 0;
  backdrop-filter: none;
}

/* ========== BSP Tree Typography ========== */
.bsp-section {
  font-family: var(--font-primary);
  font-size: 1.2rem;
  font-weight: var(--font-weight-bold);
}

/* ========== Mobile Typography Overrides ========== */
@media (max-width: 767px) {
  :root {
    --font-size-h1: var(--mobile-font-size-h1);
    --font-size-h2: var(--mobile-font-size-h2);
    --font-size-h3: var(--mobile-font-size-h3);
    --font-size-h4: var(--mobile-font-size-h4);
    --font-size-h5: var(--mobile-font-size-h5);
    --font-size-h6: var(--mobile-font-size-h6);
    --font-size-body: var(--mobile-font-size-body);
    --font-size-small: var(--mobile-font-size-small);
    --coords-hud-font-size: 0.85rem;
  }
  
  .grid-item h1 {
    margin-bottom: -60px;
    white-space: nowrap;
    padding: 10px 20px 0;
  }
  
  .grid-item h2 {
    max-width: 80%;
  }
}

/* ========== Tablet Typography Overrides ========== */
@media (min-width: 768px) and (max-width: 991px) {
  .header-content h1 {
    font-size: 1.75rem;
  }
}

/* ========== Large Desktop Typography ========== */
@media (min-width: 1600px) {
  #coords-hud {
    font-size: 1.1rem;
  }
}

/* ========== Landscape Orientation ========== */
@media (orientation: landscape) and (max-height: 500px) {
  #coords-hud {
    font-size: 0.8rem;
  }
}

/* ========== Long Title Handling ========== */
@media (max-width: 1200px) {
  .grid-item h1 {
    font-size: clamp(3rem, 20vw, 10rem);
  }
}

@media (max-width: 768px) {
  .grid-item h1 {
    font-size: clamp(1.2rem, 12vw, 3.5rem);
  }
}

/* ========== Section 1 Special Styling ========== */
.grid-item[data-section-index="0"] h1 {
  font-size: clamp(6rem, 35vw, 20rem) !important;
}

@media (max-width: 768px) {
  .grid-item[data-section-index="0"] h1 {
    font-size: clamp(2rem, 18vw, 6rem) !important;
  }
}