/* ACTA Digital Catalog — immersive slide viewer */
:root {
    --acta-cat-green: #5a9f72;
    --acta-cat-green-light: #9fe07e;
    --acta-cat-green-dark: #3d7256;
    --acta-cat-bg: #0f1a0c;
    --acta-cat-bg-soft: #1a2e14;
    --acta-cat-surface: rgba(255, 255, 255, 0.06);
    --acta-cat-border: rgba(159, 224, 126, 0.15);
    --acta-cat-text: #f0f5ec;
    --acta-cat-muted: rgba(240, 245, 236, 0.65);
    --acta-cat-header-h: 3.25rem;
    --acta-cat-bar-h: 3.5rem;
    --acta-cat-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

.acta-cat {
    margin: 0;
    min-height: 100dvh;
    min-height: 100svh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(90, 159, 114, 0.22), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(61, 114, 86, 0.15), transparent),
        linear-gradient(165deg, var(--acta-cat-bg) 0%, var(--acta-cat-bg-soft) 50%, #0d1809 100%);
    color: var(--acta-cat-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    touch-action: none;
}

.acta-cat__app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    height: 100svh;
    max-height: 100dvh;
    max-height: 100svh;
}

/* ── Header ── */
.acta-cat__header {
    flex-shrink: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--acta-cat-header-h);
    padding: 0 0.85rem;
    background: rgba(15, 26, 12, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--acta-cat-border);
}

.acta-cat__brand {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    color: var(--acta-cat-text);
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.acta-cat__brand img {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.35rem;
}

.acta-cat__title {
    flex: 1;
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--acta-cat-green-light);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acta-cat__header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.acta-cat__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--acta-cat-border);
    border-radius: 0.5rem;
    background: var(--acta-cat-surface);
    color: var(--acta-cat-text);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.acta-cat__btn:hover {
    background: rgba(90, 159, 114, 0.18);
    border-color: rgba(159, 224, 126, 0.35);
}
.acta-cat__btn:active { transform: scale(0.96); }
.acta-cat__btn--icon {
    padding: 0.4rem;
    min-width: 2.1rem;
}
.acta-cat__btn--cta {
    background: var(--acta-cat-green);
    border-color: var(--acta-cat-green);
    color: #fff;
}
.acta-cat__btn--cta:hover {
    background: #6bc47f;
    border-color: #6bc47f;
}
.acta-cat__btn-label { display: none; }
@media (min-width: 640px) {
    .acta-cat__btn-label { display: inline; }
    .acta-cat__brand span { display: inline; }
    .acta-cat__title { font-size: 0.75rem; }
}

/* ── Stage ── */
.acta-cat__stage {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: stretch;
}

.acta-cat__viewport {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
    container-type: size;
    perspective: 1400px;
    perspective-origin: 50% 50%;
    touch-action: none;
}

.acta-cat__track {
    position: relative;
    width: 100%;
    height: 100%;
    transform: translateZ(0);
}

.acta-cat__slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.35rem, 1.5vw, 1rem);
    user-select: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}
.acta-cat__slide.is-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    z-index: 3;
}
.acta-cat__slide.is-under {
    visibility: visible;
    opacity: 1;
    z-index: 2;
}
.acta-cat__slide.is-flipping {
    visibility: visible;
    opacity: 1;
    z-index: 4;
    pointer-events: none;
}

/* A4 paper (210 × 297 mm) */
.acta-cat__paper {
    position: relative;
    aspect-ratio: 210 / 297;
    width: min(100cqw, calc(100cqh * 210 / 297));
    max-height: 100cqh;
    transform-style: preserve-3d;
    transform-origin: left center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.acta-cat__paper.is-animating,
.acta-cat__paper.is-dragging {
    will-change: transform;
}

.acta-cat__paper-edge {
    display: none;
}

.acta-cat__page {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 2px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0.1px);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.acta-cat__slide.is-active .acta-cat__page {
    box-shadow: inset 0 0 0 1px rgba(159, 224, 126, 0.12);
}

.acta-cat__page img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

/* Flip uses JS transitions (GPU transform only) */
.acta-cat__paper.is-dragging {
    transition: none !important;
}

.acta-cat__page-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8faf8;
}
.acta-cat__page-loading::after {
    content: "";
    width: 2rem;
    height: 2rem;
    border: 2px solid rgba(90, 159, 114, 0.2);
    border-top-color: var(--acta-cat-green);
    border-radius: 50%;
    animation: acta-cat-spin 0.7s linear infinite;
}
.acta-cat__page img.is-loaded + .acta-cat__page-loading {
    display: none;
}

@keyframes acta-cat-spin {
    to { transform: rotate(360deg); }
}

/* Side nav arrows */
.acta-cat__nav {
    display: flex;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--acta-cat-border);
    border-radius: 50%;
    background: rgba(15, 26, 12, 0.82);
    color: var(--acta-cat-text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.acta-cat__nav:active {
    background: rgba(90, 159, 114, 0.4);
}
.acta-cat__nav:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}
.acta-cat__nav--prev { left: 0.35rem; }
.acta-cat__nav--next { right: 0.35rem; }
@media (min-width: 768px) {
    .acta-cat__nav {
        width: 2.75rem;
        height: 2.75rem;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
    .acta-cat__nav:hover {
        background: rgba(90, 159, 114, 0.35);
    }
    .acta-cat__nav--prev { left: 0.65rem; }
    .acta-cat__nav--next { right: 0.65rem; }
}

/* ── Bottom bar ── */
.acta-cat__bar {
    flex-shrink: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: rgba(15, 26, 12, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--acta-cat-border);
}

.acta-cat__progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
}
.acta-cat__progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--acta-cat-green-dark), var(--acta-cat-green-light));
    transition: width 0.35s var(--acta-cat-ease);
}

