/**
 * Principia Metaphysica - Common Shared Styles
 * =============================================
 *
 * Unified visual styling for consistency across all pages
 * (hardcoded paper and dynamic pages)
 *
 * Copyright (c) 2025-2026 Andrew Keith Watts. All rights reserved.
 */

/* ============================================
   Font Imports
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400&family=Source+Sans+Pro:wght@400;600&family=Source+Code+Pro:wght@400;500&display=swap');

/* ============================================
   CSS Variables - Unified Color Scheme
   ============================================ */

:root {
    /* Background Colors */
    --bg-dark: #0a0a0f;
    --bg-paper: #ffffff;
    --bg-paper-dark: #1a1a2e;
    --bg-sidebar: #16213e;
    --bg-card: #1a1f3a;
    --bg-card-hover: #222847;
    --bg-secondary: #151a35;
    --bg-primary: #0a0e27;

    /* Text Colors */
    --text-dark: #1a1a1a;
    --text-light: #f8f9fa;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    --text-light-muted: #888;

    /* Accent Colors - Purple/Pink Theme */
    --accent: #8b7fff;
    --accent-primary: #8b7fff;
    --accent-hover: #a394ff;
    --accent-secondary: #ff7eb6;
    --accent-gold: #ffd93d;

    /* Border Colors */
    --border: #e0e0e0;
    --border-dark: #2a2a3e;
    --border-light: #3a3a4e;
    --border-primary: #2a2f4a;
    --border-accent: #4a4f6a;

    /* Additional UI Colors */
    --code-bg: #f5f5f5;
    --shadow: rgba(0, 0, 0, 0.3);
    --success: #51cf66;
    --info: #4dabf7;
    --warning: #ffd43b;

    /* Glass Morphism */
    --glass-bg: rgba(26, 31, 58, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* ============================================
   Typography - Unified Font System
   ============================================ */

body {
    font-family: 'Crimson Text', Georgia, serif;
    line-height: 1.7;
    font-size: 11pt;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Crimson Text', Georgia, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

h3 {
    font-size: 1.3rem;
}

h4 {
    font-size: 1.1rem;
}

/* UI Text */
.ui-text {
    font-family: 'Source Sans Pro', sans-serif;
}

/* Code */
code, pre, .monospace {
    font-family: 'Source Code Pro', 'Courier New', monospace;
}

/* ============================================
   Paper Title Styles (for hardcoded paper)
   ============================================ */

h1.paper-title {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 0.3rem;
    font-weight: 700;
}

.paper-subtitle {
    font-size: 1.1rem;
    text-align: center;
    font-weight: 400;
    color: #555;
    margin-bottom: 1.5rem;
}

.author {
    text-align: center;
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.affiliation {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    margin-bottom: 2rem;
}

/* ============================================
   Section Titles
   ============================================ */

h2.section-title {
    font-size: 1.3rem;
    margin: 2.5rem 0 1rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--border);
}

h3.subsection-title {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.8rem;
    color: #333;
}

/* Dark mode section titles */
.dark-mode h2.section-title,
body:not(.paper) h2.section-title {
    border-bottom-color: var(--accent);
    color: #fff;
}

/* ============================================
   Paragraphs and Text
   ============================================ */

p {
    margin-bottom: 1rem;
    text-align: justify;
}

/* ============================================
   Abstract Boxes
   ============================================ */

.abstract {
    background: #f8f9fa;
    padding: 20px 25px;
    border-left: 4px solid var(--accent);
    margin: 2rem 0;
}

.abstract h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
}

.abstract p {
    font-size: 0.95rem;
    text-align: justify;
}

/* Dark mode abstract */
.dark-mode .abstract,
body:not(.paper) .abstract {
    background: rgba(139, 127, 255, 0.05);
    border-left-color: var(--accent-primary);
    color: var(--text-secondary);
}

/* ============================================
   Derivation Boxes
   ============================================ */

.derivation-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 1.5rem 0;
}

.derivation-box h4 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.8rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
}

.derivation-step {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.derivation-step::before {
    content: counter(step);
    counter-increment: step;
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 600;
}

.derivation-box ol {
    counter-reset: step;
    list-style: none;
    padding: 0;
}

/* Dark mode derivation boxes */
.dark-mode .derivation-box,
body:not(.paper) .derivation-box {
    background: rgba(139, 127, 255, 0.05);
    border: 1px solid rgba(139, 127, 255, 0.2);
}

.dark-mode .derivation-box h4,
body:not(.paper) .derivation-box h4 {
    border-bottom-color: rgba(139, 127, 255, 0.2);
}

/* ============================================
   Equations
   ============================================ */

.equation-block {
    margin: 1.5rem 0;
    padding: 1rem 0;
    overflow-x: auto;
}

.equation-number {
    float: right;
    color: #666;
    font-size: 0.9rem;
}

/* Dark mode equations */
.dark-mode .equation-number,
body:not(.paper) .equation-number {
    color: var(--text-muted);
}

/* ============================================
   Tables
   ============================================ */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f5f5f5;
    font-weight: 600;
}

/* Dark mode tables */
.dark-mode table,
body:not(.paper) table {
    border: 1px solid var(--border-primary);
}

.dark-mode th,
body:not(.paper) th {
    background: var(--bg-secondary);
    color: var(--accent-primary);
}

.dark-mode td,
body:not(.paper) td {
    border-bottom-color: var(--border-primary);
    color: var(--text-secondary);
}

