/* /nauka/ section styles. Loaded only on pages under /nauka/ (front-matter cascade param `page_css`). */

/* Karta pracy
 * Worksheet pages: content is wrapped in .kp-sheet, so every rule is scoped to it.
 * Colours come from the risotto palette variables (--bg, --off-bg, --inner-bg, --fg, --muted, --link, --highlight, --base0x).
 */

.kp-sheet {
    line-height: 1.6;
}

.kp-sheet .kp-print-note {
    border-left: 4px solid var(--link);
    background: var(--off-bg);
    padding: 0.75rem 1rem;
}

/* Paper only: shown in print. */
.kp-sheet .kp-print-only {
    display: none;
}

/* Jump links to the days. */
.kp-sheet .kp-days {
    font-weight: 600;
}

.kp-sheet .kp-days a {
    display: inline-block;
    padding: 0.3rem 0.15rem;
}

/* Inline maths: one expression never breaks across lines. */
.kp-sheet .kp-m {
    white-space: nowrap;
}

/* Day: one clear block per session. */
.kp-sheet .kp-day {
    margin: 3rem 0;
    padding: 1.25rem 1rem;
    border: 2px solid var(--muted);
    border-top: 6px solid var(--highlight);
    border-radius: 6px;
    background: var(--off-bg);
}

.kp-sheet .kp-day > h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.15rem;
    line-height: 1.5;
    color: var(--highlight);
}

/* Boxes inside a day: warm-up, worked example, task. */
.kp-sheet .kp-warmup,
.kp-sheet .kp-example,
.kp-sheet .kp-task {
    margin: 2rem 0;
    padding: 1rem;
    border-radius: 6px;
    background: var(--bg);
}

.kp-sheet .kp-warmup {
    border: 1px dashed var(--base0C);
}

.kp-sheet .kp-example {
    border: 1px solid var(--muted);
    border-left: 4px solid var(--base0D);
}

.kp-sheet .kp-task {
    border: 2px solid var(--base0A);
}

.kp-sheet .kp-warmup > h3,
.kp-sheet .kp-example > h3,
.kp-sheet .kp-task > h3 {
    margin: 0 0 1rem 0;
    font-size: 1.05rem;
}

.kp-sheet .kp-task > h3 {
    color: var(--base0A);
}

.kp-sheet .kp-warmup > h3::before,
.kp-sheet .kp-example > h3::before,
.kp-sheet .kp-task > h3::before {
    content: none;
}

.kp-sheet .kp-warmup > :last-child,
.kp-sheet .kp-example > :last-child,
.kp-sheet .kp-task > :last-child,
.kp-sheet .kp-day > :last-child {
    margin-bottom: 0;
}

/* Tables: scroll sideways inside their box on narrow screens. */
.kp-sheet .kp-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 0 1.5rem 0;
}

.kp-sheet .kp-table table {
    margin: 0;
    border-collapse: collapse;
    overflow-wrap: normal;
}

.kp-sheet .kp-table th,
.kp-sheet .kp-table td {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--inner-bg);
    min-width: 2.5rem;
}

.kp-sheet .kp-table th {
    background: var(--inner-bg);
}

.kp-sheet .kp-table--zapis td:nth-child(2) {
    white-space: nowrap;
}

.kp-sheet .kp-table--zapis td:nth-child(3) {
    min-width: 14rem;
}

.kp-sheet .kp-log td {
    white-space: nowrap;
}

/* Collapsed reveals. */
.kp-sheet .kp-reveal {
    margin: 0 0 1rem 0;
    border: 1px solid var(--muted);
    border-radius: 4px;
}

.kp-sheet .kp-reveal > summary {
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    color: var(--link);
    font-weight: 600;
}

.kp-sheet .kp-reveal > summary:hover {
    color: var(--hover);
}

.kp-sheet .kp-reveal[open] > summary {
    border-bottom: 1px solid var(--muted);
    margin-bottom: 1rem;
}

.kp-sheet .kp-reveal > :not(summary) {
    margin-left: 0.9rem;
    margin-right: 0.9rem;
}

.kp-sheet .kp-reveal[open] > :last-child {
    margin-bottom: 1rem;
}

.kp-sheet .kp-reveal--answer > summary {
    color: var(--base0B);
}

/* Writing space: paper only. */
.kp-sheet .kp-space {
    display: none;
}

