/* Reading options: the floating "Aa" button and its panel (js/reading-options.js).
   Self-contained, with its own fixed colours, so it can sit on any page of the
   site whatever that page's palette. What the chosen colours actually recolour
   is up to each page's stylesheet, through --read-bg and --read-fg. */

.reading-options {
    --ro-bg: #ffffff;
    --ro-fg: #1a2030;
    --ro-muted: #5f687c;
    --ro-line: #d8dbe2;
    --ro-accent: #1d4c76;
    --ro-night: #0d1221;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1100;
    font-family: 'Jost', 'Segoe UI', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    color: var(--ro-fg);
}

.reading-options *,
.reading-options *::before,
.reading-options *::after { box-sizing: border-box; }

.reading-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.55rem 1rem 0.55rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background-color: var(--ro-night);
    color: #f2f0ea;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(13, 18, 33, 0.28);
}

.reading-toggle:hover { background-color: #1a2236; }

.reading-toggle:focus-visible,
.reading-options button:focus-visible,
.reading-options select:focus-visible,
.reading-options input:focus-visible {
    outline: 3px solid #8cc8ee;
    outline-offset: 2px;
}

.reading-toggle-glyph {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1;
}

.reading-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: 21rem;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
    overflow-y: auto;
    padding: 1.1rem 1.2rem 1.2rem;
    background-color: var(--ro-bg);
    border: 1px solid var(--ro-line);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(13, 18, 33, 0.25);
}

.reading-panel[hidden] { display: none; }

.reading-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.reading-panel h2 {
    margin: 0;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ro-fg);
}

.reading-close {
    width: 2.2rem;
    height: 2.2rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ro-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.reading-close:hover { background-color: #eef0f4; color: var(--ro-fg); }

.reading-group {
    border: 0;
    margin: 0 0 0.9rem;
    padding: 0;
}

.reading-group legend,
.reading-select label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ro-muted);
}

.reading-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr));
    gap: 0.4rem;
}

.reading-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.2rem 0.3rem;
    border: 2px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ro-fg);
    font: inherit;
    font-size: 0.72rem;
    line-height: 1.15;
    text-align: center;
    cursor: pointer;
}

.reading-swatch:hover { background-color: #f3f4f7; }

.reading-swatch[aria-pressed="true"] {
    border-color: var(--ro-accent);
    background-color: #eef3f8;
}

.reading-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    font-family: 'Literata', Georgia, serif;
    font-size: 1rem;
}

.reading-pickers {
    display: flex;
    gap: 1.2rem;
}

.reading-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.reading-picker input[type="color"] {
    width: 2.6rem;
    height: 2.2rem;
    padding: 2px;
    border: 1px solid var(--ro-line);
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
}

.reading-select { margin-bottom: 0.8rem; }

.reading-select select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--ro-line);
    border-radius: 6px;
    background-color: #ffffff;
    color: var(--ro-fg);
    font: inherit;
    font-size: 0.95rem;
}

.reading-reset {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--ro-line);
    border-radius: 6px;
    background-color: #f6f7f9;
    color: var(--ro-fg);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.reading-reset:hover { background-color: #eceef2; }

/* Phones: the button shrinks to its "Aa" so it covers less of the text. */
@media (max-width: 600px) {
    .reading-toggle { padding: 0.55rem 0.75rem; }
    .reading-toggle-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

@media print {
    .reading-options { display: none; }
}

/* Shared tints, mixed from the reader's two colours, for the section
   stylesheets to use: a card a shade off the background, a chip a shade
   further, a rule line, and a muted text colour. */
:root[data-reading] {
    --rd-card: color-mix(in srgb, var(--read-bg) 94%, var(--read-fg));
    --rd-chip: color-mix(in srgb, var(--read-bg) 88%, var(--read-fg));
    --rd-line: color-mix(in srgb, var(--read-bg) 76%, var(--read-fg));
    --rd-muted: color-mix(in srgb, var(--read-fg) 70%, var(--read-bg));
}
