/* Japanese Driving Course - Unified Mobile-First Stylesheet */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #667eea;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-color: #333333;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 15px rgba(0,0,0,0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background: var(--light-bg);
    font-size: 16px;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    background: var(--white);
    min-height: 100vh;
}

@media (min-width: 768px) {
    .container {
        padding: 24px 40px;
        margin: 20px auto;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        min-height: auto;
    }
}

/* Header */
.header {
    background: var(--accent-gradient);
    color: var(--white);
    padding: 24px 20px;
    text-align: center;
    margin: -16px -16px 24px -16px;
    border-radius: 0;
}

@media (min-width: 768px) {
    .header {
        margin: -24px -40px 32px -40px;
        padding: 40px;
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

.header .brand {
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 500;
    opacity: 0.9;
    letter-spacing: 0.5px;
}

@media (min-width: 768px) {
    .header .brand {
        font-size: 1rem;
    }
}

.header h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    font-weight: 700;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .header h1 {
        font-size: 2.2rem;
    }
}

.header .subtitle {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 0;
    font-weight: 500;
}

.header .course-number {
    font-size: 0.9rem;
    opacity: 0.8;
    font-weight: 500;
}

/* Side Menu TOC */
.menu-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 1001;
    transition: var(--transition);
}

.menu-toggle:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

.side-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: var(--primary-color);
    z-index: 1002;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

.side-menu.open {
    right: 0;
}

.side-menu-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
}

.side-menu-header h2 {
    color: var(--white);
    font-size: 1.1rem;
    margin: 0;
    border: none;
    padding: 0;
}

.side-menu-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: var(--transition);
}

.side-menu-close:hover {
    opacity: 1;
}

.side-menu .toc {
    padding: 16px;
    list-style: none;
    margin: 0;
}

.side-menu .toc li {
    margin: 6px 0;
}

.side-menu .toc a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    display: block;
    padding: 12px 16px;
    border-radius: 8px;
    transition: var(--transition);
    font-size: 0.95rem;
}

.side-menu .toc a:hover,
.side-menu .toc a:focus {
    background: rgba(255,255,255,0.15);
    color: var(--secondary-color);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Legacy nav-container - hidden, replaced by side menu */
.nav-container {
    display: none;
}

/* Main Content */
.content {
    padding: 0;
}

/* Sections */
section {
    margin-bottom: 40px;
}

h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 32px 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--secondary-color);
}

h3 {
    color: var(--primary-color);
    font-size: 1.25rem;
    margin: 28px 0 14px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

h4 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin: 20px 0 10px 0;
    font-weight: 600;
}

h5 {
    color: var(--text-color);
    font-size: 1rem;
    margin: 16px 0 8px 0;
    font-weight: 600;
}

p {
    margin-bottom: 14px;
    line-height: 1.8;
}

/* Lists */
ul, ol {
    margin: 12px 0 16px 24px;
}

li {
    margin: 8px 0;
    line-height: 1.7;
}

/* Info Boxes */
.info-box,
.warning-box,
.important-box,
.success-box,
.note-box,
.reference-box {
    padding: 16px 18px;
    margin: 16px 0;
    border-radius: 10px;
    border-left: 4px solid;
}

.info-box {
    background: #e3f2fd;
    border-color: var(--secondary-color);
}

.warning-box {
    background: #fff8e1;
    border-color: var(--warning-color);
}

.important-box {
    background: #ffebee;
    border-color: var(--danger-color);
}

.success-box {
    background: #e8f5e9;
    border-color: var(--success-color);
}

.note-box {
    background: #e8f4f8;
    border-color: var(--info-color);
}

.reference-box {
    background: #f5f5f5;
    border-color: #9e9e9e;
    border-width: 2px;
}

/* Prohibition List */
.prohibition-list {
    background: #fff5f5;
    padding: 18px;
    border-radius: 10px;
    margin: 16px 0;
    border: 1px solid rgba(220,53,69,0.2);
}

.prohibition-list h4 {
    color: var(--danger-color);
    margin-bottom: 12px;
    font-size: 1rem;
}

/* Procedure Steps */
.procedure-steps {
    background: linear-gradient(135deg, #e3f2fd 0%, #f5f5f5 100%);
    padding: 18px;
    border-radius: 10px;
    margin: 16px 0;
}

.procedure-steps ol {
    margin-left: 20px;
}

.procedure-steps li {
    margin: 12px 0;
    padding: 12px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 400px;
    font-size: 0.9rem;
    box-shadow: 0 1px 8px rgba(0,0,0,0.08);
    border-radius: 10px;
    overflow: hidden;
}

th {
    background: var(--primary-color);
    color: var(--white);
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    border-right: 1px solid rgba(255,255,255,0.15);
}

th:last-child {
    border-right: none;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    vertical-align: top;
}

td:last-child {
    border-right: none;
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) {
    background: #f8f9fa;
}

@media (max-width: 600px) {
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 10px 8px;
    }
}

