/*
    CORNELL NOTES MAKER

    Markup: src/includes/cornell-notes-maker.njk, behaviour: cornell-maker.N.js.
    Uses the --pf-* tokens of the site-wide "modern shell" in index.NN.css,
    and the same field and button shapes as the Spaced Repetition Calculator.
    The preview sheet stays white in dark mode, because that is what prints.
    The deploy caches this file for a year: bump N in its name (and in the
    include) whenever it changes.
*/

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

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

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

/* The page's article styles centre every p and ul in a 630px column at 17px;
   inside the maker, the blocks below set their own size and spacing. */
.cornell p,
.cornell ul {
    max-width: none;
    letter-spacing: normal;
}

.cornell__label {
    display: block;
    margin: 0 0 8px;
    padding: 0;
    color: var(--cn-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cornell__label--inline {
    display: inline;
    margin: 0;
}

.cornell__hint {
    color: var(--cn-muted);
    font-size: 13px;
}

/* one-click classic sheets */

.cornell__quick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 16px;
    margin-bottom: 18px;
}

.cornell__quick-label {
    color: var(--cn-muted);
    font-size: 15px;
}

.cornell__quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* buttons */

.cornell__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border: 1px solid var(--cn-line);
    border-radius: 999px;
    background: var(--cn-button-bg);
    color: inherit;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s var(--pf-ease-spring), background-color 0.2s;
}

/* Beats `article a` and `body.dark .article a`: the one-click buttons are
   yellow in both themes, so their text stays ink. */
.article a.cornell__button,
body.dark .article a.cornell__button {
    color: var(--pf-ink);
    background-image: none;
}

.cornell__button:hover {
    background-color: var(--cn-button-bg-hover);
    transform: translateY(-1px);
}

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

.cornell__button--block {
    width: 100%;
}

.cornell__button:disabled {
    opacity: 0.6;
    cursor: progress;
    transform: none;
}

.cornell__button:focus-visible,
.cornell__reset:focus-visible,
.cornell__formats a:focus-visible,
.cornell__next a:focus-visible {
    outline: 2px solid var(--pf-primary-deep);
    outline-offset: 2px;
}

/* the card: options · preview · downloads */

.cornell__card {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr) 200px;
    gap: 24px;
    padding: 24px 26px;
    border: 1px solid var(--cn-line);
    border-radius: 18px;
    background: var(--pf-surface);
    box-shadow: var(--pf-shadow-card), var(--pf-inset);
}

.cornell__options {
    margin: 0;
}

.cornell .cornell__heading {
    margin: 0 0 16px;
    font-size: 17px;
    font-weight: 600;
}

.cornell__group {
    margin: 0 0 18px;
    padding: 0;
    border: 0;
    min-width: 0;
}

.cornell__group--row {
    margin-bottom: 14px;
}

.cornell__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cornell__choice {
    position: relative;
    cursor: pointer;
}

.cornell__choice input,
.cornell__check input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.cornell__choice span {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border: 1.5px solid var(--cn-line);
    border-radius: 2rem;
    font-size: 14px;
}

/* Transitions start after the first render (cornell-maker.N.js adds
   .cornell--ready), so restoring saved choices doesn't animate on load. */
.cornell--ready .cornell__choice span,
.cornell--ready .cornell__check span::before {
    transition: background-color 0.2s, border-color 0.2s;
}

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

.cornell__choice input:checked + span {
    border-color: var(--pf-primary-deep);
    background-color: var(--pf-primary);
    color: var(--pf-ink);
    font-weight: 600;
}

.cornell__choice input:focus-visible + span,
.cornell__check input:focus-visible + span::before {
    outline: 2px solid var(--pf-primary-deep);
    outline-offset: 2px;
}

.cornell__checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}

.cornell__check {
    position: relative;
    display: inline-flex;
    font-size: 14px;
    cursor: pointer;
}

.cornell__check span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cornell__check span::before {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--cn-line);
    border-radius: 5px;
    background: var(--cn-field) center / 12px no-repeat;
}

.cornell__check:hover span::before {
    border-color: var(--pf-primary-deep);
}

.cornell__check input:checked + span::before {
    border-color: var(--pf-primary-deep);
    background-color: var(--pf-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.5-5' fill='none' stroke='%23313030' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.cornell__pages {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.cornell__input {
    width: 4.5em;
    padding: 7px 10px;
    border: 1px solid var(--cn-line);
    border-radius: 10px;
    background: var(--cn-field);
    color: inherit;
    font: inherit;
    font-size: 16px;
    color-scheme: light;
}

body.dark .cornell__input {
    color-scheme: dark;
}

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

.cornell__reset {
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--cn-muted);
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.cornell__reset:hover {
    color: var(--cn-ink);
}

/* preview */

.cornell__preview-column {
    min-width: 0;
}

.cornell__preview {
    line-height: 0;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(49, 48, 48, 0.12), 0 14px 30px -18px rgba(49, 48, 48, 0.45);
    overflow: hidden;
}

.cornell .cornell__preview svg,
.cornell .cornell__preview img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.cornell .cornell__caption {
    margin: 12px 0 0;
    color: var(--cn-muted);
    font-size: 13px;
    line-height: 1.5;
}

/* downloads */

.cornell__downloads {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 26px;
}

.cornell .cornell__tip {
    margin: 4px 0 0;
    color: var(--cn-muted);
    font-size: 13px;
    line-height: 1.5;
}

.cornell__tip--warn {
    color: var(--cn-ink);
}

/* fixed copies and next steps */

.cornell__formats,
.cornell__next {
    margin-top: 16px;
    padding: 14px 18px;
    border: 1px solid var(--cn-line);
    border-radius: 14px;
    background: var(--cn-panel);
}

.cornell .cornell__format-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
}

.cornell__format-list li {
    margin: 0;
    padding: 0;
    font-size: 15px;
}

.cornell__format-list li::before {
    content: none;
}

.cornell__formats a,
.cornell__next a {
    color: inherit;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--pf-primary-deep);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.cornell__next {
    font-size: 15px;
    line-height: 1.6;
}

.cornell__next-title {
    margin-right: 8px;
    color: var(--cn-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cornell__next-main {
    font-weight: 600;
}

.cornell__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;
}

/* line-style pictures in the page copy */

.cornell-styles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    max-width: 630px;
    margin: 24px auto 0;
    padding: 0;
}

.cornell-styles figure {
    margin: 0;
}

.article .cornell-styles img {
    margin: 0;
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(49, 48, 48, 0.12), 0 10px 22px -16px rgba(49, 48, 48, 0.45);
}

.cornell-styles figcaption {
    margin-top: 8px;
    font-size: 14px;
    text-align: center;
}

.article .cornell-disclaimer {
    margin-top: 40px;
    color: var(--pf-body);
    font-size: 14px;
}

body.dark .article .cornell-disclaimer {
    color: rgba(255, 255, 255, 0.62);
}

/* Narrower screens: options and preview side by side, downloads below. */
@media (max-width: 900px) {
    .cornell__card {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .cornell__downloads {
        grid-column: 1 / -1;
        padding-top: 0;
    }
}

/* Phones: one column, in the order options, preview, downloads. */
@media (max-width: 620px) {
    .cornell {
        margin-top: 24px;
    }

    .cornell__card {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
        padding: 18px 16px;
    }

    .cornell__quick {
        flex-direction: column;
    }

    .cornell__quick-buttons .cornell__button {
        flex: 1 1 140px;
    }

    .cornell__preview-column {
        max-width: 360px;
        width: 100%;
        margin: 0 auto;
    }

    .cornell-styles {
        gap: 10px;
    }
}

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