/* ============================================
   Core Styles - Shared across all examples
   ============================================ */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #3f509c 0%, #764ba2 100%);
    padding: 40px 20px;
    min-height: 100vh;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #000;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    left: 20px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Navigation */
.nav {
    margin-bottom: 30px;
}

.nav a {
    color: #3f509c;
    text-decoration: none;
    font-weight: bold;
}

.nav a:hover {
    text-decoration: underline;
}

/* Site-wide Navigation Bar */
.site-nav {
    background: #3f509c;
    color: #fff;
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 30px;
}

.site-nav .site-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-nav .brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.site-nav .nav-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.site-nav .nav-list a {
    color: #fff;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    display: block;
}

.site-nav .nav-list a:hover {
    background: rgba(255, 255, 255, 0.18);
}

.site-nav .nav-list a[aria-current="page"] {
    background: #1d2b6b;
    font-weight: 700;
}

@media (max-width: 700px) {
    .site-nav .site-nav-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .site-nav .nav-list {
        gap: 6px;
    }
}

/* Headings */
h1 {
    color: #333;
    margin-bottom: 20px;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e1e4e8;
}

h3 {
    color: #3f509c;
    margin-bottom: 15px;
}

/* Theory Section */
.theory {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 40px;
    border-left: 5px solid #3f509c;
}

.theory h2 {
    color: #3f509c;
    margin-bottom: 15px;
    border-bottom: none;
}

.theory p {
    line-height: 1.6;
    color: #333;
}

.theory ul {
    margin-top: 15px;
    margin-left: 25px;
}

.theory li {
    margin: 8px 0;
    line-height: 1.6;
}

/* Demo Sections */
.demo-section {
    margin: 40px 0;
}

.demo-section h3 {
    color: #333;
    margin-bottom: 15px;
}

/* Code Blocks */
.code-block {
    background: #282c34;
    color: #abb2bf;
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

.code-block .selector {
    color: #e5c07b;
}

.code-block .property {
    color: #fac3c8;
}

.code-block .value {
    color: #98c379;
}

.code-block .comment {
    color: #e1e6f0;
    font-style: italic;
}

/* Demo Containers */
.demo-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 8px;
    margin: 20px 0;
    border: 2px solid #e1e4e8;
}

/* Demo Boxes */
.demo-box {
    background: #3f509c;
    color: white;
    padding: 30px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    margin: 20px 0;
}

/* Explanations */
.explanation {
    background: #fff3cd;
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
    border-left: 4px solid #ffc107;
}

.explanation strong {
    color: #856404;
}

/* Measurements Display */
.measurements {
    background: #fff3cd;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 2px solid #ffc107;
}

.measurements h3 {
    color: #856404;
    margin-bottom: 15px;
}

.measurement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.measurement-item {
    background: white;
    padding: 12px;
    border-radius: 5px;
    border-left: 4px solid #3f509c;
}

.measurement-item strong {
    color: #3f509c;
    display: block;
    margin-bottom: 5px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 5px;
    overflow: hidden;
    margin: 20px 0;
}

th {
    background: #4356a8;
    color: #fff;
    padding: 12px 15px;
    text-align: left;
}

