/* =========================================================
   Design Tokens
   ========================================================= */

:root {
    color-scheme: light;

    --ink: #172033;
    --ink-soft: #344054;
    --muted: #667085;

    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --accent-soft: #eef2ff;

    --bg: #f7f8fc;
    --card: #ffffff;

    --line: #e5e7eb;
    --line-soft: #eef0f4;

    --success-soft: #f0fdf4;

    --radius-lg: 18px;
    --radius-md: 12px;

    --shadow-sm:
        0 2px 8px rgba(16, 24, 40, 0.04);

    --shadow-md:
        0 8px 30px rgba(16, 24, 40, 0.06);
}


/* =========================================================
   Reset
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;

    background: var(--bg);
    color: var(--ink);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 16px;
    line-height: 1.7;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input {
    font: inherit;
}


/* =========================================================
   Main Layout
   ========================================================= */

.wrap {
    width: min(
        calc(100% - 40px),
        860px
    );

    margin: 0 auto;

    padding:
        42px
        0
        80px;
}


/* =========================================================
   Header
   ========================================================= */

header {
    margin-bottom: 28px;
}

.site-name {
    margin-bottom: 8px;

    color: var(--muted);

    font-size: 1rem;
    font-weight: 600;

    letter-spacing: -0.01em;
    text-transform: uppercase;
}

h1 {
    margin: 0;

    color: var(--ink);

    font-size:
        clamp(
            3rem,
            8vw,
            5rem
        );

    line-height: 0.95;

    font-weight: 800;

    letter-spacing: -0.055em;
}

.sub {
    margin-top: 18px;

    color: var(--muted);

    font-size: 1rem;
}


/* =========================================================
   Search Box
   ========================================================= */

.search {
    display: flex;

    gap: 12px;

    margin:
        30px
        0
        34px;
}

.search input {
    flex: 1;

    min-width: 0;

    height: 58px;

    padding:
        0
        18px;

    border:
        1px solid
        var(--line);

    border-radius:
        var(--radius-md);

    background: #fff;

    color: var(--ink);

    font-size: 1.05rem;

    box-shadow: var(--shadow-sm);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.search input::placeholder {
    color: #98a2b3;
}

.search input:hover {
    border-color: #d0d5dd;
}

.search input:focus {
    outline: none;

    border-color:
        var(--accent);

    box-shadow:
        0 0 0 4px
        rgba(79, 70, 229, 0.10);
}

.search button {
    flex: 0 0 auto;

    height: 58px;

    padding:
        0
        24px;

    border: 0;

    border-radius:
        var(--radius-md);

    background:
        var(--accent);

    color: #fff;

    font-size: 1rem;
    font-weight: 700;

    cursor: pointer;

    box-shadow:
        0 4px 12px
        rgba(79, 70, 229, 0.20);

    transition:
        background 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.search button:hover {
    background:
        var(--accent-dark);

    box-shadow:
        0 6px 16px
        rgba(79, 70, 229, 0.25);

    transform:
        translateY(-1px);
}

.search button:active {
    transform:
        translateY(0);
}


/* =========================================================
   Lesson Sections
   ========================================================= */

section {
    margin:
        16px
        0;

    padding:
        24px
        26px;

    background:
        var(--card);

    border:
        1px solid
        var(--line);

    border-radius:
        var(--radius-lg);

    box-shadow:
        var(--shadow-sm);

    transition:
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

section:hover {
    border-color:
        #dfe2e8;

    box-shadow:
        var(--shadow-md);
}


/* Section Heading */

section > h2 {
    display: flex;
    align-items: center;

    margin:
        0
        0
        18px;

    padding-bottom:
        12px;

    border-bottom:
        1px solid
        var(--line-soft);

    color:
        var(--ink);

    font-size:
        1.08rem;

    line-height: 1.35;

    font-weight: 800;

    letter-spacing:
        -0.015em;
}

/* Accent bar before every section heading. */
section > h2::before {
    content: "";

    display: inline-block;

    width: 4px;
    height: 18px;

    margin-right: 10px;

    border-radius: 999px;

    background:
        var(--accent);
}


/* Section Content */

section > div {
    color:
        var(--ink-soft);

    font-size:
        1rem;

    line-height:
        1.85;
}

section p {
    margin:
        0
        0
        12px;
}

section p:last-child {
    margin-bottom: 0;
}

section strong,
section b {
    color:
        var(--ink);

    font-weight:
        700;
}

section em,
section i {
    color:
        var(--ink);

    font-style:
        italic;
}

section code {
    padding:
        2px
        6px;

    border-radius:
        6px;

    background:
        #f2f4f7;

    color:
        #344054;

    font-size:
        0.92em;
}


/* Lists */

section ul,
section ol {
    margin:
        8px
        0
        0;

    padding-left:
        26px;
}

section li {
    margin-bottom:
        12px;

    padding-left:
        3px;
}

section li:last-child {
    margin-bottom:
        0;
}

section ul li::marker {
    color:
        var(--accent);

    font-size:
        0.9em;
}

section ol {
    counter-reset:
        example;
}

section ol li::marker {
    color:
        var(--accent);

    font-weight:
        700;
}


/* Example Translation */

section span {
    color:
        var(--muted);
}

/* English sentence should stand out from the Chinese translation. */
section ol li span {
    margin-left:
        6px;

    font-size:
        0.95em;
}


/* =========================================================
   Error
   ========================================================= */

.error {
    padding:
        16px
        18px;

    border:
        1px solid
        #fecdd3;

    border-radius:
        var(--radius-md);

    background:
        #fff1f2;

    color:
        #9f1239;

    font-size:
        0.95rem;
}


.correction {
    padding:
        16px
        18px;

    border:
        1px solid
        #fecaca;

    border-radius:
        var(--radius-md);

    background:
        #fff1f2;

    color:
        #b91c1c;

    font-size:
        1.05rem;

    font-weight:
        600;

    margin-bottom:
        20px;
}

.correction strong {
    color:
        #991b1b;

    text-decoration:
        underline;
}


/* =========================================================
   Cache Metadata
   ========================================================= */

.meta {
    margin-top:
        24px;

    color:
        var(--muted);

    font-size:
        0.72rem;

    letter-spacing:
        0.01em;
}

.meta .dot {
    margin:
        0
        6px;
}


/* =========================================================
   Empty / Word Lookup
   ========================================================= */

.word-placeholder {
    color:
        var(--muted);
}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 640px) {

    .wrap {
        width:
            calc(100% - 28px);

        padding:
            26px
            0
            50px;
    }

    h1 {
        font-size:
            clamp(
                2.8rem,
                15vw,
                4rem
            );
    }

    .search {
        gap: 8px;

        margin:
            24px
            0
            24px;
    }

    .search input {
        height: 52px;

        padding:
            0
            14px;

        font-size:
            1rem;
    }

    .search button {
        height: 52px;

        padding:
            0
            16px;
    }

    section {
        margin:
            12px
            0;

        padding:
            20px 18px;

        border-radius:
            15px;
    }

    section > h2 {
        margin-bottom:
            15px;

        font-size:
            1rem;
    }

    section > div {
        font-size:
            0.98rem;

        line-height:
            1.8;
    }

}


/* =========================================================
   Small Mobile
   ========================================================= */

@media (max-width: 420px) {

    .search {
        flex-direction:
            column;
    }

    .search input,
    .search button {
        width:
            100%;
    }

    .search button {
        height:
            50px;
    }

}
