/* ============================================================
   Airmic Swag Bag – CSS v2
   No scrolling shelf – books fill rows based on screen width
   Books show PDF first-page thumbnail, lift on hover/tap
   ============================================================ */

.asb-wrap *,
.asb-wrap *::before,
.asb-wrap *::after,
.asb-modal *,
.asb-modal *::before,
.asb-modal *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.asb-wrap {
    --asb-navy:      #1a3a5c;
    --asb-teal:      #1a7a8c;
    --asb-teal-dark: #155f6e;
    --asb-white:     #ffffff;
    --asb-off:       #f4f8fb;
    --asb-border:    #dde6ee;
    --asb-text:      #1a2b3c;
    --asb-muted:     #5a7080;
    --asb-shelf:     #0a1e36;
    --asb-shelf-top: #1a3a5c;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    color: var(--asb-text);
    width: 100%;
}

/* ---------- Category tabs ---------- */
.asb-cat-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    flex-wrap: wrap;
    background: var(--asb-white);
    border-bottom: 1px solid var(--asb-border);
}

.asb-cat-tab {
    padding: 8px 16px;
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: #e8eef4;
    color: #1a3a5c;
    transition: all .2s;
    white-space: nowrap;
    letter-spacing: .01em;
}

.asb-cat-tab.active,
.asb-cat-tab:hover {
    background: rgb(0, 118, 165);
    color: #fff;
}

/* ---------- Shelf section ---------- */
.asb-shelf-section {
    padding: 20px 0 0;
    background: var(--asb-off);
}

.asb-shelf-row-wrap { margin-bottom: 0; }

.asb-shelf-row {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
}

.asb-plank {
    height: 18px;
    background: linear-gradient(180deg, var(--asb-shelf-top) 0%, var(--asb-shelf) 60%, #1a0e06 100%);
    box-shadow: 0 5px 18px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,255,255,.08);
    margin-bottom: 24px;
}

/* ---------- Book ---------- */
.asb-book {
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    perspective: 600px;
    transition: transform .25s ease;
    outline: none;
}

.asb-book:hover,
.asb-book:focus-visible {
    transform: translateY(-22px) scale(1.06);
    z-index: 5;
}

.asb-book-inner {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .45s cubic-bezier(.4,0,.2,1);
    position: relative;
}

.asb-book:hover .asb-book-inner,
.asb-book:focus-visible .asb-book-inner {
    transform: rotateY(-18deg);
}

.asb-spine {
    position: absolute;
    inset: 0;
    border-radius: 2px 7px 7px 2px;
    overflow: hidden;
    box-shadow:
        inset -4px 0 8px rgba(0,0,0,.3),
        inset 3px 0 5px rgba(255,255,255,.12),
        4px 6px 18px rgba(0,0,0,.38);
}

.asb-spine::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,.28);
    border-radius: 2px 5px 0 0;
    z-index: 2;
    pointer-events: none;
}

.asb-spine::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 7px;
    background: linear-gradient(90deg, rgba(0,0,0,.28), transparent);
    z-index: 2;
    pointer-events: none;
    border-radius: 2px 0 0 2px;
}

.asb-book-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asb-book-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    opacity: .5;
}

.asb-book-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.8);
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    padding: 6px;
    text-transform: uppercase;
    letter-spacing: .07em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ---------- Empty state ---------- */
.asb-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--asb-muted);
}

.asb-empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }

/* ============================================================
   MODAL / PDF VIEWER
   ============================================================ */
.asb-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-end;
}

.asb-modal[hidden] { display: none !important; }

.asb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 24, 38, .75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

.asb-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    background: var(--asb-white);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,.35);
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    animation: asbSlideUp .35s cubic-bezier(.4,0,.2,1);
}

@keyframes asbSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.asb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
    gap: 12px;
    background: var(--asb-navy);
    border-radius: 20px 20px 0 0;
}

.asb-modal-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.asb-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asb-modal-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.7);
}

.asb-modal-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.asb-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    background: rgb(0, 118, 165);
    color: #fff;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s;
    letter-spacing: .01em;
}

.asb-btn-download:hover {
    background: #005a80;
    color: #fff;
}

.asb-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.3);
    background: transparent;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.8);
    transition: background .2s, color .2s, border-color .2s;
    flex-shrink: 0;
}

.asb-modal-close:hover { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.6); }

.asb-viewer {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: #e8ecf0;
    -webkit-overflow-scrolling: touch;
}

.asb-viewer-loading {
    width: calc(100% - 32px);
    aspect-ratio: 1 / 1.4142; /* A4 portrait */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--asb-muted);
    font-size: 14px;
    background: #ffffff;
    box-shadow: 0 4px 24px rgba(0,0,0,.22);
    border-radius: 3px;
    margin: 16px auto;
}

.asb-viewer-loading.hidden { display: none; }

.asb-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(26,122,140,.2);
    border-top-color: var(--asb-teal);
    border-radius: 50%;
    animation: asbSpin .8s linear infinite;
}

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

.asb-pages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
}

.asb-page-wrap {
    box-shadow: 0 4px 24px rgba(0,0,0,.22);
    border-radius: 3px;
    overflow: hidden;
    background: #fff;
    display: none;
    animation: asbFadeIn .3s ease;
}

.asb-page-wrap.active { display: block; }

@keyframes asbFadeIn {
    from { opacity: 0; transform: scale(.98); }
    to   { opacity: 1; transform: scale(1); }
}

.asb-page-wrap canvas { display: block; max-width: 100%; }

.asb-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
    background: var(--asb-navy);
    border-radius: 0 0 20px 20px;
}

.asb-nav-btn {
    padding: 8px 20px;
    border-radius: 0;
    border: none;
    background: rgb(0, 118, 165);
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background .2s;
    min-width: 80px;
    letter-spacing: .01em;
}

.asb-nav-btn:hover:not(:disabled) { background: #005a80; color: #fff; }
.asb-nav-btn:disabled { opacity: .3; cursor: default; }
.asb-page-indicator { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.8); }

@media (min-width: 768px) {
    .asb-modal-panel { border-radius: 20px; margin: auto; max-height: 88vh; }
    .asb-modal-header { border-radius: 20px 20px 0 0; }
    .asb-modal-footer { border-radius: 0 0 20px 20px; }
    .asb-modal { align-items: center; }
}
