/*
 * How an article is read (js/blog-settings.js): the size of the letters of the text (only the text of the article, not the blocks around it), the text justified to a
 * block, and the reading mode, which covers the whole site with the article alone, so nothing around it disturbs the reader. The button with the settings is in
 * the bar of the reading (Blog/detail.latte) and opens the panel below it.
 */

/* ---- the size of the letters: three, the middle one is the usual ---- */
.blog-page.blog-font-small {
    --blog-text-size: 1rem;
}

.blog-page.blog-font-large {
    --blog-text-size: 1.32rem;
}

/* ---- the text justified to a block: only on a screen wide enough for it (on a narrow column the gaps between the words grow) ---- */
@media (min-width: 768px) {
    .blog-page.is-justified .blog-body p,
    .blog-page.is-justified .blog-body li {
        text-align: justify;
        hyphens: auto;
        -webkit-hyphens: auto;
    }
}

/* ---- the panel with the settings, under the bar ---- */
.blog-settings {
    position: absolute;
    top: calc(100% + .4rem);
    right: 0;
    z-index: 5;
    width: min(21rem, 100%);
    padding: .9rem 1rem 1rem;
    background: #fff;
    border: 1px solid #dedcd6;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(20, 40, 70, .18);
}

.blog-settings[hidden] {
    display: none;
}

.blog-settings-title {
    margin: 0 0 .4rem;
    color: #5a6878;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.blog-settings-group + .blog-settings-group {
    margin-top: .9rem;
}

.blog-settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.blog-setting {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-width: 3rem;
    padding: .35rem .8rem;
    background: #fff;
    border: 2px solid #cfd8e3;
    border-radius: 999px;
    color: #2d3b4b;
    font-weight: 700;
    cursor: pointer;
}

.blog-setting:hover,
.blog-setting:focus-visible {
    border-color: var(--blog-accent);
}

.blog-setting[aria-pressed="true"],
.blog-setting[aria-checked="true"] {
    background: var(--blog-fill);
    border-color: var(--blog-fill);
    color: #fff;
}

.blog-setting[hidden] {
    display: none;
}

/* the paper before the reading mode is on: visibly off, with the reason under it */
.blog-setting:disabled {
    opacity: .45;
    border-color: #cfd8e3;
    cursor: not-allowed;
}

.blog-settings-hint {
    margin: .45rem 0 0;
    color: #5a6878;
    font-size: .82rem;
}

.blog-settings-hint[hidden] {
    display: none;
}

/* the justifying is offered only where it is done */
.blog-settings-group--justify {
    display: none;
}

@media (min-width: 768px) {
    .blog-settings-group--justify {
        display: block;
    }
}

/* the button that leaves the reading mode is only in the reading mode */
.blog-bar-exit {
    display: none;
}

/* ---- the reading mode: the article alone over the whole site ---- */
html.blog-reading-open {
    overflow: hidden;
}

.blog-page.is-reading {
    --reading-bg: #fff;
    --reading-text: #1f2d3d;
    --blog-sticky-top: 0px;
    position: fixed;
    inset: 0;
    z-index: 1900;
    max-width: none;
    margin: 0;
    padding: 0 1rem 4rem;
    overflow-y: auto;
    background: var(--reading-bg);
    color: var(--reading-text);
}

.blog-page.is-reading .blog-article {
    max-width: 48rem;
    margin: 0 auto;
    padding-top: 1.25rem;
}

/* what is not the article is not there: the tips and the other articles under it, the invitation, the table of contents at the side */
.blog-page.is-reading .blog-tips,
.blog-page.is-reading .blog-others,
.blog-page.is-reading .info-cta,
.blog-page.is-reading .blog-toc {
    display: none;
}

.blog-page.is-reading .blog-layout {
    display: block;
}

.blog-page.is-reading .blog-layout > .blog-main {
    max-width: none;
}

.blog-page.is-reading .blog-bar {
    top: .5rem;
}

.blog-page.is-reading .blog-bar-exit {
    display: inline-block;
}

.blog-page.is-reading .blog-title,
.blog-page.is-reading .blog-lead,
.blog-page.is-reading .blog-body,
.blog-page.is-reading .blog-bar-label {
    color: var(--reading-text);
}

/* the paper: warm, for the eyes in the evening (the dark reading is the dark theme of the site) */
.blog-page.is-reading[data-reading-theme="sepia"] {
    --reading-bg: #f4ecd8;
    --reading-text: #3b2f1e;
}

.blog-page.is-reading[data-reading-theme="sepia"] .blog-bar,
.blog-page.is-reading[data-reading-theme="sepia"] .blog-settings,
.blog-page.is-reading[data-reading-theme="sepia"] .blog-bar-menu {
    background: #faf4e4;
    border-color: #d9ccaa;
}

html[data-theme="dark"] .blog-page.is-reading {
    --reading-bg: var(--dark-page);
    --reading-text: var(--dark-text);
}

html[data-theme="dark"] .blog-settings {
    background: var(--dark-surface);
    border-color: var(--dark-border);
}

html[data-theme="dark"] .blog-settings-title,
html[data-theme="dark"] .blog-settings-hint {
    color: var(--dark-muted);
}

html[data-theme="dark"] .blog-setting {
    background: var(--dark-surface-2);
    border-color: var(--dark-border);
    color: var(--dark-text);
}

html[data-theme="dark"] .blog-setting[aria-pressed="true"],
html[data-theme="dark"] .blog-setting[aria-checked="true"] {
    background: var(--blog-fill);
    border-color: var(--blog-fill);
    color: #fff;
}
