/**
 * Multibrot Set Visualization Styles
 * Responsive, accessible design for interactive fractal exploration
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #3b82f6;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.multibrot-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    opacity: 0.95;
    font-weight: 300;
}

/* Main Content */
main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

/* Canvas Wrapper */
.canvas-wrapper {
    position: relative;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

#multibrotCanvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    touch-action: none;
}

#multibrotCanvas:active {
    cursor: grabbing;
}

/* Info Overlay */
.info-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
    z-index: 10;
}

/* Loading Indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.loading-indicator.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
    display: flex;
    flex-direction: column;
    gap: 5px;
    pointer-events: none;
}

.info-item {
    display: flex;
    gap: 5px;
}

/* Controls Panel */
.controls-panel {
    background: var(--bg-primary);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.control-group {
    margin-bottom: 20px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    margin: 10px 0;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--secondary-color);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: var(--secondary-color);
}

.control-group select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s;
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Presets Buttons */
.presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.preset-btn {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    font-weight: 500;
}

.preset-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.preset-btn:active {
    transform: translateY(0);
}

/* Reset Button */
.reset-button {
    width: 100%;
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-button:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.reset-button:active {
    transform: translateY(0);
}

/* Formula Display */
.formula-display {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.formula-display h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.formula-item {
    margin: 8px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.math-formula {
    font-family: 'Times New Roman', serif;
    font-style: italic;
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Instructions */
.instructions {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.instructions h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 5px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding-left: 20px;
    position: relative;
}

.instructions li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

/* Explanation Section */
.explanation {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 40px;
}

.explanation h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.explanation h3 {
    font-size: 1.3rem;
    margin: 25px 0 12px 0;
    color: var(--text-primary);
}

.explanation p {
    margin-bottom: 15px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.explanation ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 15px;
}

.explanation li {
    padding: 10px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-secondary);
    line-height: 1.7;
}

.explanation li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
    line-height: 1;
}

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

/* Responsive Design */
@media (min-width: 768px) {
    main {
        grid-template-columns: 2fr 1fr;
    }

    .canvas-wrapper {
        order: 1;
    }

    .controls-panel {
        order: 2;
    }
}

@media (max-width: 767px) {
    .multibrot-container {
        padding: 10px;
    }

    header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }

    .explanation {
        padding: 20px;
    }

    .explanation h2 {
        font-size: 1.5rem;
    }

    .explanation h3 {
        font-size: 1.1rem;
    }

    .info-overlay {
        font-size: 0.75rem;
        padding: 8px 10px;
    }

    .presets {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Print Styles */
@media print {
    header {
        background: white;
        color: black;
    }

    .controls-panel,
    .info-overlay {
        display: none;
    }

    .canvas-wrapper {
        box-shadow: none;
    }
}
