/* Reading: builds on the shared course components in listening.css */

/* Hero card */
.rd-demo {
    position: relative;
    margin: 0;
    padding: 30px 30px 26px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background:
        repeating-linear-gradient(180deg, transparent 0 39px, color-mix(in srgb, var(--accent) 6%, transparent) 39px 40px),
        linear-gradient(160deg, color-mix(in srgb, #d9772b 8%, var(--surface)), var(--surface) 60%);
    box-shadow: var(--shadow), 0 30px 60px -30px color-mix(in srgb, #d9772b 40%, transparent);
    transform: rotate(1.2deg);
    transition: transform .4s cubic-bezier(.2, .8, .2, 1);
}

.rd-demo:hover { transform: rotate(0); }

.rd-demo-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }

.rd-demo-time { color: var(--muted); font-size: 14px; font-weight: 600; }

.rd-demo h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.2; }

.rd-demo p { margin: 0 0 12px; font-family: var(--serif); font-size: 19px; line-height: 1.7; }

.rd-demo-fade { color: var(--muted); -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); }

.rd-demo-word {
    position: relative;
    padding: 0 3px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-bottom: 2px dotted var(--accent);
}

.rd-demo-pop {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--sans);
    font-size: 14px;
    white-space: nowrap;
    transform: translateX(-50%);
    box-shadow: var(--shadow);
    animation: rd-float 3s ease-in-out infinite;
}

.rd-demo-pop::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    border: 7px solid transparent;
    border-top-color: var(--ink);
    transform: translateX(-50%);
}

.rd-demo-tfng { display: flex; gap: 8px; margin-top: 8px; }