.acta-cat__bar-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--acta-cat-bar-h);
    padding: 0.4rem 0.65rem;
}

/* Mobile bottom prev/next */
.acta-cat__mob-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--acta-cat-border);
    border-radius: 0.5rem;
    background: var(--acta-cat-surface);
    color: var(--acta-cat-text);
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.acta-cat__mob-nav:active {
    background: rgba(90, 159, 114, 0.3);
}
.acta-cat__mob-nav:disabled {
    opacity: 0.25;
    pointer-events: none;
}
@media (min-width: 768px) {
    .acta-cat__mob-nav { display: none; }
}

.acta-cat__bar-center {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.acta-cat__counter {
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--acta-cat-green-light);
    min-width: 3.5rem;
}

.acta-cat__dots {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.25rem 0;
    -webkit-overflow-scrolling: touch;
}
.acta-cat__dots::-webkit-scrollbar { display: none; }

.acta-cat__dot {
    flex-shrink: 0;
    width: 0.4rem;
    height: 0.4rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.2s, width 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.acta-cat__dot.is-active {
    background: var(--acta-cat-green);
    transform: scale(1.2);
    width: 1.25rem;
    border-radius: 0.25rem;
}
.acta-cat__dot:hover:not(.is-active) {
    background: rgba(159, 224, 126, 0.5);
}

.acta-cat__swipe-hint {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 2rem;
    background: rgba(15, 26, 12, 0.7);
    backdrop-filter: blur(8px);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--acta-cat-muted);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.4s;
    z-index: 10;
}
.acta-cat__swipe-hint.is-hidden { opacity: 0; }

/* ── Grid overlay ── */
.acta-cat__grid {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    background: rgba(10, 16, 8, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.acta-cat__grid.is-open {
    opacity: 1;
    visibility: visible;
}

.acta-cat__grid-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--acta-cat-border);
}
.acta-cat__grid-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--acta-cat-green-light);
}

.acta-cat__grid-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

.acta-cat__grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    gap: 0.75rem;
    max-width: 56rem;
    margin: 0 auto;
}
@media (min-width: 640px) {
    .acta-cat__grid-list {
        grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
        gap: 1rem;
    }
}

.acta-cat__grid-item {
    position: relative;
    aspect-ratio: 210 / 297;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    padding: 0;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.acta-cat__grid-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.acta-cat__grid-item.is-current {
    border-color: var(--acta-cat-green);
    box-shadow: 0 0 0 2px rgba(90, 159, 114, 0.3);
}
.acta-cat__grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}
.acta-cat__grid-item span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.25rem 0.4rem;
    background: linear-gradient(transparent, rgba(15, 26, 12, 0.85));
    font-size: 0.6875rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
}

/* ── End screen ── */
.acta-cat__end {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(10, 16, 8, 0.94);
    backdrop-filter: blur(24px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s, visibility 0.4s;
}
.acta-cat__end.is-visible {
    opacity: 1;
    visibility: visible;
}

.acta-cat__end-card {
    max-width: 22rem;
    text-align: center;
    padding: 2rem 1.5rem;
    border-radius: 1rem;
    background: linear-gradient(160deg, rgba(45, 82, 32, 0.6), rgba(26, 46, 20, 0.8));
    border: 1px solid var(--acta-cat-border);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.acta-cat__end-card img {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.65rem;
    margin-bottom: 1rem;
}
.acta-cat__end-card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    color: var(--acta-cat-green-light);
}
.acta-cat__end-card p {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    color: var(--acta-cat-muted);
    line-height: 1.5;
}
.acta-cat__end-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.acta-cat__end-actions .acta-cat__btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
}

/* ── Empty & toast ── */
.acta-cat__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    color: var(--acta-cat-muted);
}
.acta-cat__empty a {
    color: var(--acta-cat-green-light);
    font-weight: 600;
}

.acta-cat__toast {
    position: fixed;
    bottom: calc(var(--acta-cat-bar-h) + 1rem);
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    z-index: 300;
    padding: 0.6rem 1.1rem;
    border-radius: 2rem;
    background: rgba(26, 46, 20, 0.95);
    border: 1px solid var(--acta-cat-border);
    color: var(--acta-cat-text);
    font-size: 0.8125rem;
    font-weight: 600;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
}
.acta-cat__toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.acta-cat--flipping .acta-cat__header,
.acta-cat--flipping .acta-cat__bar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

@media (prefers-reduced-motion: reduce) {
    .acta-cat__paper {
        transition-duration: 0.01ms !important;
    }
    .acta-cat__progress-fill,
    .acta-cat__grid,
    .acta-cat__end,
    .acta-cat__toast,
    .acta-cat__dot,
    .acta-cat__grid-item {
        transition: none !important;
        animation: none !important;
    }
}

@media print {
    .acta-cat__header,
    .acta-cat__bar,
    .acta-cat__nav,
    .acta-cat__grid,
    .acta-cat__end,
    .acta-cat__toast,
    .acta-cat__swipe-hint { display: none !important; }
    .acta-cat { overflow: visible; background: #fff; }
    .acta-cat__app { height: auto; max-height: none; }
    .acta-cat__slide { position: static; visibility: visible; opacity: 1; page-break-after: always; padding: 0; }
    .acta-cat__paper { width: 100%; max-height: none; filter: none; }
}
