/*
 * Lokadarshan newspaper reader.
 */

/* The reader fills the window: the page itself never scrolls, only the
   newspaper stage and the thumbnail rail do. */
body.is-reader {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.is-reader .ld-site {
    height: 100%;
    min-height: 0;
}

.is-reader .ld-header {
    flex: none;
}

.is-reader .ld-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.ld-reader {
    --ld-bar-h: 60px;
    --ld-thumbs-w: 172px;
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    background: #e5e8ee;
}

.ld-reader > * {
    flex: none;
}

@media (max-width: 991.98px) {
    .ld-reader {
        --ld-bar-h: 56px;
    }

    /* Room for the fixed bottom bar. */
    .is-reader .ld-main {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
}

.ld-only-mobile {
    display: none !important;
}

@media (max-width: 991.98px) {
    .ld-only-desktop {
        display: none !important;
    }

    .ld-only-mobile {
        display: flex !important;
    }
}

.ld-reader__preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px var(--ld-gutter);
    background: var(--ld-amber-soft);
    color: #6d4200;
    font-weight: 600;
}

/* ---------------------------------------------------------------- Toolbar */

.ld-reader__bar {
    position: sticky;
    top: 0;
    z-index: 1025;
    display: flex;
    align-items: center;
    gap: 8px 12px;
    min-height: var(--ld-bar-h);
    padding: 8px clamp(8px, 2vw, 16px);
    border-bottom: 1px solid #d8ce22;
    background: var(--ld-yellow);
    box-shadow: 0 2px 10px rgba(27, 35, 51, 0.12);
}

.ld-bar__group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* Only the title shrinks (with an ellipsis); control groups keep their size. */
.ld-bar__group--start {
    flex: 1 1 auto;
}

.ld-bar__group--pages,
.ld-bar__group--zoom,
.ld-bar__group--end {
    flex: none;
}

.ld-bar__group--end {
    margin-left: auto;
}

.ld-bar-btn {
    --bs-btn-bg: rgba(255, 255, 255, 0.92);
    --bs-btn-color: var(--ld-ink);
    --bs-btn-border-color: rgba(27, 35, 51, 0.2);
    --bs-btn-hover-bg: #fff;
    --bs-btn-hover-color: var(--ld-ink);
    --bs-btn-hover-border-color: rgba(27, 35, 51, 0.45);
    --bs-btn-active-bg: #fff;
    --bs-btn-active-color: var(--ld-blue-ink);
    --bs-btn-active-border-color: var(--ld-ink);
    --bs-btn-disabled-bg: rgba(255, 255, 255, 0.55);
    --bs-btn-disabled-color: var(--ld-ink-3);
    --bs-btn-disabled-border-color: rgba(27, 35, 51, 0.12);
    --bs-btn-padding-x: 0.6rem;
    min-width: 40px;
    min-height: 40px;
    font-weight: 600;
    white-space: nowrap;
}

.ld-bar-btn[aria-pressed="true"] {
    --bs-btn-bg: var(--ld-ink);
    --bs-btn-color: #fff;
    --bs-btn-border-color: var(--ld-ink);
    --bs-btn-hover-bg: var(--ld-ink);
    --bs-btn-hover-color: #fff;
}

.ld-bar-btn.dropdown-toggle::after {
    margin-left: 0.1rem;
}

.ld-bar-text {
    font-size: 0.9375rem;
}

@media (max-width: 1279.98px) {
    .ld-hide-below-xl {
        display: none !important;
    }
}

@media (max-width: 1439.98px) {
    .ld-bar__group--end .ld-bar-text {
        display: none;
    }
}

.ld-reader__title {
    display: grid;
    min-width: 0;
    margin-left: 4px;
    line-height: 1.15;
}

.ld-reader__title h1 {
    margin: 0;
    overflow: hidden;
    font-size: 1.0625rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ld-reader__title span {
    overflow: hidden;
    color: #3b4558;
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ld-page-select {
    width: auto;
    min-width: 150px;
    min-height: 40px;
    border-color: rgba(27, 35, 51, 0.2);
    font-weight: 600;
}

.ld-zoom-label {
    min-width: 72px;
    color: var(--ld-ink);
    font-size: 0.875rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ld-more-menu {
    min-width: 240px;
    padding: 6px;
}

.ld-more-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    border-radius: var(--ld-radius-s);
}

.ld-effect-setting {
    margin: 0;
    padding: 6px 12px 8px;
    border: 0;
}

.ld-effect-setting legend {
    float: none;
    margin-bottom: 4px;
    color: var(--ld-ink-3);
    font-size: 0.8125rem;
    font-weight: 600;
}

.ld-effect-setting label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    cursor: pointer;
}

.ld-effect-setting .ld-effect-setting__sound {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--ld-line);
}

/* ---------------------------------------------------------------- Body */

.ld-reader__body {
    position: relative;
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
}

@media (min-width: 992px) {
    .ld-reader__body {
        grid-template-columns: var(--ld-thumbs-w) minmax(0, 1fr);
    }

    .ld-reader[data-thumbs="closed"] .ld-reader__body {
        grid-template-columns: 0 minmax(0, 1fr);
    }
}

/* Thumbnails */
.ld-thumbs {
    display: none;
}

@media (min-width: 992px) {
    .ld-thumbs {
        display: block;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-right: 1px solid var(--ld-line);
        background: var(--ld-surface);
        scrollbar-width: thin;
    }

    .ld-reader[data-thumbs="closed"] .ld-thumbs {
        visibility: hidden;
        border: 0;
    }
}

.ld-thumbs ol,
.ld-drawer-thumbs {
    margin: 0;
    padding: 10px 0;
    list-style: none;
}

.ld-thumb {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: 8px 18px;
    border: 0;
    background: transparent;
    color: var(--ld-ink-2);
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
}

.ld-thumb img,
.ld-thumb__placeholder {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--ld-line);
    border-radius: 2px;
    background: #fff;
    box-shadow: var(--ld-shadow-1);
    aspect-ratio: 240 / 357;
    object-fit: cover;
    object-position: top center;
}

