/* Presentation settings of lesson widgets (see lesson-widget-settings.js).
   Every class here is produced by widgetSettingClasses() for a non-default value:
   lw-<key>-<value>, booleans as lw-<key>. Defaults have no class, so blocks without
   settings keep the base styles from styles.css. Link this file after styles.css.
   Only the semantic theme tokens are used, so light and dark themes keep working.
   Containers with a block gap other than the learner view can set --lw-gap and --lw-bleed. */

/* General: space above the widget. The learner view separates blocks by a grid gap. */
.lesson-block-content > .lw-spacing-none:not(:first-child) { margin-block-start: calc(-1 * var(--lw-gap, 1.05rem)); }
.lesson-block-content > .lw-spacing-sm:not(:first-child) { margin-block-start: calc(.45rem - var(--lw-gap, 1.05rem)); }
.lesson-block-content > .lw-spacing-lg:not(:first-child) { margin-block-start: calc(2.25rem - var(--lw-gap, 1.05rem)); }

/* General: a wide widget extends into the surrounding padding, never beyond the viewport. */
.lesson-block-content > .lw-width-wide {
    max-inline-size: none;
    margin-inline: calc(-1 * var(--lw-bleed, clamp(0rem, 3vw, 1rem)));
}

/* General: background. Callouts keep their tone bar; a subtle surface only calms the background. */
.lw-surface-subtle, .lw-surface-accent { padding: .85rem 1rem; border-radius: .7rem; }
.lw-surface-subtle:not(.lesson-block-callout) { border: 1px solid var(--line); background: var(--surface-muted); }
.lw-surface-accent:not(.lesson-block-callout) {
    border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--line));
    background: var(--blue-soft);
}

/* Heading and paragraph alignment; media stays start-aligned by default and centres on request. */
.lw-align-center { justify-items: center; text-align: center; }
.lw-align-start { justify-items: start; text-align: start; }

/* Heading: subsection level (rendered as h3). */
.lesson-block-content .lesson-block-heading.lw-level-3,
.lesson-block-heading.lw-level-3 { font-size: clamp(1.12rem, 2.2vw, 1.35rem); letter-spacing: -.015em; }

/* Paragraph: text size. */
.lesson-block-content .lesson-block-copy.lw-size-lead,
.lesson-block-copy.lw-size-lead { font-size: clamp(1.06rem, 1.8vw, 1.2rem); line-height: 1.6; }
.lesson-block-content .lesson-block-copy.lw-size-small,
.lesson-block-copy.lw-size-small { font-size: .9rem; line-height: 1.55; }

/* Callout tones. Text stays --ink on the soft background in both themes; the tone colours the bar.
   There is no shared amber token yet, so the warning pair is local: #8a4b0a on #ffefc7 (6.0:1)
   and #f8c66d on #3d3020 (8.1:1); --ink on either background stays above 11:1. */
.lesson-block-callout.lw-tone-tip {
    --lw-tone: color-mix(in srgb, var(--lime) 55%, var(--ink));
    --lw-tone-soft: color-mix(in srgb, var(--lime) 18%, var(--surface));
}
.lesson-block-callout.lw-tone-warning {
    --lw-warning: #8a4b0a;
    --lw-warning-soft: #ffefc7;
    --lw-tone: var(--lw-warning);
    --lw-tone-soft: var(--lw-warning-soft);
}
html[data-theme="dark"] .lesson-block-callout.lw-tone-warning {
    --lw-warning: #f8c66d;
    --lw-warning-soft: #3d3020;
}
.lesson-block-callout.lw-tone-success {
    --lw-tone: var(--success);
    --lw-tone-soft: var(--success-soft);
}
.lesson-block-callout:is(.lw-tone-tip, .lw-tone-warning, .lw-tone-success) {
    border-inline-start-color: var(--lw-tone);
    background: var(--lw-tone-soft);
    color: var(--ink);
}
.lesson-block-callout.lw-surface-subtle { background: var(--surface-muted); }

/* Exercise: hint and sample solution are open; a rule separates them from the task. */
.lw-hints-open details { padding-block-start: .55rem; border-block-start: 1px solid var(--line); }

/* Quiz and multiple choice: answers in two columns where there is room. */
.lw-layout-grid .quiz-options { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }

/* Flashcards: every card visible as its own question and answer. */
.lw-layout-grid .lesson-flashcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: .75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.lw-layout-grid .lesson-flashcard {
    display: grid;
    align-content: start;
    gap: .5rem;
    min-inline-size: 0;
    padding: .75rem .85rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    background: var(--surface);
    color: var(--ink);
}
.lw-layout-grid .lesson-flashcard > .lesson-block-copy { font-weight: 600; }
.lw-layout-grid .lesson-flashcard > details { margin: 0; }
.lw-layout-grid .lesson-flashcard > details > summary { color: var(--blue); font-weight: 650; cursor: pointer; }
.lw-layout-grid .lesson-flashcard > details > p { margin-block-start: .4rem; }
.lw-layout-grid .lesson-flashcard > .field-hint:empty { display: none; }

/* Checklist: numbered steps keep ordered-list semantics. */
.lw-marker-number .lesson-checklist-steps {
    display: grid;
    gap: .6rem;
    margin: 0;
    padding-inline-start: 1.6rem;
    list-style: decimal;
}
.lw-marker-number .lesson-checklist-steps > li { min-inline-size: 0; padding-inline-start: .2rem; }
.lw-marker-number .lesson-checklist-steps > li::marker { color: var(--quiet); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Table: alternating row backgrounds. */
.lw-striped .lesson-table tbody tr:nth-child(even) > td { background: var(--surface-muted); }

/* Paragraph: each image inside the text stands between the text around it and never exceeds the text width. */
.lesson-rich-flow .lesson-rich-image {
    display: grid;
    justify-items: start;
    max-inline-size: 100%;
    margin: .75rem 0;
    white-space: normal;
}
.lesson-rich-flow .lesson-rich-image img { max-inline-size: 100%; block-size: auto; }
.lesson-rich-image-alt { font-style: italic; color: var(--quiet); }

/* Studio: atomic image chips and the image panel of the formatted text field. */
.lesson-rich-image-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    max-inline-size: 100%;
    margin: 0 .15rem;
    padding: .05rem .45rem;
    border: 1px solid var(--line);
    border-radius: .4rem;
    background: var(--surface-muted);
    color: var(--ink);
    font: inherit;
    font-size: .85em;
    line-height: 1.5;
    vertical-align: baseline;
    cursor: pointer;
    user-select: none;
}
.lesson-rich-image-chip .icon { inline-size: 1em; block-size: 1em; flex: none; }
.lesson-rich-image-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.lesson-rich-image-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 16rem; }
.lesson-rich-image-panel {
    display: grid;
    gap: .65rem;
    min-inline-size: 0;
    margin: .5rem 0 0;
    padding: .75rem .85rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    background: var(--surface);
}
.lesson-rich-image-panel > legend { padding: 0 .25rem; font-weight: 600; }
