/* ===== Fullscreen presentation roller deck ===== */

html.presentation-active,
html.presentation-active body {
    overflow: hidden;
}

#presentationOverlay {
    --pres-card-width: min(880px, 72vw);
    --pres-app-background-image: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 48%, rgba(98, 82, 154, 0.28), transparent 34%),
        radial-gradient(circle at 18% 20%, rgba(30, 93, 118, 0.18), transparent 28%),
        linear-gradient(145deg, #08090d 0%, #11131b 55%, #090a0f 100%);
    isolation: isolate;
}

#presentationOverlay.hidden {
    display: none;
}

#presentationOverlay::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse at center 78%, rgba(255, 255, 255, 0.08), transparent 58%);
}

#presentationOverlay::after {
    content: '';
    position: absolute;
    inset: -1%;
    z-index: 0;
    pointer-events: none;
    background-image: var(--pres-app-background-image);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    filter: saturate(0.82) brightness(0.72);
    opacity: 0;
    transform: scale(1.02);
    transition: opacity 220ms ease;
}

#presentationOverlay.has-app-background::after {
    opacity: 0.46;
}

.pres-deck {
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: clamp(1rem, 2.2vw, 2.25rem);
    width: 100%;
    height: 100%;
    padding: 7vh max(1.5rem, calc((100% - var(--pres-card-width)) / 2));
    overflow-x: auto;
    overflow-y: hidden;
    perspective: 1800px;
    scroll-snap-type: none;
    scroll-behavior: smooth;
    scrollbar-width: none;
    overscroll-behavior: contain;
}

.pres-deck::-webkit-scrollbar {
    display: none;
}

.pres-message {
    box-sizing: border-box;
    flex: 0 0 var(--pres-card-width);
    height: min(82vh, 800px);
    max-height: calc(100vh - 3rem);
    padding: clamp(1.4rem, 2.7vw, 2.6rem);
    overflow: auto;
    scrollbar-color: rgba(226, 232, 240, 0.3) transparent;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    position: relative;
    color: #e9edf7;
    background: linear-gradient(155deg, rgba(31, 34, 45, 0.98), rgba(19, 21, 29, 0.99));
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 18px;
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.46);
    opacity: 0.42;
    transform: scale(0.76);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    cursor: pointer;
    outline: none;
    transition:
        transform 430ms cubic-bezier(0.2, 0.78, 0.24, 1),
        opacity 300ms ease,
        box-shadow 320ms ease,
        border-color 320ms ease;
}

.pres-message::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.pres-message::-webkit-scrollbar-track {
    margin: 12px 0;
    background: transparent;
}

.pres-message::-webkit-scrollbar-thumb {
    min-height: 44px;
    background: rgba(226, 232, 240, 0.3);
    background-clip: padding-box;
    border: 3px solid transparent;
    border-radius: 999px;
}

.pres-message::-webkit-scrollbar-thumb:hover {
    background: rgba(226, 232, 240, 0.5);
    background-clip: padding-box;
}

.pres-message::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.pres-message::-webkit-scrollbar-corner {
    background: transparent;
}

.pres-message.is-before {
    opacity: 0.56;
    transform: rotateY(40deg) translateX(34px) scale(0.83);
    transform-origin: right center;
}

.pres-message.is-after {
    opacity: 0.56;
    transform: rotateY(-40deg) translateX(-34px) scale(0.83);
    transform-origin: left center;
}

.pres-message.is-active {
    z-index: 3;
    opacity: 1;
    cursor: default;
    transform: translateZ(90px) scale(1);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 36px 90px rgba(0, 0, 0, 0.62);
}

.pres-message:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.88);
    outline-offset: 5px;
}

.pres-message:not(.is-active) .pres-content-inner {
    pointer-events: none;
    user-select: none;
}