@media (max-width: 30rem) {
    .kp-sheet .kp-day {
        padding: 1rem 0.5rem;
    }

    .kp-sheet .kp-warmup,
    .kp-sheet .kp-example,
    .kp-sheet .kp-task {
        padding: 0.75rem 0.6rem;
    }

    .kp-sheet .kp-reveal > :not(summary) {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    .kp-sheet .kp-table th,
    .kp-sheet .kp-table td {
        padding: 0.35rem 0.45rem;
    }

    .kp-sheet .kp-table td:first-child {
        min-width: 0;
    }

    /* Zapis tables: the note goes under its line, so nothing is off-screen. */
    .kp-sheet .kp-table--zapis thead {
        display: none;
    }

    .kp-sheet .kp-table--zapis table,
    .kp-sheet .kp-table--zapis tbody {
        display: block;
    }

    .kp-sheet .kp-table--zapis tr {
        display: grid;
        grid-template-columns: 1.5rem 1fr;
        border-bottom: 1px solid var(--inner-bg);
    }

    .kp-sheet .kp-table--zapis td {
        border: 0;
        min-width: 0;
        padding: 0.3rem 0.4rem;
    }

    .kp-sheet .kp-table--zapis td:nth-child(2) {
        font-size: 0.95em;
    }

    .kp-sheet .kp-table--zapis td:nth-child(3) {
        grid-column: 2;
        min-width: 0;
        padding-top: 0;
        font-size: 0.9em;
        opacity: 0.8;
    }

    .kp-sheet .kp-log {
        font-size: 0.85em;
    }
}

@media print {
    @page {
        margin: 1.5cm;
    }

    body:has(.kp-sheet) .page__header,
    body:has(.kp-sheet) .page__footer,
    body:has(.kp-sheet) .page__aside,
    body:has(.kp-sheet) .post__meta {
        display: none !important;
    }

    body:has(.kp-sheet) .page {
        display: block;
        max-width: none;
        margin: 0;
    }

    body:has(.kp-sheet),
    body:has(.kp-sheet) * {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
    }

    body:has(.kp-sheet) {
        font-size: 11pt;
        line-height: 1.45;
    }

    .kp-sheet .kp-logbook {
        break-inside: avoid;
    }

    body:has(.kp-sheet) li::marker {
        color: #000;
    }

    body:has(.kp-sheet) h1::before,
    body:has(.kp-sheet) h2::before,
    body:has(.kp-sheet) h3::before {
        content: none;
    }

    body:has(.kp-sheet) a {
        text-decoration: none;
    }

    .kp-sheet .kp-print-note,
    .kp-sheet .kp-days,
    .kp-sheet .kp-reveal {
        display: none !important;
    }

    .kp-sheet .kp-print-only {
        display: block;
    }

    .kp-sheet .kp-day {
        break-before: page;
        margin: 0;
        padding: 0;
        border: 0;
    }

    .kp-sheet .kp-day > h2 {
        font-size: 1.2rem;
        border-bottom: 2px solid #000;
        padding-bottom: 0.25rem;
    }

    .kp-sheet .kp-warmup,
    .kp-sheet .kp-task {
        break-inside: avoid;
    }

    .kp-sheet .kp-warmup,
    .kp-sheet .kp-example,
    .kp-sheet .kp-task {
        margin: 0 0 0.8cm 0;
        padding: 0.4cm;
        border: 1px solid #000;
    }

    .kp-sheet .kp-task {
        border-width: 2px;
    }

    .kp-sheet .kp-table {
        overflow: visible;
        break-inside: avoid;
    }

    .kp-sheet .kp-table th,
    .kp-sheet .kp-table td {
        border: 1px solid #000;
    }

    .kp-sheet .kp-table--zapis td:nth-child(3) {
        min-width: 0;
    }

    .kp-sheet .kp-space {
        display: block;
        height: 5cm;
        margin: 0.4cm 0 0 0;
        border: 1px dashed #000;
    }

    .kp-sheet .kp-log table {
        width: 100%;
        table-layout: fixed;
    }

    .kp-sheet .kp-log th:nth-child(1) { width: 9%; }
    .kp-sheet .kp-log th:nth-child(2) { width: 17%; }
    .kp-sheet .kp-log th:nth-child(3) { width: 15%; }
    .kp-sheet .kp-log th:nth-child(4) { width: 17%; }
    .kp-sheet .kp-log th:nth-child(5) { width: 13%; }
    .kp-sheet .kp-log th:nth-child(6) { width: 29%; }

    .kp-sheet .kp-log td {
        height: 1.2cm;
        vertical-align: middle;
    }
}

/* Fiszki Anki
 * Anki deck page: content is wrapped in .ak-page. Inline SVG phone mockups use .ak-shot.
 * Colours come from the risotto palette variables, so the mockups follow the site theme.
 */

.ak-page {
    line-height: 1.6;
}

.ak-page .ak-download {
    margin: 1.5rem 0 2rem 0;
}

.ak-page .ak-download a {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--highlight);
    border-radius: 6px;
    background: var(--bg);
    color: var(--highlight);
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.ak-page .ak-download a:hover,
.ak-page .ak-download a:focus-visible {
    border-color: var(--hover);
    color: var(--hover);
}

.ak-page .ak-download__file {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--base04);
    overflow-wrap: anywhere;
}

