/* ==========================================================================
   AsciiDoc Koans - Workshop Styles
   Responsive Flexbox Layout
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    scroll-behavior: smooth;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #2c3e50;
    background: #fafafa;
}

/* --- Layout: Sidebar + Content --- */
.layout {
    display: flex;
    min-height: 100vh;
}

#nav {
    width: 240px;
    flex-shrink: 0;
    padding: 20px;
    background: #f0f4f8;
    border-right: 1px solid #d0d7de;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#nav h2 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}

#nav > span {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.lang-switch {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 12px;
}

.lang-switch a {
    padding: 3px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: #666;
    border: 1px solid #d0d7de;
    transition: all 0.2s;
}

.lang-switch a:hover {
    border-color: #999;
    color: #333;
}

.lang-switch a.active {
    background: #1976d2;
    color: #fff;
    border-color: #1976d2;
}

#content {
    flex: 1;
    min-width: 0;
    padding: 24px 32px 60px;
    max-width: 900px;
}

/* --- Progress Bar --- */
.progress-bar {
    background: #d0d7de;
    border-radius: 10px;
    height: 22px;
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    background: #4caf50;
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.progress-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #333;
}

/* --- Score Table --- */
table#score {
    font-size: 12px;
    margin-top: 8px;
}

table#score tr td {
    padding: 2px 6px;
}

/* --- Exercise Boxes --- */
div.target {
    border: none;
    border-left: 3px solid #b0bec5;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #f5f7fa;
    position: relative;
}

div.target:before {
    content: 'target';
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #90a4ae;
    margin-bottom: 8px;
}

div.rendered {
    border: none;
    border-left: 3px solid #e57373;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #fef5f5;
    position: relative;
    transition: border-color 0.3s ease, background 0.3s ease;
}

div.rendered:before {
    content: 'your result';
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #e57373;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

div.rendered.correct {
    border-left-color: #4caf50;
    background: #f0faf0;
}

div.rendered.correct:before {
    content: 'correct ✓';
    color: #4caf50;
}

/* Hide empty hints */
.hint:empty {
    display: none;
}

/* --- Hint / Instructions --- */
.hint {
    margin-bottom: 12px;
    padding: 12px 16px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    font-size: 0.9em;
    color: #5d4037;
}

/* --- Description --- */
.description {
    margin-bottom: 16px;
    line-height: 1.7;
}

.description h3, .description h2 {
    margin-top: 0;
}

/* --- Input Label --- */
.input-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1976d2;
    margin-bottom: 4px;
}

/* --- Textarea Input --- */
.input {
    width: 100%;
    min-height: 8em;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    padding: 12px 16px;
    border: 2px solid #1976d2;
    border-radius: 8px;
    background: #e3f2fd;
    color: #2c3e50;
    display: block;
    overflow: hidden;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}

.input:focus {
    outline: none;
    border-color: #1565c0;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
}

/* --- Next Button --- */
button#next {
    background: #1976d2;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 28px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button#next:hover {
    background: #1565c0;
}

/* --- Separator --- */
hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 32px 0;
}

/* --- Doc Links --- */
.docs {
    text-decoration: none;
}

/* --- Diff Highlights --- */
ins {
    text-decoration: none;
    background-color: #d4fcbc;
    display: inline-block;
    min-width: 1em;
    min-height: 1em;
}

del {
    text-decoration: line-through;
    background-color: #fbb6c2;
    color: #555;
    display: inline-block;
    min-width: 1em;
    min-height: 1em;
}

ins.mod {
    background-color: #fafaa9;
    display: inline-block;
    min-width: 1em;
    min-height: 1em;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

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

    #nav {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 200;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid #d0d7de;
        background: #f0f4f8;
    }

    #nav h2 {
        margin: 0;
        font-size: 16px;
        flex: 1;
    }

    #nav > span, #nav #score {
        display: none;
    }

    .progress-bar {
        margin: 0;
        flex: 1;
        min-width: 100px;
        height: 18px;
    }

    #content {
        padding: 16px;
    }

    .input {
        font-size: 16px; /* prevents iOS zoom on focus */
        min-height: 6em;
    }

    div.target, div.rendered {
        padding: 12px;
    }

    button#next {
        width: 100%;
        padding: 14px;
    }
}

@media (max-width: 480px) {
    #content {
        padding: 12px 8px;
    }

    .hint {
        font-size: 0.85em;
        padding: 8px 12px;
    }
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    body {
        background: #1e1e2e;
        color: #cdd6f4;
    }

    #nav {
        background: #181825;
        border-right-color: #313244;
        border-bottom-color: #313244;
    }

    #nav h2 { color: #cdd6f4; }
    #nav > span { color: #a6adc8; }

    #content {
        background: #1e1e2e;
    }

    div.target {
        border-left-color: #45475a;
        background: #181825;
    }

    div.target:before {
        color: #6c7086;
    }

    div.rendered {
        border-left-color: #f38ba8;
        background: #1e1525;
    }

    div.rendered:before {
        color: #f38ba8;
    }

    div.rendered.correct {
        border-left-color: #a6e3a1;
        background: #1a2520;
    }

    div.rendered.correct:before {
        color: #a6e3a1;
    }

    .input-label {
        color: #89b4fa;
    }

    .input {
        background: #1a1a3e;
        color: #cdd6f4;
        border-color: #89b4fa;
    }

    .input:focus {
        border-color: #b4d0fb;
        background: #11111b;
        box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.2);
    }

    .hint {
        background: #2a2a3e;
        border-color: #45475a;
        color: #cdd6f4;
    }

    .progress-bar {
        background: #313244;
    }

    .progress-fill {
        background: #a6e3a1;
    }

    .progress-label {
        color: #cdd6f4;
    }

    hr {
        border-top-color: #313244;
    }

    a { color: #89b4fa; }

    button#next {
        background: #89b4fa;
        color: #1e1e2e;
    }

    button#next:hover {
        background: #74c7ec;
    }

    #score, table#score { color: #a6adc8; }

    .description { color: #cdd6f4; }
}