.rd-demo-tfng span {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.rd-demo-tfng .is-picked { border-color: var(--good); background: var(--good-soft); color: var(--good); }

/* Hub cards */
.rd-card-lines {
    position: absolute;
    right: 18px;
    bottom: 54px;
    z-index: -1;
    width: 70px;
    height: 34px;
    background: repeating-linear-gradient(180deg, var(--level) 0 4px, transparent 4px 10px);
    -webkit-mask: linear-gradient(90deg, #000 60%, transparent);
    mask: linear-gradient(90deg, #000 60%, transparent);
    opacity: .18;
}

/* Lesson */
.rd-lesson { position: relative; padding-bottom: 80px; }

.rd-stepper { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.rd-predict {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    padding: 20px 22px;
    border-left: 4px solid var(--tip-line);
    border-radius: 16px;
    background: var(--tip);
}

.rd-predict-icon { font-size: 30px; line-height: 1; }

.rd-predict strong { display: block; margin-bottom: 2px; font-size: 18px; }

.rd-predict p { margin: 0; }

.rd-predict-summary { margin-top: 10px !important; color: var(--muted); font-style: italic; }

.rd-toolbar {
    position: sticky;
    top: calc(var(--header-height) + 84px);
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.rd-size { display: flex; padding: 3px; border-radius: 11px; background: var(--surface-2); }

.rd-size button {
    min-width: 40px;
    padding: 5px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.rd-size button:hover { background: var(--surface); }

.rd-timer {
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--level) 12%, transparent);
    color: var(--level);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.rd-tip { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; }

.rd-text {
    padding: clamp(22px, 4vw, 44px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.rd-para { position: relative; padding-right: 48px; }

.rd-para + .rd-para { margin-top: 1.1em; }

.rd-para-text {
    margin: 0;
    font-family: var(--serif);
    font-size: 21px;
    line-height: 1.85;
    color: var(--ink);
    hyphens: auto;
}

.rd-size-0 .rd-para-text { font-size: 18px; }
.rd-size-1 .rd-para-text { font-size: 21px; }
.rd-size-2 .rd-para-text { font-size: 24px; }
.rd-size-3 .rd-para-text { font-size: 28px; }

.rd-para-uzbek {
    margin: 8px 0 0;
    padding: 10px 14px;
    border-left: 3px solid var(--level);
    border-radius: 0 12px 12px 0;
    background: color-mix(in srgb, var(--level) 7%, var(--surface));
    color: var(--muted);
    font-size: 16px;
    line-height: 1.6;
    animation: rd-rise .25s;
}

.rd-para-tools {
    position: absolute;
    top: 4px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rd-para-tools button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    opacity: .55;
    transition: opacity .15s, color .15s, border-color .15s, background .15s;
}

.rd-para-tools svg { width: 17px; height: 17px; }

.rd-para:hover .rd-para-tools button, .rd-para-tools button:focus-visible { opacity: 1; }

.rd-para-tools button:hover { border-color: var(--level); color: var(--level); }

.rd-para-tools button.is-playing, .rd-para.is-translated [data-rd-para-translate] { opacity: 1; border-color: var(--level); background: var(--level); color: #fff; }

.rd-text .w { border-radius: 4px; cursor: pointer; transition: background .12s; }

.rd-text .w:hover { background: color-mix(in srgb, var(--level) 12%, transparent); }

.rd-key {
    padding: 0 2px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--level) 14%, transparent);
    border-bottom: 2px dotted var(--level);
    color: inherit;
    cursor: pointer;
}

.hide-keys .rd-key { background: transparent; border-bottom-color: transparent; }

.rd-text .is-active { background: var(--level); color: #fff; border-bottom-color: var(--level); }

.rd-popover {
    position: absolute;
    z-index: 30;
    width: min(320px, calc(100% - 8px));
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--ink);
    color: var(--bg);
    box-shadow: 0 20px 50px -10px rgb(0 0 0 / 40%);
    animation: rd-rise .18s;
}

.rd-popover-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.rd-popover strong { font-family: var(--serif); font-size: 22px; font-weight: 600; }

.rd-popover p { margin: 4px 0 8px; font-size: 16px; font-weight: 600; }

.rd-popover p.is-muted { color: color-mix(in srgb, var(--bg) 70%, transparent); font-weight: 400; }

.rd-popover a { color: #7fe0cc; font-size: 14px; font-weight: 600; text-decoration: none; }

.rd-popover a[hidden] { display: none; }

.rd-pop-speak {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: rgb(255 255 255 / 14%);
    color: inherit;
    cursor: pointer;
}

.rd-pop-speak svg { width: 18px; height: 18px; }

.rd-pop-speak.is-playing { background: var(--level); }

/* Questions */
.rd-qtype {
    display: inline-block;
    margin-bottom: 10px;
    padding: 2px 10px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--level) 12%, transparent);
    color: var(--level);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.rd-tfng-head { margin-top: 40px; }

.rd-tfng { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.rd-tfng button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s, transform .15s, background .15s;
}

.rd-tfng button small { color: var(--muted); font-size: 12.5px; font-weight: 600; }

.rd-tfng button:hover:not(:disabled) { border-color: var(--level); transform: translateY(-1px); }

.rd-tfng button:disabled { cursor: default; }

.rd-tfng button.is-right { border-color: var(--good); background: var(--good-soft); color: var(--good); }

.rd-tfng button.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); animation: ls-shake .35s; }

/* Word matching */
.rd-match { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 12px; }

.rd-match-col { display: grid; gap: 8px; align-content: start; }

.rd-match-item {
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s, opacity .3s;
}

.rd-match-item:not(.is-meaning) { font-family: var(--serif); font-size: 19px; }

.rd-match-item.is-meaning { font-size: 15.5px; font-weight: 500; }

.rd-match-item:hover:not(:disabled) { border-color: var(--level); transform: translateY(-1px); }

.rd-match-item.is-selected { border-color: var(--level); background: color-mix(in srgb, var(--level) 12%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--level) 18%, transparent); }

.rd-match-item.is-matched { border-color: var(--good); background: var(--good-soft); color: var(--good); opacity: .75; cursor: default; }

.rd-match-item.is-wrong { border-color: var(--bad); background: var(--bad-soft); animation: ls-shake .35s; }

.rd-speed-note { max-width: 52ch; margin: -10px auto 22px; color: var(--muted); font-size: 15px; text-align: center; }

@keyframes rd-rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes rd-float {
    50% { transform: translateX(-50%) translateY(-4px); }
}

@media (max-width: 900px) {
    .rd-demo { transform: none; }
    .rd-toolbar { top: calc(var(--header-height) + 76px); }
}

@media (max-width: 620px) {
    .rd-demo { padding: 22px 20px; border-radius: 22px; }
    .rd-demo h3 { font-size: 23px; }
    .rd-demo p { font-size: 17px; }
    .rd-toolbar { gap: 8px 14px; padding: 8px 10px; }
    .rd-toolbar .ls-switch { font-size: 13.5px; }
    .rd-text { padding: 18px 16px; border-radius: 18px; }
    .rd-para { padding-right: 40px; }
    .rd-para-tools button { opacity: 1; width: 30px; height: 30px; }
    .rd-size-0 .rd-para-text { font-size: 16.5px; }
    .rd-size-1 .rd-para-text { font-size: 18.5px; }
    .rd-size-2 .rd-para-text { font-size: 21px; }
    .rd-size-3 .rd-para-text { font-size: 24px; }
    .rd-tfng button { padding: 10px 4px; font-size: 14px; }
    .rd-match { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 8px; }
    .rd-match-item { padding: 10px 11px; border-radius: 12px; }
    .rd-match-item:not(.is-meaning) { font-size: 16.5px; }
    .rd-match-item.is-meaning { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .rd-demo-pop, .rd-para-uzbek, .rd-popover { animation: none; }
}
