/* ============================================
   Aptitude Enhanced CSS - Visual Learning System
   ============================================ */

/* CSS Variables for Enhanced Styling */
:root {
    --formula-gradient-start: #667eea;
    --formula-gradient-end: #764ba2;
    --tip-color: #3b82f6;
    --warning-color: #fb923c;
    --important-color: #22c55e;
    --step-accent: var(--accent-color, #00c2ff);
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    --hover-shadow: 0 8px 25px rgba(0, 194, 255, 0.3);
}

/* ============================================
   Formula Cards
   ============================================ */

.formula-card {
    background: linear-gradient(135deg, var(--formula-gradient-start) 0%, var(--formula-gradient-end) 100%);
    border-radius: 12px;
    padding: 25px 30px;
    margin: 25px 0;
    color: white;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.formula-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.formula-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.formula-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.formula-card-content {
    font-size: 1.4rem;
    font-family: var(--monospace-font, 'JetBrains Mono', monospace);
    font-weight: 600;
    text-align: center;
    margin: 15px 0;
    line-height: 1.6;
}

.formula-card-description {
    font-size: 0.95rem;
    opacity: 0.85;
    margin-top: 12px;
    line-height: 1.5;
}

.formula-card-examples {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ============================================
   Step-by-Step Boxes
   ============================================ */

.step-container {
    margin: 30px 0;
    position: relative;
}

.step-box {
    background: var(--card-bg, rgba(28, 43, 74, 0.6));
    border-left: 4px solid var(--step-accent);
    border-radius: 0 8px 8px 0;
    padding: 20px 25px;
    margin: 15px 0;
    position: relative;
    transition: all 0.3s ease;
}

.step-box:hover {
    background: rgba(0, 194, 255, 0.08);
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 194, 255, 0.15);
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--step-accent);
    color: var(--secondary-color, #070b18);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.95rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.step-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.step-text {
    flex: 1;
    line-height: 1.7;
    color: var(--text-color, #e1e6f2);
}

.step-calculation {
    font-family: var(--monospace-font, 'JetBrains Mono', monospace);
    background: rgba(7, 11, 24, 0.5);
    padding: 10px 15px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 1.05rem;
    color: var(--accent-color, #00c2ff);
}

/* Step Flow Arrows */
.step-box:not(:last-child)::after {
    content: '↓';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    color: var(--step-accent);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(5px); }
}

/* ============================================
   Color-Coded Information Boxes
   ============================================ */

.tip-box,
.warning-box,
.important-box,
.note-box {
    border-radius: 8px;
    padding: 18px 22px;
    margin: 20px 0;
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transition: all 0.3s ease;
}

.tip-box:hover,
.warning-box:hover,
.important-box:hover,
.note-box:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Tip Box - Blue */
.tip-box {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--tip-color);
}

.tip-box::before {
    content: '💡';
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Warning Box - Orange */
.warning-box {
    background: rgba(251, 146, 60, 0.1);
    border-left-color: var(--warning-color);
}

.warning-box::before {
    content: '⚠️';
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Important Box - Green */
.important-box {
    background: rgba(34, 197, 94, 0.1);
    border-left-color: var(--important-color);
}

.important-box::before {
    content: '✓';
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--important-color);
    flex-shrink: 0;
}

/* Note Box - Cyan */
.note-box {
    background: rgba(0, 194, 255, 0.1);
    border-left-color: var(--accent-color, #00c2ff);
}

.note-box::before {
    content: '📝';
    font-size: 1.5rem;
    flex-shrink: 0;
}

.box-content {
    flex: 1;
    line-height: 1.7;
    color: var(--text-color, #e1e6f2);
}

.box-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tip-box .box-title { color: var(--tip-color); }
.warning-box .box-title { color: var(--warning-color); }
.important-box .box-title { color: var(--important-color); }
.note-box .box-title { color: var(--accent-color, #00c2ff); }

/* ============================================
   Enhanced Example Boxes
   ============================================ */

.example-box-enhanced {
    background: rgba(20, 36, 64, 0.7);
    border: 1px solid rgba(0, 194, 255, 0.2);
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
    transition: all 0.3s ease;
}

.example-box-enhanced:hover {
    border-color: var(--accent-color, #00c2ff);
    box-shadow: 0 6px 20px rgba(0, 194, 255, 0.2);
}

.example-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 194, 255, 0.2);
}

.example-icon {
    font-size: 1.5rem;
}

.example-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-color, #00c2ff);
}

.example-question {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 15px;
    color: var(--text-color, #e1e6f2);
}

.example-solution {
    margin-top: 15px;
}

.example-answer {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1));
    border-left: 4px solid var(--important-color);
    padding: 15px 20px;
    border-radius: 0 8px 8px 0;
    margin-top: 15px;
    font-weight: 600;
    color: var(--important-color);
}

/* ============================================
   Geometry Diagrams
   ============================================ */

.geometry-diagram {
    max-width: 500px;
    margin: 30px auto;
    padding: 20px;
    background: rgba(7, 11, 24, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(0, 194, 255, 0.2);
    text-align: center;
}

.geometry-diagram svg {
    width: 100%;
    height: auto;
    cursor: pointer;
    transition: all 0.3s ease;
}

.geometry-diagram:hover svg {
    transform: scale(1.05);
}

.geometry-diagram .highlight {
    transition: all 0.3s ease;
}

.geometry-diagram:hover .highlight {
    fill: var(--accent-color, #00c2ff);
    opacity: 0.3;
}

.diagram-label {
    font-family: var(--monospace-font, 'JetBrains Mono', monospace);
    font-size: 14px;
    fill: var(--text-color, #e1e6f2);
}

.diagram-dimension {
    font-family: var(--monospace-font, 'JetBrains Mono', monospace);
    font-size: 12px;
    fill: var(--accent-color, #00c2ff);
    font-weight: 600;
}

/* ============================================
   Progress Indicators
   ============================================ */

.progress-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(
        var(--accent-color, #00c2ff) calc(var(--progress, 0) * 1%),
        rgba(255, 255, 255, 0.1) 0
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 20px auto;
}

.progress-circle::before {
    content: '';
    position: absolute;
    width: 90px;
    height: 90px;
    background: var(--card-bg, rgba(28, 43, 74, 0.9));
    border-radius: 50%;
}

.progress-text {
    position: relative;
    z-index: 1;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color, #00c2ff);
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color, #00c2ff), var(--highlight-color, #ffc700));
    border-radius: 6px;
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================
   Interactive Chart Containers
   ============================================ */

.chart-container {
    background: rgba(7, 11, 24, 0.5);
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    border: 1px solid rgba(0, 194, 255, 0.2);
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-color, #00c2ff);
    margin-bottom: 20px;
    text-align: center;
}

.chart-canvas {
    max-height: 400px;
    margin: 0 auto;
}

.chart-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.chart-toggle-btn {
    background: rgba(28, 43, 74, 0.8);
    color: var(--text-color, #e1e6f2);
    border: 1px solid rgba(0, 194, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.chart-toggle-btn:hover {
    background: rgba(0, 194, 255, 0.2);
    border-color: var(--accent-color, #00c2ff);
}

.chart-toggle-btn.active {
    background: var(--accent-color, #00c2ff);
    color: var(--secondary-color, #070b18);
    font-weight: 600;
}

/* ============================================
   Infographic Styles
   ============================================ */

.infographic-container {
    background: linear-gradient(135deg, rgba(28, 43, 74, 0.8), rgba(7, 11, 24, 0.8));
    border-radius: 16px;
    padding: 35px;
    margin: 35px 0;
    border: 2px solid rgba(0, 194, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.infographic-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 194, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.infographic-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color, #00c2ff);
    text-align: center;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.infographic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.infographic-item {
    background: rgba(7, 11, 24, 0.6);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(0, 194, 255, 0.2);
    transition: all 0.3s ease;
}

.infographic-item:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color, #00c2ff);
    box-shadow: 0 8px 25px rgba(0, 194, 255, 0.2);
}

.infographic-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--highlight-color, #ffc700);
}

.infographic-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color, #e1e6f2);
    margin-bottom: 10px;
}

.infographic-formula {
    font-family: var(--monospace-font, 'JetBrains Mono', monospace);
    font-size: 1.2rem;
    color: var(--accent-color, #00c2ff);
    font-weight: 600;
}

/* ============================================
   Sticky Table of Contents
   ============================================ */

.toc-sidebar {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: var(--card-bg, rgba(28, 43, 74, 0.6));
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(0, 194, 255, 0.2);
}

.toc-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-color, #00c2ff);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(0, 194, 255, 0.2);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 8px;
}

.toc-link {
    display: block;
    padding: 10px 15px;
    color: var(--text-color, #e1e6f2);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    font-size: 0.95rem;
}

.toc-link:hover {
    background: rgba(0, 194, 255, 0.1);
    border-left-color: var(--accent-color, #00c2ff);
    transform: translateX(5px);
}

.toc-link.active {
    background: rgba(0, 194, 255, 0.2);
    border-left-color: var(--accent-color, #00c2ff);
    color: var(--accent-color, #00c2ff);
    font-weight: 600;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 20px;
    background: rgba(7, 11, 24, 0.5);
    border-radius: 8px;
    font-size: 0.9rem;
}

.breadcrumb-item {
    color: var(--text-color, #e1e6f2);
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-item:hover {
    color: var(--accent-color, #00c2ff);
}

.breadcrumb-separator {
    color: rgba(225, 230, 242, 0.4);
}

.breadcrumb-item.active {
    color: var(--accent-color, #00c2ff);
    font-weight: 600;
}

/* Sequential Navigation Buttons */
.sequential-nav {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid rgba(0, 194, 255, 0.2);
}

.nav-prev,
.nav-next {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: rgba(28, 43, 74, 0.8);
    border: 1px solid rgba(0, 194, 255, 0.3);
    border-radius: 8px;
    color: var(--text-color, #e1e6f2);
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 600;
}

.nav-prev:hover,
.nav-next:hover {
    background: rgba(0, 194, 255, 0.2);
    border-color: var(--accent-color, #00c2ff);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 194, 255, 0.2);
}

.nav-prev:disabled,
.nav-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   Responsive Design - Mobile First
   ============================================ */

/* Base styles are mobile-first (320px+) */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .formula-card {
        padding: 30px 35px;
    }
    
    .infographic-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .formula-card-content {
        font-size: 1.6rem;
    }
    
    .step-box {
        padding: 25px 30px;
    }
    
    .infographic-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .chart-container {
        padding: 30px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .geometry-diagram {
        max-width: 600px;
    }
    
    .progress-circle {
        width: 140px;
        height: 140px;
    }
    
    .progress-circle::before {
        width: 110px;
        height: 110px;
    }
}

/* Mobile-specific adjustments (max-width: 767px) */
@media (max-width: 767px) {
    .formula-card {
        padding: 20px;
        margin: 20px 0;
    }
    
    .formula-card-content {
        font-size: 1.2rem;
    }
    
    .step-box {
        padding: 15px 18px;
        margin: 12px 0;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
    
    .step-box:not(:last-child)::after {
        font-size: 24px;
        bottom: -22px;
    }
    
    .tip-box,
    .warning-box,
    .important-box,
    .note-box {
        padding: 15px 18px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .example-box-enhanced {
        padding: 20px;
    }
    
    .geometry-diagram {
        max-width: 100%;
        padding: 15px;
    }
    
    .progress-circle {
        width: 100px;
        height: 100px;
    }
    
    .progress-circle::before {
        width: 75px;
        height: 75px;
    }
    
    .progress-text {
        font-size: 1.5rem;
    }
    
    .chart-container {
        padding: 20px 15px;
    }
    
    .chart-canvas {
        max-height: 300px;
    }
    
    .infographic-container {
        padding: 25px 20px;
    }
    
    .infographic-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .toc-sidebar {
        position: static;
        max-height: none;
        margin-bottom: 20px;
    }
    
    .sequential-nav {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-prev,
    .nav-next {
        width: 100%;
        justify-content: center;
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575px) {
    .formula-card {
        padding: 18px 15px;
    }
    
    .formula-card-title {
        font-size: 1rem;
    }
    
    .formula-card-content {
        font-size: 1.1rem;
    }
    
    .step-calculation {
        font-size: 0.95rem;
        padding: 8px 12px;
    }
    
    .box-title {
        font-size: 0.95rem;
    }
    
    .example-title {
        font-size: 1.05rem;
    }
    
    .example-question {
        font-size: 1rem;
    }
    
    .chart-title {
        font-size: 1.1rem;
    }
    
    .chart-toggle-btn {
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    
    .infographic-title {
        font-size: 1.4rem;
    }
    
    .infographic-icon {
        font-size: 2.5rem;
    }
    
    .infographic-label {
        font-size: 1rem;
    }
    
    .infographic-formula {
        font-size: 1.05rem;
    }
}

/* Touch-friendly interactions for mobile */
@media (hover: none) and (pointer: coarse) {
    .formula-card:active {
        transform: scale(0.98);
    }
    
    .step-box:active {
        transform: translateX(3px);
    }
    
    .tip-box:active,
    .warning-box:active,
    .important-box:active,
    .note-box:active {
        transform: translateX(3px);
    }
    
    .chart-toggle-btn:active {
        transform: scale(0.95);
    }
    
    .toc-link:active {
        transform: translateX(3px);
    }
    
    .nav-prev:active,
    .nav-next:active {
        transform: scale(0.98);
    }
}

/* ============================================
   Accessibility Enhancements
   ============================================ */

/* Focus styles for keyboard navigation */
.formula-card:focus-visible,
.step-box:focus-visible,
.toc-link:focus-visible,
.chart-toggle-btn:focus-visible,
.nav-prev:focus-visible,
.nav-next:focus-visible {
    outline: 3px solid var(--accent-color, #00c2ff);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .step-box:not(:last-child)::after {
        animation: none;
    }
    
    .progress-bar-fill::after {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .formula-card,
    .step-box,
    .tip-box,
    .warning-box,
    .important-box,
    .note-box,
    .example-box-enhanced,
    .chart-container,
    .infographic-container {
        border-width: 2px;
    }
    
    .toc-link.active,
    .chart-toggle-btn.active {
        border: 2px solid currentColor;
    }
}

/* Print styles */
@media print {
    .formula-card,
    .step-box,
    .example-box-enhanced,
    .chart-container,
    .infographic-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .toc-sidebar,
    .sequential-nav {
        display: none;
    }
    
    .formula-card {
        background: white;
        color: black;
        border: 2px solid black;
    }
    
    .step-box:not(:last-child)::after {
        display: none;
    }
}

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

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

.text-highlight {
    color: var(--accent-color, #00c2ff);
    font-weight: 600;
}

.text-muted {
    color: rgba(225, 230, 242, 0.6);
}

.mb-small { margin-bottom: 15px; }
.mb-medium { margin-bottom: 25px; }
.mb-large { margin-bottom: 35px; }

.mt-small { margin-top: 15px; }
.mt-medium { margin-top: 25px; }
.mt-large { margin-top: 35px; }
