/* ====================================
   Layout wrapper
==================================== */

#content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    padding: 0 1em;
    margin: auto;
}

/* ====================================
   Chapter Selector (for mobile)
==================================== */

aside,
.translation-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

aside {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

#lbl-chapter-select {
    font-size: 0.9rem;
    font-style: italic;
    white-space: nowrap;
    flex: 0 0 auto;
}

.select-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

#chapter-select {
    width: 100%;
    padding: 0.7rem 2.5rem 0.7rem 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

#chapter-select:focus {
    outline: none;
    border-color: var(--border);
}

.select-chevron {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.2rem;
    height: 1.2rem;
    color: var(--text);
    pointer-events: none;
    opacity: 0.9;
}

#chapter-select:active+.select-chevron {
    transform: translateY(-50%) scale(0.95);
}

/* ====================================
   Chapter Menu (for desktop)
==================================== */

aside h2 {
    display: none;
    font-family: 'Cinzel', serif;
    font-size: 1.2em;
    color: #4A5A3D;
}

aside li {
    position: relative;
    width: 100%;
    margin-bottom: 0.2em;
}

aside .link {
    display: block;
    padding: 0.3em 3em 0.3em 0.5em;
    color: var(--text);
}

aside .link::after {
    right: 0;
    bottom: -0.1em;
    background-color: #2B3D2F;
    transform-origin: left;
    transition: transform 0.5s ease, height 0.3s ease, background-color 0.3s ease;
}

aside .link:hover::after,
aside .link.active::after {
    transform: scaleX(1);
    height: 3px;
    background-color: var(--accent);
}

aside .link.active {
    color: var(--accent);
    font-weight: 600;
    background-color: #f3f0e6;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.toc-scroll {
    display: none;
    margin-top: 0.5rem;
    position: relative;
    min-height: 0;
    padding-right: 12px;
    overscroll-behavior: contain;
    overflow: hidden;
}

.toc-scroll>ul {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.toc-scroll>ul::-webkit-scrollbar {
    display: none;
}

.faux-scrollbar {
    position: absolute;
    top: 0;
    right: 4px;
    width: 8px;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s;
}

.toc-scroll:hover .faux-scrollbar {
    opacity: 1;
    pointer-events: auto;
}

.faux-scrollbar::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 4px;
    bottom: 4px;
    border-radius: 6px;
    background: transparent;
}

.faux-thumb {
    position: absolute;
    left: 1px;
    right: 1px;
    width: auto;
    border-radius: 6px;
    background: rgba(120, 120, 120, 0.9);
    transition: background .12s, opacity .12s;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.toc-scroll:hover .faux-thumb {
    background: rgba(100, 100, 100, 0.95);
}

.no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* ====================================
   Translation Section
==================================== */

.translations {
    flex: 1;
}

.translation-block {
    display: none;
}

.translation-block.active {
    display: block;
}

.translation-block h3 {
    border-bottom: 1px solid rgba(76, 107, 71, 0.6);
    padding-bottom: 0.3em;
}

.dialogue {
    opacity: 0;
}

.context {
    font-style: italic;
    margin: 1rem 0 0.5rem 0;
}

/* ====================================
   Dialogue boxes
==================================== */

.box {
    padding: 1rem;
    background-color: #f3f0e6;
    border-radius: 4px;
    border-left: 4px solid var(--text);
    opacity: 1;
    transition: opacity 0.4s ease;
    text-align: justify;
}

.box p {
    margin-bottom: 1rem;
}

.box p:last-child {
    margin-bottom: 0;
}

/* ====================================
   Separator between dialogues
==================================== */

.separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1em;
    margin: 1.5rem 0;
    opacity: 0.8;
}

.separator::before,
.separator::after {
    content: "";
    flex: 1;
    height: 2px;
}

.separator::before {
    background: linear-gradient(to right, transparent, #4C6B47);
}

.separator::after {
    background: linear-gradient(to right, #4C6B47, transparent);
}

.separator span {
    color: #4C6B47;
    font-size: 1.1em;
    transform: translateY(-0.1em);
}

/* ====================================
   Media Queries
==================================== */
/* Tablets */
@media (min-width: 600px) {
    .separator {
        margin: 3rem 0;
    }
}

/* Desktops */
@media (min-width: 900px) {
    aside {
        width: auto;
        position: sticky;
        top: 6em;
        max-height: min(60vh, 500px);
        display: grid;
        grid-template-rows: auto 1fr;
        overflow: hidden;
        align-items: unset;
        margin-bottom: 1rem;
        gap: 0;
    }

    #content-wrapper {
        flex-direction: row;
        align-items: flex-start;
        margin: 4em auto;
        padding: 0 1em;
        gap: 2em;
    }

    aside, .translation-block {
        padding: 1.5rem;
    }

    .toc-scroll, aside h2 {
        display: block;
    }

    #lbl-chapter-select, #select-wrapper, #chapter-select, .select-chevron {
        display: none;
    }
}