/* ────────────────────────────────────────────────────────────────
   TOOL — YouTube Lesson Generator

   Built on the site's own tokens (tools.css :root), so the lab reads
   as part of the catalogue rather than a bolted-on app. The old
   standalone plugin shipped a slate-and-blue Tailwind-ish palette
   inline in the shortcode, which looked like a different website.

   ⚠️ Every button here names its own background. The site's base
   .at-btn sets geometry and type but no fill — a bare .at-btn is
   painted by Astra's own button rule, which is theme blue on an
   indigo site. Variants (--primary, --ghost, --tiny) bring their own.

   3.0.0  2026-08-17  Rebuilt for the platform.
   ──────────────────────────────────────────────────────────────── */

.il {
    font-family: var(--at-font);
    color: var(--at-ink);
}

/* ── the panel's own width ──────────────────────────────────────
   The standard tool panel is 860px, which suits a form with one
   textarea in it. This tool is a video with a transcript beside it,
   and at 860px the pair sit in a narrow column under a much wider
   header — the page reads as though the content slipped off centre.
   1180px is not an arbitrary widening: it is exactly the width of
   .at-page__inner, the column the header, the breadcrumbs and the
   related-tools grid all already use, so the lab lines up with them
   rather than introducing a fourth width. Not `layout: app`, which
   removes the max-width entirely and would overshoot the header.  */
.at-tool[data-at-panel="youtube-lesson-generator"] { max-width: 1180px; }

/* ── video and transcript, side by side where there is room ──── */
.il-lab { display: grid; gap: 18px; }

@media (min-width: 1000px) {
    .il-lab {
        grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
        align-items: start;
    }
    .il-lab .il-stage  { margin-bottom: 0; }
    /* Roughly the height of the video beside it, so the two columns
       finish together instead of leaving a ragged edge. */
    .il-lab .il-script { max-height: min(68vh, 620px); }
}

.il-notice { margin-bottom: 18px; }

.il-boot {
    display: grid;
    place-items: center;
    min-height: 220px;
}

/* ── bars ───────────────────────────────────────────────────── */

.il-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--at-line);
}
.il-bar__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--at-ink-deep);
}
.il-bar__acts { display: flex; flex-wrap: wrap; gap: 8px; }

.il-pill {
    display: inline-block;
    margin-inline-start: 8px;
    padding: 3px 10px;
    border-radius: var(--at-radius-pill);
    background: var(--at-primary-tint);
    color: var(--at-primary-deep);
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
}

/* ── the shelf ──────────────────────────────────────────────── */

.il-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.il-card {
    display: flex;
    flex-direction: column;
    background: var(--at-surface);
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius);
    box-shadow: var(--at-shadow-xs);
    overflow: hidden;
    transition: transform .18s var(--at-ease), box-shadow .18s var(--at-ease);
}
.il-card:hover { transform: translateY(-2px); box-shadow: var(--at-shadow-md); }
.il-card.is-shared { border-color: var(--at-primary-soft); }

.il-card__thumb {
    aspect-ratio: 16 / 9;
    background: var(--at-lilac) center / cover no-repeat;
}
.il-card__body { padding: 14px 16px 4px; flex: 1; }
.il-card__title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: var(--at-ink-deep);
    line-height: 1.35;
}
.il-card__meta { margin: 0; font-size: 13px; color: var(--at-ink-soft); }
.il-card__acts { display: flex; gap: 8px; padding: 12px 16px 16px; }

.il-empty {
    padding: 34px;
    text-align: center;
    background: var(--at-lilac);
    border-radius: var(--at-radius);
    color: var(--at-ink-soft);
}
.il-empty p { margin: 0 0 8px; }
.il-empty p:last-child { margin: 0; max-width: 52ch; margin-inline: auto; }

/* ── the stage ──────────────────────────────────────────────── */

.il-stage { margin-bottom: 18px; }
.il-video {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--at-radius);
    overflow: hidden;
    box-shadow: var(--at-shadow-md);
}
.il-video iframe,
.il-video > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ── the transcript ─────────────────────────────────────────── */

