/* Cheat sheet (cheat-sheet.mjs): the full-page sheet and its print layout, and the
   sheet list on the GuideMate Brain card's dialog. Links are text and an arrow, no box. */
.cs-dialog {
    width: min(980px, calc(100vw - 32px));
    height: calc(100vh - 32px);
    max-height: none;
    margin: auto;
    padding: 0;
    border: 1.5px solid #1B3A4B;
    border-radius: 16px;
    background: #FFFDF8;
    color: #1B3A4B;
    box-shadow: 0 24px 60px rgba(13, 29, 54, 0.22);
    font-family: 'Hanken Grotesk', system-ui, sans-serif;
}
.cs-dialog[open] { display: flex; flex-direction: column; }
.cs-dialog::backdrop { background: rgba(13, 29, 54, 0.38); }
.cs-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding: 28px 44px 14px;
    border-bottom: 1px solid #E6DCC6;
}
.cs-titles { min-width: 0; }
.cs-eyebrow {
    margin: 0;
    font: 600 11px/1.2 'Space Grotesk', system-ui, sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #B08A3A;
}
.cs-title { margin: 6px 0 0; font: 700 1.7rem/1.2 'Space Grotesk', system-ui, sans-serif; text-wrap: balance; }
.cs-sub { margin: 6px 0 0; font-size: 14px; color: #6B6450; }
.cs-actions { display: flex; align-items: center; gap: 20px; flex: none; }
.cs-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: #B08A3A;
    font: 600 14px/1.3 'Space Grotesk', system-ui, sans-serif;
    cursor: pointer;
}
.cs-link:hover:not(:disabled) { color: #8C6A24; }
.cs-link:disabled { color: #4E7A5A; cursor: default; }
.cs-close {
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: #1B3A4B;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.cs-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 44px 40px; }

/* The sheet itself: chapter sections, short bullets, maths typeset. */
.cs-sheet { font-size: 15px; line-height: 1.55; }
.cs-sheet h2 {
    margin: 26px 0 8px;
    padding-top: 18px;
    border-top: 1px solid #E6DCC6;
    font: 700 1.25rem/1.25 'Space Grotesk', system-ui, sans-serif;
    color: #1B3A4B;
}
.cs-sheet h2:first-child { border-top: 0; padding-top: 0; margin-top: 14px; }
.cs-sheet h3 {
    margin: 16px 0 6px;
    font: 600 11.5px/1.2 'Space Grotesk', system-ui, sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8C6A24;
}
.cs-sheet ul { margin: 0; padding-left: 20px; list-style: disc; }
.cs-sheet li + li { margin-top: 6px; }
.cs-sheet li::marker { color: #B08A3A; }
.cs-sheet strong { color: #1B3A4B; }
.cs-sheet p { margin: 8px 0; }
.cs-sheet .katex { font-size: 1.02em; }

/* The card's dialog: sheets already made. */
.cs-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; }
.cs-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px dashed #E6DCC6;
}
.cs-row-text { min-width: 0; display: grid; gap: 2px; }
.cs-row-title { font-weight: 600; font-size: 14.5px; }
.cs-row-sub { font-size: 12.5px; color: #8C846E; }
.cs-row-state { flex: none; font: 600 13.5px 'Space Grotesk', system-ui, sans-serif; color: #8C846E; }
.cs-row-state.is-failed { color: #CE6B5A; font-weight: 500; font-family: inherit; font-size: 12.5px; max-width: 46%; text-align: right; }
.cs-error { margin: 10px 0 0; font-size: 14px; color: #B5503F; }

@media (max-width: 640px) {
    .cs-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); }
    .cs-head { padding: 20px 20px 12px; flex-direction: column; gap: 12px; }
    .cs-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 12px 18px; }
    .cs-body { padding: 6px 20px 28px; }
    .cs-title { font-size: 1.4rem; }
}

/* Printing (Save as PDF): only the sheet, on plain paper. */
@media print {
    body.cs-printing > *:not(.cs-dialog) { display: none !important; }
    body.cs-printing { background: #fff !important; }
    body.cs-printing .cs-dialog {
        position: static;
        inset: auto;
        margin: 0;
        padding-top: 4px;
        width: auto;
        height: auto;
        border: 0;
        box-shadow: none;
        background: #fff;
    }
    body.cs-printing .cs-dialog::backdrop { background: transparent; }
    body.cs-printing .cs-actions { display: none; }
    body.cs-printing .cs-head { padding: 0 0 10px; }
    body.cs-printing .cs-body { padding: 4px 0 0; overflow: visible; }
    body.cs-printing .cs-sheet li { break-inside: avoid; }
    body.cs-printing .cs-sheet h2 { break-after: avoid; }
}
