/* ===== Learning path + lesson preview (js/path.js) ===== */

/* --- header --- */
.path-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.path-head-text {
    min-width: 0;
}
.mode-card .path-head h3 {
    text-align: left;
    margin: 0 0 4px;
}
.path-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.back-btn.path-free-btn {
    flex: none;
    padding: 8px 14px;
    font-size: 0.85rem;
}
.path-bar {
    height: 10px;
    margin: 14px 0 6px;
    border-radius: 999px;
    background: var(--track);
    overflow: hidden;
}
.path-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: inherit;
    transition: width 0.4s ease;
}

.path-source {
    margin: 4px 2px 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted);
}
.path-source:empty {
    display: none;
}

/* --- units --- */
.path-units {
    margin-top: 14px;
}
.path-unit {
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 10px;
    background: var(--surface);
}
html[data-theme="dark"] .path-unit {
    background: var(--bg-card);
}
.path-unit-head {
    list-style: none;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
}
.path-unit-head::-webkit-details-marker {
    display: none;
}
.path-unit-head::before {
    content: '▸';
    color: var(--text-muted);
    transition: transform 0.15s ease;
}
.path-unit[open] > .path-unit-head::before {
    transform: rotate(90deg);
}
.path-unit-name {
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--text);
}
.path-unit-range {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.path-unit-state {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--accent-green);
}
.path-unit.locked .path-unit-name {
    color: var(--text-muted);
}

/* phones: the units as collapsible sections; desktop: .path-wide */
.path-wide {
    display: none;
}
@media (min-width: 1024px) {
    .path-accordion {
        display: none;
    }
    .path-wide {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 18px;
        align-items: start;
    }
    .path-stage {
        margin-bottom: 0;
    }
    /* a short set (the 40-word topics) has a single unit: no list beside it */
    .path-wide.path-one-unit {
        grid-template-columns: minmax(0, 1fr);
    }
    .path-one-unit .path-unit-list {
        display: none;
    }
    .path-stage > .path-unit-head {
        cursor: default;
        border-bottom: 1px dashed var(--line);
    }
    .path-stage > .path-unit-head::before {
        content: none;
    }
    /* a unit's levels in rows of five instead of one long zigzag column, and a level's words
       in two columns, so both fit one 1080p screen (big check, 2026-10-24) */
    .path-stage .path-nodes {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        justify-items: center;
        row-gap: 30px;
        padding-top: 22px;
    }
    .path-stage .path-node-wrap { transform: none; }
    .lesson-card .lesson-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
    /* the unit list scrolls in its own box, ending above the buttons under the path */
    .path-wide .path-unit-list { max-height: max(260px, calc(100vh - 470px)); }
    .path-unit-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
        position: sticky;
        top: 16px;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
        padding: 2px 4px 6px 2px;
    }
    .path-unit-btn {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 10px;
        width: 100%;
        padding: 11px 14px;
        text-align: left;
        border: 2px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: 0 3px 0 var(--edge);
        color: var(--text);
        font: inherit;
        cursor: pointer;
        transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.2s;
    }
    html[data-theme="dark"] .path-unit-btn {
        background: var(--bg-card);
    }
    .path-unit-btn:hover {
        border-color: var(--primary);
    }
    .path-unit-btn:active {
        transform: translateY(3px);
        box-shadow: none;
    }
    .path-unit-btn.selected {
        border-color: var(--primary);
        background: var(--primary-soft);
        box-shadow: 0 3px 0 var(--primary-edge);
    }
    .path-unit-btn.locked .path-unit-name {
        color: var(--text-muted);
    }
    .path-unit-btn .path-unit-state {
        margin-left: auto;
    }
    .path-unit-count {
        flex-basis: 100%;
        font-size: 0.78rem;
        color: var(--text-muted);
    }
}

/* --- nodes (zigzag, chunky like the buttons) --- */
.path-nodes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 8px 0 18px;
}
.path-node-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(var(--x, 0));
}
.path-node {
    width: 62px;
    height: 58px;
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    -webkit-tap-highlight-color: transparent;
}
.path-node.done {
    background: var(--ink);
    color: var(--paper);
    box-shadow: 0 5px 0 #000;
}
html[data-theme="dark"] .path-node.done {
    box-shadow: 0 5px 0 #a99d86;
}
.path-node.current {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 5px 0 var(--primary-edge), 0 0 0 7px var(--primary-soft);
}
.path-node.locked {
    background: var(--track);
    color: var(--text-muted);
    box-shadow: 0 5px 0 var(--edge);
    font-size: 1.1rem;
}
.path-node:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 transparent;
}
.path-node.current:active {
    box-shadow: 0 0 0 7px var(--primary-soft);
}
.path-node-label {
    margin-top: 9px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.path-start {
    position: absolute;
    left: calc(100% + 10px);
    top: 16px;
    padding: 3px 10px;
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
    animation: path-start-bob 1.6s ease-in-out infinite;
}
@keyframes path-start-bob {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(3px); }
}
.path-chest {
    font-size: 1.8rem;
    filter: grayscale(1);
    opacity: 0.55;
}
.path-chest.open {
    filter: none;
    opacity: 1;
}

/* --- lesson preview --- */
.lesson-hint {
    text-align: center;
    margin: -8px 0 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
/* Japanese / Korean: the 羅馬拼音 switch and, on a first level, the way to the alphabet */
.lesson-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; margin: -4px 0 14px; font-size: 0.85rem; color: var(--text-secondary); }
.lesson-tools[hidden] { display: none; }
.lesson-card .mode-btn.lesson-romaji { flex: none; width: auto; min-width: 0; margin: 0; padding: 5px 14px; font-size: 0.85rem; }
.lesson-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.lesson-word {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}
html[data-theme="dark"] .lesson-word {
    background: var(--bg-card);
}
.lesson-word-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.lesson-word-text {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}
.lesson-word-reading {
    font-size: 0.8rem;
    color: var(--text-pink);
}
.lesson-word-meaning {
    font-size: 0.92rem;
    color: var(--text-secondary);
    word-break: break-word;
}
.speak-btn.lesson-speak,
.speak-btn.lesson-note {
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

/* --- lesson result banner (above the score) --- */
.lesson-result {
    margin: 0 auto 14px;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 800;
    text-align: center;
}
.lesson-result.pass {
    background: var(--success-bg);
    color: var(--success-text);
    border: 2px solid var(--success);
}
.lesson-result.fail {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 2px solid var(--danger);
}

@media (max-width: 560px) {
    .lesson-word {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }
    .lesson-word-meaning {
        grid-column: 1;
        grid-row: 2;
    }
    .speak-btn.lesson-speak {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
    .speak-btn.lesson-note {
        grid-column: 3;
        grid-row: 1 / span 2;
    }
    /* the zigzag is narrower on phones so the "開始！" tag still fits */
    .path-node-wrap {
        transform: translateX(calc(var(--x, 0) * 0.6));
    }
}

@media (prefers-reduced-motion: reduce) {
    .path-start { animation: none; }
}
