/*
 * WSJ Typography System for FX Magazine
 * Wall Street Journal inspired typography with trading-specific styles
 * @package fxmag
 */

/* Font Face Declarations */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700;1,800;1,900&family=Source+Sans+Pro:ital,wght@0,300;0,400;0,600;0,700;0,900;1,300;1,400;1,600;1,700;1,900&family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap');

/* CSS Custom Properties for Typography Scale */
:root {
    /* Font Family Variables */
    --font-family-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-family-sans: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-family-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Inconsolata', 'Fira Mono', 'Droid Sans Mono', 'Source Code Pro', monospace;
    
    /* WSJ Typography Scale - Using clamp() for responsive scaling */
    --font-size-xxl: clamp(2.25rem, 4vw, 3.5rem);     /* 36px - 56px */
    --font-size-xl: clamp(1.875rem, 3.5vw, 2.75rem);  /* 30px - 44px */
    --font-size-lg: clamp(1.5rem, 3vw, 2.25rem);      /* 24px - 36px */
    --font-size-md: clamp(1.25rem, 2.5vw, 1.875rem);  /* 20px - 30px */
    --font-size-sm: clamp(1.125rem, 2vw, 1.5rem);     /* 18px - 24px */
    --font-size-xs: clamp(1rem, 1.5vw, 1.25rem);      /* 16px - 20px */
    
    /* Body Text Sizes */
    --font-size-body-lead: clamp(1.25rem, 2vw, 1.375rem);  /* 20px - 22px */
    --font-size-body: clamp(1rem, 1.5vw, 1.125rem);        /* 16px - 18px */
    --font-size-body-small: clamp(0.875rem, 1.25vw, 1rem); /* 14px - 16px */
    --font-size-caption: clamp(0.75rem, 1vw, 0.875rem);    /* 12px - 14px */
    
    /* Line Heights */
    --line-height-tight: 1.1;
    --line-height-snug: 1.2;
    --line-height-normal: 1.4;
    --line-height-relaxed: 1.6;
    --line-height-loose: 1.8;
    
    /* Letter Spacing */
    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
    --letter-spacing-wider: 0.05em;
    
    /* Font Weights */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;
    --font-weight-black: 900;
    
    /* Trading Colors */
    --color-price-up: #16a34a;    /* Green for profit/up */
    --color-price-down: #dc2626;  /* Red for loss/down */
    --color-price-neutral: #6b7280; /* Gray for neutral */
    --color-price-up-bg: #dcfce7;
    --color-price-down-bg: #fee2e2;
    --color-price-neutral-bg: #f3f4f6;
}

/* Font Loading Optimization */
@supports (font-display: swap) {
    @font-face {
        font-family: 'Playfair Display';
        font-display: swap;
    }
    
    @font-face {
        font-family: 'Source Sans Pro';
        font-display: swap;
    }
    
    @font-face {
        font-family: 'JetBrains Mono';
        font-display: swap;
    }
}

/* WSJ Headline Classes */
.wsj-headline-xxl {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-xxl);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    margin-bottom: 1.5rem;
    color: #1a1a1a;
}

.wsj-headline-xl {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    margin-bottom: 1.25rem;
    color: #1a1a1a;
}

.wsj-headline-lg {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 1rem;
    color: #1a1a1a;
}

.wsj-headline-md {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-snug);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 0.875rem;
    color: #1a1a1a;
}

.wsj-headline-sm {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 0.75rem;
    color: #1a1a1a;
}

.wsj-headline-xs {
    font-family: var(--font-family-serif);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 0.5rem;
    color: #1a1a1a;
}

/* WSJ Body Text Classes */
.wsj-body-lead {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-body-lead);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-relaxed);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 1.5rem;
    color: #374151;
}

.wsj-body {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-relaxed);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 1.25rem;
    color: #374151;
}

.wsj-body-small {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    letter-spacing: var(--letter-spacing-normal);
    margin-bottom: 1rem;
    color: #6b7280;
}

/* WSJ Caption and Metadata Classes */
.wsj-caption {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    letter-spacing: var(--letter-spacing-wide);
    margin-bottom: 0.5rem;
    color: #9ca3af;
    text-transform: uppercase;
}

.wsj-byline {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    letter-spacing: var(--letter-spacing-wide);
    color: #6b7280;
    text-transform: uppercase;
}

.wsj-timestamp {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: #9ca3af;
    font-style: italic;
}

/* Code and Monospace */
.wsj-code {
    font-family: var(--font-family-mono);
    font-size: 0.875em;
    font-weight: var(--font-weight-normal);
    background-color: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    color: #1f2937;
}

.wsj-pre {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-relaxed);
    background-color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid #d1d5db;
    overflow-x: auto;
    color: #1f2937;
}

/* Trading-Specific Typography */
.price-up {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-semibold);
    color: var(--color-price-up);
}

.price-down {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-semibold);
    color: var(--color-price-down);
}

.price-neutral {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-medium);
    color: var(--color-price-neutral);
}

.price-change {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-semibold);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    display: inline-block;
}

.price-change.up {
    color: var(--color-price-up);
    background-color: var(--color-price-up-bg);
}

