/* ============================================
   LEGAL PAGES - PROFESSIONAL DESIGN
   ============================================ */

/* Legal Hero Section */
.legal-hero {
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 140px 32px 80px;
    background: linear-gradient(135deg,
        var(--bg-primary) 0%,
        var(--bg-secondary) 100%
    );
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.legal-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 40% 50%,
        rgba(124, 58, 237, 0.12) 0%,
        transparent 50%
    );
}

.legal-hero-content {
    max-width: 800px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.legal-icon {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 32px;
    box-shadow: 0 20px 60px rgba(124, 58, 237, 0.3);
}

.legal-icon i {
    font-size: 48px;
    color: white;
}

.legal-hero h1 {
    font-size: clamp(36px, 5vw, 56px);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 20px;
    color: var(--text-primary);
    line-height: 1.2;
}

.legal-subtitle {
    font-size: clamp(17px, 2vw, 21px);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Legal Content */
.legal-content {
    padding: 80px 32px 120px;
    background: var(--bg-primary);
}

.legal-container {
    max-width: 1100px;
    margin: 0 auto;
}

/* Wider section for text-heavy content */
.legal-section-wide {
    max-width: 100%;
}

.legal-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 32px;
}

.legal-section h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.legal-section h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 32px;
    margin-bottom: 16px;
}

.legal-section p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.legal-section ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 24px;
}

.legal-section ul li {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-left: 28px;
    position: relative;
}

.legal-section ul li::before {
    content: "•";
    color: var(--accent);
    font-size: 20px;
    position: absolute;
    left: 8px;
    top: -2px;
}

.legal-section a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.legal-section a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.legal-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Info Box */
.info-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.info-box h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 16px;
}

.info-box p {
    margin-bottom: 0;
}

/* Formula Box - for mathematical formulas */
.formula-box {
    background: rgba(30, 30, 35, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px 32px;
    margin: 28px 0;
}

.formula-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px !important;
}

/* Tool-specific limitations - italic and light blue */
.tool-limit {
    font-style: italic;
    color: #60a5fa;
}

.formula {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    color: var(--text-primary);
    margin: 16px 0;
    font-family: 'Times New Roman', serif;
    flex-wrap: wrap;
}

/* MathML Styling */
math {
    font-family: 'Times New Roman', 'Latin Modern Math', 'STIX Two Math', 'Cambria Math', serif;
    font-size: 22px;
    color: var(--text-primary);
    line-height: 1.5;
}

math[display="block"] {
    display: block;
    margin: 24px 0;
    text-align: left;
}

/* KaTeX Formula Styling */
.katex-display {
    overflow: visible !important;
    overflow-x: visible !important;
    margin: 20px 0 !important;
    text-align: left !important;
}

.katex-display > .katex {
    text-align: left !important;
}

.katex {
    font-size: 1.15em !important;
    color: var(--text-primary) !important;
}

.formula-box .katex-display {
    margin: 16px 0 !important;
}

/* MathML variables italic */
math mi {
    font-style: italic;
    padding: 0 1px;
}

/* Multi-character identifiers (like "real") should not be italic */
math mi[mathvariant="normal"] {
    font-style: normal;
}

/* MathML numbers upright */
math mn {
    font-style: normal;
}

/* MathML operators */
math mo {
    font-style: normal;
    padding: 0 2px;
}

/* MathML text */
math mtext {
    font-style: normal;
    padding: 0 4px;
}

/* Fractions */
math mfrac {
    vertical-align: middle;
    padding: 0 4px;
}

/* Subscripts and superscripts */
math msub > *:nth-child(2),
math msup > *:nth-child(2),
math msubsup > *:nth-child(2),
math msubsup > *:nth-child(3) {
    font-size: 0.75em;
}

/* Under/over scripts (for product/sum limits) */
math munderover {
    vertical-align: middle;
    padding: 0 6px;
}

math munderover > mo:first-child {
    font-size: 1.8em;
    line-height: 1;
}

math munderover > *:nth-child(2),
math munderover > *:nth-child(3) {
    font-size: 0.65em;
    color: var(--text-secondary);
}

/* Parentheses in MathML */
math mo:is([fence="true"]),
math mo:is([stretchy="true"]) {
    font-size: 1.2em;
}

/* Subscripts in legend */
.formula-legend math {
    font-size: 14px;
    display: inline;
    vertical-align: baseline;
}

.formula-legend math mi {
    padding: 0;
}

.formula-legend math msub > *:nth-child(2) {
    font-size: 0.8em;
}

.formula-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    vertical-align: middle;
}

.formula-numerator {
    border-bottom: 2px solid var(--text-primary);
    padding: 0 8px 4px;
}

.formula-denominator {
    padding: 4px 8px 0;
}

.formula-equals {
    font-size: 20px;
}

.formula-result {
    color: #4ade80;
    font-weight: 600;
}

.formula-legend {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 16px 0 20px !important;
    padding-left: 8px;
}