/* Quiz/Let's Try Section */
.lets-try {
    background: linear-gradient(135deg, #fff9c4 0%, #ffecb3 100%);
    padding: 20px;
    border-radius: var(--radius);
    margin: 32px 0;
    border: 2px solid #ffd54f;
}

.lets-try h3 {
    color: var(--primary-color);
    border-bottom: 3px solid #ff7043;
    margin-bottom: 16px;
    padding-bottom: 10px;
}

.lets-try ol {
    margin-left: 0;
    list-style: none;
}

.lets-try li {
    margin: 12px 0;
    padding: 14px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    font-size: 0.95rem;
}

/* Emphasis */
strong {
    color: var(--danger-color);
    font-weight: 600;
}

em {
    color: var(--secondary-color);
    font-style: italic;
}

.highlight {
    background: #fff59d;
    padding: 2px 6px;
    border-radius: 4px;
}

/* No-marker list (for lists with inline numbers like ①②③) */
ol.no-marker {
    list-style: none;
    margin-left: 0;
    padding-left: 0;
}

ol.no-marker li {
    padding-left: 1em;
}

/* Navigation Links */
.nav-links {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 40px 0 20px 0;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--secondary-color);
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95rem;
}

.nav-links a:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.nav-links a.prev::before {
    content: '←';
}

.nav-links a.next::after {
    content: '→';
}

.nav-links a.home {
    background: var(--accent-gradient);
}

/* Footer */
.footer {
    margin-top: 40px;
    padding: 24px 0;
    border-top: 2px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer p {
    margin-bottom: 8px;
}

/* Index Page Specific */
.course-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.course-list li {
    margin: 0;
}

.course-list a {
    display: block;
    padding: 18px 20px;
    margin: 12px 0;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.course-list a:hover {
    border-color: var(--secondary-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.course-list .course-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.course-list .course-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stage-group {
    margin: 32px 0;
}

.stage-group h2 {
    font-size: 1.3rem;
    color: var(--white);
    background: var(--accent-gradient);
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: none;
}

/* Print Styles */
@media print {
    .nav-container,
    .back-to-top,
    .nav-links {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
        box-shadow: none;
        padding: 20px;
    }
    
    .header {
        background: none;
        color: var(--text-color);
        border-bottom: 2px solid var(--text-color);
    }
    
    section {
        page-break-inside: avoid;
    }
}

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

/* Focus styles */
a:focus,
button:focus {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --light-bg: #1a1a2e;
        --white: #16213e;
        --text-color: #e8e8e8;
        --text-muted: #a0a0a0;
        --border-color: #333355;
        --primary-color: #8eaadc;
        --accent-gradient: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    }
    
    .header {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #ffffff;
    }
    
    .header .brand,
    .header h1,
    .header .subtitle {
        color: #ffffff;
        opacity: 1;
    }
    
    .header .brand {
        opacity: 0.85;
    }
    
    .menu-toggle {
        background: #667eea;
        color: #ffffff;
    }
    
    .menu-toggle:hover {
        background: #764ba2;
    }
    
    .side-menu {
        background: #1a202c;
    }
    
    .side-menu-header {
        background: rgba(0,0,0,0.3);
    }
    
    .side-menu-header h2 {
        color: #ffffff;
    }
    
    th {
        background: #2d3748;
        color: #ffffff;
    }
    
    .highlight {
        background: #5c4d1a;
        color: #ffd54f;
    }
    
    .info-box {
        background: #1a2a3a;
    }
    
    .warning-box {
        background: #2a2a1a;
    }
    
    .important-box {
        background: #2a1a1a;
    }
    
    .success-box {
        background: #1a2a1a;
    }
    
    .note-box {
        background: #1a2a2a;
    }
    
    .reference-box {
        background: #222233;
    }
    
    .prohibition-list {
        background: #2a1a1a;
    }
    
    .procedure-steps {
        background: linear-gradient(135deg, #1a2a3a 0%, #222233 100%);
    }
    
    .procedure-steps li {
        background: #16213e;
    }
    
    tr:nth-child(even) {
        background: #1a1a2e;
    }
    
    .lets-try {
        background: linear-gradient(135deg, #2a2a1a 0%, #332a1a 100%);
        border-color: #665522;
    }
    
    .lets-try li {
        background: #16213e;
    }
    
    .course-list a {
        background: #16213e;
        border-color: #333355;
    }
    
    .course-list .course-title {
        color: #8eaadc;
    }
    
    .stage-group h2 {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #ffffff;
    }
    
    strong {
        color: #ff6b6b;
    }
    
    em {
        color: #64b5f6;
    }
    
    .nav-links a {
        color: #ffffff;
    }
    
    .prohibition-list h4 {
        color: #ff6b6b;
    }
    
    .lets-try h3 {
        color: #e8e8e8;
        border-color: #ff7043;
    }
    
    h2, h3, h4 {
        color: #8eaadc;
    }
    
    .side-menu-close {
        color: #ffffff;
    }
}