.pres-message.pres-role-user {
    background: linear-gradient(150deg, #172038 0%, #101626 100%);
}

.pres-message.pres-role-whiteboard {
    background: linear-gradient(155deg, #20232b 0%, #15171d 100%);
    border-color: rgba(203, 213, 225, 0.16);
}

.pres-message.pres-role-whiteboard .pres-label-media {
    color: #cbd5e1;
}

.pres-message.pres-role-whiteboard .pres-img {
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
}

.pres-whiteboard-zoom {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: zoom-in;
    outline: none;
}

.pres-whiteboard-zoom .pres-img {
    transition: filter 180ms ease, border-color 180ms ease;
}

.pres-whiteboard-zoom:hover .pres-img,
.pres-whiteboard-zoom:focus-visible .pres-img {
    filter: brightness(1.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.pres-whiteboard-zoom:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.88);
    outline-offset: 5px;
}

.pres-whiteboard-zoom-hint {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    padding: 0.42rem 0.68rem;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.pres-whiteboard-zoom:hover .pres-whiteboard-zoom-hint,
.pres-whiteboard-zoom:focus-visible .pres-whiteboard-zoom-hint {
    opacity: 1;
    transform: translateY(0);
}

.pres-message.pres-role-embed {
    background: linear-gradient(150deg, #10251d 0%, #0d1714 100%);
}

.pres-content-inner {
    width: 100%;
    min-height: 100%;
}

.pres-msg-label {
    margin-bottom: 1rem;
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    opacity: 0.72;
}

.pres-label-ai { color: #c4b5fd; }
.pres-label-user { color: #a5b4fc; }
.pres-label-media { color: #facc15; }
.pres-label-embed { color: #6ee7b7; }

.pres-msg-body {
    color: #e8ecf5;
    font-size: clamp(1.05rem, 1.35vw, 1.28rem);
    line-height: 1.75;
}

.pres-user-text {
    color: #eef2ff;
    font-size: clamp(1.25rem, 2vw, 1.8rem);
    line-height: 1.55;
}

.pres-msg-body h1,
.pres-msg-body h2,
.pres-msg-body h3,
.pres-msg-body h4,
.pres-msg-body h5,
.pres-msg-body h6 {
    color: #ffffff;
    line-height: 1.2;
}

.pres-msg-body h1 { margin: 0 0 1rem; font-size: clamp(2rem, 3.4vw, 3.25rem); }
.pres-msg-body h2 { margin: 1.4rem 0 0.8rem; font-size: clamp(1.65rem, 2.5vw, 2.35rem); }
.pres-msg-body h3 { margin: 1.2rem 0 0.65rem; font-size: clamp(1.3rem, 1.8vw, 1.7rem); }
.pres-msg-body h4,
.pres-msg-body h5,
.pres-msg-body h6 { margin: 1rem 0 0.55rem; font-size: 1.15rem; }

.pres-msg-body p { margin: 0 0 1rem; }
.pres-msg-body p:last-child { margin-bottom: 0; }

.pres-msg-body ul,
.pres-msg-body ol {
    margin: 0.6rem 0 1rem;
    padding-left: 1.7rem;
}

.pres-msg-body li { margin-bottom: 0.5rem; }
.pres-msg-body strong { color: #ffffff; }
.pres-msg-body em { color: rgba(232, 236, 245, 0.82); }

.pres-msg-body code {
    padding: 0.12em 0.45em;
    color: #a5f3fc;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    font-family: var(--font-mono, monospace);
    font-size: 0.88em;
}

.pres-msg-body pre {
    margin: 0.8rem 0 1rem;
    padding: 1.15rem 1.3rem;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.26);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.pres-msg-body pre code {
    padding: 0;
    background: none;
    border: 0;
}

.pres-msg-body blockquote {
    margin: 1rem 0;
    padding-left: 1.2rem;
    color: rgba(232, 236, 245, 0.74);
    border-left: 3px solid #a78bfa;
}

.pres-msg-body table {
    width: 100%;
    margin: 0.8rem 0 1rem;
    border-collapse: collapse;
}

.pres-msg-body th,
.pres-msg-body td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.pres-msg-body th {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
}

.pres-msg-body a { color: #a5b4fc; }

.pres-img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(min(82vh, 800px) - 7rem);
    margin: 0 auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 16px 52px rgba(0, 0, 0, 0.5);
}

.pres-img-caption {
    margin-top: 0.85rem;
    color: rgba(232, 236, 245, 0.58);
    font-size: 0.9rem;
    text-align: center;
}

.pres-embed {
    overflow: hidden;
    background: #0c0e13;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.pres-embed iframe {
    display: block;
    width: 100%;
    min-height: min(60vh, 560px);
    border: 0;
}

.pres-msg-body .katex { color: #f7f7fb; }
.pres-msg-body .katex-display { overflow-x: auto; }

.pres-whiteboard-lightbox {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding: clamp(1.25rem, 4vw, 3.5rem);
    background: rgba(7, 9, 13, 0.84);
    backdrop-filter: blur(14px);
}

.pres-whiteboard-lightbox.hidden {
    display: none;
}

.pres-whiteboard-lightbox-content {
    display: grid;
    place-items: center;
    gap: 0.8rem;
    max-width: 100%;
    max-height: 100%;
}

.pres-whiteboard-lightbox-image {
    display: block;
    max-width: min(94vw, 1500px);
    max-height: calc(100vh - 7rem);
    object-fit: contain;
    background: #202224;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.pres-whiteboard-lightbox-hint {
    color: rgba(241, 245, 249, 0.76);
    font-size: 0.82rem;
    text-align: center;
}

.pres-whiteboard-lightbox-close {
    position: absolute;
    top: clamp(0.8rem, 2vw, 1.4rem);
    right: clamp(0.8rem, 2vw, 1.4rem);
    z-index: 1;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

.pres-whiteboard-lightbox-close:hover,
.pres-whiteboard-lightbox-close:focus-visible {
    background: rgba(30, 41, 59, 0.96);
    outline: 3px solid rgba(255, 255, 255, 0.9);
    outline-offset: 3px;
    transform: scale(1.04);
}

/* Match the slideshow to the app's selected light theme. Dark mode uses the
   base presentation palette above. */
[data-theme="light"] #presentationOverlay {
    background:
        radial-gradient(circle at 50% 46%, rgba(144, 124, 101, 0.17), transparent 35%),
        radial-gradient(circle at 18% 18%, rgba(103, 134, 158, 0.12), transparent 30%),
        linear-gradient(145deg, #e8e2da 0%, #f7f3ee 54%, #e5dfd7 100%);
}

[data-theme="light"] #presentationOverlay::before {
    background: radial-gradient(ellipse at center 78%, rgba(255, 255, 255, 0.72), transparent 60%);
}

[data-theme="light"] #presentationOverlay.has-app-background::after {
    filter: saturate(0.72) brightness(1.04) contrast(0.92);
    opacity: 0.5;
}

[data-theme="light"] .pres-message {
    color: #2a2422;
    background: linear-gradient(155deg, rgba(255, 253, 250, 0.99), rgba(245, 241, 236, 0.99));
    border-color: rgba(74, 63, 57, 0.15);
    box-shadow: 0 22px 58px rgba(42, 36, 34, 0.18);
    scrollbar-color: rgba(74, 63, 57, 0.3) transparent;
}

[data-theme="light"] .pres-message::-webkit-scrollbar-thumb {
    background: rgba(74, 63, 57, 0.3);
    background-clip: padding-box;
}

[data-theme="light"] .pres-message::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 63, 57, 0.48);
    background-clip: padding-box;
}

[data-theme="light"] .pres-message.is-active {
    border-color: rgba(74, 63, 57, 0.24);
    box-shadow: 0 34px 82px rgba(42, 36, 34, 0.24);
}

[data-theme="light"] .pres-message:focus-visible {
    outline-color: rgba(42, 36, 34, 0.88);
}

[data-theme="light"] .pres-message.pres-role-user {
    background: linear-gradient(150deg, #eef3fb 0%, #e2eaf5 100%);
}

[data-theme="light"] .pres-message.pres-role-whiteboard {
    background: linear-gradient(155deg, #f8f5f0 0%, #ece7df 100%);
    border-color: rgba(95, 89, 81, 0.2);
}

[data-theme="light"] .pres-message.pres-role-whiteboard .pres-label-media {
    color: #5f6670;
}

[data-theme="light"] .pres-message.pres-role-whiteboard .pres-img {
    border-color: rgba(42, 36, 34, 0.1);
    box-shadow: 0 2px 10px rgba(42, 36, 34, 0.16);
}

[data-theme="light"] .pres-whiteboard-zoom:hover .pres-img,
[data-theme="light"] .pres-whiteboard-zoom:focus-visible .pres-img {
    border-color: rgba(42, 36, 34, 0.24);
}

[data-theme="light"] .pres-whiteboard-zoom:focus-visible {
    outline-color: rgba(42, 36, 34, 0.84);
}

[data-theme="light"] .pres-message.pres-role-embed {
    background: linear-gradient(150deg, #eef7f1 0%, #e1eee6 100%);
}

[data-theme="light"] .pres-label-ai { color: #6d5b8f; }
[data-theme="light"] .pres-label-user { color: #4c6288; }
[data-theme="light"] .pres-label-media { color: #8a6a14; }
[data-theme="light"] .pres-label-embed { color: #47735f; }

[data-theme="light"] .pres-msg-body,
[data-theme="light"] .pres-user-text {
    color: #302a27;
}

[data-theme="light"] .pres-msg-body h1,
[data-theme="light"] .pres-msg-body h2,
[data-theme="light"] .pres-msg-body h3,
[data-theme="light"] .pres-msg-body h4,
[data-theme="light"] .pres-msg-body h5,
[data-theme="light"] .pres-msg-body h6,
[data-theme="light"] .pres-msg-body strong {
    color: #1f1b19;
}

[data-theme="light"] .pres-msg-body em {
    color: rgba(48, 42, 39, 0.82);
}

[data-theme="light"] .pres-msg-body code {
    color: #0e6574;
    background: rgba(42, 36, 34, 0.07);
    border-color: rgba(42, 36, 34, 0.1);
}

[data-theme="light"] .pres-msg-body pre {
    background: rgba(42, 36, 34, 0.06);
    border-color: rgba(42, 36, 34, 0.11);
}

[data-theme="light"] .pres-msg-body blockquote {
    color: rgba(48, 42, 39, 0.72);
    border-left-color: #7c6aa4;
}

[data-theme="light"] .pres-msg-body th,
[data-theme="light"] .pres-msg-body td {
    border-bottom-color: rgba(42, 36, 34, 0.12);
}

[data-theme="light"] .pres-msg-body th {
    color: #211d1b;
    background: rgba(42, 36, 34, 0.06);
}

[data-theme="light"] .pres-msg-body a { color: #506aa0; }
[data-theme="light"] .pres-img { box-shadow: 0 14px 36px rgba(42, 36, 34, 0.18); }
[data-theme="light"] .pres-img-caption { color: rgba(48, 42, 39, 0.62); }

[data-theme="light"] .pres-embed {
    background: #fffdfa;
    border-color: rgba(42, 36, 34, 0.13);
}

[data-theme="light"] .pres-msg-body .katex { color: #211d1b; }

[data-theme="light"] .pres-whiteboard-lightbox {
    background: rgba(245, 241, 236, 0.88);
}

[data-theme="light"] .pres-whiteboard-lightbox-image {
    border-color: rgba(42, 36, 34, 0.14);
    box-shadow: 0 24px 70px rgba(42, 36, 34, 0.24);
}

[data-theme="light"] .pres-whiteboard-lightbox-hint {
    color: rgba(42, 36, 34, 0.68);
}

[data-theme="light"] .pres-whiteboard-lightbox-close {
    color: #2a2422;
    background: rgba(255, 253, 250, 0.88);
    border-color: rgba(42, 36, 34, 0.14);
}

[data-theme="light"] .pres-whiteboard-lightbox-close:hover,
[data-theme="light"] .pres-whiteboard-lightbox-close:focus-visible {
    background: #fffdfa;
    outline-color: rgba(42, 36, 34, 0.82);
}

@media (max-width: 760px) {
    #presentationOverlay { --pres-card-width: 88vw; }
    .pres-deck { gap: 0.7rem; padding-block: 5vh; }
    .pres-message { height: 84vh; padding: 1.25rem; border-radius: 14px; }
    .pres-message.is-before { transform: rotateY(24deg) translateX(16px) scale(0.88); }
    .pres-message.is-after { transform: rotateY(-24deg) translateX(-16px) scale(0.88); }
}

@media (prefers-reduced-motion: reduce) {
    .pres-deck { scroll-behavior: auto; }
    .pres-message,
    .pres-whiteboard-zoom .pres-img,
    .pres-whiteboard-zoom-hint,
    .pres-whiteboard-lightbox-close { transition: none; }
}
