/*
    SPACED REPETITION CALCULATOR

    Markup: src/includes/spaced-repetition-calculator.njk, behaviour:
    spaced-repetition.N.js. Uses the --pf-* tokens of the site-wide "modern
    shell" in index.NN.css. The deploy caches this file for a year: bump N in
    its name (and in the include) whenever it changes.
*/

.spaced-rep {
    --sr-ink: var(--text-color-light);
    --sr-muted: #77746f;
    --sr-button-bg: rgba(255, 255, 255, 0.75);
    --sr-button-bg-hover: #fff;
    --sr-line: var(--pf-line);
    --sr-field: rgba(255, 255, 255, 0.85);
    --sr-panel: rgba(255, 255, 255, 0.55);

    max-width: 760px;
    margin: 30px auto 0;
    font-family: var(--pf-font);
    font-weight: 400;
    letter-spacing: normal;
    color: var(--sr-ink);
}

body.dark .spaced-rep {
    --sr-ink: var(--text-color-dark);
    --sr-muted: rgba(255, 255, 255, 0.62);
    --sr-button-bg: rgba(255, 255, 255, 0.08);
    --sr-button-bg-hover: rgba(255, 255, 255, 0.16);
    --sr-line: var(--pf-line-dark);
    --sr-field: rgba(255, 255, 255, 0.08);
    --sr-panel: rgba(255, 255, 255, 0.05);
}

.spaced-rep__card {
    padding: 24px 26px;
    border: 1px solid var(--sr-line);
    border-radius: 18px;
    background: var(--pf-surface);
    box-shadow: var(--pf-shadow-card), var(--pf-inset);
}

.spaced-rep__label {
    display: block;
    margin-bottom: 8px;
    color: var(--sr-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.spaced-rep__input {
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--sr-line);
    border-radius: 10px;
    background: var(--sr-field);
    color: inherit;
    font: inherit;
    font-size: 16px;
    color-scheme: light;
}

body.dark .spaced-rep__input {
    color-scheme: dark;
}

.spaced-rep__input:focus {
    border-color: var(--pf-primary-deep);
    outline: 2px solid rgba(254, 190, 22, 0.35);
    outline-offset: 0;
}

/* exam date */

.spaced-rep__exam {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 18px;
}

.spaced-rep__field {
    display: flex;
    flex-direction: column;
}

.spaced-rep__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 4px;
}

.spaced-rep__chip {
    padding: 0.35rem 0.9rem;
    border: 1.5px solid var(--sr-line);
    border-radius: 2rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.spaced-rep__chip:hover {
    border-color: var(--pf-primary-deep);
    background-color: rgba(255, 212, 101, 0.15);
}

/* topics */

.spaced-rep__topics {
    margin-top: 22px;
}

.spaced-rep__topic {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 11.5em 36px;
    gap: 8px;
    align-items: center;
}

.spaced-rep__topic + .spaced-rep__topic {
    margin-top: 8px;
}

.spaced-rep__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--sr-muted);
    cursor: pointer;
}

.spaced-rep__remove:hover:not(:disabled) {
    background: var(--sr-button-bg);
    color: var(--sr-ink);
}

.spaced-rep__remove:disabled {
    opacity: 0.3;
    cursor: default;
}

.spaced-rep__add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 2px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

.spaced-rep__add:hover:not(:disabled) {
    text-decoration: underline;
    text-decoration-color: var(--pf-primary-deep);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.spaced-rep__add:disabled {
    opacity: 0.4;
    cursor: default;
}

/* the schedule */

.spaced-rep__result {
    display: block;
    margin-top: 22px;
    padding: 18px 20px;
    border-radius: 14px;
    background: var(--sr-panel);
}

.spaced-rep__summary {
    display: block;
    font-size: 16px;
    line-height: 1.55;
}

.spaced-rep .spaced-rep__days {
    max-width: none;
    margin: 14px 0 0;
    padding: 0;
    font-size: 15px;
    line-height: 1.4;
    letter-spacing: normal;
    list-style: none;
}

.spaced-rep__day {
    display: grid;
    grid-template-columns: 7.5em 6.5em minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: baseline;
    padding: 9px 0;
    border-top: 1px solid var(--sr-line);
}

.spaced-rep__date {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.spaced-rep__when {
    color: var(--sr-muted);
    font-size: 14px;
}

.spaced-rep__badge {
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--pf-primary);
    color: var(--pf-ink);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.spaced-rep__day.is-past {
    opacity: 0.45;
}

.spaced-rep__day.is-today .spaced-rep__when {
    color: var(--sr-ink);
    font-weight: 600;
}

.spaced-rep__day--exam .spaced-rep__day-topics {
    font-weight: 600;
}

/* actions */

.spaced-rep__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.spaced-rep__button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--sr-line);
    border-radius: 999px;
    background: var(--sr-button-bg);
    color: inherit;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s var(--pf-ease-spring), background-color 0.2s;
}

.spaced-rep__button:hover {
    background: var(--sr-button-bg-hover);
    transform: translateY(-1px);
}

.spaced-rep__button--primary,
.spaced-rep__button--primary:hover {
    border-color: transparent;
    background: var(--pf-primary);
    color: var(--pf-ink);
    font-weight: 600;
    box-shadow: 0 10px 22px -10px rgba(254, 190, 22, 0.7);
}

.spaced-rep__button--quiet {
    margin-left: auto;
    border-color: transparent;
    background: transparent;
    color: var(--sr-muted);
}

.spaced-rep:not(.has-schedule) .spaced-rep__button:not(.spaced-rep__button--quiet) {
    opacity: 0.5;
}

/* under the card */

.spaced-rep__tip {
    display: block;
    margin-top: 12px;
    color: var(--sr-muted);
    font-size: 14px;
    text-align: center;
}

.spaced-rep__visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 680px) {
    .spaced-rep {
        margin-top: 24px;
    }

    .spaced-rep__card {
        padding: 16px 14px;
    }

    .spaced-rep__result {
        padding: 14px;
    }

    .spaced-rep__topic {
        grid-template-columns: minmax(0, 1fr) 36px;
    }

    .spaced-rep__topic-name {
        grid-column: 1 / -1;
    }

    .spaced-rep__day {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .spaced-rep__day-topics {
        grid-column: 1 / -1;
    }

    .spaced-rep__when {
        text-align: right;
    }

    .spaced-rep__badge {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .spaced-rep__button--quiet {
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spaced-rep__button {
        transition: none;
    }
}

/* Print just the schedule. */
@media print {
    body > *:not(.content),
    .content > *:not(main),
    main > *:not(.spaced-rep) {
        display: none !important;
    }

    .spaced-rep,
    body.dark .spaced-rep {
        --sr-ink: #000;
        --sr-muted: #555;
        --sr-line: #ccc;
        max-width: none;
        margin: 0;
        color: #000;
    }

    .spaced-rep__card {
        padding: 0;
        border: 0;
        background: none;
        box-shadow: none;
    }

    .spaced-rep__exam,
    .spaced-rep__topics,
    .spaced-rep__actions,
    .spaced-rep__tip {
        display: none;
    }

    .spaced-rep__result {
        margin: 0;
        padding: 0;
        background: none;
    }

    .spaced-rep__day {
        break-inside: avoid;
    }

    .spaced-rep__day.is-past {
        opacity: 1;
    }
}
