/* =============================================================================
   ALLOVE E-Book — Public Stylesheet (v2)
   Palette: White · Red-Purple #8B1A2B · Gold #C9A875
   ============================================================================= */

:root {
    --eb-color-primary:      #8B1A2B;
    --eb-color-primary-dark: #6B1320;
    --eb-color-primary-soft: #FBF1F3;
    --eb-color-gold:         #C9A875;
    --eb-color-gold-soft:    #F4EAD3;
    --eb-color-bg:           #FFFFFF;
    --eb-color-bg-soft:      #FBFAF9;
    --eb-color-text:         #1A1A1A;
    --eb-color-text-muted:   #6B6B6B;
    --eb-color-border:       #ECE6E7;
    --eb-shadow-soft:        0 4px 18px rgba(139, 26, 43, 0.08);
    --eb-shadow-card:        0 8px 26px rgba(139, 26, 43, 0.13);
    --eb-shadow-flag:        0 6px 18px rgba(0, 0, 0, 0.18);
    --eb-radius-md:          14px;
    --eb-radius-lg:          22px;
    --eb-font-sans:          -apple-system, BlinkMacSystemFont, "Segoe UI",
                             "Sarabun", "Helvetica Neue", Arial, sans-serif;
    --eb-font-serif:         "Georgia", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--eb-color-bg);
    color: var(--eb-color-text);
    font-family: var(--eb-font-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    color: var(--eb-color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover { color: var(--eb-color-primary-dark); }

img { display: block; max-width: 100%; height: auto; }

/* ===========================================================================
   FULL-SCREEN BANNER BACKGROUND (only for index.php / when eb-body-banner)
   =========================================================================== */
.eb-page-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    pointer-events: none;
}
.eb-body-banner { background: transparent; }

/* ===========================================================================
   HEADER (red-purple bar + gold accent rule)
   =========================================================================== */
.eb-header {
    background: var(--eb-color-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(0,0,0,0.08);
}
.eb-header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.eb-brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    text-decoration: none;
}
.eb-brand-logo {
    width: 50px;
    height: 50px;
    background: transparent;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    padding: 0;
    flex-shrink: 0;
    image-rendering: -webkit-optimize-contrast;
}
.eb-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.eb-brand-name {
    font-family: var(--eb-font-serif);
    font-size: 18px;
    letter-spacing: 4px;
    font-weight: 600;
}
.eb-brand-sub {
    font-size: 11px;
    letter-spacing: 1.8px;
    opacity: 0.85;
    margin-top: 3px;
    text-transform: uppercase;
}
.eb-header-nav { display: flex; gap: 14px; }
.eb-nav-link {
    color: #fff;
    font-size: 13px;
    padding: 7px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.eb-nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.55);
    color: #fff;
}
.eb-header-rule {
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--eb-color-gold) 0%,
        var(--eb-color-gold) 30%,
        rgba(201, 168, 117, 0.3) 30%,
        rgba(201, 168, 117, 0.3) 100%
    );
}

/* ===========================================================================
   HERO (over banner background) — logo + title
   =========================================================================== */
.eb-main { min-height: calc(100vh - 200px); }

.eb-hero {
    text-align: center;
    padding: 44px 24px 24px;
    max-width: 900px;
    margin: 0 auto;
}
.eb-hero-logo {
    display: block;
    margin: 0 auto 18px;
    background: transparent;
    border: 0;
    padding: 0;
    box-shadow: none;
    text-align: center;
}
.eb-hero-logo img {
    max-height: 140px;
    max-width: 320px;
    height: auto;
    width: auto;
    margin: 0 auto;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}
.eb-hero-eyebrow {
    display: inline-block;
    color: var(--eb-color-primary);
    font-size: 11px;
    letter-spacing: 4px;
    text-transform: uppercase;
    padding: 5px 18px;
    border: 1px solid var(--eb-color-gold);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    margin-bottom: 14px;
    font-weight: 500;
}
.eb-hero-title {
    font-family: var(--eb-font-serif);
    font-size: 38px;
    font-weight: 600;
    line-height: 1.15;
    margin: 4px 0 4px;
    color: var(--eb-color-text);
}
.eb-hero-title-en {
    font-family: var(--eb-font-serif);
    font-size: 19px;
    font-weight: 400;
    color: var(--eb-color-primary);
    letter-spacing: 5px;
    margin: 0;
    text-transform: uppercase;
}
.eb-hero-divider {
    width: 70px;
    height: 2px;
    background: var(--eb-color-gold);
    margin: 16px auto 0;
    border-radius: 2px;
}

/* ===========================================================================
   LANGUAGE GRID — LIONMALL-style cards with gold border accent
   =========================================================================== */
.eb-lang-grid-wrap {
    max-width: 740px;
    margin: 0 auto;
    padding: 12px 22px 60px;
}
.eb-lang-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 22px;
}

