﻿/* General Variables */
:root {
    --primary-color: #1D3557;
    --secondary-color: #457B9D;
    --background-gradient: linear-gradient(90deg, rgba(168, 218, 220, 0.7), rgba(188, 236, 224, 0.7));
    --transparent-gradient: linear-gradient(90deg, rgba(168, 218, 220, 0), rgba(188, 236, 224, 0));
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
    --h1-scale-factor: 0.4; /* Scale factor for h2 relative to h1 */
}

/* General Container Styles */
.main-container {
    font-family: 'Georgia', serif;
    line-height: 1.6;
    padding: 30px;
    margin: 0 auto;
    width: 90%;
    max-width: 800px;
    background-color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

/* Header Styles */
.main-header {
    background: var(--background-gradient);
    color: var(--primary-color);
    padding: 7px 13px;
    text-align: center;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    font-family: "Georgia", serif;
}

    .main-header h1 {
        font-size: clamp(20px, 5vw, 50px); /* Adjust dynamically between 20px and 50px */
        margin: 0;
        text-shadow: var(--text-shadow);
    }

    .main-header h2 {
        font-size: calc(var(--h1-scale-factor) * clamp(20px, 5vw, 50px)); /* Scale proportionately */
        margin-top: 5px;
        font-style: italic;
        color: var(--secondary-color);
        text-align: right;
    }

/* Paragraph Styles */
.paragraph {
    margin: 1em 0;
    line-height: 1.6;
}

    .paragraph h1 {
        font-style: italic;
    }

/* Typography */
.italic {
    font-style: italic;
}

/* Quote and Descriptions */
.quote,
.equation-description {
    margin: 1em 0;
    line-height: 1.6;
    padding-left: 1em;
    border-left: 3px solid #ccc;
    color: #444;
    font-style: italic;
}

/* Quote Citation */
.quote-citation {
    margin-top: 0.5em;
    padding-left: 2em;
    font-style: normal;
    font-size: 0.9em;
    color: #666;
}

/* Equation Styles */
.equation-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* Required for absolute positioning of .equation-reference */
    margin: 1em 0; /* Add spacing around equations */
}

.equation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative; /* Allow .equation to maintain its layout */
    text-align: center;
    margin: 20px auto;
    padding: 10px;
    width: 100%; /* Spans the full width of the container */
    max-width: 800px; /* Ensure container has a consistent max width */
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    background-color: rgba(179, 213, 215, 0.3); /* Reduced alpha for subtlety */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    box-sizing: border-box; /* Include padding in dimensions */
    overflow: visible;
}

.equation-content {
    display: inline-block;
    text-align: center; /* Ensure centered alignment */
    transform-origin: center center;
    margin: 0; /* Allow JS to handle margins */
    position: static; /* Ensure no conflicts with relative or absolute. JS calculates positioning to scale and center equations. */
}

.equation-reference {
    position: absolute; /* Position relative to .equation-wrapper */
    bottom: -10px; /* Align near the bottom of the .equation */
    right: 15px; /* Align near the right edge of the .equation */
    font-size: 0.9em; /* Adjust font size as needed */
    color: #555; /* Subtle text color */
    font-style: italic; /* Match the style in your design */
    text-align: right; /* Align text to the right */
}

/* General Link Styles */
.link {
    background: var(--transparent-gradient);
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid rgba(168, 218, 220, 0.3); /* Faint underline using border */
    border-radius: 6px;
    display: inline-block;
    font-weight: 500;
    transition: background 0.5s ease, box-shadow 0.5s ease, color 0.3s ease, transform 0.3s ease;
    position: relative;
}

    .link:hover {
        background: var(--background-gradient);
        box-shadow: var(--box-shadow);
        color: var(--primary-color);
        text-decoration: none;
    }

    .link:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

/* Equation-Specific Link Styles */
.equation-link {
    font-style: italic;
}

.equation-preview {
    display: none;
    position: absolute;
    flex-direction: column;
    margin: 20px auto;
    padding: 10px;
    bottom: 50%;
    width: 800px;
    max-width: 800px;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    background-color: rgba(234, 242, 243, 1.0);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    overflow: visible;
}

.equation-preview-content {
    display: inline-block;
    text-align: center;
    transform-origin: center center;
    margin: 0;
    position: static;
}

.equation-link:hover .equation-preview {
    display: block;
    opacity: 1;
}

.placeholder-image {
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
}


/* Poem Formatting */
.poem {
    white-space: pre-wrap;
    font-family: inherit;
    margin: 1em 0;
    line-height: 1.6;
}

/* Spinner for background processing */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin-left: 0.5rem;
    vertical-align: text-bottom;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