.ld-thumb__placeholder {
    display: grid;
    place-items: center;
    color: var(--ld-ink-3);
    font-size: 1.5rem;
}

.ld-thumb:hover img {
    border-color: var(--ld-line-strong);
}

.ld-thumb[aria-current="page"] {
    color: var(--ld-blue-ink);
}

.ld-thumb[aria-current="page"] img,
.ld-thumb[aria-current="page"] .ld-thumb__placeholder {
    outline: 3px solid var(--ld-blue);
    outline-offset: 2px;
}

.ld-thumb:focus-visible {
    outline-offset: -3px;
}

/* Stage */
.ld-stage {
    position: relative;
    min-width: 0;
    padding: clamp(8px, 1.6vw, 20px);
    overflow: auto;
    overscroll-behavior: contain;
    touch-action: manipulation;
    scrollbar-gutter: stable;
}

.ld-stage:focus-visible {
    outline: 3px solid var(--ld-blue);
    outline-offset: -3px;
}

.ld-reader[data-zoomed="true"] .ld-stage {
    cursor: grab;
}

.ld-stage.is-panning {
    cursor: grabbing;
    user-select: none;
}

.ld-page-wrap {
    position: relative;
    width: 100%;
    margin-inline: auto;
}

/* A PDF page fills the stage and scrolls inside its own viewer. */
.ld-page-wrap:has(> .ld-pdf:not([hidden])) {
    height: 100%;
}

.ld-page {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    box-shadow: var(--ld-shadow-paper);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ld-pdf {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 300px;
    border: 0;
    background: #fff;
    box-shadow: var(--ld-shadow-paper);
}

.ld-stage__status {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 16px;
    pointer-events: none;
}

.ld-stage__status-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 420px;
    padding: 14px 18px;
    border-radius: var(--ld-radius);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--ld-shadow-2);
    font-weight: 600;
    text-align: center;
    pointer-events: auto;
}

.ld-stage__status.is-error .ld-stage__status-box {
    color: var(--ld-red);
}