.eb-lang-card {
    position: relative;
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid var(--eb-color-gold);
    border-radius: 50px;
    padding: 18px 76px 18px 24px;
    display: flex;
    align-items: center;
    min-height: 64px;
    box-shadow: var(--eb-shadow-card);
    text-decoration: none;
    color: var(--eb-color-text);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.eb-lang-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(139, 26, 43, 0.2);
    color: var(--eb-color-text);
}
.eb-lang-card:hover .eb-lang-flag {
    transform: translateY(-50%) scale(1.05);
}

/* "E-Book" pill — overlaps top-left edge */
.eb-lang-pill {
    position: absolute;
    top: -12px;
    left: 22px;
    background: var(--eb-color-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1.5px;
    padding: 4px 16px;
    border-radius: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(139, 26, 43, 0.25);
}

/* Language name — single line, English uppercase, big serif */
.eb-lang-name {
    flex: 1;
    text-align: center;
    font-family: var(--eb-font-serif);
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.8px;
    color: var(--eb-color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    line-height: 1.2;
}

/* Flag column — circular with thick gold border, overlaps right edge */
.eb-lang-flag {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--eb-color-gold);
    background: var(--eb-color-bg-soft);
    box-shadow: var(--eb-shadow-flag);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

/* Empty state */
.eb-empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--eb-color-text-muted);
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--eb-radius-md);
    border: 1px dashed var(--eb-color-border);
    max-width: 600px;
    margin: 0 auto;
}

/* ===========================================================================
   FOOTER — red-purple bar, white text, single line, NO wrap
   =========================================================================== */
.eb-footer {
    background: var(--eb-color-primary);
    margin-top: 30px;
    position: relative;
    z-index: 1;
}
.eb-footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 16px 14px;
    text-align: center;
    overflow: hidden;
}
.eb-footer-text {
    margin: 0;
    color: #fff;
    font-size: 12px;
    letter-spacing: 2px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===========================================================================
   VIEWER PAGE — 3:4 aspect ratio per page (Desktop spread = 3:2)
   =========================================================================== */
.eb-viewer-bar {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 28px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.eb-viewer-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--eb-color-border);
    border-radius: 999px;
    color: var(--eb-color-text);
    text-decoration: none;
    font-size: 14px;
    background: #fff;
    transition: all 0.2s ease;
}
.eb-viewer-back:hover {
    background: var(--eb-color-primary-soft);
    border-color: var(--eb-color-primary);
    color: var(--eb-color-primary);
}
.eb-viewer-lang {
    font-family: var(--eb-font-serif);
    font-size: 20px;
    font-weight: 600;
    color: var(--eb-color-text);
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    padding: 6px 18px 6px 6px;
    border-radius: 999px;
    border: 1px solid var(--eb-color-border);
}
.eb-viewer-lang img {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--eb-color-gold);
}
.eb-viewer-lang-en {
    font-family: var(--eb-font-sans);
    font-size: 12px;
    color: var(--eb-color-text-muted);
    letter-spacing: 1px;
    margin-left: 4px;
    text-transform: uppercase;
}

/* Stage + flipbook — 3:4 page ratio (so spread = 6:4 = 3:2) */
.eb-stage {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 22px 0;
}
.eb-flipbook-frame {
    background: var(--eb-color-bg-soft);
    border: 1px solid var(--eb-color-border);
    border-radius: var(--eb-radius-lg);
    padding: 26px;
    position: relative;
    box-shadow: var(--eb-shadow-soft);
}
.eb-flipbook {
    position: relative;
    margin: 0 auto;
    perspective: 2400px;
    width: 100%;
    max-width: 960px;
    aspect-ratio: 3 / 2;       /* 2-page spread = 6:4 = 3:2 */
    user-select: none;
}
.eb-page {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;                /* each page = half spread = 3:4 */
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.85s cubic-bezier(.4,.1,.3,1);
    cursor: pointer;
    will-change: transform;
}
.eb-page.flipped { transform: rotateY(-180deg); }
.eb-page-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: #fff;
    overflow: hidden;
    border: 1px solid var(--eb-color-border);
}
.eb-page-face.front {
    border-radius: 0 6px 6px 0;
    border-left: 0;
}
.eb-page-face.back {
    transform: rotateY(180deg);
    border-radius: 6px 0 0 6px;
    border-right: 0;
}
.eb-page-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}
.eb-page-num {
    position: absolute;
    bottom: 8px;
    font-size: 11px;
    color: var(--eb-color-text-muted);
    letter-spacing: 1px;
    pointer-events: none;
}
.eb-page-face.front .eb-page-num { right: 14px; }
.eb-page-face.back  .eb-page-num { left: 14px; }

