/* =========================================================
   01. GLOBAL THEME VARIABLES
   ========================================================= */

:root {
    --header-bg: #ffffff;
    --footer-bg: #20374e;
    --footer-text: #ffffff;
    --viewer-bg: #e4e9ef;

    --toolbar-bg: #263d54;
    --toolbar-text: #ffffff;
    --toolbar-hover: #3e5d7b;

    --accent-color: #41c4f8;
    --text-color: #263747;

    --header-height: 85px;
    --footer-height: 75px;

    --logo-max-width: 260px;
    --logo-max-height: 62px;

    --border-radius: 8px;

    --transition-speed: 0.2s;

    --font-family: Arial, Helvetica, sans-serif;
}

/* =========================================================
   02. RESET AND BASE STYLES
   ========================================================= */

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

html {
    min-height: 100%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;

    display: flex;
    flex-direction: column;

    background-color: var(--viewer-bg);
    color: var(--text-color);
    font-family: var(--font-family);

    overflow-x: hidden;

    /* Discourage text selection and image dragging. */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;

    -webkit-touch-callout: none;
}

[hidden] {
    display: none !important;
}

button {
    font: inherit;
}

img,
canvas {
    -webkit-user-drag: none;
    user-select: none;
}

/* =========================================================
   03. HEADER SECTION
   ========================================================= */

.site-header {
    position: relative;
    z-index: 10;

    display: flex;
    align-items: center;
    justify-content: center;

    min-height: var(--header-height);
    padding: 12px 20px;

    background-color: var(--header-bg);

    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.company-logo {
    display: block;

    width: auto;
    height: auto;

    max-width: min(100%, var(--logo-max-width));
    max-height: var(--logo-max-height);

    object-fit: contain;
}

/* =========================================================
   04. MAIN SECTION
   ========================================================= */

.site-main {
    display: flex;
    flex-direction: column;
    flex: 1;

    width: 100%;
    min-width: 0;

    padding: 18px;

    background: radial-gradient(
        ellipse at center,
        #f5f7fa 0%,
        var(--viewer-bg) 65%,
        #c5ced9 100%
    );
}

.viewer-shell {
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    flex: 1;
    min-width: 0;
    width: 100%;

    gap: 14px;
}

/* =========================================================
   05. FLIPBOOK VIEWPORT
   ========================================================= */

.book-viewport {
    width: 100%;
    height: 70vh;
    height: 70dvh;

    min-height: 220px;

    display: flex;

    overflow: auto;
    overscroll-behavior: contain;

    scrollbar-width: thin;
    cursor: pointer;
}

.book-stage {
    position: relative;

    flex-shrink: 0;

    margin: auto;
    min-width: 1px;
    min-height: 1px;
}

#flipbook {
    margin: auto;
}

/* Each PDF page is rendered into a canvas element. */

.pdf-page {
    background-color: #ffffff;
    overflow: hidden;
}

.pdf-page canvas {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;
    pointer-events: none;
}

/* =========================================================
   06. VIEWER CONTROL TOOLBAR
   ========================================================= */

.viewer-toolbar {
    display: flex;

    align-items: center;
    justify-content: center;
    flex-wrap: wrap;

    gap: 4px;
    padding: 6px;

    max-width: 100%;

    background-color: var(--toolbar-bg);
    color: var(--toolbar-text);

    border-radius: var(--border-radius);

    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);

    user-select: none;
}

.viewer-toolbar button {
    display: inline-flex;

    justify-content: center;
    align-items: center;

    min-width: 38px;
    min-height: 38px;

    padding: 6px 10px;

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: var(--toolbar-text);

    font-size: 18px;

    cursor: pointer;

    transition:
        background-color var(--transition-speed),
        opacity var(--transition-speed);
}

@media (hover: hover) {
    .viewer-toolbar button:hover:not(:disabled) {
        background-color: var(--toolbar-hover);
    }
}

.viewer-toolbar button:active:not(:disabled) {
    background-color: var(--toolbar-hover);
}

