/* =========================================================
   Ebooks: listing, detail, checkout, library
   (loaded together with /cr-style.css; all classes cr-ebk-*)
   ========================================================= */

.cr-ebk-hero { background: linear-gradient(135deg, #0b1d36 0%, #14355e 100%); color: #fff; padding: 44px 20px 40px; text-align: center; }
.cr-ebk-hero h1 { font-size: 36px; margin: 0 0 10px; color: #fff; line-height: 1.15; }
.cr-ebk-hero p { max-width: 640px; margin: 0 auto; font-size: 17px; line-height: 1.6; color: #dbe6f3; }

.cr-ebk-wrap { max-width: 1100px; margin: 0 auto; padding: 28px 20px 56px; font-family: var(--font-body); color: var(--black); }

/* ---- filters ---- */
.cr-ebk-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.cr-ebk-filters form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.cr-ebk-filters input[type=text] { flex: 1; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.cr-ebk-filters select { padding: 10px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; font-family: inherit; }
.cr-ebk-filters button { background: var(--navy); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 700; cursor: pointer; }
.cr-ebk-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.cr-ebk-chip { background: #eef3fa; color: #0f2744; text-decoration: none; padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.cr-ebk-chip:hover { background: #e8a020; }
.cr-ebk-chip.active { background: var(--navy); color: #fff; }

/* ---- grid + card ---- */
.cr-ebk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.cr-ebk-card { display: flex; flex-direction: column; background: #fff; border: 1px solid #e3e8ef; border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.cr-ebk-card:hover { box-shadow: 0 6px 20px rgba(15, 39, 68, .12); transform: translateY(-2px); }
.cr-ebk-cover { position: relative; aspect-ratio: 3 / 4; background: #eef3fa; }
.cr-ebk-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-ebk-badge { position: absolute; top: 10px; right: 10px; background: #16a34a; color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.cr-ebk-badge.off { background: #dc2626; }
.cr-ebk-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cr-ebk-title { font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--navy); }
.cr-ebk-sub { font-size: 12.5px; color: var(--text-muted); }
.cr-ebk-price { margin-top: auto; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cr-ebk-price .now { font-size: 20px; font-weight: 800; color: #111; }
.cr-ebk-price .was { font-size: 14px; color: #888; text-decoration: line-through; }
.cr-ebk-price .free { font-size: 18px; font-weight: 800; color: #16a34a; }
.cr-ebk-empty { text-align: center; padding: 48px 12px; color: var(--text-muted); }

/* ---- detail ---- */
.cr-ebk-crumb { font-size: 13px; color: #b9c9de; margin-bottom: 10px; }
.cr-ebk-crumb a { color: #dbe6f3; }
.cr-ebk-detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 36px; align-items: start; }
.cr-ebk-detail .cr-ebk-cover { border-radius: 12px; overflow: hidden; border: 1px solid #e3e8ef; box-shadow: 0 6px 24px rgba(15, 39, 68, .12); }
.cr-ebk-detail h1 { font-size: 30px; line-height: 1.2; margin: 0 0 8px; }
.cr-ebk-by { color: var(--text-muted); font-size: 15px; margin-bottom: 14px; }
.cr-ebk-buy { background: #f6f8fb; border: 1px solid #e3e8ef; border-radius: 12px; padding: 18px 20px; margin: 16px 0 22px; }
.cr-ebk-buy .now { font-size: 32px; font-weight: 800; }
.cr-ebk-buy .was { font-size: 18px; color: #888; text-decoration: line-through; margin-left: 10px; }
.cr-ebk-buy .off { margin-left: 10px; background: #dc2626; color: #fff; font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.cr-ebk-buy .free { font-size: 32px; font-weight: 800; color: #16a34a; }
.cr-ebk-tax { font-size: 13px; color: var(--text-muted); margin: 4px 0 14px; }
.cr-ebk-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cr-ebk-btn { display: inline-block; padding: 12px 26px; border-radius: 8px; font-weight: 700; font-size: 16px; text-decoration: none; border: 0; cursor: pointer; font-family: inherit; }
.cr-ebk-btn.primary { background: #e8a020; color: #0f2744; }
.cr-ebk-btn.primary:hover { filter: brightness(1.07); }
.cr-ebk-btn.dark { background: var(--navy); color: #fff; }
.cr-ebk-btn.ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.cr-ebk-note { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.cr-ebk-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 24px; }
.cr-ebk-fact { background: #fff; border: 1px solid #e3e8ef; border-radius: 10px; padding: 10px 14px; }
.cr-ebk-fact span { display: block; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.cr-ebk-fact strong { font-size: 15px; }
.cr-ebk-section { margin: 0 0 26px; }
.cr-ebk-section h2 { font-size: 20px; margin: 0 0 10px; }
.cr-ebk-section p { margin: 0 0 12px; line-height: 1.7; font-size: 16px; }
.cr-ebk-toc { margin: 0; padding-left: 22px; line-height: 1.8; }
.cr-ebk-related { margin-top: 44px; }
.cr-ebk-related h2 { font-size: 22px; margin: 0 0 16px; }

/* ---- library / checkout / success ---- */
.cr-ebk-page { max-width: 960px; margin: 0 auto; padding: 28px 20px 56px; font-family: var(--font-body); }
.cr-ebk-page h1 { font-size: 26px; margin: 0 0 18px; }
.cr-ebk-lib { display: flex; gap: 16px; align-items: center; background: #fff; border: 1px solid #e3e8ef; border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.cr-ebk-lib img { width: 64px; height: 86px; object-fit: cover; border-radius: 6px; border: 1px solid #e3e8ef; flex-shrink: 0; background: #eef3fa; }
.cr-ebk-lib-info { flex: 1; min-width: 0; }
.cr-ebk-lib-title { font-size: 17px; font-weight: 700; color: var(--navy); }
.cr-ebk-lib-meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.cr-ebk-lib-act { display: flex; gap: 8px; flex-wrap: wrap; }
.cr-ebk-lib-act .cr-ebk-btn { padding: 9px 16px; font-size: 14px; }
.cr-ebk-table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; border: 1px solid #e3e8ef; border-radius: 10px; overflow: hidden; }
.cr-ebk-table th { text-align: left; background: #f6f8fb; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.cr-ebk-table td { padding: 10px 12px; border-top: 1px solid #e3e8ef; }
.cr-ebk-box { background: #fff; border: 1px solid #e3e8ef; border-radius: 12px; padding: 20px 22px; margin-bottom: 16px; }
.cr-ebk-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 15px; }
.cr-ebk-line.total { border-top: 1px solid #e3e8ef; margin-top: 6px; padding-top: 12px; font-size: 19px; font-weight: 800; }
.cr-ebk-line .muted { color: var(--text-muted); font-size: 13px; }
.cr-ebk-coupon { display: flex; gap: 8px; margin: 12px 0; }
.cr-ebk-coupon input { flex: 1; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; text-transform: uppercase; font-family: inherit; }
.cr-ebk-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 8px 0; }
.cr-ebk-err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 8px 0; }

@media (max-width: 760px) {
    .cr-ebk-detail { grid-template-columns: 1fr; gap: 22px; }
    .cr-ebk-detail .cr-ebk-cover { max-width: 260px; margin: 0 auto; }
    .cr-ebk-hero h1 { font-size: 28px; }
    .cr-ebk-lib { flex-wrap: wrap; }
}

/* ---- My Ebooks: same width and heading sizes as the other account pages (keep after the rules above) ---- */
.cr-ebk-page.cr-ebk-mine { max-width: 1100px; padding-top: 24px; }
.cr-ebk-mine h1 { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--navy); margin: 0 0 14px; }
.cr-ebk-mine h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--navy); margin: 30px 0 14px; scroll-margin-top: 80px; }
.cr-ebk-mine .cr-ebk-related { margin-top: 0; }
.cr-ebk-hint { font-size: 13px; color: var(--text-muted); margin: -8px 0 14px; }
@media (max-width: 760px) {
    .cr-ebk-mine .cr-ebk-lib-act { width: 100%; }        /* buttons and messages go under the title */
    .cr-ebk-mine .cr-ebk-lib-act .cr-ebk-btn { padding: 9px 12px; }
    .cr-ebk-mine .cr-ebk-table { font-size: 12.5px; }    /* give the item name more room */
    .cr-ebk-mine .cr-ebk-table th, .cr-ebk-mine .cr-ebk-table td { padding: 8px 5px; }
    .cr-ebk-mine .cr-ebk-table th { font-size: 10.5px; letter-spacing: 0; }
    .cr-ebk-mine .cr-ebk-table td:last-child { word-break: break-all; font-size: 11.5px; }
}

/* Phones: search box on its own row, price/sort/button share the next row (no sideways scroll) */
@media (max-width: 600px) {
    .cr-ebk-filters form { flex-wrap: wrap; min-width: 0; width: 100%; }
    .cr-ebk-filters input[type=text] { flex: 1 1 100%; min-width: 0; }
    .cr-ebk-filters select { flex: 1 1 0; min-width: 0; }
}