.eb-flipbook-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 100%;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--eb-color-primary);
    font-size: 36px;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 50;
    line-height: 1;
}
.eb-flipbook-frame:hover .eb-flipbook-nav { opacity: 0.55; }
.eb-flipbook-nav:hover { opacity: 1 !important; background: rgba(139, 26, 43, 0.04); }
.eb-flipbook-nav.left  { left: 0; border-radius: var(--eb-radius-lg) 0 0 var(--eb-radius-lg); }
.eb-flipbook-nav.right { right: 0; border-radius: 0 var(--eb-radius-lg) var(--eb-radius-lg) 0; }
.eb-flipbook-nav:disabled { opacity: 0 !important; cursor: not-allowed; }

/* Toolbar */
.eb-toolbar {
    max-width: 1100px;
    margin: 0 auto;
    padding: 22px 22px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.eb-tool-btn {
    background: #fff;
    color: var(--eb-color-text);
    border: 1px solid var(--eb-color-border);
    border-radius: 999px;
    padding: 10px 22px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 100px;
}
.eb-tool-btn:hover:not(:disabled) {
    border-color: var(--eb-color-primary);
    background: var(--eb-color-primary-soft);
    color: var(--eb-color-primary);
}
.eb-tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.eb-tool-counter {
    font-family: var(--eb-font-serif);
    font-size: 14px;
    color: var(--eb-color-text-muted);
    padding: 0 14px;
    font-variant-numeric: tabular-nums;
    min-width: 130px;
    text-align: center;
}

/* ===========================================================================
   MOBILE
   =========================================================================== */
@media (max-width: 760px) {
    .eb-header-inner { padding: 12px 16px; gap: 10px; }
    .eb-brand-logo { width: 40px; height: 40px; padding: 0; }
    .eb-brand-name { font-size: 15px; letter-spacing: 3px; }
    .eb-brand-sub { font-size: 9px; letter-spacing: 1.2px; }
    .eb-nav-link { padding: 6px 12px; font-size: 11px; }

    .eb-hero { padding: 26px 18px 14px; }
    .eb-hero-logo { margin-bottom: 12px; }
    .eb-hero-logo img { max-height: 100px; max-width: 240px; }
    .eb-hero-eyebrow { font-size: 9px; letter-spacing: 3px; padding: 4px 14px; margin-bottom: 10px; }
    .eb-hero-title { font-size: 26px; }
    .eb-hero-title-en { font-size: 13px; letter-spacing: 3px; }
    .eb-hero-divider { width: 50px; margin-top: 12px; }

    /* Cards switch to single column on mobile */
    .eb-lang-grid-wrap { padding: 8px 16px 40px; max-width: 460px; }
    .eb-lang-grid { grid-template-columns: 1fr; gap: 22px; }
    .eb-lang-card {
        border-radius: 40px;
        padding: 14px 64px 14px 18px;
        min-height: 56px;
    }
    .eb-lang-pill {
        font-size: 9px;
        padding: 3px 12px;
        top: -10px;
        left: 16px;
        letter-spacing: 1px;
    }
    .eb-lang-name { font-size: 14px; letter-spacing: 0.5px; }
    .eb-lang-flag { width: 58px; height: 58px; right: -5px; border-width: 3px; }

    /* Footer mobile — single line still */
    .eb-footer-inner { padding: 12px 12px; }
    .eb-footer-text { font-size: 9.5px; letter-spacing: 1.2px; }

    /* Viewer mobile */
    .eb-viewer-bar { padding: 16px 16px 4px; gap: 10px; }
    .eb-viewer-lang { font-size: 16px; padding: 4px 14px 4px 4px; }
    .eb-viewer-lang img { width: 32px; height: 32px; }
    .eb-viewer-lang-en { font-size: 10px; }
    .eb-stage { padding: 10px 12px 0; }
    .eb-flipbook-frame { padding: 14px; border-radius: var(--eb-radius-md); }
    .eb-flipbook-nav { width: 36px; font-size: 26px; }
    .eb-toolbar { padding: 14px 16px 24px; gap: 8px; }
    .eb-tool-btn { padding: 7px 14px; font-size: 12px; min-width: 80px; }
    .eb-tool-counter { font-size: 12px; min-width: 100px; }
}

/* Very small screens — extra footer protection so single-line stays */
@media (max-width: 380px) {
    .eb-footer-text { font-size: 8.5px; letter-spacing: 0.8px; }
}

/* On very small screens flipbook switches to single page (3:4 aspect) */
@media (max-width: 560px) {
    .eb-flipbook { aspect-ratio: 3 / 4; max-width: 400px; }
    .eb-page { left: 0; width: 100%; }
    .eb-page-face.front,
    .eb-page-face.back { border-radius: 6px; border: 1px solid var(--eb-color-border); }
}

@media (prefers-reduced-motion: reduce) {
    .eb-page,
    .eb-lang-card,
    .eb-lang-flag { transition: none; }
}
