/* ==========================================================================
   Waqt Al-Hadhara - flipbook.css
   Styles for the company profile flipbook page
   ========================================================================== */

body {
    background-color: var(--color-bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
.fb-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
}

html.light-mode .fb-header {
    background-color: rgba(250, 248, 244, 0.92);
}

.fb-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.fb-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.25s ease;
}

.fb-back:hover {
    color: var(--color-gold);
}

.fb-header-center {
    text-align: center;
    flex: 1;
}

.fb-header-center h1 {
    font-family: var(--font-headers);
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    color: var(--color-text-primary);
    margin-bottom: 0;
    line-height: 1.3;
}

.fb-header-center .fb-subtitle {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.fb-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---- Theme & Language Toggles ---- */
.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(229, 184, 105, 0.15);
    color: var(--color-gold);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 4px;
}

.btn-icon:hover {
    background: rgba(229, 184, 105, 0.1);
    border-color: var(--color-gold);
    transform: translateY(-2px);
}

html.light-mode .btn-icon {
    background: rgba(184, 134, 11, 0.06);
    border-color: rgba(184, 134, 11, 0.25);
}

.lang-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: transform 0.25s ease;
}

.lang-toggle:hover {
    transform: scale(1.08);
}

.lang-flag {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
    outline: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(0.92);
    pointer-events: none;
}

.lang-flag.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ---- Main Content ---- */
.fb-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px 60px;
}

.fb-hero {
    text-align: center;
    margin-bottom: 32px;
    max-width: 700px;
}

.fb-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(229, 184, 105, 0.12);
    border: 1px solid var(--color-gold);
    padding: 8px 18px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-gold-bright);
    margin-bottom: 20px;
}

html.light-mode .fb-hero-badge {
    background-color: rgba(184, 134, 11, 0.08);
    border-color: var(--color-gold);
    color: var(--color-gold);
}

.fb-hero h2 {
    font-family: var(--font-headers);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    color: var(--color-text-primary);
    margin-bottom: 12px;
    line-height: 1.3;
}

.fb-hero p {
    font-size: 1rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
    max-width: 560px;
    margin: 0 auto;
}

/* ---- Flipbook Wrapper ---- */
.fb-wrapper {
    width: 100%;
    max-width: 1100px;
    position: relative;
    /* Small outer margin so the book doesn't touch the viewport edge */
    padding: 8px 8px 16px;
    box-sizing: border-box;
    /* Reserve the canvas area up-front so dFlip's loader mounts inside a
       pre-sized, centered box. Without this, the loader renders at left=0
       during dFlip's first measure pass and snaps to center once mounted,
       causing a visible layout shift. */
    min-height: 520px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Constrain DearFlip's root element on small screens */
.fb-wrapper ._df_book {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    margin: 0 auto;
    touch-action: pan-y;
}

/* DearFlip's .df-book-stage inner padding.
   Keep bottom ≥ 55px so the toolbar (.df-ui-controls) never overlaps the page.
   Left/right kept small — the JS paddingLeft/Right options handle the sides. */
.fb-wrapper .df-book-stage {
    padding: 10px 20px 55px !important;
    box-sizing: border-box;
}

/* DearFlip's .df-container — transparent so the page background shows through.
   The book pages themselves have their own white/paper background. */
.fb-wrapper .df-container {
    width: 100%;
    max-width: 100%;
    background-color: transparent;
    border-radius: 8px;
    overflow: hidden;
    /* Center the book canvas horizontally inside the container */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Safety net: prevent canvas/page overflow beyond the wrapper */
.fb-wrapper .df-container canvas,
.fb-wrapper .df-container .df-page,
.fb-wrapper .df-container .df-canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* RTL: force LTR on the flipbook container so DearFlip's absolute coordinate
   calculations (originating from top-left) work correctly.
   The page-flipping direction itself is controlled by the JS option direction: 2.
   The wrapper already has dir="ltr" in the markup, so the first two selectors
   below are defensive (covering dynamic re-renders or older HTML). */
html[dir="rtl"] .fb-wrapper,
.fb-wrapper .df-container,
.fb-wrapper .df-book-stage {
    direction: ltr !important;
}

/* Ensure the outline table of contents panel aligns right and reads RTL in Arabic */
.fb-wrapper .df-container .df-outline {
    direction: rtl !important;
    text-align: right !important;
}

/* ---- Entrance Animation ---- */
.fb-fade-in {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: opacity 1.2s cubic-bezier(0.22, 1, 0.36, 1),
                transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
}

.fb-fade-in.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Honor reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    .fb-fade-in,
    .fb-fade-in.visible {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ---- Bottom CTA ---- */
.fb-cta {
    text-align: center;
    padding: 40px 20px 60px;
    background-color: var(--color-bg-primary);
}

.fb-cta h3 {
    font-family: var(--font-headers);
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: var(--color-text-primary);
    margin-bottom: 10px;
}

.fb-cta p {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
    background-color: var(--color-gold);
    color: var(--color-text-dark);
}

.btn-primary:hover {
    background-color: var(--color-gold-bright);
    transform: translateY(-2px);
    box-shadow: 4px 4px 0px rgba(229, 184, 105, 0.25);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text-primary);
    border: 1px solid rgba(229, 184, 105, 0.4);
}

.btn-secondary:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
    background-color: rgba(229, 184, 105, 0.08);
    transform: translateY(-2px);
}

html.light-mode .btn-secondary {
    border-color: rgba(184, 134, 11, 0.35);
}

.btn-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---- Footer ---- */
.fb-footer {
    border-top: 1px solid var(--color-border-grey);
    padding: 20px 0;
    text-align: center;
    background-color: var(--color-bg-deep);
}

.fb-footer p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* ---- Reading Progress ---- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-gold), var(--color-gold-bright));
    z-index: 10001;
    transition: width 0.1s linear;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    .fb-header-center .fb-subtitle {
        display: none;
    }
    .fb-back span {
        display: none;
    }
    /* Smaller flipbook on mobile — leave more room for the CTA below.
       With pageSize:0 dFlip sizes the book to the wrapper width (it scales
       to fit by default), so max-height:60vh just caps very tall PDFs
       (e.g. A4 portrait). See: https://js.dearflip.com/docs/options-list/ */
    .fb-wrapper ._df_book {
        max-height: 60vh;
    }
    /* Reduce outer wrapper padding on mobile — the viewport is already tight */
    .fb-wrapper {
        padding: 8px 8px 12px;
        min-height: 360px;
    }
    /* dflip's own .df-xs .df-book-stage forces side padding to 20px which is
       too tight; bump it back up so the book has some inset on phones. */
    .fb-wrapper .df-book-stage {
        padding: 32px 24px 60px !important;
    }
    /* Hide the decorative inner shadow on phones — saves a paint layer */
    .fb-wrapper .df-container {
        box-shadow: none;
        border-radius: 2px;
    }
    /* On phones the page-flip gestures (pan-x) can hijack vertical scroll.
       Be explicit: allow vertical scroll, only the flipbook handles horizontal. */
    .fb-wrapper ._df_book,
    .fb-wrapper .df-container {
        touch-action: pan-y;
    }
}