.viewer-toolbar button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.viewer-toolbar button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-counter {
    min-width: 70px;

    font-size: 13px;
    font-weight: 600;
    text-align: center;

    white-space: nowrap;
}

#zoom-reset {
    min-width: 56px;
    font-size: 13px;
}

.toolbar-divider {
    height: 25px;
    width: 1px;

    margin: 0 3px;

    background-color: rgba(255, 255, 255, 0.2);
}

/* =========================================================
   07. LOADING INDICATOR
   ========================================================= */

.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 12px;

    background-color: var(--viewer-bg);
}

.loading-overlay p {
    margin: 0;
    font-size: 14px;
}

.spinner {
    width: 46px;
    height: 46px;

    border: 4px solid rgba(38, 61, 84, 0.15);
    border-top-color: var(--toolbar-bg);
    border-radius: 50%;

    animation: spinner-rotate 0.85s linear infinite;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

#loading-progress {
    width: min(220px, 75%);
    height: 8px;
    accent-color: var(--toolbar-bg);
}

/* =========================================================
   08. ERROR MESSAGE
   ========================================================= */

.viewer-error {
    padding: 20px;

    max-width: 500px;

    color: #8b2332;
    background-color: #fff1f2;

    border: 1px solid #e5a5ad;
    border-radius: var(--border-radius);

    text-align: center;
    line-height: 1.6;
}

/* =========================================================
   09. FOOTER SECTION
   ========================================================= */

.site-footer {
    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 7px;

    min-height: var(--footer-height);

    padding: 16px 12px;

    background-color: var(--footer-bg);
    color: var(--footer-text);

    text-align: center;
}

.site-footer p {
    margin: 0;
}

.copyright {
    font-size: 13px;
    line-height: 1.6;
}

.powered-by {
    font-size: 11px;
    opacity: 0.75;
    letter-spacing: 0.3px;
}

/* =========================================================
   10. FULLSCREEN MODE
   ========================================================= */

.viewer-shell:fullscreen {
    width: 100%;
    height: 100%;

    padding: 12px;

    background-color: var(--viewer-bg);
}

.viewer-shell:fullscreen .book-viewport {
    flex: 1;
    height: auto;
    min-height: 0;
}

/* =========================================================
   11. TABLET AND MOBILE RESPONSIVENESS
   ========================================================= */

@media (max-width: 768px) {

    :root {
        --header-height: 70px;
        --footer-height: 65px;

        --logo-max-width: 220px;
        --logo-max-height: 50px;
    }

    .site-main {
        padding: 12px 8px;
    }

    .viewer-shell {
        gap: 10px;
    }

    .book-viewport {
        height: 68vh;
        height: 68dvh;
    }

    .viewer-toolbar button {
        min-width: 36px;
        min-height: 44px;
        padding: 5px 8px;
    }

    .copyright {
        font-size: 12px;
    }
}

@media (max-width: 480px) {

    .viewer-toolbar {
        gap: 2px;
        padding: 4px;
    }

    .page-counter {
        min-width: 54px;
        font-size: 12px;
    }

    .toolbar-divider {
        display: none;
    }

    #zoom-reset {
        min-width: 48px;
    }

    .powered-by {
        font-size: 10px;
    }
}

/* Mobile phones in landscape orientation */

@media (orientation: landscape) and (max-height: 500px) {

    :root {
        --header-height: 52px;
        --footer-height: 48px;
        --logo-max-height: 34px;
    }

    .site-header {
        padding: 6px;
    }

    .site-main {
        padding: 8px;
    }

    .book-viewport {
        height: 62dvh;
        min-height: 140px;
    }

    .site-footer {
        padding: 6px;
        gap: 3px;
    }
}

/* Respect reduced-motion accessibility preferences. */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================
   12. DISCOURAGE PRINTING OF BROCHURE CONTENT
   ========================================================= */

@media print {
    body {
        display: none !important;
    }
}