/* Front markers, same wording as on the cards. */
.ak-page .ak-marker {
    display: inline-block;
    margin: 0 0.4rem 0.2rem 0;
    padding: 0 0.6rem;
    border-radius: 999px;
    background: var(--inner-bg);
    color: var(--fg);
    font-weight: 600;
    white-space: nowrap;
}

/* Grading table. */
.ak-page .ak-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 0 1rem 0;
}

.ak-page .ak-table table {
    margin: 0;
    border-collapse: collapse;
    overflow-wrap: normal;
}

.ak-page .ak-table th,
.ak-page .ak-table td {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--inner-bg);
}

.ak-page .ak-table th {
    background: var(--inner-bg);
}

.ak-page .ak-table td:last-child {
    white-space: nowrap;
}

/* Figures with SVG mockups. */
.ak-page .ak-fig {
    max-width: 20rem;
    margin: 1.5rem auto;
}

.ak-page .ak-fig figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--base04);
    text-align: center;
}

.ak-shot {
    display: block;
    width: 100%;
    height: auto;
    color: var(--fg);
}

.ak-shot text {
    fill: currentColor;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    font-size: 13px;
}

.ak-shot .ak-small { font-size: 12px; }
.ak-shot .ak-tiny { font-size: 11px; }
.ak-shot .ak-mid { font-size: 15px; }
.ak-shot .ak-big { font-size: 28px; }
.ak-shot .ak-strong { font-weight: 700; }
.ak-shot .ak-dim { fill: var(--base04); }
.ak-shot .ak-accent { fill: var(--highlight); }
.ak-shot .ak-ok { fill: var(--base0B); font-weight: 700; }
.ak-shot .ak-off { fill: var(--base04); }
.ak-shot .ak-new { fill: var(--base0D); }
.ak-shot .ak-lrn { fill: var(--base08); }
.ak-shot .ak-rev { fill: var(--base0B); }

.ak-shot .ak-phone {
    fill: var(--inner-bg);
    stroke: var(--muted);
    stroke-width: 2;
}

.ak-shot .ak-screen { fill: var(--bg); }
.ak-shot .ak-bar { fill: var(--off-bg); }
.ak-shot .ak-ph { fill: var(--inner-bg); }
.ak-shot .ak-ph--bar { fill: var(--muted); }
.ak-shot .ak-dot { fill: currentColor; }

.ak-shot .ak-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ak-shot .ak-menu {
    fill: var(--off-bg);
    stroke: var(--muted);
    stroke-width: 1.5;
}

.ak-shot .ak-card { fill: var(--off-bg); }

.ak-shot .ak-field {
    fill: var(--bg);
    stroke: var(--muted);
    stroke-width: 1.5;
}

.ak-shot .ak-toggle { fill: var(--base0B); }
.ak-shot .ak-knob { fill: var(--bg); }
.ak-shot .ak-pill { fill: var(--inner-bg); }
.ak-shot .ak-button { fill: var(--inner-bg); }

.ak-shot .ak-line {
    stroke: var(--muted);
    stroke-width: 1.5;
}

.ak-shot .ak-touch {
    fill: var(--highlight);
    opacity: 0.4;
}

.ak-shot .ak-hl {
    fill: none;
    stroke: var(--highlight);
    stroke-width: 2.5;
}

.ak-shot .ak-btn {
    fill: var(--off-bg);
    stroke-width: 2;
}

.ak-shot .ak-btn--again { stroke: var(--base08); }
.ak-shot .ak-btn--hard { stroke: var(--base04); }
.ak-shot .ak-btn--good { stroke: var(--base0B); }
.ak-shot .ak-btn--easy { stroke: var(--muted); }

.ak-shot .ak-cross {
    stroke: var(--base08);
    stroke-width: 2;
    stroke-linecap: round;
}