.il-script {
    /* Not decoration: this is the scroll container the active line is
       kept inside, and a static container hands `offsetTop` to whatever
       Astra wrapper happens to be positioned instead — which sends the
       auto-scroll to a page coordinate rather than a line. */
    position: relative;
    max-height: 320px;
    overflow-y: auto;
    padding: 12px;
    background: var(--at-surface);
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius);
    font-family: var(--at-font-ar);
    font-size: 19px;
    line-height: 2.1;
    /* Deliberately NOT `scroll-behavior: smooth`. In scrollTo(),
       `behavior: 'auto'` does not mean "jump" — it means "whatever the
       CSS says", so declaring smooth here quietly turns every instant
       scroll back into an animated one, including the long jump after
       a seek. tool.js asks for 'smooth' by name when it wants easing. */
}
/* Listening-only mode: the text is still there for the screen reader
   and for the click targets, just not for the eye. */
.il-script.is-hidden .il-line__text,
.il-script.is-hidden .il-line__en { filter: blur(6px); user-select: none; }

.il-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    padding: 6px 10px;
    border-radius: var(--at-radius-sm);
    border: 1px solid transparent;
    transition: background .2s var(--at-ease);
}
.il-line:hover { background: var(--at-paper); }
.il-line.is-now {
    background: var(--at-primary-tint);
    border-color: var(--at-primary-soft);
}
.il-line__text { flex: 1; }
.il-line__en {
    flex-basis: 100%;
    font-family: var(--at-font);
    font-size: 13px;
    color: var(--at-ink-soft);
    text-align: start;
}

.il-line__t {
    flex: none;
    padding: 2px 8px;
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius-pill);
    background: var(--at-surface);
    color: var(--at-ink-soft);
    font: 600 12px/1.6 var(--at-font);
    cursor: pointer;
}
.il-line__t:hover { background: var(--at-primary); color: #fff; border-color: transparent; }

.il-line__acts { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.il-line:hover .il-line__acts,
.il-line.is-now .il-line__acts { opacity: 1; }

.il-mini {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--at-line);
    border-radius: 50%;
    background: var(--at-surface);
    color: var(--at-ink-soft);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}
.il-mini:hover  { background: var(--at-primary); color: #fff; border-color: transparent; }
.il-mini.is-on  { background: var(--at-accent); color: #fff; border-color: transparent; }

.il-word {
    padding: 1px 3px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
}
.il-word:hover   { background: var(--at-accent-tint); }
.il-word.is-sel  { background: var(--at-accent); color: #fff; }
.il-word.is-kept { box-shadow: inset 0 -2px 0 var(--at-primary-soft); }

.il-hint { font-size: 13px; color: var(--at-ink-soft); margin: 8px 0 0; }

/* ── panels ─────────────────────────────────────────────────── */

.il-panel {
    margin-top: 18px;
    padding: 20px;
    background: var(--at-lilac);
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius);
}
.il-panel h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--at-ink-deep);
}
.il-panel__head { margin-bottom: 12px; }
.il-panel__head .il-hint { margin-top: 2px; }

.il-sel {
    margin-bottom: 12px;
    padding: 12px 16px;
    background: var(--at-surface);
    border: 1px dashed var(--at-line-strong);
    border-radius: var(--at-radius-sm);
    font-family: var(--at-font-ar);
    font-size: 20px;
    text-align: center;
    color: var(--at-ink-deep);
}

.il-btns { display: flex; flex-wrap: wrap; gap: 8px; }
/* The fill the base class deliberately leaves off. */
.il-btns .at-btn {
    background: var(--at-surface);
    color: var(--at-ink);
    border-color: var(--at-line-strong);
}
.il-btns .at-btn:hover:not([disabled]) { background: var(--at-paper); }
.il-btns .at-btn--primary { background: var(--at-primary) !important; color: #fff; }
.il-btns .at-btn--ghost   { background: var(--at-surface) !important; }

.il-status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--at-radius-sm);
    background: var(--at-surface);
    border: 1px solid var(--at-line);
    font-size: 14px;
    color: var(--at-ink-soft);
    min-height: 20px;
}
.il-status.is-busy  { border-color: var(--at-primary-soft); color: var(--at-primary-deep); }
.il-status.is-ok    { border-color: var(--at-green); color: #3C7A5D; }
.il-status.is-error { border-color: var(--at-danger); color: var(--at-danger); }
.il-status.is-rec   { border-color: var(--at-rose); color: var(--at-rose); font-weight: 600; }

.il-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--at-line);
    font-size: 14px;
    color: var(--at-ink-soft);
}
.il-opts label { display: inline-flex; align-items: center; gap: 8px; }
.il-opts select {
    padding: 6px 10px;
    border: 1px solid var(--at-line-strong);
    border-radius: var(--at-radius-sm);
    background: var(--at-surface);
    font: inherit;
    color: var(--at-ink);
}
.il-check { cursor: pointer; }

