/* Claude Code Primer - Mobile-First Design System */
/* Base styles are for mobile, then we enhance for larger screens */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Mobile-First Base Styles */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #000000;
    background-color: #ffffff;
    padding: 60px 1rem 1rem 1rem; /* Add top padding for sticky header */
    margin: 0;
    width: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sticky Mobile Navigation */
.mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-arrow {
    font-size: 24px;
    text-decoration: none;
    color: #000000;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: background 0.2s;
}

.nav-arrow:active {
    background: #f0f0f0;
}

.nav-arrow.disabled {
    color: #cccccc;
    pointer-events: none;
}

.nav-title {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 10px;
}

/* Mobile Typography Scale */
h1 {
    font-size: 1.75rem;
    line-height: 1.2;
    margin: 1rem 0;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 1rem 0;
    font-weight: 600;
}

h3 {
    font-size: 1.25rem;
    line-height: 1.4;
    margin: 0.75rem 0;
    font-weight: 600;
}

h4 {
    font-size: 1.1rem;
    line-height: 1.4;
    margin: 0.75rem 0;
    font-weight: 600;
}

p {
    margin-bottom: 1rem;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Mobile-Optimized Links */
a {
    color: #0066cc;
    text-decoration: none;
    touch-action: manipulation;
    padding: 0.25rem 0;
    display: inline-block;
}

a:active {
    color: #0052a3;
}

/* Mobile Navigation */
.chapter-nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 0;
    border-bottom: 2px solid #000000;
    margin-bottom: 1.5rem;
}

.chapter-nav.bottom {
    border-bottom: none;
    border-top: 2px solid #000000;
    margin-top: 2rem;
    margin-bottom: 0;
}

.nav-prev,
.nav-next,
.nav-home {
    background-color: #f8f8f8;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.nav-prev:active,
.nav-next:active,
.nav-home:active {
    background-color: #e0e0e0;
    transform: scale(0.98);
}

/* Mobile-First Book Header */
.book-header {
    text-align: center;
    padding: 1.5rem 0;
    border-bottom: 2px solid #000000;
    margin-bottom: 1.5rem;
}

.book-header h1 {
    font-size: 1.75rem;
    margin: 0 0 0.5rem 0;
}

.book-header .subtitle {
    font-style: italic;
    font-size: 1rem;
    color: #666;
}

/* Mobile Chapter List */
.chapter-list {
    list-style: none;
    padding: 0;
}

.chapter-list li {
    margin-bottom: 1rem;
}

.chapter-list a {
    display: block;
    padding: 1rem;
    border: 2px solid #000000;
    border-radius: 8px;
    background-color: #ffffff;
    transition: all 0.2s ease;
}

.chapter-list a:active {
    background-color: #f0f0f0;
    transform: scale(0.98);
}

.chapter-number {
    display: block;
    font-weight: bold;
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.chapter-title {
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.25rem;
    color: #000;
}

.chapter-subtitle {
    font-style: italic;
    color: #666;
    font-size: 0.875rem;
    display: block;
}

/* Mobile Content Optimization */
.chapter-content {
    width: 100%;
    max-width: 100%;
}

.chapter-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem 0;
    border-radius: 4px;
}

.chapter-content blockquote {
    margin: 1rem 0;
    padding: 1rem;
    padding-left: 1.5rem;
    border-left: 4px solid #000000;
    font-style: italic;
    background-color: #f8f8f8;
    border-radius: 0 4px 4px 0;
}

.chapter-content pre {
    background-color: #f5f5f5;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.875rem;
    -webkit-overflow-scrolling: touch;
}

.chapter-content code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    background-color: #f5f5f5;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-size: 0.875rem;
}

.chapter-content pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.875rem;
}

.chapter-content ul,
.chapter-content ol {
    margin-bottom: 1rem;
    margin-left: 1.5rem;
    padding-left: 0;
}

.chapter-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Mobile Tables */
.chapter-content table {
    width: 100%;
    overflow-x: auto;
    display: block;
    margin: 1rem 0;
    -webkit-overflow-scrolling: touch;
}

.chapter-content th,
.chapter-content td {
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    text-align: left;
}

/* Mobile Footer */
.book-footer {
    text-align: center;
    padding: 2rem 0 1rem 0;
    margin-top: 3rem;
    border-top: 2px solid #000000;
    font-size: 0.875rem;
}

/* Touch-Friendly Buttons */
button,
.button,
input[type="submit"],
input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    touch-action: manipulation;
}

/* Tablet Styles (iPad Mini and up) */
@media (min-width: 481px) {
    body {
        padding: 1.5rem;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    .chapter-nav {
        flex-direction: row;
        justify-content: space-between;
        gap: 1rem;
    }
    
    .nav-prev,
    .nav-next {
        flex: 1;
    }
    
    .nav-home {
        flex: 0 0 auto;
    }
}

/* Small Desktop (768px and up) */
@media (min-width: 768px) {
    body {
        padding: 2rem;
        max-width: 700px;
        margin: 0 auto;
    }
    
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    
    p {
        text-align: justify;
        hyphens: auto;
    }
    
    .book-header {
        padding: 3rem 0;
    }
    
    .chapter-content pre {
        font-size: 1rem;
    }
    
    .chapter-content code {
        font-size: 0.9rem;
    }
}

/* Large Desktop (1024px and up) */
@media (min-width: 1024px) {
    body {
        font-size: 18px;
        line-height: 1.8;
    }
    
    .chapter-list a:hover {
        background-color: #f0f0f0;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    
    a:hover {
        text-decoration: underline;
    }
}

/* Accessibility Improvements */
:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        color: #ffffff;
        background-color: #1a1a1a;
    }
    
    a {
        color: #66b3ff;
    }
    
    .nav-prev,
    .nav-next,
    .nav-home {
        background-color: #2a2a2a;
        border-color: #3a3a3a;
        color: #ffffff;
    }
    
    .chapter-list a {
        background-color: #1a1a1a;
        border-color: #3a3a3a;
        color: #ffffff;
    }
    
    .chapter-content pre {
        background-color: #2a2a2a;
        border-color: #3a3a3a;
    }
    
    .chapter-content code {
        background-color: #2a2a2a;
    }
    
    .chapter-content blockquote {
        background-color: #2a2a2a;
        border-left-color: #666;
    }
}

/* Print Styles */
@media print {
    body {
        font-size: 12pt;
        line-height: 1.5;
        padding: 0;
    }
    
    .chapter-nav,
    .book-footer {
        display: none;
    }
    
    a {
        color: #000000;
        text-decoration: none;
    }
    
    .chapter-header {
        page-break-after: avoid;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
}