/* ============================================
   Code Blocks
   ============================================ */

pre {
    background: var(--code-bg);
    padding: 15px 20px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 1rem 0;
    border-left: 3px solid var(--accent);
}

code {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9em;
    background: #f0f0f0;
    padding: 2px 5px;
    border-radius: 3px;
}

pre code {
    background: none;
    padding: 0;
}

/* Dark mode code */
.dark-mode pre,
body:not(.paper) pre {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-left-color: var(--accent-primary);
}

.dark-mode code,
body:not(.paper) code {
    background: rgba(139, 127, 255, 0.1);
    color: var(--accent-primary);
}

/* ============================================
   Cards (Modern Style for Dynamic Pages)
   ============================================ */

.card {
    background: rgba(26, 31, 58, 0.6);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    padding: 1.75rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: opacity 0.4s ease;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 48px rgba(139, 127, 255, 0.25);
    border-color: rgba(139, 127, 255, 0.3);
    background: rgba(26, 31, 58, 0.8);
    backdrop-filter: blur(20px) saturate(200%);
    -webkit-backdrop-filter: blur(20px) saturate(200%);
}

.card:hover::before {
    opacity: 1;
}

.card h3 {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    font-size: 1.35rem;
    font-weight: 600;
}

.card .subtitle {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.card .description {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ============================================
   Links
   ============================================ */

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Dark mode links */
.dark-mode a,
body:not(.paper) a {
    color: var(--accent-primary);
}

.dark-mode a:hover,
body:not(.paper) a:hover {
    color: var(--accent-secondary);
}

/* ============================================
   Tags and Badges
   ============================================ */

.tag {
    background: rgba(139, 127, 255, 0.15);
    color: var(--accent-primary);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(139, 127, 255, 0.3);
    transition: all 0.3s ease;
    display: inline-block;
}

.tag:hover {
    background: rgba(139, 127, 255, 0.25);
    transform: translateY(-1px);
}

/* ============================================
   Lists
   ============================================ */

ul, ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.3rem;
}

/* ============================================
   References
   ============================================ */

.references {
    font-size: 0.9rem;
}

.references li {
    margin-bottom: 0.5rem;
}

/* ============================================
   SVG Diagrams
   ============================================ */

.diagram-container {
    margin: 2rem 0;
    text-align: center;
}

.diagram-container svg {
    max-width: 100%;
    height: auto;
}

.diagram-caption {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

.dark-mode .diagram-caption,
body:not(.paper) .diagram-caption {
    color: var(--text-muted);
}

/* ============================================
   Gradient Text Effects
   ============================================ */

.gradient-text {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   Glass Morphism Effects
   ============================================ */

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Status Badges (for formulas)
   ============================================ */

.status-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-exact-match {
    background: rgba(80, 200, 120, 0.2);
    color: #50c878;
    border: 1px solid rgba(80, 200, 120, 0.4);
}

.status-validated {
    background: rgba(139, 127, 255, 0.2);
    color: var(--accent-primary);
    border: 1px solid rgba(139, 127, 255, 0.4);
}

.status-geometric {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.4);
}

.status-prediction {
    background: rgba(255, 126, 182, 0.2);
    color: #ff7eb6;
    border: 1px solid rgba(255, 126, 182, 0.4);
}

/* ============================================
   Responsive Design
   ============================================ */

@media screen and (max-width: 768px) {
    body {
        font-size: 10pt;
    }

    h1.paper-title {
        font-size: 1.4rem;
    }

    .paper-subtitle {
        font-size: 1rem;
    }

    h2.section-title {
        font-size: 1.15rem;
    }

    h3.subsection-title {
        font-size: 1rem;
    }

    .abstract {
        padding: 15px;
    }

    .derivation-box {
        padding: 15px;
        margin: 1rem 0;
    }

    .equation-block {
        padding: 0.5rem 0;
        font-size: 0.9rem;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.8rem;
    }

    th, td {
        padding: 8px 10px;
    }

    pre {
        padding: 10px 12px;
        font-size: 0.75rem;
    }

    .card {
        padding: 1.25rem;
    }
}

@media screen and (max-width: 480px) {
    h1.paper-title {
        font-size: 1.2rem;
    }

    h2.section-title {
        font-size: 1.05rem;
    }

    .derivation-box {
        padding: 12px;
        border-radius: 6px;
    }

    .derivation-step {
        padding-left: 1.2rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    body {
        background: white;
        color: black;
    }

    .card {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    a {
        color: #0066cc;
        text-decoration: underline;
    }

    @page {
        size: A4;
        margin: 25mm 20mm;
    }
}

/* ============================================
   Utility Classes
   ============================================ */

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

.text-justify {
    text-align: justify;
}

.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }

.hidden {
    display: none;
}

.visible {
    display: block;
}

/* ============================================
   Final Visual Polish
   ============================================ */

/* Smooth page transitions for interactive elements */
* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Text shadows for readability on glass cards */
.glass h2, .glass h3,
.glass-card h2, .glass-card h3,
.card h2, .card h3 {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Loading shimmer effect */
.loading-shimmer {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Polished scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 127, 255, 0.3);
    border-radius: 4px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 127, 255, 0.5);
}

/* Firefox scrollbar styling */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 127, 255, 0.3) rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Ensure smooth scrolling behavior */
html {
    scroll-behavior: smooth;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Selection color */
::selection {
    background: rgba(139, 127, 255, 0.3);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(139, 127, 255, 0.3);
    color: var(--text-primary);
}
