/* ============================================
   SUPPLEMENTARY ANGLES - IMPROVED STYLESHEET
   Performance Optimized Version 1.1
   ============================================ */

/* CSS Variables - Modern Design System */
:root {
    --primary: #0052cc;
    --primary-dark: #0041a3;
    --primary-light: #3d8aff;
    --primary-lighter: #e3eeff;

    --secondary: #667eea;
    --accent: #764ba2;
    --success: #28a745;
    --success-light: #d4edda;
    --warning: #ffc107;
    --danger: #dc3545;

    --text-dark: #1a1a1a;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-light: #e2e8f0;

    --bg-white: #ffffff;
    --bg-light: #f7fafc;
    --bg-lighter: #edf2f7;
    --bg-blue: #e3eeff;

    --border: #cbd5e0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 15px 40px rgba(0, 0, 0, 0.20);

    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-white);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: var(--text-dark);
}

h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 2.2rem;
    color: var(--primary);
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--primary-lighter);
    position: relative;
}

h2::before {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

h3 {
    font-size: 1.5rem;
    color: var(--primary-dark);
}

h4 {
    font-size: 1.25rem;
    color: var(--primary);
}

p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

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

strong, b {
    font-weight: 700;
    color: var(--primary-dark);
}

code {
    background: var(--bg-lighter);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--primary-dark);
}