/* Edge arrows (pointer devices): always visible, brand blue. */
.ld-edge {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: none;
    place-items: center;
    width: 44px;
    height: 88px;
    border: 2px solid #fff;
    background: var(--ld-blue);
    color: #fff;
    font-size: 1.5rem;
    -webkit-text-stroke: 0.5px currentColor;
    box-shadow: 0 6px 18px rgba(23, 63, 159, 0.35);
    transform: translateY(-50%);
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.ld-edge:hover {
    background: var(--ld-blue-ink);
    box-shadow: 0 8px 22px rgba(23, 63, 159, 0.5);
}

.ld-edge:active {
    background: #12347f;
}

.ld-edge:focus-visible {
    outline: 3px solid var(--ld-yellow);
    outline-offset: 2px;
}

.ld-edge--prev {
    left: calc(var(--ld-thumbs-w) + 8px);
    border-radius: 0 var(--ld-radius) var(--ld-radius) 0;
}

.ld-reader[data-thumbs="closed"] .ld-edge--prev {
    left: 8px;
}

.ld-edge--next {
    right: 22px;
    border-radius: var(--ld-radius) 0 0 var(--ld-radius);
}

@media (hover: hover) and (min-width: 992px) {
    .ld-edge {
        display: grid;
    }
}

.ld-edge:disabled {
    visibility: hidden;
}

/* Page-turn layers (created by ld-reader.js): the turning sheet is drawn
   on a canvas over the stage, with a still copy of the page beneath it when
   that page is not the one on the stage. Both stay under the edge arrows
   and the loading message. */
.ld-curl,
.ld-turn {
    position: absolute;
    pointer-events: none;
}

.ld-turn {
    z-index: 1;
    overflow: hidden;
    background: #fff;
}

.ld-turn img {
    position: absolute;
    max-width: none;
}

/* Its own layer, so redrawing it doesn't repaint the page underneath. */
.ld-curl {
    z-index: 2;
    will-change: transform;
}

/* Bottom bar (small screens) */
.ld-reader__bottom {
    position: fixed;
    inset: auto 0 0;
    z-index: 1030;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #d8ce22;
    background: var(--ld-yellow);
    box-shadow: 0 -2px 10px rgba(27, 35, 51, 0.12);
}

/* Next is the main action on a phone, so it stands out from Prev. */
.ld-reader__bottom [data-ld-nav="next"] {
    --bs-btn-bg: var(--ld-blue);
    --bs-btn-color: #fff;
    --bs-btn-border-color: var(--ld-blue);
    --bs-btn-hover-bg: var(--ld-blue-ink);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-border-color: var(--ld-blue-ink);
    --bs-btn-active-bg: #12347f;
    --bs-btn-active-color: #fff;
    --bs-btn-active-border-color: #12347f;
}

.ld-bottom-pages {
    min-width: 0;
}

/* Touch screens: label shown while a page is dragged sideways */
.ld-swipe-label {
    position: absolute;
    top: 50%;
    z-index: 7;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(27, 35, 51, 0.84);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(27, 35, 51, 0.25);
    transform: translateY(-50%);
    pointer-events: none;
    transition: background-color 0.12s ease;
}

.ld-swipe-label[hidden] {
    display: none;
}

.ld-swipe-label[data-side="right"] {
    right: 12px;
}

.ld-swipe-label[data-side="left"] {
    left: 12px;
}

/* Far enough: letting go now turns the page. */
.ld-swipe-label.is-ready {
    background: var(--ld-blue);
}

/* First-visit hint on touch screens */
.ld-swipe-hint {
    position: absolute;
    top: 46%;
    left: 50%;
    z-index: 7;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 18px 10px 14px;
    border-radius: 999px;
    background: rgba(27, 35, 51, 0.88);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(27, 35, 51, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: ld-hint-in 0.25s ease-out;
    transition: opacity 0.2s ease;
}

.ld-swipe-hint[hidden] {
    display: none;
}

.ld-swipe-hint.is-leaving {
    opacity: 0;
}

.ld-swipe-hint__hand {
    display: inline-grid;
    color: var(--ld-yellow);
    font-size: 1.4rem;
    animation: ld-hint-swipe 1.3s ease-in-out 3;
}

@keyframes ld-hint-in {
    from {
        opacity: 0;
    }
}

@keyframes ld-hint-swipe {
    0%,
    100% {
        transform: translateX(7px);
    }

    50% {
        transform: translateX(-7px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ld-swipe-hint,
    .ld-swipe-hint__hand {
        animation: none;
    }
}

.ld-bottom-pages span {
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 992px) {
    .ld-reader__bottom {
        display: none;
    }
}

/* Mobile pages drawer */
.ld-pages-drawer {
    --bs-offcanvas-height: min(70vh, 560px);
}

.ld-drawer-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 4px;
    padding: 0;
}

.ld-drawer-thumbs .ld-thumb {
    padding: 6px;
}

/* Crop bar */
.ld-cropbar {
    position: fixed;
    inset: auto 0 0;
    z-index: 1040;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--ld-line);
    background: #fff;
    box-shadow: 0 -6px 20px rgba(27, 35, 51, 0.15);
}

.ld-cropbar[hidden] {
    display: none;
}

.ld-cropbar__hint {
    color: var(--ld-ink-2);
    font-weight: 600;
}

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

@media (max-width: 575.98px) {
    .ld-cropbar__hint {
        width: 100%;
        font-size: 0.875rem;
    }

    .ld-cropbar__actions {
        width: 100%;
    }

    .ld-cropbar__actions .btn {
        flex: 1 1 0;
        padding-inline: 0.4rem;
    }
}

.ld-reader.is-cropping .ld-reader__bottom,
.ld-reader.is-cropping .ld-edge {
    display: none;
}

.cropper-container {
    max-width: 100%;
}

/* Fullscreen */
.ld-reader:fullscreen {
    overflow: hidden;
    background: #e5e8ee;
}

/* Shortcuts dialog */
.ld-shortcuts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 12px 0 0;
}

.ld-shortcuts dt {
    white-space: nowrap;
}

.ld-shortcuts dd {
    margin: 0;
    color: var(--ld-ink-2);
}

.ld-shortcuts kbd {
    display: inline-block;
    min-width: 1.8em;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--ld-line-strong);
    border-radius: 4px;
    background: var(--ld-paper);
    color: var(--ld-ink);
    font-size: 0.8125rem;
    text-align: center;
    box-shadow: inset 0 -1px 0 var(--ld-line-strong);
}