.formula-legend sub {
    font-size: 10px;
    font-style: italic;
    font-family: 'Times New Roman', serif;
}

/* Subsection header - for grouping related formulas */
.formula-subsection {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 8px 0 18px;
    text-decoration: underline;
    font-style: italic;
}

/* First subsection in a formula box needs no top margin */
.formula-box > .formula-subsection:first-child {
    margin-top: 0;
}

/* Product notation (big Pi) */
.formula-product {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
    vertical-align: middle;
    margin-right: 6px;
    margin-left: 4px;
}

.formula-product-symbol {
    font-size: 36px;
    line-height: 0.85;
    font-family: 'Times New Roman', serif;
}

.formula-product-upper,
.formula-product-lower {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.1;
}

/* Sum notation (big Sigma) */
.formula-sum {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
    vertical-align: middle;
    margin-right: 6px;
    margin-left: 4px;
}

.formula-sum-symbol {
    font-size: 36px;
    line-height: 0.85;
    font-family: 'Times New Roman', serif;
}

.formula-sum-upper,
.formula-sum-lower {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.1;
}

/* Parentheses for formulas */
.formula-paren {
    font-size: 48px;
    line-height: 0.9;
    vertical-align: middle;
    font-weight: 100;
    margin: 0 -2px;
}

.formula-paren-left {
    margin-right: 2px;
}

.formula-paren-right {
    margin-left: 2px;
}

/* Exponent notation */
.formula-exp {
    display: inline-flex;
    align-items: flex-start;
}

.formula-exp-base {
    display: inline-flex;
    align-items: center;
}

.formula-exp-power {
    font-size: 14px;
    vertical-align: super;
    margin-left: 2px;
}

/* Fraction as exponent (1/n style) */
.formula-exp-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    line-height: 1;
    vertical-align: super;
    margin-left: 2px;
    position: relative;
    top: -8px;
}

.formula-exp-fraction .exp-num {
    border-bottom: 1px solid var(--text-primary);
    padding: 0 3px 1px;
}

.formula-exp-fraction .exp-denom {
    padding: 1px 3px 0;
}

/* Inline subscript in formulas */
.formula sub {
    font-size: 13px;
    vertical-align: sub;
    font-family: 'Times New Roman', serif;
    font-style: italic;
}

/* Section divider within formula boxes */
.formula-divider {
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/* Source link styling */
.source-link {
    font-size: 14px;
    color: var(--accent);
    word-break: break-all;
}

/* Source list for references */
.source-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 16px;
}

.source-list li {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 0;
    padding-left: 24px;
}

.source-list li::before {
    display: none;
}

.source-list li strong {
    display: block;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.source-list li a {
    font-size: 14px;
    color: var(--accent);
    word-break: break-all;
}

/* Orange highlighted text for important terms */
.highlight-term {
    color: #f59e0b;
}

/* Sources Grid - Compact Links */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.source-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.source-card:hover {
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateY(-2px);
    text-decoration: none;
}

.source-card strong {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

.source-card span {
    font-size: 12px;
    color: var(--accent);
}

/* Hints Section - Stacked Layout */
.hints-stack {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.hint-card-stacked {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 32px;
}

.hint-card-stacked:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.hint-title {
    font-size: 18px;
    font-weight: 600;
    color: #f59e0b;
    margin: 0 0 16px 0;
    text-decoration: underline;
}

.hint-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.hint-content p {
    margin-bottom: 16px;
}

.hint-content p:last-child {
    margin-bottom: 0;
}

.hint-content a {
    color: var(--accent);
    text-decoration: none;
}

.hint-content a:hover {
    text-decoration: underline;
}

.hint-list {
    list-style: disc;
    padding-left: 24px;
    margin: 12px 0 16px;
}

.hint-list li {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding-left: 8px;
}

.hint-list li::before {
    display: none;
}

/* Legacy Hints Grid (for reference) */
.hints-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.hint-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.hint-card:hover {
    border-color: rgba(139, 92, 246, 0.3);
}

.hint-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    background: rgba(139, 92, 246, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.hint-card-header i {
    font-size: 20px;
    color: var(--accent);
}

.hint-card-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.hint-card-content {
    padding: 24px;
    min-height: 100px;
}

.hint-placeholder {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

/* Legal Update */
.legal-update {
    text-align: center;
    padding: 24px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-top: 40px;
}

.legal-update p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .legal-hero {
        min-height: 40vh;
        padding: 120px 24px 60px;
    }

    .legal-icon {
        width: 80px;
        height: 80px;
        border-radius: 20px;
    }

    .legal-icon i {
        font-size: 40px;
    }

    .legal-content {
        padding: 60px 24px 80px;
    }

    .legal-section {
        padding: 28px 20px;
    }

    .legal-section h2 {
        font-size: 24px;
    }

    .legal-section h3 {
        font-size: 20px;
    }

    .legal-section p,
    .legal-section ul li {
        font-size: 15px;
    }

    .info-box {
        padding: 20px;
    }
}
