@charset "UTF-8";

@font-face {
    font-family: 'Literata';
    src: url('/fonts/Literata-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Literata';
    src: url('/fonts/Literata-Bold.woff2') format('woff2');
    font-weight: bold;
}

@font-face {
    font-family: 'Literata';
    src: url('/fonts/Literata-Italic.woff2') format('woff2');
    font-style: italic;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

:root {
    color-scheme: light dark;
    --body-font: 'Literata', Georgia, serif;
    --heading-font: 'Lexend', sans-serif;
    --text-color: light-dark(#000, #f2f3f4);
    --muted-color: light-dark(#7a7b7c, #a1a2a3);
    --background-color: light-dark(#f2f3f4, #000);
    --hl-background-color: light-dark(#ccc, #444);
    --sn-width: 200px;
    --sn-gap: 35px;
    --link-color: light-dark(#385cc7, #9ab3ff);
    --csz-color: light-dark(#b00, #e44);
}

body {
    font-family: var(--body-font);
    font-size: clamp(1rem, 1rem + 0.3dvmin, 1.25rem);
    background-color: var(--background-color);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

[id] {
    scroll-margin-top: calc(15vh);
}

p {
    text-align: justify;
    hyphens: auto;
    text-wrap: pretty;
    line-height: 1.5;
    margin-bottom: 1em;
}

body:not(.ruby-enabled) ruby {
    display: inline;
    > rt {
        display: none;
    }
}

body.ruby-enabled ruby {
    ruby-align: space-around;
    line-height: 2.2;
    > rt {
        font-size: 0.75em;
        line-height: 1;
        margin: 0 0.5ch;
        color: var(--muted-color);
    }
}

.balance {
    text-wrap: balance;
}

.nowrap {
    text-wrap: nowrap;
}

a {
    color: var(--link-color);
    text-decoration: none;
    outline: none;
}

a:hover,
a:hover * {
    text-decoration: underline;
}

hr {
    width: 33%;
    margin: 35px auto;
    border: none;
    height: 1px;
    background: var(--text-color);
    position: relative;
    overflow: visible;

    &::before {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) rotate(45deg);
        width: 8px;
        height: 8px;
        background-color: var(--text-color);
        box-shadow: 0 0 0 5px var(--background-color);
    }
}

hgroup,
hgroup *,
h1,
h2,
h3 {
    font-family: var(--heading-font);
    text-wrap: balance;
}

site-header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 50;

    > #main-header {
        display: block;
        padding: 10px;
        text-align: center;
        color: var(--text-color);
        background-color: var(--background-color);
        box-shadow: 0 0 12px var(--muted-color);
        text-decoration: none;

        & svg {
            height: 1.6ex;
            width: auto;
            display: inline-block;
            vertical-align: middle;
            margin-right: 8px;
            color: var(--csz-color);
        }

        & h1 {
            text-transform: uppercase;
            letter-spacing: 0.1em;
            font-size: 1.5rem;
            display: inline-block;
            vertical-align: middle;
            font-weight: normal;
        }
    }
}

#home main {
    & p,
    & h1,
    & hgroup,
    & hgroup > * {
        text-align: center;
        font-weight: normal;
        hyphens: none;
    }

    & h1 {
        text-transform: uppercase;
        font-size: 1.66rem;
        margin-bottom: 15px;
    }

    & h2 {
        font-size: 1.66rem;
    }
}

& .info-box {
    background-color: var(--hl-background-color);
    width: fit-content;
    max-width: 80%;
    margin: 2em auto;
    padding: 1em 1.5em;
    border-radius: 0.5em;
    text-align: justify;
    hyphens: auto;
    text-wrap: pretty;

    & p:last-of-type {
        margin-bottom: 0;
    }
}

header.book {
    position: relative;
    width: 100%;

    > img {
        display: block;
        width: 100%;
        height: auto;
        max-height: 150vh;
        object-fit: cover;
        object-position: center center;
        mask-image: linear-gradient(
            to bottom,
            hsl(0, 0%, 0%) calc(100% - 15dvh),
            hsla(0, 0%, 0%, 0.738) calc(100% - 15dvh * 0.81),
            hsla(0, 0%, 0%, 0.541) calc(100% - 15dvh * 0.66),
            hsla(0, 0%, 0%, 0.382) calc(100% - 15dvh * 0.53),
            hsla(0, 0%, 0%, 0.278) calc(100% - 15dvh * 0.435),
            hsla(0, 0%, 0%, 0.194) calc(100% - 15dvh * 0.35),
            hsla(0, 0%, 0%, 0.126) calc(100% - 15dvh * 0.27),
            hsla(0, 0%, 0%, 0.075) calc(100% - 15dvh * 0.198),
            hsla(0, 0%, 0%, 0.042) calc(100% - 15dvh * 0.139),
            hsla(0, 0%, 0%, 0.021) calc(100% - 15dvh * 0.09),
            hsla(0, 0%, 0%, 0.008) calc(100% - 15dvh * 0.048),
            hsla(0, 0%, 0%, 0.002) calc(100% - 15dvh * 0.018),
            hsla(0, 0%, 0%, 0) 100%
        );
    }

    > .cover-portrait {
        display: none;
        aspect-ratio: 9 / 16;
    }

    > .cover-landscape {
        display: block;
        aspect-ratio: 3 / 2;
    }

    > hgroup {
        position: absolute;
        top: 5%;
        left: 50%;
        transform: translateX(-50%);
        background-color: rgba(0, 0, 0, 0.6);
        padding: max(.5rem, 3%) max(1rem, 8%);
        text-align: center;
        color: #f2f3f4;
        max-width: 90%;

        > * { text-align: center; }

        > h1 {
            font-size: max(1.1rem, 4vw);
            font-weight: bold;
            margin-bottom: 0.5em;
        }

        > h2 {
            font-size: max(1rem, 2.5vw);
            font-weight: normal;
            margin-bottom: 0.5em;
        }

        > p {
            font-size: max(0.875rem, 2vw);
            font-weight: normal;
        }
    }
}

@media (prefers-color-scheme: dark) {

    header img,
    .book-card img {
        filter: brightness(0.7) contrast(0.9) saturate(0.8);
    }
}

side-note {
    display: inline;
    white-space: nowrap;
    
    & .sn-toggle {
        display: none;
    }

    & .sn-idx {
        display: inline-block;
        max-height: 2rem;
        counter-increment: sn-counter;
        user-select: none;
        pointer-events: none;
        text-decoration: none;
    }

    & .sn-idx::after {
        content: counter(sn-counter);
        cursor: pointer;
        font-size: 0.8rem;
        top: -0.5rem;
        position: relative;
        vertical-align: baseline;
        user-select: none;
        text-decoration: none;
    }

    & .sn::before {
        content: counter(sn-counter);
        padding-right: 0.1rem;
        font-size: 0.8rem;
        top: -0.2rem;
        position: relative;
        vertical-align: baseline;
        user-select: none;
    }

    & .sn {
        float: right;
        clear: right;
        width: var(--sn-width);
        margin-right: calc(-1 * var(--sn-width) - var(--sn-gap));
        margin-left: var(--sn-gap);
        margin-top: 0.3rem;
        margin-bottom: 20px;
        font-size: 0.9rem;
        line-height: 1.4;
        position: relative;
        white-space: normal;
    }
}

main {
    max-width: 65ch;
    margin: 0 auto;
    padding: 2rem 1rem 5rem;

    > * {
        max-width: 65ch;
    }

    & strong {
        font-weight: normal;
        font-variant: small-caps;
    }
}

main.book {
    max-width: calc(45ch + var(--sn-width) + var(--sn-gap));

    & section {
        counter-reset: sn-counter;

        & img {
            display: block;
            height: 50svh;
            width: auto;
            max-width: 100%;
            margin: 30px auto;
        }

        & footer.signature {
            text-align: right;
            margin-top: 1em;
            font-style: italic;
        }

        & footer {
            text-align: justify;
            hyphens: auto;
            text-wrap: pretty;
            font-size: smaller;
        }
    }

    & [data-pid].audio-playing {
        background-color: var(--hl-background-color);
        box-shadow: 0 0 0 10px var(--hl-background-color);
    }

    & [data-pid].audio-playing:not(hgroup) {
        border-radius: 0.5em;
    }

    & nav ul {
        list-style: none;

        >li {
            text-align: justify;
            hyphens: auto;
            text-wrap: pretty;
            line-height: 1.1;
            margin-bottom: 6px;
        }

        >li.break {
            margin-top: 25px;
        }
    }

    & h2 {
        font-weight: 500;
        font-size: clamp(1.5rem, 1.5rem + 1vw, 2rem);
        margin: 1em 0;

        > a {
            color: inherit;
            text-decoration: none;
        }

        > a:hover {
            text-decoration: underline;
        }
    }

    & section hgroup {
        margin: 2em 0 1em;
        position: relative;
        border-bottom: 1.2pt solid currentColor;
        padding-bottom: 2pt;
    }

    & section hgroup p {
        text-transform: uppercase;
        font-size: 0.9rem;
        margin-bottom: 0;
        text-align: left;
    }

    & section hgroup h2 {
        margin: 0;
        position: relative;

        & .chapter-play-button {
            position: absolute;
            left: -25px;
            bottom: 10px;
            background: none;
            border: none;
            color: var(--text-color);
            cursor: pointer;
            padding-right: 5px;
            display: inline-block;
            opacity: 0.5;
            transition: opacity 0.2s ease, transform 0.2s ease;

            &:hover {
                opacity: 1;
                transform: scale(1.1);
            }

            & svg {
                display: block;
                width: 20px;
                height: 20px;
            }
        }

        @media (max-width: 850px) {
            & .chapter-play-button {
                position: static;
                display: inline-flex;
                vertical-align: baseline;
            }
        }
    }

    & #colophon {
        border-top: 1px solid currentColor;
        margin-top: 2em;
        padding-top: 2em;

        & p {
            text-align: center;
        }
    }
}

@media (max-width: 1200px) {
    main {
        max-width: 45ch;
    }

    main > * {
        margin-left: auto;
        margin-right: auto;
    }

    .sn-toggle {
        display: none;
    }

    .sn-toggle~.sn {
        display: none;
    }

    .sn-toggle:checked~.sn {
        display: block;
        float: none;
        position: static;
        width: 100%;
        margin: 1em 0;
        clear: both;
        padding: 0.5em 0;
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
    }

    side-note {
        & .sn-idx {
            pointer-events: auto;
            cursor: pointer;
            color: var(--link-color);
        }

        & .sn-idx::after {
            text-decoration: underline;
        }

        & .sn-idx:hover::after {
            text-decoration: none;
        }
    }
}

@media (min-width: 1201px) and (max-width: 1319px) {
    :root {
        --sn-width: 200px;
    }
}

@media (min-width: 1320px) {
    :root {
        --sn-width: 250px;
    }
}

@media (min-width: 1550px) {
    :root {
        --sn-width: 300px;
    }
}

@media (orientation: portrait) {
    header.book > .cover-portrait {
        display: block;
    }

    header.book > .cover-landscape {
        display: none;
    }
}

.book-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    margin: 10px auto 25px auto;
    padding: 0 1rem;

    & .book-card {
        display: block;
        text-decoration: none;
        width: min(100%, 400px);
        transition: transform 0.2s ease;
        border-radius: 10px;
        position: relative;

        & img {
            width: 100%;
            height: auto;
            display: block;
            border-radius: 10px;
        }

        & .book-info {
            position: absolute;
            top: 8%;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.6);
            padding: max(.5rem, 3%) max(1rem, 8%);
            text-align: center;
            max-width: 90%;

            & .book-title {
                font-family: var(--heading-font);
                font-size: 1.25rem;
                font-weight: bold;
                color: #f2f3f4;
                margin-bottom: 0.5em;
                text-transform: uppercase;
                text-wrap: balance;
            }

            & .book-author {
                font-family: var(--heading-font);
                font-size: 1rem;
                color: #f2f3f4;
                text-transform: uppercase;
            }
        }
    }

    & .book-card:hover {
        transform: translateY(-4px);

        & * {
            text-decoration: none;
        }
    }
}

#audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--background-color);
    padding: 0.25rem 0.5rem;
    z-index: 100;
    box-shadow: 0 0 12px var(--muted-color);

    & nav {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: clamp(10px, 2dvw, 1rem);
        margin: 0 auto;
    }

    & .time-display {
        font-size: 0.75rem;
        font-family: var(--heading-font);
        opacity: 0.7;
        min-width: 3em;
        text-align: center;
    }

    & .progress-bar {
        flex: 1;
        max-width: 200px;
        height: 16px;
        background-color: transparent;
        border: 1.5px solid currentColor;
        border-radius: 8px;
        overflow: hidden;
    }

    & .progress-fill {
        height: 100%;
        background-color: currentColor;
        width: 0%;
        transition: width 0.1s ease-out;
    }

    & button {
        background: none;
        border: none;
        color: currentColor;
        cursor: pointer;
        padding: 10px 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        transition: all 0.2s ease;
        touch-action: manipulation;

        &:hover {
            transform: scale(1.2);
        }

        &:active {
            transform: scale(0.95);
        }

        & svg {
            display: block;
            width: 24px;
            height: 24px;
        }
    }

    & button.play-pause {
        & svg {
            width: 28px;
            height: 28px;
        }
    }
}