/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Kanit', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

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

.nav-brand h1 {
    color: #4f46e5;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 700;
}

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

.nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.nav-menu a:hover {
    color: #4f46e5;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: #333;
    margin: 3px 0;
    transition: 0.3s;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem 1rem;
}

.hero-content {
    z-index: 2;
    color: white;
    max-width: 800px;
    padding: 2rem;
    width: 100%;
}

.hero-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 1s ease-out;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 2rem;
    opacity: 0.9;
    animation: fadeInUp 1s ease-out 0.2s both;
    line-height: 1.4;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeInUp 1s ease-out 0.4s both;
}

.btn {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    font-size: clamp(0.9rem, 2vw, 1rem);
    min-width: 120px;
    text-align: center;
}

.btn-primary {
    background: #4f46e5;
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    background: #3730a3;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.circuit-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.1;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.3) 2px, transparent 2px),
        radial-gradient(circle at 80% 50%, rgba(255, 255, 255, 0.3) 2px, transparent 2px),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        radial-gradient(circle at 60% 80%, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 50px 50px, 50px 50px;
    animation: float 20s ease-in-out infinite;
}

/* Chapters Section */
.chapters {
    padding: clamp(3rem, 8vw, 5rem) 0;
    background: white;
}

.section-title {
    text-align: center;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 3rem;
    color: #1f2937;
    line-height: 1.2;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(350px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
    margin-top: 2rem;
}

.chapter-card {
    background: white;
    border-radius: 20px;
    padding: clamp(1.5rem, 4vw, 2rem);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.chapter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
}

.chapter-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.chapter-icon {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 1rem;
    display: block;
}

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

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

.chapter-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.topic-tag {
    background: #f3f4f6;
    color: #374151;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    font-weight: 500;
}

.chapter-link {
    display: inline-block;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    padding: clamp(0.6rem, 2vw, 0.75rem) clamp(1.2rem, 3vw, 1.5rem);
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: clamp(0.85rem, 2vw, 1rem);
    width: 100%;
    text-align: center;
}

.chapter-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 70, 229, 0.4);
}

/* About Section */
.about {
    padding: clamp(3rem, 8vw, 5rem) 0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.about-content {
    max-width: 800px;
    margin: 0 auto;
}

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

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
    margin-top: 3rem;
}

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

.feature-icon {
    font-size: clamp(2rem, 4vw, 2.5rem);
    margin-bottom: 1rem;
}

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

.feature p {
    color: #6b7280;
    font-size: clamp(0.8rem, 2vw, 0.875rem);
}

/* Footer */
.footer {
    background: #1f2937;
    color: white;
    text-align: center;
    padding: clamp(1.5rem, 4vw, 2rem) 0;
}

.footer p {
    font-size: clamp(0.8rem, 2vw, 1rem);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Enhanced Responsive Design */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .chapters-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* Tablets */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 1rem 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu li {
        text-align: center;
        padding: 0.5rem 0;
    }
    
    .navbar {
        padding: 1rem;
    }
    
    .hero {
        padding: 1rem;
    }
    
    .hero-content {
        padding: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
    
    .btn {
        width: 100%;
        max-width: 250px;
    }
    
    .chapters-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
}

/* Large phones */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .hero {
        min-height: 90vh;
        padding: 0.5rem;
    }
    
    .hero-content {
        padding: 1rem 0.5rem;
    }
    
    .chapter-card {
        margin: 0 auto;
        max-width: 100%;
    }
    
    .chapter-topics {
        justify-content: center;
    }
    
    .topic-tag {
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
    }
}

/* Small phones */
@media (max-width: 360px) {
    .hero-title {
        font-size: 1.8rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
    }
    
    .chapter-card {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }
}

/* iPad specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .chapters-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-subtitle {
        font-size: 1.3rem;
    }
    
    .features {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* iPad Pro and large tablets */
@media (min-width: 1024px) and (max-width: 1366px) {
    .chapters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px; /* iOS recommended touch target size */
    }
    
    .chapter-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-menu a {
        padding: 0.75rem 1rem;
        display: block;
    }
    
    /* Remove hover effects on touch devices */
    .chapter-card:hover {
        transform: none;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    }
    
    .btn-primary:hover {
        transform: none;
        background: #4f46e5;
        box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    }
    
    .btn-secondary:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.2);
    }
    
    .chapter-link:hover {
        transform: none;
        box-shadow: none;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-title {
        text-rendering: optimizeLegibility;
    }
    
    .section-title {
        text-rendering: optimizeLegibility;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: 1rem 0;
    }
    
    .hero-content {
        padding: 1rem;
    }
    
    .hero-title {
        font-size: 2.2rem;
        margin-bottom: 0.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .hero-buttons {
        flex-direction: row;
        gap: 1rem;
    }
}

/* Print styles */
@media print {
    .header,
    .hero-buttons,
    .circuit-bg {
        display: none;
    }
    
    .hero {
        min-height: auto;
        padding: 2rem 0;
        background: white;
        color: black;
    }
    
    .hero-title,
    .hero-subtitle {
        color: black;
        text-shadow: none;
    }
    
    .chapter-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

