/* ==========================================================================
   "Explain it simply" checker and the worked example (/feynman-technique/).
   Built on the tokens in site.css and the .tool shell in tools.css.
   The highlights are drawn in a backdrop behind a transparent textarea, so
   both must share exactly the same font, padding, border and wrapping.
   ========================================================================== */

.xs { scroll-margin-top: 90px; }

/* ---------- Steps ---------- */

.xs-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px !important; counter-reset: xs; }
.xs-steps li {
    counter-increment: xs;
    display: flex; flex-direction: column; gap: 8px;
    font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3);
    line-height: 1.25;
}
.xs-steps li::before { content: ''; height: 3px; border-radius: 2px; background: var(--line-strong); transition: background 0.5s var(--ease); }
.xs-steps li span::before { content: counter(xs) '. '; }
.xs-steps li.is-on { color: var(--text-2); }
.xs-steps li.is-on::before { background: var(--text-2); }
.xs-steps li[aria-current='step'] { color: var(--text); }
.xs-steps li[aria-current='step']::before { background: var(--spectrum); }

.xs-prompt { font-size: 16px; line-height: 1.5; color: var(--text); min-height: 3em; margin-bottom: 18px !important; }

/* ---------- Fields ---------- */

.xs-field { display: flex; flex-direction: column; gap: 8px; }
.xs-field + .xs-field { margin-top: 16px !important; }
.xs-field > label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.xs-field > label small { font-weight: 400; color: var(--text-3); }

/* ---------- Editor: backdrop with highlights, transparent textarea on top ---------- */

.xs-editor { position: relative; }
.xs-backdrop,
.prose .xs-textarea {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-family: var(--font);
    font-size: 17px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: normal;
    word-spacing: normal;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
    tab-size: 4;
}
.xs-backdrop {
    min-height: 210px;
    background: var(--surface-2);
    color: transparent;
    pointer-events: none;
    user-select: none;
}
.prose .xs-textarea {
    position: absolute; inset: 0; width: 100%; height: 100%;
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
    caret-color: var(--text);
    resize: none;
    overflow: hidden;
}
.xs-textarea::placeholder { color: var(--text-3); }

/* Marks keep the text's exact metrics: no padding, no weight change */
.xs-m { color: transparent; border-radius: 3px; padding: 0; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.xs-m--sentence { background: none; box-shadow: inset 0 -2px 0 rgba(86, 166, 238, 0.9); border-radius: 0; }
.xs-m--word { background: rgba(240, 211, 92, 0.34); }
.xs-m--jargon { background: rgba(245, 96, 154, 0.4); }

/* Legend chips and finding labels share the same colours */
.xs-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px !important; font-size: 14px; color: var(--text-3); }
.xs-legend span { display: inline-flex; align-items: center; gap: 7px; }
.xs-legend i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.xs-legend .is-sentence { background: none; box-shadow: inset 0 -3px 0 rgba(86, 166, 238, 0.95); border-radius: 0; }
.xs-legend .is-word { background: rgba(240, 211, 92, 0.55); }
.xs-legend .is-jargon { background: rgba(245, 96, 154, 0.6); }

/* ---------- Numbers ---------- */

.xs-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px !important; }
.xs-stat { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.xs-stat b { display: block; font-size: clamp(22px, 2.6vw, 28px); font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.xs-stat span { display: block; font-size: 13px; color: var(--text-3); line-height: 1.35; margin-top: 2px; }
.xs-stat small { display: block; font-size: 12px; color: #b4acff; margin-top: 4px; font-variant-numeric: tabular-nums; }
.xs-stat small:empty { display: none; }

/* ---------- Findings ---------- */

.xs-gaps { margin-top: 22px !important; padding-top: 20px; border-top: 1px solid var(--line); }
.xs-gaps-head { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); margin-bottom: 10px; }
.xs-gaps-empty { font-size: 15px; color: var(--text-3); line-height: 1.5; }
.xs-gaps-empty:empty { display: none; }
.xs-flags { display: grid; gap: 6px; }
.xs-flag {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%;
    padding: 10px 14px; border-radius: 12px; text-align: left;
    background: var(--surface-2); border: 1px solid var(--line);
    font: inherit; font-size: 15px; line-height: 1.45; color: var(--text-2); cursor: pointer;
    transition: border-color 0.2s ease;
}
.xs-flag:hover { border-color: var(--line-strong); }
.xs-flag:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.xs-flag q { color: var(--text-2); font-style: italic; quotes: none; }
.xs-tip { flex: 1 1 100%; color: var(--text-3); font-size: 14px; }
.xs-k { display: inline-block; padding: 1px 7px; border-radius: 6px; font-weight: 600; color: var(--text); }
.xs-k--sentence { background: rgba(86, 166, 238, 0.14); box-shadow: inset 0 -2px 0 rgba(86, 166, 238, 0.9); border-radius: 4px 4px 0 0; }
.xs-k--word { background: rgba(240, 211, 92, 0.3); }
.xs-k--jargon { background: rgba(245, 96, 154, 0.32); }
.xs-more { font-size: 14px; color: var(--text-3); padding: 4px 2px; }

.xs .tool-actions .btn:disabled { display: none; }

/* ---------- Worked example: two drafts ---------- */

.xs-drafts { display: grid; gap: 12px; }
.xs-draft { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.xs-draft.is-after { border-color: rgba(127, 210, 124, 0.4); }
.xs-draft-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.xs-draft-head b { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.xs-draft-head span { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.prose .xs-draft p { font-size: 17px; line-height: 1.6; color: var(--text); }
.xs-draft .xs-m { color: inherit; padding: 1px 0; }

@media (max-width: 640px) {
    .xs-steps { gap: 6px; }
    .xs-steps li { font-size: 11px; letter-spacing: 0.02em; }
    .xs-prompt { font-size: 15px; min-height: 4.5em; }
    .xs-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .xs-backdrop, .prose .xs-textarea { font-size: 16px; padding: 12px 14px; }
    .xs-backdrop { min-height: 240px; }
    .xs-draft { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .xs-steps li::before { transition: none; }
}
