/* Inter Variable Font Face Declaration */
@font-face {
  font-family: 'Inter var';
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
  font-named-instance: 'Regular';
  src: url('/fonts/InterVariable.woff2') format('woff2-variations'),
       url('/fonts/InterVariable.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* JetBrains Mono Regular Font Face Declaration */
@font-face {
  font-family: 'JetBrains Mono';
  font-weight: 400;
  font-display: swap;
  font-style: normal;
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
}

/* Crimson Pro Variable - Normal */
@font-face {
  font-family: 'Crimson Pro';
  font-weight: 200 900;
  font-display: swap;
  font-style: normal;
  src: url('/fonts/crimson-pro-latin-wght-normal.woff2') format('woff2-variations'),
       url('/fonts/crimson-pro-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Crimson Pro Variable - Italic */
@font-face {
  font-family: 'Crimson Pro';
  font-weight: 200 900;
  font-display: swap;
  font-style: italic;
  src: url('/fonts/crimson-pro-latin-wght-italic.woff2') format('woff2-variations'),
       url('/fonts/crimson-pro-latin-wght-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Fallback font stacks */
:root {
  --font-sans-fallback: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-mono-fallback: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-serif-fallback: Georgia, "Times New Roman", Times, serif;
}

/* Default state - use fallback fonts */
html {
  font-family: var(--font-sans-fallback);
}

/* When fonts are loaded, use Inter */
.fonts-loaded {
  font-family: 'Inter var', var(--font-sans-fallback);
}

/* Ensure all elements inherit the font except code */
* {
  font-family: inherit;
}

/* Code elements use monospace fallback initially */
code, pre, kbd, samp, tt {
  font-family: var(--font-mono-fallback);
}

/* When fonts are loaded, use JetBrains Mono */
.fonts-loaded code,
.fonts-loaded pre,
.fonts-loaded kbd,
.fonts-loaded samp,
.fonts-loaded tt {
  font-family: 'JetBrains Mono', var(--font-mono-fallback);
}

/* Prevent layout shift by matching metrics */
body {
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.011em;
  font-weight: 400;
}

/* Font weight utilities that work with variable fonts */
.fonts-loaded .font-thin { font-weight: 100; }
.fonts-loaded .font-extralight { font-weight: 200; }
.fonts-loaded .font-light { font-weight: 300; }
.fonts-loaded .font-normal { font-weight: 400; }
.fonts-loaded .font-medium { font-weight: 500; }
.fonts-loaded .font-semibold { font-weight: 600; }
.fonts-loaded .font-bold { font-weight: 700; }
.fonts-loaded .font-extrabold { font-weight: 800; }
.fonts-loaded .font-black { font-weight: 900; }

.fonts-loaded .prose {
  font-family: 'Crimson Pro', var(--font-serif-fallback);
}

/* Optimize font rendering */
.fonts-loaded body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
