/* =====================================================================
   EXERCISES: practice section, read-aloud lists, multiple choice, gap-fill dropdowns, web ticks and crosses.
   ===================================================================== */

/* ---- Practice ---- */
.practice-title {
    margin-block: 32px 16px;
    padding: 0;
    color: #8c92ac;                    /* charcoal */
    font-size: clamp(1.5rem, 3.4vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.read-aloud { list-style: none; padding: 0; counter-reset: n; }

.read-aloud li {
    counter-increment: n;
    display: flex; align-items: center; gap: 10px;
    padding-block: 5px;
    font-size: 1.02rem;
}

.read-aloud li::before { content: counter(n) "."; font-weight: 700; min-width: 1.5em; }

.read-aloud li span { flex: 1; }

.read-aloud .say { margin-right: 0; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px 16px; }

.choice {
    padding: 10px 12px;
    background: rgb(255 255 255 / .65); border-radius: 8px;
    transition: box-shadow .2s ease;
}

.choice__word { margin-bottom: 4px; font-weight: 700; font-size: 1.05rem; }

.choice label { display: flex; align-items: center; gap: 8px; padding-block: 3px; cursor: pointer; }

.choice input { accent-color: var(--accent); margin: 0; width: 1.05em; height: 1.05em; }

.choice.is-right { box-shadow: inset 0 0 0 2px var(--right); }

.choice.is-wrong { box-shadow: inset 0 0 0 2px var(--wrong); }

.check {
    margin-top: 14px; padding: 9px 20px;
    border: 0; border-radius: 99px;
    background: var(--accent); color: #fff;
    font: inherit; font-weight: 700; cursor: pointer;
}

.check:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.score { margin-left: 12px; font-weight: 700; }

.spot-words { font-size: clamp(1rem, 2.4vw, 1.15rem); font-weight: 700; margin-block: 4px 12px; }

.tips ul { padding-left: 20px; }

.tips li + li { margin-top: 4px; }

.answers { margin-top: 8px; font-size: .85rem; color: var(--muted); }

.answers summary { cursor: pointer; font-weight: 700; color: var(--ink); }

.answers b { color: var(--coral); }

/* ======================= END PHONE MENU ROW + SEARCH ======================= */
/* =====================================================================
   GAP-FILL EXERCISES  (dropdowns in sentences + web ticks / crosses)
   Markup: <ol class="gapfill"> <li> text <select class="dropdown" data-answer="n"> …
           <span class="resultImage"></span></li>
   ===================================================================== */
.gapfill {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: q;
}

.gapfill li {
    counter-increment: q;
    position: relative;
    padding: 10px 16px 10px 3.2em;
    line-height: 2.9;                    /* room between wrapped lines for the 38 px boxes */
    font-size: 1rem;
}

.gapfill li + li { border-top: 1.5px solid #fff; }

.gapfill li:nth-child(even) { background: rgb(255 255 255 / .45); }

.gapfill li::before {
    content: counter(q) ".";
    position: absolute;
    left: 16px;
    font-weight: 700;
    color: var(--accent);
}

/* the dropdowns: rounded pills in the sentence */
.gapfill select {
    -webkit-appearance: none;
    appearance: none;
    margin: 0 6px;
    padding: 6px 32px 6px 14px;          /* a little taller (was 3px) */
    border: 2px solid var(--accent);
    border-radius: 99px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6072' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
    vertical-align: middle;
    transition: box-shadow .15s ease;
}

.gapfill select:hover { box-shadow: 0 0 0 3px rgb(0 0 0 / .06); }

.gapfill select:focus, .gapfill select:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgb(46 134 171 / .18); }   /* single soft highlight when clicked */

.gapfill select:invalid,
.gapfill select.is-empty { color: var(--muted); }   /* "?" in grey; stays bold so the dropdown never changes width */

/* ---- Web ticks and crosses (no image files) ---- */
.mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    margin-left: 8px;
    border-radius: 50%;
    vertical-align: middle;
}

.mark:not(.is-right):not(.is-wrong) { visibility: hidden; }   /* invisible until answered, but its space is kept so the sentence doesn't move */

.mark.is-right { background: var(--right); }

.mark.is-wrong { background: var(--wrong); }

.mark::after {
    content: "";
    width: 14px;
    height: 14px;
    background: #fff;
    -webkit-mask: var(--icon) center / contain no-repeat;
            mask: var(--icon) center / contain no-repeat;
}

.mark.is-right { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E"); }

.mark.is-wrong { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }

.mark.pop { animation: mark-pop .4s ease forwards; }

@keyframes mark-pop {
    0%   { transform: scale(0);   opacity: 0; }
    50%  { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}

@media (max-width: 640px) {
    .gapfill li { padding-left: 2.6em; padding-right: 12px; line-height: 3.1; }   /* room between wrapped lines for the 38 px boxes */
    .gapfill li::before { left: 12px; }
}

@media print {
    .gapfill select { background-image: none; padding-right: 14px; }
}

/* =====================================================================
   TYPED ANSWERS  (text boxes in sentences, same look as the dropdowns)
   Markup: <li> If it <input type="text" class="textbox" data-answer="rains" placeholder="?"> (rain) …
           <span class="resultImage"></span></li>
   Several right answers: data-answer="don't leave | do not leave"
   ===================================================================== */
.gapfill input.textbox {
    width: 8ch;                          /* the script sets each box to fit its longest answer */
    min-width: 6ch;
    max-width: calc(100% - 40px);        /* room for its padding and border, so it never spills past the line */
    margin: 0 6px;
    padding: 6px 12px;                   /* a little taller (was 3px) */
    border: 2px solid var(--accent);
    border-radius: 99px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    vertical-align: middle;
    box-sizing: content-box;
    transition: box-shadow .15s ease;
}
.gapfill input.textbox::placeholder { color: var(--muted); opacity: 1; }
.gapfill input.textbox:hover { box-shadow: 0 0 0 3px rgb(0 0 0 / .06); }
.gapfill input.textbox:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgb(46 134 171 / .18); }
@media print {
    .gapfill input.textbox { border-width: 0 0 1.5px; border-radius: 0; }
}
/* Lift the dropdowns and text boxes very slightly, so they sit centred on the
   capital letters of the sentence ("vertical-align: middle" alone centres them
   on the small letters, which looks a touch low). */
.gapfill select,
.gapfill input.textbox { position: relative; top: -.1em; }
.gapfill.rewrite input.textbox { top: 0; }      /* rewrite boxes sit on their own line */
/* The tick/cross at the end of a sentence never drops onto a line of its own:
   it hangs into the row's right-hand padding instead of taking up line space. */
.gapfill:not(.order):not(.rewrite) > li { padding-right: 48px; }
.gapfill:not(.order):not(.rewrite) > li > .mark { margin-right: -34px; }
@media (max-width: 640px) {
    .gapfill:not(.order):not(.rewrite) > li { padding-right: 42px; }
}
/* ======================= END TYPED ANSWERS ======================= */

/* =====================================================================
   REWRITE EXERCISES  (a sentence to change, then a long answer box under it)
   Markup: <ol class="gapfill rewrite">
             <li><span class="cue">I wash my car every week. <span class="cue-word">have</span></span>
                 <span class="answer-line"><input type="text" class="textbox" data-answer="…">.<span class="resultImage"></span></span></li>
   All the boxes on the page are the same width: just wide enough for the
   longest accepted answer (set by exercises.js). On phones they fit the screen.
   ===================================================================== */
.gapfill.rewrite li { padding-top: 10px; padding-bottom: 14px; line-height: 2.5; }   /* tall enough for the word box; number and sentence share it */
.gapfill.rewrite .cue { display: block; }
.gapfill.rewrite .cue-word {            /* the word to use: same height as the answer boxes */
    display: inline-block;
    margin-left: 4px;
    padding: 6px 14px;
    border: 2px solid var(--accent);
    border-radius: 99px;
    background: #fff;
    color: var(--accent);
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    vertical-align: middle;
    position: relative;
    top: -.1em;                          /* centred on the capital letters, like the boxes */
}
.gapfill.rewrite .answer-line { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.gapfill.rewrite input.textbox {
    flex: 0 1 auto;
    max-width: 100%;
    min-width: 0;
    margin: 0 6px 0 0;
    padding-left: 10px;
    padding-right: 10px;
    text-align: left;
    font-weight: 400;                    /* long sentences are easier to read in normal type */
}
.gapfill.rewrite input.textbox::placeholder { font-weight: 400; }
.gapfill.rewrite .answer-line .mark { flex: none; }
@media (max-width: 640px) {
    .gapfill.rewrite .answer-line { margin-left: -6px; }
    .gapfill.rewrite input.textbox { font-size: .9rem; padding-left: 6px; padding-right: 6px; }
}
/* ======================= END REWRITE EXERCISES ======================= */

/* ===== Exercise numbers: a fixed column, numbers lined up on the right (9. / 10.),
   then a clear gap before the sentence. Same on the page and in the saved PDF. ===== */
.gapfill li { padding-left: calc(10px + 2em + .7em); }
.gapfill li::before {
    left: 10px;
    width: 2em;                          /* room for "99." */
    text-align: right;
    font-variant-numeric: tabular-nums;  /* every digit the same width */
}
@media (max-width: 640px) {
    .gapfill li { padding-left: calc(6px + 2em + .55em); }
    .gapfill li::before { left: 6px; }
}
/* the saved PDF writes its own numbers (.pdf-num): line them up the same way */
.pdf-sheet ol.gapfill > li { padding-left: calc(8px + 2em + .6em) !important; }
.pdf-sheet ol.gapfill .pdf-num { left: 8px; width: 2em; text-align: right; font-variant-numeric: tabular-nums; }

/* Ticks and crosses in the sentences: lift them a little so they look centred on the line
   (vertical-align: middle lines them up with the lowercase letters, which sits slightly low) */
.gapfill > li > .mark { position: relative; top: -1.5px; }
@media (max-width: 600px) { .gapfill > li > .mark { top: -0.5px; } }

/* The + / − / ? sign after each sentence (positive, negative, question), on every page:
   a light grey circle with a white sign, lined up with the sentence and the tick or cross */
.gapfill .form-tag, .lesson .form-tag {
    display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; margin-left: 6px;
    border: 0; border-radius: 50%; background: #9AA0A8; color: #fff;
    font-weight: 800; font-size: .9rem; line-height: 1;
    /* lined up exactly like the tick and cross (same vertical-align and the same lift),
       so the two always sit level, whatever font or browser is used */
    vertical-align: middle; position: relative; top: -1.5px;
}
@media (max-width: 600px) { .gapfill .form-tag, .lesson .form-tag { top: -0.5px; } }
.lesson .words th .form-tag { margin: 0 6px 0 0; }   /* the same sign in a lesson table, before the word */

/* The "?" in the answer boxes: a lighter grey, so it doesn't stand out before anything is typed */
.gapfill input.textbox::placeholder { color: #B4B9C1; opacity: 1; }

/* ===== "More suggestions" drop-down under a rewrite answer (first used on Misplaced Modifiers) =====
   Markup inside a .gapfill li:
   <details class="more"><summary>More suggestions</summary><ul><li>…</li></ul></details> */
.gapfill .more { margin-top: 8px; line-height: 1.5; }
.gapfill .more summary {
    display: flex; width: fit-content; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 8px;
    background: #D4E8F2; color: #1E5A78;
    font-weight: 700; font-size: .9rem;
    cursor: pointer; list-style: none; user-select: none;
    transition: background-color .15s;
}
.gapfill .more summary::-webkit-details-marker { display: none; }
.gapfill .more summary::before {          /* the light bulb */
    content: ""; width: 17px; height: 17px; flex: none; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h1m8-9v1m8 8h1M5.6 5.6l.7.7m12.1-.7-.7.7'/%3E%3Cpath d='M9 16a5 5 0 1 1 6 0a3.5 3.5 0 0 0-1 3a2 2 0 0 1-4 0a3.5 3.5 0 0 0-1-3'/%3E%3Cpath d='M9.7 17h4.6'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h1m8-9v1m8 8h1M5.6 5.6l.7.7m12.1-.7-.7.7'/%3E%3Cpath d='M9 16a5 5 0 1 1 6 0a3.5 3.5 0 0 0-1 3a2 2 0 0 1-4 0a3.5 3.5 0 0 0-1-3'/%3E%3Cpath d='M9.7 17h4.6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.gapfill .more:not([open]) summary:hover { background: #C2DDEB; }
/* open: the button becomes a tab, and the list drops down from it in the same colour */
.gapfill .more[open] summary { border-radius: 8px 8px 0 0; }
.gapfill .more ul {
    margin: 0 calc(10px + 2em + .7em - 16px) 2px 0;      /* right gap = the left gap before the sentence */
    padding: 10px 16px; list-style: none;
    border-radius: 0 12px 12px 12px; background: #D4E8F2;
}
@media (max-width: 640px) {
    .gapfill .more ul { margin-right: calc(6px + 2em + .55em - 12px); }
}
.gapfill .more ul li,
.gapfill.rewrite .more ul li { counter-increment: none; padding: 5px 0 !important; background: none; line-height: 1.5; border-top: 0; }
.gapfill .more ul li::before { content: none; display: none; }
.gapfill .more ul li + li,
.gapfill.rewrite .more ul li + li { border-top: 1px solid rgb(30 90 120 / .15); }
@media print { .gapfill .more { display: none; } }