tbody th {
    background: #eef1fb;
    color: #333;
    font-weight: bold;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e1e4e8;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:nth-child(even) td {
    background: #f8f9fa;
}

/* Calculations */
.calculation {
    background: #d4edda;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 2px solid #1d8335;
}

.calculation h3 {
    color: #155724;
    margin-bottom: 10px;
}

.formula {
    font-family: 'Courier New', monospace;
    background: white;
    padding: 15px;
    border-radius: 5px;
    margin: 10px 0;
    font-weight: bold;
    color: #333;
}

/* Interactive Controls */
.interactive-controls {
    background: #e7f3ff;
    padding: 25px;
    border-radius: 8px;
    margin: 30px 0;
}

.control-group {
    margin: 15px 0;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

.control-group input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
}

.value-display {
    color: #3f509c;
    font-weight: bold;
}

/* Key Points / Academic Notes */
.key-points,
.academic-note {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 30px 0;
    border-left: 5px solid #6c757d;
}

.key-points h3,
.academic-note h4 {
    color: #495057;
    margin-bottom: 15px;
}

.key-points ul {
    list-style-position: inside;
    color: #666;
}

.key-points li {
    margin: 10px 0;
    padding-left: 10px;
    line-height: 1.6;
}

.academic-note p {
    line-height: 1.6;
    margin-bottom: 10px;
}

/* Tip Cards */
.tip-card {
    background: white;
    padding: 20px;
    margin-top: 10px;
    border-radius: 8px;
    border-left: 4px solid #3f509c;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.tip-card h4 {
    color: #3f509c;
    margin-bottom: 10px;
}

.tip-card p {
    line-height: 1.6;
    color: #666;
}

/* Buttons */
.toggle-button {
    background: #3f509c;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    margin: 5px;
    transition: background 0.3s ease;
}

.toggle-button:hover {
    background: #764ba2;
}

.toggle-button:active {
    transform: scale(0.98);
}

/* Hero & Intro (shared site sections) */
.hero {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 8px;
    margin-bottom: 40px;
}

.hero h1 {
    color: #4356a8;
    font-size: 2.5em;
    margin-bottom: 15px;
}

.hero p {
    font-size: 1.2em;
    color: #666;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

.intro {
    background: #e7f3ff;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 5px solid #4356a8;
    color: #1b1f23;
}

.intro h2 {
    color: #4356a8;
    margin-bottom: 15px;
    border-bottom: none;
}

/* Code Panel (copy-paste code view) */
.code-panel {
    background: #282c34;
    border-radius: 8px;
    margin: 20px 0;
    overflow: hidden;
}

.code-tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    background: #21252b;
    padding: 6px 8px;
}

.code-tab {
    background: transparent;
    color: #abb2bf;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: inherit;
}

.code-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.code-tab.is-active {
    background: #4356a8;
    color: #fff;
}

.copy-btn {
    margin-left: auto;
    background: #4356a8;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: inherit;
}

.copy-btn:hover {
    background: #764ba2;
}

.copy-btn.copied {
    background: #1d8335;
}

.code-panel pre {
    margin: 0;
    padding: 16px 20px;
    overflow-x: auto;
}

.code-panel code {
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    line-height: 1.6;
    color: #d8dce4;
    white-space: pre;
    display: block;
}

/* Exercises */
.exercises {
    margin: 40px 0;
}

.exercises h2 {
    color: #3f509c;
}

.exercise {
    background: #f8f9fa;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.exercise h3 {
    color: #3f509c;
    margin-bottom: 10px;
}

.exercise-task {
    color: #333;
    line-height: 1.6;
    margin-bottom: 10px;
}

.exercise-solution {
    margin-top: 10px;
    border-top: 1px dashed #e1e4e8;
    padding-top: 10px;
}

.exercise-solution summary {
    cursor: pointer;
    font-weight: bold;
    color: #4356a8;
    padding: 6px 0;
}

.exercise-solution summary:hover {
    text-decoration: underline;
}

.exercise-explanation {
    margin-top: 12px;
    padding: 12px;
    background: #e7f3ff;
    border-radius: 5px;
    color: #333;
    line-height: 1.6;
}

/* Scaffolded exercise: preparation, tools, hints, self-check, stretch */
.exercise-prep {
    background: #eef1fb;
    border-left: 4px solid #3f509c;
    padding: 10px 14px;
    border-radius: 4px;
    color: #333;
    line-height: 1.6;
    margin-bottom: 12px;
}

.challenge-tools {
    background: #fff8e1;
    border-left: 4px solid #ffc107;
    padding: 10px 14px;
    border-radius: 4px;
    color: #333;
    line-height: 1.7;
    margin-bottom: 12px;
}

.challenge-tools code,
.starter code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.hint {
    margin-top: 8px;
    border: 1px solid #e1e4e8;
    border-radius: 5px;
    background: #fff;
    overflow: hidden;
}

.hint summary {
    cursor: pointer;
    padding: 8px 12px;
    font-weight: bold;
    color: #4356a8;
    background: #f4f6fb;
}

.hint summary:hover {
    text-decoration: underline;
}

.hint[open] summary {
    border-bottom: 1px solid #e1e4e8;
}

.hint > div,
.hint > p {
    padding: 10px 12px;
    line-height: 1.6;
    color: #333;
}

.self-check {
    background: #d4edda;
    border: 1px solid #1d8335;
    border-radius: 5px;
    padding: 10px 14px;
    margin-top: 12px;
    color: #1b1f23;
    line-height: 1.6;
}

.self-check ul {
    margin: 6px 0 0 20px;
}

.stretch {
    background: #f8e9f8;
    border: 1px dashed #9c27b0;
    border-radius: 5px;
    padding: 10px 14px;
    margin-top: 12px;
    color: #333;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 20px 10px;
    }

    .container {
        padding: 20px;
    }

    .measurement-grid {
        grid-template-columns: 1fr;
    }

    .theory-content,
    .comparison-container,
    .prevention-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 10px;
}

.mt-2 {
    margin-top: 20px;
}

.mt-3 {
    margin-top: 30px;
}

.mb-1 {
    margin-bottom: 10px;
}

.mb-2 {
    margin-bottom: 20px;
}

.mb-3 {
    margin-bottom: 30px;
}


/* Previous / next topic navigation */
.prev-next {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 40px 0 0;
}

.prev-next a {
    color: #4356a8;
    font-weight: bold;
    text-decoration: none;
    padding: 10px 16px;
    border: 2px solid #4356a8;
    border-radius: 6px;
}

.prev-next a:hover {
    background: #4356a8;
    color: #fff;
}

.prev-next .spacer {
    flex: 1;
}

.footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px 0;
    border-top: 2px solid #e1e4e8;
    color: #fff3f3;
}

.footer p {
    line-height: 1.6;
}

.footer a {
    color: #4356a8;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}