.price-change.down {
    color: var(--color-price-down);
    background-color: var(--color-price-down-bg);
}

.price-change.neutral {
    color: var(--color-price-neutral);
    background-color: var(--color-price-neutral-bg);
}

.currency-pair {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    color: #1f2937;
}

.lot-size,
.pip-value,
.spread {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-medium);
    color: #6b7280;
}

/* Market Status Indicators */
.market-open {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--color-price-up);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

.market-closed {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--color-price-down);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

.market-premarket {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--color-price-neutral);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

/* Signal Types */
.signal-buy {
    font-family: var(--font-family-sans);
    font-weight: var(--font-weight-bold);
    color: var(--color-price-up);
    text-transform: uppercase;
}

.signal-sell {
    font-family: var(--font-family-sans);
    font-weight: var(--font-weight-bold);
    color: var(--color-price-down);
    text-transform: uppercase;
}

.signal-hold {
    font-family: var(--font-family-sans);
    font-weight: var(--font-weight-bold);
    color: var(--color-price-neutral);
    text-transform: uppercase;
}

/* Utility Classes */
.text-italic {
    font-style: italic;
}

.text-bold {
    font-weight: var(--font-weight-bold);
}

.text-semibold {
    font-weight: var(--font-weight-semibold);
}

.text-medium {
    font-weight: var(--font-weight-medium);
}

.text-light {
    font-weight: var(--font-weight-light);
}

.text-uppercase {
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

.text-capitalize {
    text-transform: capitalize;
}

/* Responsive Typography Adjustments */
@media (max-width: 768px) {
    :root {
        --line-height-tight: 1.15;
        --line-height-snug: 1.25;
        --line-height-normal: 1.45;
        --line-height-relaxed: 1.65;
    }
    
    .wsj-headline-xxl,
    .wsj-headline-xl {
        margin-bottom: 1rem;
    }
    
    .wsj-body-lead {
        margin-bottom: 1.25rem;
    }
}

@media (max-width: 480px) {
    .wsj-headline-xxl,
    .wsj-headline-xl,
    .wsj-headline-lg {
        line-height: var(--line-height-snug);
    }
    
    .price-change {
        font-size: 0.75rem;
        padding: 0.0625rem 0.25rem;
    }
}

/* Print Styles */
@media print {
    :root {
        --font-size-xxl: 24pt;
        --font-size-xl: 20pt;
        --font-size-lg: 18pt;
        --font-size-md: 16pt;
        --font-size-sm: 14pt;
        --font-size-xs: 12pt;
        --font-size-body-lead: 14pt;
        --font-size-body: 12pt;
        --font-size-body-small: 10pt;
        --font-size-caption: 9pt;
    }
    
    .wsj-headline-xxl,
    .wsj-headline-xl,
    .wsj-headline-lg,
    .wsj-headline-md,
    .wsj-headline-sm,
    .wsj-headline-xs {
        color: #000;
        font-weight: var(--font-weight-bold);
        page-break-after: avoid;
    }
    
    .wsj-body-lead,
    .wsj-body,
    .wsj-body-small {
        color: #000;
        orphans: 3;
        widows: 3;
    }
    
    .price-up,
    .signal-buy {
        color: #000;
        font-weight: var(--font-weight-bold);
    }
    
    .price-down,
    .signal-sell {
        color: #000;
        font-weight: var(--font-weight-bold);
        text-decoration: underline;
    }
    
    .price-change {
        background-color: transparent !important;
        border: 1px solid #000;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .theme-dark .wsj-headline-xxl,
    .theme-dark .wsj-headline-xl,
    .theme-dark .wsj-headline-lg,
    .theme-dark .wsj-headline-md,
    .theme-dark .wsj-headline-sm,
    .theme-dark .wsj-headline-xs {
        color: #f9fafb;
    }
    
    .theme-dark .wsj-body-lead,
    .theme-dark .wsj-body {
        color: #d1d5db;
    }
    
    .theme-dark .wsj-body-small {
        color: #9ca3af;
    }
    
    .theme-dark .wsj-caption,
    .theme-dark .wsj-timestamp {
        color: #6b7280;
    }
    
    .theme-dark .wsj-byline {
        color: #9ca3af;
    }
    
    .theme-dark .wsj-code {
        background-color: #374151;
        color: #f3f4f6;
    }
    
    .theme-dark .wsj-pre {
        background-color: #1f2937;
        border-left-color: #4b5563;
        color: #f3f4f6;
    }
    
    .theme-dark .currency-pair {
        color: #f9fafb;
    }
    
    .theme-dark .lot-size,
    .theme-dark .pip-value,
    .theme-dark .spread {
        color: #9ca3af;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --color-price-up: #008000;
        --color-price-down: #cc0000;
        --color-price-neutral: #000000;
    }
    
    .wsj-headline-xxl,
    .wsj-headline-xl,
    .wsj-headline-lg,
    .wsj-headline-md,
    .wsj-headline-sm,
    .wsj-headline-xs {
        color: #000000;
        font-weight: var(--font-weight-bold);
    }
    
    .wsj-body-lead,
    .wsj-body,
    .wsj-body-small {
        color: #000000;
    }
    
    .price-change {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}