/* ── saved words ────────────────────────────────────────────── */

.il-vocab { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--at-line); }
.il-vocab h4 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.il-vocab h4 .il-hint { margin: 0; font-weight: 400; }
.il-vocab__list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.il-vocab__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 14px;
    background: var(--at-surface);
    border: 1px solid var(--at-line-strong);
    border-radius: var(--at-radius-pill);
    font-family: var(--at-font-ar);
    font-size: 17px;
}
.il-vocab__empty { color: var(--at-ink-muted); font-size: 14px; }

/* ── matching ───────────────────────────────────────────────── */

.il-match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.il-match__col { display: flex; flex-direction: column; gap: 8px; }
.il-tile {
    padding: 12px 14px;
    background: var(--at-surface);
    border: 2px solid var(--at-line);
    border-radius: var(--at-radius-sm);
    font: 500 16px/1.5 var(--at-font);
    color: var(--at-ink-deep);
    cursor: pointer;
    transition: border-color .15s, background .15s, opacity .2s;
}
.il-match__col[dir="rtl"] .il-tile { font-family: var(--at-font-ar); font-size: 18px; }
.il-tile:hover    { border-color: var(--at-primary-soft); }
.il-tile.is-on    { border-color: var(--at-primary); background: var(--at-primary-tint); }
.il-tile.is-done  { border-color: var(--at-green); background: #EEF7F2; opacity: .55; cursor: default; }
.il-tile.is-wrong { border-color: var(--at-danger); background: #FCEFEF; animation: il-shake .4s; }

@keyframes il-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
}

/* ── questions ──────────────────────────────────────────────── */

.il-q {
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--at-surface);
    border: 1px solid var(--at-line);
    border-radius: var(--at-radius-sm);
}
.il-q__q { margin: 0 0 10px; font-size: 17px; font-weight: 600; color: var(--at-ink-deep); font-family: var(--at-font-ar); }
.il-q__row { margin-bottom: 10px; }
.il-q__a {
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--at-line-strong);
    color: #3C7A5D;
}

/* ── editor ─────────────────────────────────────────────────── */

.il-form { display: grid; gap: 16px; }
.il-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.il-form textarea { font-family: var(--at-font-ar); line-height: 1.9; }
.il-form__acts { display: flex; flex-wrap: wrap; gap: 10px; }
.il-form__acts .at-btn {
    background: var(--at-surface);
    color: var(--at-ink);
    border-color: var(--at-line-strong);
}
.il-form__acts .at-btn--primary { background: var(--at-primary) !important; color: #fff; }

/* ── narrow screens ─────────────────────────────────────────── */

@media (max-width: 640px) {
    .il-match,
    .il-form__row { grid-template-columns: 1fr; }
    .il-script { font-size: 17px; max-height: 260px; }
    .il-line__acts { opacity: 1; }
    .il-btns .at-btn { flex: 1 1 auto; justify-content: center; }
}
