/*
============================================
Claude Code Tutorial - CSS
EXACT MATCH to spark.kunalamin.com style
============================================
- Apple-inspired design: clarity, depth, and simplicity.
- Uses 'Inter' font for clean, neutral aesthetic.
- Pure white background and dark text for high contrast.
*/

:root {
    --text-color: #1d1d1f;
    --secondary-text-color: #6e6e73;
    --background-color: #ffffff;
    --border-color: #d2d2d7;
    --code-bg: #f5f5f7;
    --accent-color: #0071e3;
    --max-width: 1600px;
    --content-width: 820px;
    --nav-width: 260px;
    --header-height: 60px;
}

/*
============================================
ICON STYLES (Heroicons)
============================================
*/
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-md {
    width: 20px;
    height: 20px;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

/*
============================================
RESET & CORE STYLES
============================================
*/
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/*
============================================
MAIN LAYOUT & STRUCTURE
============================================
- Two-column layout for larger screens
- Mobile collapses to single column
*/
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
}

#table-of-contents {
    width: var(--nav-width);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: calc(var(--header-height) + 40px) 20px 40px 0;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

main {
    flex-grow: 1;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: calc(var(--header-height) + 40px) 40px 100px 40px;
}

/*
============================================
HEADER
============================================
- Fixed header with blur effect
*/
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.search-button, .close-button, .nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}

.search-button:hover, .close-button:hover, .nav-toggle:hover {
    opacity: 0.7;
}

/*
============================================
TABLE OF CONTENTS
============================================
*/
#toc-nav {
    list-style: none;
}

#toc-nav h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-color);
}

#toc-nav ul {
    list-style: none;
}

#toc-nav li a {
    color: var(--secondary-text-color);
    text-decoration: none;
    display: block;
    padding: 8px 0;
    font-size: 14px;
    transition: color 0.2s ease;
    border-left: 2px solid transparent;
    padding-left: 10px;
    margin-left: -12px;
}

#toc-nav li a:hover {
    color: var(--text-color);
}

#toc-nav li a.active {
    color: #000;
    font-weight: 500;
    border-left-color: #000;
}

/*
============================================
TYPOGRAPHY & CONTENT
============================================
*/
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.page-intro {
    font-size: 18px;
    color: var(--secondary-text-color);
    margin-bottom: 40px;
}

.chapter-title {
    font-size: 24px;
    color: var(--text-color);
}

.chapter-content h3 {
    font-size: 20px;
    margin-top: 30px;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}

.chapter-content h4 {
    font-size: 16px;
    color: var(--secondary-text-color);
    margin-top: 25px;
    margin-bottom: 10px;
}

p, li {
    font-size: 16px;
    margin-bottom: 1em;
}

ul, ol {
    padding-left: 20px;
    margin-bottom: 1em;
}

ul li, ol li {
    margin-bottom: 0.5em;
}

/* Remove bullet points from list items that start with SVG icons */
/* This targets the 502 list items that begin with <svg class="icon"> */
/* List items without icons will retain their default bullet styling */
li:has(> svg.icon:first-child) {
    list-style: none;
}

strong, b {
    font-weight: 600;
}

kbd {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9em;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 40px 0;
}

/*
============================================
COLLAPSIBLE SECTIONS (<details>)
============================================
*/
.chapter {
    margin-bottom: 20px;
}

details {
    border-bottom: 1px solid var(--border-color);
}

summary {
    list-style: none;
    cursor: pointer;
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease-in-out;
    flex-shrink: 0;
}

details[open] > summary::after {
    transform: rotate(90deg);
}

.chapter-content {
    padding-bottom: 30px;
}

/*
============================================
CODE BLOCKS
============================================
*/
.code-wrapper {
    position: relative;
    margin-bottom: 1em;
}

pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.5;
}

code {
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
}

p > code, li > code {
    background-color: var(--code-bg);
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.9em;
}

pre code {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Copy button */
.copy-code-button {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background-color: var(--text-color);
    color: var(--background-color);
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.copy-code-button:hover {
    opacity: 1;
}

.copy-code-button.copied {
    background-color: #4caf50;
}

.code-platform-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary-text-color);
    margin: 20px 0 10px 0;
}

/* Tables */
table.command-list {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: 14px;
}
table.command-list th, table.command-list td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}
table.command-list th {
    font-weight: 600;
}
table.command-list td:first-child {
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
}

/*
============================================
SEARCH MODAL
============================================
*/
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.search-modal.is-active {
    opacity: 1;
    visibility: visible;
}

.search-content {
    width: 90%;
    max-width: 700px;
}

.search-modal .close-button {
    position: absolute;
    top: 20px;
    right: 20px;
}

#search-input {
    width: 100%;
    border: none;
    border-bottom: 2px solid var(--text-color);
    background: transparent;
    font-size: 32px;
    padding: 10px 0;
    font-weight: 500;
    outline: none;
    color: var(--text-color);
    margin-bottom: 30px;
}

#search-results {
    max-height: 60vh;
    overflow-y: auto;
}

.search-result-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: block;
    text-decoration: none;
    color: var(--text-color);
    border-radius: 8px;
    margin-bottom: 5px;
}

.search-result-item:hover {
    background-color: var(--code-bg);
}

.search-result-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 5px;
}

.search-result-context {
    font-size: 14px;
    color: var(--secondary-text-color);
    line-height: 1.5;
}

mark {
    background-color: #ffe081;
    color: #000;
    border-radius: 3px;
    padding: 1px 3px;
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 48px;
    height: 48px;
    background-color: var(--text-color);
    color: var(--background-color);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: all;
}

.back-to-top:hover {
    transform: translateY(-4px);
}

/* FOOTER */
.site-footer {
    text-align: center;
    padding: 40px 20px;
    font-size: 12px;
    color: var(--secondary-text-color);
}
.site-footer p {
    font-size: 12px;
}

/*
============================================
RESPONSIVE DESIGN (MOBILE-FIRST)
============================================
*/
.nav-toggle {
    display: none;
}

@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    #table-of-contents {
        position: fixed;
        left: -300px;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        background-color: var(--background-color);
        z-index: 99;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        padding-left: 20px;
    }

    #table-of-contents.mobile-open {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    main {
        width: 100%;
        padding: calc(var(--header-height) + 20px) 20px 50px 20px;
    }

    .header-content {
        padding: 0 20px;
    }

    #search-input {
        font-size: 24px;
    }
}

@media print {
    .site-header,
    .nav-toggle,
    .back-to-top,
    .search-button {
        display: none;
    }

    #table-of-contents {
        display: none;
    }

    main {
        margin-left: 0;
        max-width: 100%;
    }

    .chapter {
        page-break-inside: avoid;
    }

    a {
        color: var(--text-color);
        text-decoration: underline;
    }
}

/*
============================================
CHAPTER QUIZ LINKS - Bidirectional Navigation
============================================
*/
.chapter-quiz-link {
    margin-top: 32px;
    padding: 24px;
    background: var(--code-bg);
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.chapter-quiz-link p {
    margin-bottom: 12px;
    color: var(--text-color);
    font-size: 1rem;
}

.btn-quiz-link {
    display: inline-block;
    padding: 12px 24px;
    background: var(--text-color);
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 2px solid var(--text-color);
}

.btn-quiz-link:hover {
    background: #ffffff;
    color: var(--text-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 29, 31, 0.2);
}

.btn-quiz-link:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .chapter-quiz-link {
        padding: 20px;
    }

    .btn-quiz-link {
        display: block;
        width: 100%;
        padding: 14px 20px;
    }
}