kbd {
    background: var(--text-primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    border: 1px solid var(--text-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================
   LAYOUT
   ============================================ */

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

.container-sm {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
    background: var(--bg-white);
    border-bottom: 2px solid var(--primary-lighter);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: var(--text-primary);
    font-weight: 600;
    transition: var(--transition);
    position: relative;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.nav-menu a:hover::after {
    width: 100%;
}

@media (max-width: 768px) {
    .nav-menu {
        gap: 1rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    color: white;
    padding: 5rem 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg viewBox="0 0 1200 600" xmlns="http://www.w3.org/2000/svg"><circle cx="200" cy="100" r="80" fill="rgba(255,255,255,0.05)"/><circle cx="1000" cy="500" r="150" fill="rgba(255,255,255,0.03)"/><path d="M0 300 Q300 250 600 300 T1200 300" stroke="rgba(255,255,255,0.1)" fill="none" stroke-width="2"/></svg>') no-repeat center;
    background-size: cover;
}

.hero .container {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    color: white;
    background: none;
    -webkit-text-fill-color: unset;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.hero-subtitle {
    font-size: 1.3rem;
    margin-bottom: 2.5rem;
    color: rgba(255, 255, 255, 0.95);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-block;
    padding: 0.9rem 2rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary-lighter);
}

.btn-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   CONTENT SECTIONS
   ============================================ */

.main-content {
    padding: 3rem 0;
}

.content-section {
    margin-bottom: 3.5rem;
}

/* ============================================
   CARDS & BOXES
   ============================================ */

.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.definition-box {
    background: linear-gradient(135deg, var(--primary-lighter) 0%, #f0ebff 100%);
    border-left: 5px solid var(--primary);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 2rem 0;
}

.definition-box p {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin: 0;
}

.example-card {
    background: var(--bg-light);
    border-left: 4px solid var(--success);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.example-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.example-card h4 {
    color: var(--success);
    margin-top: 0;
}

.memory-trick {
    background: linear-gradient(135deg, #fff8e1 0%, #ffe0b2 100%);
    border: 2px dashed var(--warning);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.memory-trick strong {
    color: #f57f17;
}

.success-box {
    background: var(--success-light);
    border-left: 4px solid var(--success);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}

/* ============================================
   LISTS & TABLES
   ============================================ */

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

li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.property-list li {
    list-style: none;
    padding-left: 2rem;
    position: relative;
}

.property-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
    font-size: 1.2rem;
}

.numbered-steps {
    counter-reset: step-counter;
    list-style: none;
}

.numbered-steps li {
    counter-increment: step-counter;
    padding-left: 3.5rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.numbered-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

thead {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: var(--primary-lighter);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   SPECIAL SECTIONS
   ============================================ */

.toc-section {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 3rem;
    border-left: 5px solid var(--primary);
}

.toc-section h2 {
    margin-top: 0;
    font-size: 1.5rem;
}

.toc ul {
    list-style: none;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.toc li {
    margin-bottom: 0;
}

.toc a {
    display: block;
    padding: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    transition: var(--transition);
    border-radius: 6px;
}

.toc a:hover {
    background: var(--primary-lighter);
    text-decoration: none;
    padding-left: 1.25rem;
}

/* Reference Grid */
.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.reference-card {
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--primary-lighter) 100%);
    border: 2px solid var(--primary);
    padding: 1.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.reference-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.reference-card h3 {
    margin-top: 0;
    color: var(--primary);
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary);
}

.reference-card p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.reference-note {
    margin-top: 0.75rem !important;
    padding-top: 0.75rem;
    border-top: 1px solid var(--primary);
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem !important;
}

/* Real-world Applications Grid */
.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.app-card {
    background: var(--bg-white);
    border: 2px solid var(--border);
    padding: 2rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.app-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-8px);
}

.app-card h3 {
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-icon {
    font-size: 2rem;
}

/* ============================================
   FORMULA & VISUALIZATION
   ============================================ */

.formula-box {
    background: linear-gradient(135deg, #e3eeff 0%, #f0ebff 100%);
    border: 2px solid var(--primary);
    padding: 2.5rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    text-align: center;
}

.formula-box p {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
    font-family: 'Courier New', monospace;
}

.visual-example {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.visual-example svg {
    max-width: 100%;
    height: auto;
    max-height: 400px;
}

/* ============================================
   FAQ SECTION
   ============================================ */

.faq-container {
    display: grid;
    gap: 1rem;
    margin: 2rem 0;
}

.faq-item {
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.faq-item:hover {
    border-color: var(--primary);
}

.faq-item summary {
    padding: 1.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-dark);
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    background: var(--bg-light);
}

.faq-item summary:hover {
    background: var(--primary-lighter);
}

.faq-item[open] summary {
    background: linear-gradient(135deg, var(--primary-lighter) 0%, #f0ebff 100%);
    color: var(--primary);
}

.faq-item summary::after {
    content: '▼';
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.faq-item[open] summary::after {
    transform: rotate(-180deg);
}

.faq-answer {
    padding: 1.5rem;
    border-top: 2px solid var(--border);
    background: var(--bg-white);
    animation: slideDown 0.3s ease;
}

.faq-answer p {
    margin-bottom: 1rem;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--accent) 100%);
    color: white;
    padding: 3rem 20px 1.5rem;
    margin-top: 4rem;
}

footer a {
    color: #b0c4ff;
}

footer a:hover {
    color: white;
    text-decoration: none;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: white;
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 0;
}

.footer-section ul {
    list-style: none;
    margin-left: 0;
}

.footer-section ul li {
    margin-bottom: 0.75rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1.5rem;
    text-align: center;
    opacity: 0.9;
}

/* ============================================
   UTILITIES
   ============================================ */

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

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.hidden {
    display: none !important;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* ============================================
   ACCESSIBILITY
   ============================================ */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1rem;
    text-decoration: none;
    z-index: 100;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--secondary);
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--secondary);
    outline-offset: 2px;
}

button:focus,
input:focus,
a:focus {
    outline: 3px solid var(--secondary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .hero {
        padding: 3rem 20px;
    }

    .hero h1 {
        font-size: 2rem;
    }

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

    .hero-cta {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

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

    .toc ul {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .container {
        padding: 0 15px;
    }

    .definition-box,
    .example-card {
        padding: 1rem;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 0.75rem;
    }

    .visual-example {
        min-height: 200px;
    }
}
