/* Enhanced CSS for Python Course - Responsive, Accessible, and Modern */

/* ===========================
   Import existing base styles
   =========================== */
@import url('main.css');

/* ===========================
   Responsive Design
   =========================== */

/* Container for responsive content */
.responsive-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Responsive Canvas/SVG wrapper */
.canvas-wrapper, .svg-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
}

.responsive-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Mobile-first responsive breakpoints */
@media (max-width: 768px) {
    body {
        margin-left: 10px;
        margin-right: 10px;
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.5rem;
        padding: 0.75rem;
        margin: 0.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
        margin-left: 10px;
        margin-right: 10px;
    }
    
    h3 {
        font-size: 1.1rem;
        margin-left: 15px;
        margin-right: 15px;
    }
    
    pre {
        margin-left: 10px;
        margin-right: 10px;
        font-size: 12px;
        overflow-x: auto;
    }
    
    p {
        margin-left: 15px;
        margin-right: 15px;
    }
    
    /* Hide canvas on mobile, show mobile message */
    canvas {
        display: none;
    }
    
    .mobile-diagram-note {
        display: block;
        padding: 15px;
        background: #e8f4f8;
        border-radius: 5px;
        text-align: center;
        color: #2c3e50;
        margin: 20px 10px;
    }
    
    /* Stack navigation elements vertically on mobile */
    .lesson-nav {
        flex-direction: column;
        gap: 10px;
    }
    
    .lesson-nav a {
        width: 100%;
        text-align: center;
    }
}

@media (min-width: 769px) {
    .mobile-diagram-note {
        display: none;
    }
}

@media (max-width: 480px) {
    /* Even smaller screens */
    blockquote {
        margin-left: 20px;
        margin-right: 20px;
    }
    
    table {
        font-size: 12px;
    }
}

/* ===========================
   Accessibility Improvements
   =========================== */

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    left: -10000px;
    top: 30px;
    z-index: 999;
    padding: 10px;
    background: rgb(59, 130, 246);
    color: white;
    text-decoration: none;
    border-radius: 0 5px 5px 0;
}

.skip-to-main:focus {
    left: 0;
}

/* Focus indicators */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid rgb(59, 130, 246);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background-color: white;
        color: black;
    }
    
    h1, h2, h3, h4 {
        background-color: black;
        color: white;
    }
    
    a {
        color: blue;
        text-decoration: underline;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Improve link visibility */
a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* ===========================
   Code Highlighting (Prism.js compatible)
   =========================== */

/* Better code block styling */
pre[class*="language-"],
code[class*="language-"] {
    color: #383a42;
    background: #fafafa;
    font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 14px;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.5;
    tab-size: 4;
    hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
    padding: 1em;
    margin: 1em 0;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid #e1e4e8;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
    padding: .1em .3em;
    border-radius: .3em;
    white-space: normal;
    background: #f6f8fa;
}

/* Line numbers */
.line-numbers {
    position: relative;
    padding-left: 3.8em !important;
    counter-reset: linenumber;
}

.line-numbers > code {
    position: relative;
    white-space: inherit;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #e1e4e8;
    user-select: none;
}

.line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #6a737d;
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* Token colors for syntax highlighting */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #6a737d;
    font-style: italic;
}

.token.punctuation {
    color: #383a42;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #e45649;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #50a14f;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #a626a4;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #4078f2;
}

.token.function,
.token.class-name {
    color: #c18401;
}

.token.regex,
.token.important,
.token.variable {
    color: #e06c75;
}

/* Override the green color that's hard to read */
code, pre {
    color: #383a42 !important;
    background-color: #f6f8fa !important;
}

/* Python-specific highlighting when not using Prism */
.python-code {
    background: #f6f8fa !important;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
}

/* ===========================
   Navigation Improvements
   =========================== */

/* Lesson navigation */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 40px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e4e8;
}

.lesson-nav a {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: rgb(59, 130, 246);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    font-weight: bold;
}

.lesson-nav a:hover {
    background: rgb(37, 99, 235);
    text-decoration: none;
}

.lesson-nav a:focus {
    outline: 3px solid rgb(37, 99, 235);
    outline-offset: 2px;
}

.lesson-nav .prev-lesson::before {
    content: "← ";
    margin-right: 5px;
}

.lesson-nav .next-lesson::after {
    content: " →";
    margin-left: 5px;
}

.lesson-nav .current-lesson {
    font-weight: bold;
    color: #2c3e50;
}

/* Breadcrumb navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 20px;
    font-size: 14px;
}

.breadcrumb a {
    color: rgb(59, 130, 246);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb .separator {
    margin: 0 10px;
    color: #6a737d;
}

.breadcrumb .current {
    color: #2c3e50;
    font-weight: bold;
}

/* Reading time indicator */
.reading-time {
    display: inline-block;
    padding: 5px 10px;
    background: #e8f4f8;
    border-radius: 20px;
    font-size: 14px;
    color: #2c3e50;
    margin: 10px 0;
}

.reading-time::before {
    content: "⏱️ ";
    margin-right: 5px;
}

/* Progress indicator */
.progress-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #e1e4e8;
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, rgb(59, 130, 246), rgb(37, 99, 235));
    width: 0;
    transition: width 0.3s ease;
}

/* ===========================
   Enhanced Exercise Cards
   =========================== */

.exercise-card {
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    margin: 20px 0;
    overflow: hidden;
}

.exercise-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e4e8;
}

.exercise-header h3 {
    margin: 0;
    padding: 0;
    background: none;
    color: #2c3e50;
}

.difficulty-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.difficulty-badge.easy {
    background: #d4edda;
    color: #155724;
}

.difficulty-badge.medium {
    background: #fff3cd;
    color: #856404;
}

.difficulty-badge.hard {
    background: #f8d7da;
    color: #721c24;
}

.time-estimate {
    font-size: 12px;
    color: #6a737d;
}

.exercise-body {
    padding: 15px;
}

.exercise-actions {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e1e4e8;
    display: flex;
    gap: 10px;
}

.exercise-actions button {
    padding: 8px 16px;
    border: 1px solid #e1e4e8;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.exercise-actions button:hover {
    background: #f8f9fa;
    border-color: rgb(59, 130, 246);
}

/* ===========================
   Print Styles
   =========================== */

@media print {
    body {
        background: white;
        color: black;
    }
    
    .lesson-nav,
    .progress-indicator,
    .skip-to-main,
    canvas,
    .mobile-diagram-note {
        display: none !important;
    }
    
    h1, h2, h3, h4 {
        background: none !important;
        color: black !important;
        border-bottom: 2px solid black;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    pre {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}

/* ===========================
   Dark Mode Support
   =========================== */

@media (prefers-color-scheme: dark) {
    body {
        background-color: #1e1e1e;
        color: #d4d4d4;
    }
    
    h1, h2, h3, h4 {
        background-color: #2d53a3;
    }
    
    pre, code {
        background-color: #2d2d30 !important;
        color: #d4d4d4 !important;
        border-color: #3e3e42;
    }
    
    .lesson-nav,
    .breadcrumb,
    .exercise-header,
    .exercise-actions {
        background: #2d2d30;
        border-color: #3e3e42;
    }
    
    a {
        color: #569cd6;
    }
    
    blockquote {
        background-color: #2d2d30;
        color: #d4d4d4;
    }
}