/* ==========================================================================
   Interactive tools on content pages (review schedule, forgetting curve).
   Built on the tokens in site.css; lives inside .prose, so list and spacing
   rules from article.css are reset here.
   ========================================================================== */

.tool {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 3vw, 32px);
    font-size: 16px;
    line-height: 1.45;
    color: var(--text);
}
.tool [hidden] { display: none !important; }
.tool ol, .tool ul { list-style: none; padding: 0; margin: 0; }
.prose .tool li + li { margin-top: 0; }

/* ---------- Form ---------- */

.tool-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; border: 0; }
.tool-form .field { display: flex; flex-direction: column; gap: 8px; min-width: 0; border: 0; padding: 0; margin: 0; }
.tool-form .field--wide { grid-column: 1 / -1; }
.tool-form label, .tool-form legend { font-size: 14px; font-weight: 600; color: var(--text-2); padding: 0; }
.tool-form legend { margin-bottom: 8px; }
.tool-form label small { font-weight: 400; color: var(--text-3); }

.tool-input {
    width: 100%; height: 48px; padding: 0 14px;
    border-radius: 14px; border: 1px solid var(--line-strong);
    background: var(--surface-2); color: var(--text);
    font: inherit; font-size: 16px;
    color-scheme: dark;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tool-input::placeholder { color: var(--text-3); }
.tool-input:hover { border-color: rgba(255, 255, 255, 0.24); }
.tool-input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(123, 108, 246, 0.25); }
.tool-input[aria-invalid='true'] { border-color: var(--orange); }

/* Segmented control built from radio inputs */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-strong); }
.seg label { position: relative; margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
    display: flex; align-items: center; justify-content: center; height: 38px; padding: 0 10px;
    border-radius: 10px; font-size: 15px; font-weight: 600; color: var(--text-2); text-align: center;
    transition: background-color 0.25s ease, color 0.25s ease;
}
.seg input:checked + span { background: var(--text); color: #000; }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- Review schedule result ---------- */

.tool-result { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.tool-result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tool-result-head b { font-size: 18px; letter-spacing: -0.015em; }
.tool-result-head span { font-size: 14px; color: var(--text-3); }

.srs-list { display: flex; flex-direction: column; gap: 8px; counter-reset: review; }
.srs-item {
    counter-increment: review;
    display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 14px;
    padding: 12px 16px 12px 12px; border-radius: 14px;
    background: var(--surface-2); border: 1px solid var(--line);
}
.srs-item::before {
    content: counter(review);
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(123, 108, 246, 0.16); color: #b4acff; font-weight: 700; font-size: 15px;
}
.srs-item.is-final::before { background: rgba(127, 210, 124, 0.16); color: var(--green); }
.srs-date { font-weight: 600; font-size: 16px; }
.srs-date small { display: block; font-weight: 400; font-size: 13px; color: var(--text-3); margin-top: 2px; }
.srs-when { font-size: 14px; color: var(--text-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.srs-item.is-past { opacity: 0.55; }
.srs-item.is-past .srs-when { color: var(--orange); }
.srs-item.is-today { border-color: rgba(123, 108, 246, 0.6); }
.srs-item.is-today .srs-when { color: #b4acff; font-weight: 600; }

/* Timeline: positions on a square-root scale so early reviews don't bunch up */
.srs-timeline { position: relative; height: 54px; margin: 22px 6px 4px; }
.srs-timeline::before { content: ''; position: absolute; left: 0; right: 0; top: 13px; height: 2px; border-radius: 1px; background: linear-gradient(90deg, var(--violet), var(--pink), var(--orange), var(--green), var(--cyan)); opacity: 0.55; }
.srs-tick { position: absolute; top: 6px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.srs-tick i { width: 16px; height: 16px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 4px var(--surface); }
.srs-tick.is-start i { background: var(--surface-2); border: 2px solid var(--text-2); }
.srs-tick.is-exam i { background: var(--green); }
.srs-tick span { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.tool-actions .btn { height: 46px; font-size: 15px; padding: 0 20px; }
.tool-actions .btn svg { width: 18px; height: 18px; }
.tool-note { margin-top: 14px; font-size: 14px; color: var(--text-3); }
.tool-note:empty { display: none; }

/* ---------- Interactive forgetting curve ---------- */

.fc-tool .fc-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.fc-preset {
    height: 38px; padding: 0 16px; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--surface-2);
    font-size: 14px; font-weight: 600; color: var(--text-2);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.fc-preset:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.24); }
.fc-preset[aria-pressed='true'] { background: var(--text); color: #000; border-color: transparent; }

.fc-chart { position: relative; border-radius: 16px; touch-action: manipulation; cursor: crosshair; }
.fc-chart:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.fc-chart svg { width: 100%; height: auto; overflow: visible; display: block; }
.fc-chart .chart-yes { stroke-width: 5; }
.fc-area { fill: url(#fcArea); }
.fc-cursor { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.5; stroke-dasharray: 4 6; opacity: 0; transition: opacity 0.15s ease; }
.fc-cursor-label { fill: var(--text-2); font-size: 15px; font-weight: 600; font-family: var(--font); opacity: 0; transition: opacity 0.15s ease; }
.fc-chart.is-pointing .fc-cursor, .fc-chart.is-pointing .fc-cursor-label { opacity: 1; }
.fc-review-line { stroke: rgba(255, 255, 255, 0.18); stroke-width: 1.5; }
.fc-review-dot { fill: #fff; }

.fc-readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.fc-stat { padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.fc-stat b { display: block; font-size: clamp(24px, 3vw, 30px); font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.fc-stat span { font-size: 13px; color: var(--text-3); }
.fc-stat.is-yes b { background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fc-hint { margin-top: 14px; font-size: 14px; color: var(--text-3); }
.prose .fc-tool figcaption { text-align: left; margin-top: 0; }
.fc-tool .chart-note { line-height: 1.5; }

@media (max-width: 640px) {
    .tool-form { grid-template-columns: 1fr; }
    .srs-item { grid-template-columns: 30px 1fr; padding: 12px; }
    .srs-item::before { width: 30px; height: 30px; font-size: 14px; }
    .srs-when { grid-column: 2; text-align: left; margin-top: -8px; }
    .fc-readout { gap: 8px; }
    .fc-stat { padding: 12px; }
    .fc-stat span { font-size: 12px; line-height: 1.35; display: block; margin-top: 2px; }
    .fc-preset { height: 34px; padding: 0 13px; font-size: 13px; }
    .fc-chart .chart-label, .fc-chart .chart-tag, .fc-cursor-label { font-size: 28px; }
}
