/* Chapter-specific styles with enhanced responsive design */

/* Base chapter styles */
.chapter-content {
    padding-top: 80px;
    background: #f8fafc;
}

.chapter-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: clamp(2rem, 6vw, 3rem) 0;
    text-align: center;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.back-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    font-size: clamp(0.9rem, 2vw, 1rem);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.back-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.chapter-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: clamp(0.8rem, 2vw, 1rem);
    backdrop-filter: blur(10px);
}

.chapter-title {
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.chapter-subtitle {
    font-size: clamp(1rem, 3vw, 1.5rem);
    opacity: 0.9;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.chapter-meta {
    display: flex;
    justify-content: center;
    gap: clamp(1rem, 3vw, 2rem);
    flex-wrap: wrap;
}

.chapter-meta span {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

/* Chapter layout */
.chapter-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 3rem;
    margin-top: 2rem;
    align-items: start;
}

/* Table of Contents */
.toc {
    position: sticky;
    top: 100px;
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    height: fit-content;
}

.toc h3 {
    margin-bottom: 1rem;
    color: #1f2937;
    font-weight: 600;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

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

.toc-list li {
    margin-bottom: 0.5rem;
}

.toc-list li a {
    display: block;
    padding: 0.75rem 1rem;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.toc-list li a:hover {
    background: #4f46e5;
    color: white;
    transform: translateX(5px);
}

/* Content sections */
.chapter-content {
    background: white;
}

.content-section {
    padding: clamp(2rem, 5vw, 3rem) 0;
    background: white;
    margin-bottom: 2rem;
}

.content-section:nth-child(even) {
    background: #f8fafc;
}

.content-section h2 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 2rem;
    color: #1f2937;
    line-height: 1.2;
}

.content-section h3 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
    line-height: 1.3;
}

.content-section p {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: #4b5563;
}

/* Highlight boxes */
.highlight-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-left: 4px solid #4f46e5;
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 10px;
    margin: 2rem 0;
}

.highlight-box h3,
.highlight-box h4 {
    color: #1f2937;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.highlight-box p {
    font-size: clamp(0.9rem, 2vw, 1rem);
    line-height: 1.6;
}

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

.highlight-box li {
    padding: 0.5rem 0;
    position: relative;
    padding-left: 1.5rem;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.highlight-box li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: bold;
}

/* Images */
.content-image {
    width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    margin: 2rem 0;
}

.content-image:hover {
    transform: scale(1.02);
}

.image-caption {
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: #6b7280;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Grids and cards */
.concept-grid,
.component-grid,
.sensor-grid,
.application-grid,
.tech-grid,
.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
    margin: 2rem 0;
}

.concept-card,
.component-card,
.sensor-card,
.app-card,
.tech-card,
.benefit-card {
    background: white;
    padding: clamp(1.5rem, 4vw, 2rem);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.concept-card:hover,
.component-card:hover,
.sensor-card:hover,
.app-card:hover,
.tech-card:hover,
.benefit-card:hover {
    transform: translateY(-5px);
}

.concept-icon,
.sensor-icon,
.app-icon,
.tech-icon,
.benefit-icon {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 1rem;
    display: block;
}

.concept-card h4,
.component-card h4,
.sensor-card h4,
.app-card h4,
.tech-card h4,
.benefit-card h4 {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
    line-height: 1.3;
}

.concept-card p,
.component-card p,
.sensor-card p,
.app-card p,
.tech-card p,
.benefit-card p {
    color: #6b7280;
    line-height: 1.6;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Special card types */
.benefit-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #059669);
}

.sensor-card ul,
.app-card ul {
    list-style: none;
    padding-left: 0;
    margin-top: 1rem;
}

.sensor-card li,
.app-card li {
    padding: 0.25rem 0;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
}

/* Microcontroller comparison */
.microcontroller-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
    margin: 2rem 0;
}

.mc-card {
    background: white;
    padding: clamp(1.5rem, 4vw, 2rem);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.mc-card h4 {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.mc-card p {
    color: #6b7280;
    margin-bottom: 1rem;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

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

.mc-card li {
    padding: 0.5rem 0;
    position: relative;
    padding-left: 1.5rem;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.mc-card li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #4f46e5;
    font-weight: bold;
}

/* Formula box */
.formula-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 10px;
    margin: 2rem 0;
    text-align: center;
}

.formula-box h4 {
    color: #1f2937;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.formula {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 700;
    color: #f59e0b;
    background: white;
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
}

/* Steps container */
.steps-container {
    margin: 2rem 0;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.step-number {
    background: #4f46e5;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.step-content h4 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.step-content p {
    color: #6b7280;
    font-size: clamp(0.9rem, 2vw, 1rem);
    line-height: 1.6;
}

/* Conclusion box */
.conclusion-box {
    background: #f0fdf4;
    border-left: 4px solid #10b981;
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 10px;
    margin: 2rem 0;
}

.conclusion-box h3 {
    color: #1f2937;
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.conclusion-box p {
    color: #4b5563;
    line-height: 1.6;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Navigation */
.chapter-navigation {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin: 3rem 0;
    flex-wrap: wrap;
}

.nav-btn {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
    font-size: clamp(0.9rem, 2vw, 1rem);
    min-width: 200px;
}

.nav-btn.prev {
    background: #f3f4f6;
    color: #374151;
}

.nav-btn.prev:hover {
    background: #e5e7eb;
    transform: translateX(-5px);
}

.nav-btn.next {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
}

.nav-btn.next:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(79, 70, 229, 0.4);
}

/* Enhanced Responsive Design */

/* Large tablets */
@media (max-width: 1024px) {
    .chapter-layout {
        grid-template-columns: 200px 1fr;
        gap: 2rem;
    }
    
    .toc {
        padding: 1.5rem;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .chapter-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .toc {
        position: static;
        margin-bottom: 2rem;
        order: -1;
    }
    
    .toc-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .toc-list li {
        margin-bottom: 0;
    }
    
    .toc-list li a {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .chapter-nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .chapter-meta {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .concept-grid,
    .component-grid,
    .sensor-grid,
    .application-grid,
    .tech-grid,
    .benefits-grid {
        grid-template-columns: 1fr;
    }
    
    .microcontroller-comparison {
        grid-template-columns: 1fr;
    }
    
    .chapter-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-btn {
        min-width: auto;
    }
    
    .step {
        flex-direction: column;
        text-align: center;
    }
    
    .step-number {
        align-self: center;
    }
}

/* Large phones */
@media (max-width: 480px) {
    .chapter-content {
        padding-top: 70px;
    }
    
    .chapter-header {
        padding: 2rem 0;
    }
    
    .content-section {
        padding: 2rem 0;
    }
    
    .concept-card,
    .component-card,
    .sensor-card,
    .app-card,
    .tech-card,
    .benefit-card,
    .mc-card {
        padding: 1rem;
    }
    
    .toc {
        padding: 1rem;
    }
    
    .toc-list {
        flex-direction: column;
    }
    
    .toc-list li a {
        text-align: center;
    }
    
    .formula {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .step {
        padding: 0.75rem;
    }
}

/* Small phones */
@media (max-width: 360px) {
    .chapter-title {
        font-size: 1.5rem;
    }
    
    .chapter-subtitle {
        font-size: 0.95rem;
    }
    
    .concept-card,
    .component-card,
    .sensor-card,
    .app-card,
    .tech-card,
    .benefit-card,
    .mc-card {
        padding: 0.75rem;
    }
    
    .nav-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .toc-list li a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .back-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .concept-card:hover,
    .component-card:hover,
    .sensor-card:hover,
    .app-card:hover,
    .tech-card:hover,
    .benefit-card:hover {
        transform: none;
    }
    
    .content-image:hover {
        transform: none;
    }
    
    .nav-btn.prev:hover {
        transform: none;
        background: #f3f4f6;
    }
    
    .nav-btn.next:hover {
        transform: none;
        box-shadow: none;
    }
    
    .toc-list li a:hover {
        transform: none;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .chapter-header {
        padding: 1.5rem 0;
    }
    
    .chapter-title {
        font-size: 2rem;
        margin-bottom: 0.25rem;
    }
    
    .chapter-subtitle {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .chapter-meta {
        flex-direction: row;
        gap: 1rem;
    }
}

/* Print styles */
@media print {
    .toc,
    .chapter-navigation,
    .back-link {
        display: none;
    }
    
    .chapter-layout {
        grid-template-columns: 1fr;
    }
    
    .chapter-header {
        background: white;
        color: black;
        padding: 1rem 0;
    }
    
    .chapter-title,
    .chapter-subtitle {
        color: black;
        text-shadow: none;
    }
    
    .content-section {
        break-inside: avoid;
        background: white;
    }
    
    .concept-card,
    .component-card,
    .sensor-card,
    .app-card,
    .tech-card,
    .benefit-card,
    .mc-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .content-image {
        max-width: 100%;
        box-shadow: none;
    }
}