/* Clickable articles laid over the page */
.ld-hotspots {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.ld-hotspot {
    position: absolute;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 2px;
    background: transparent;
    cursor: pointer;
    outline: 2px solid transparent;
    outline-offset: -1px;
    transition: background-color 0.15s ease, outline-color 0.15s ease;
    -webkit-tap-highlight-color: rgba(200, 18, 111, 0.12);
}

@media (hover: hover) {
    .ld-hotspot:hover {
        background: rgba(200, 18, 111, 0.07);
        outline-color: rgba(200, 18, 111, 0.85);
    }
}

.ld-hotspot:focus-visible {
    background: rgba(36, 87, 214, 0.08);
    outline: 3px solid var(--ld-blue);
}

/* Drafts are only sent to CMS admins previewing the edition. */
.ld-hotspot[data-draft="true"] {
    outline: 2px dashed rgba(138, 83, 0, 0.65);
}

.ld-reader.is-cropping .ld-hotspots,
.ld-stage.is-panning .ld-hotspots {
    pointer-events: none;
}

.ld-reader.is-cropping .ld-hotspots {
    display: none;
}

/* Article dialog */
.ld-article {
    width: min(1000px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100dvh - 24px);
    padding: 0;
    border: 0;
    border-radius: var(--ld-radius-l);
    background: var(--ld-surface);
    color: var(--ld-ink);
    box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.5);
    overflow: hidden;
}

.ld-article[open] {
    display: flex;
    flex-direction: column;
}

.ld-article::backdrop {
    background: rgba(15, 23, 42, 0.72);
}

.ld-article__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 10px 10px 18px;
    border-bottom: 1px solid var(--ld-line);
}

.ld-article__heading {
    min-width: 0;
}

.ld-article__title {
    margin: 0;
    font-family: var(--ld-font-display);
    font-size: var(--ld-step-1);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.ld-article__meta {
    margin: 2px 0 0;
    color: var(--ld-ink-3);
    font-size: var(--ld-step--1);
}

.ld-article__body {
    position: relative;
    flex: 1 1 auto;
    min-height: 220px;
    padding: clamp(8px, 2vw, 18px);
    overflow: auto;
    overscroll-behavior: contain;
    background: var(--ld-paper);
}

.ld-article__image {
    display: block;
    max-width: 100%;
    height: auto;
    margin-inline: auto;
    background: #fff;
    box-shadow: var(--ld-shadow-paper);
}

.ld-article__loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    padding: 16px;
    color: var(--ld-ink-2);
    text-align: center;
}

.ld-article__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--ld-line);
}

.ld-article__share {
    display: flex;
    gap: 6px;
}

.ld-article__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 575.98px) {
    .ld-article {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
    }

    .ld-article__actions .btn {
        padding-inline: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ld-edge,
    .ld-hotspot {
        transition: none;
    }
}

@media print {
    .ld-reader__bar,
    .ld-reader__bottom,
    .ld-thumbs,
    .ld-edge,
    .ld-hotspots {
        display: none !important;
    }

    body.is-reader,
    .is-reader .ld-site {
        height: auto;
        overflow: visible;
    }

    .ld-reader__body {
        display: block;
        height: auto;
    }

    .ld-stage {
        overflow: visible;
        padding: 0;
    }

    .ld-page {
        box-shadow: none;
    }
}
