:root {
    --bg: #FFFFFF;
    --surface: #F5F5F5;
    --surface-2: #EBEBEB;
    --border: #E0E0E0;
    --text-muted: #6B6B6B;
    --text: #0A0A0A;
    --primary: #0A0A0A;
    --on-primary: #FFFFFF;
    color-scheme: light;
}

/* Segue o sistema do usuário, a menos que ele escolha manualmente */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0A0A0A;
        --surface: #141414;
        --surface-2: #1F1F1F;
        --border: #2E2E2E;
        --text-muted: #A3A3A3;
        --text: #FAFAFA;
        --primary: #FFFFFF;
        --on-primary: #0A0A0A;
        color-scheme: dark;
    }
}

/* Escolha manual via botão de tema */
:root[data-theme="dark"] {
    --bg: #0A0A0A;
    --surface: #141414;
    --surface-2: #1F1F1F;
    --border: #2E2E2E;
    --text-muted: #A3A3A3;
    --text: #FAFAFA;
    --primary: #FFFFFF;
    --on-primary: #0A0A0A;
    color-scheme: dark;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    transition: background-color .2s ease, color .2s ease;
}

section[id] {
    scroll-margin-top: 5rem;
}

/* Ícone do botão de tema: mostra a lua no light e o sol no dark */
.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

:root[data-theme="dark"] .icon-sun {
    display: block;
}

:root[data-theme="dark"] .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun {
        display: block;
    }

    :root:not([data-theme="light"]) .icon-moon {
        display: none;
    }
}

/* ============ Animações (GSAP) ============ */
/* Estado inicial "escondido" dos elementos animados. Só se aplica com JS
   habilitado (classe .js no <html>), senão o conteúdo aparece normal. */
.js .reveal,
.js [data-reveal-group]>* {
    opacity: 0;
    transform: translateY(24px);
    will-change: opacity, transform;
}

.js .reveal-header {
    opacity: 0;
    transform: translateY(-16px);
}

@media (prefers-reduced-motion: reduce) {

    .js .reveal,
    .js [data-reveal-group]>*,
    .js .reveal-header {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ============ Projetos: destaque, snapshot e fundos animados ============ */

/* Luzes de fundo que se movem (cores suaves, adaptadas ao tema) */
:root {
    --glow-1: rgba(0, 0, 0, 0.09);
    --glow-2: rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] {
    --glow-1: rgba(255, 255, 255, 0.1);
    --glow-2: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --glow-1: rgba(255, 255, 255, 0.1);
        --glow-2: rgba(255, 255, 255, 0.06);
    }
}

.lights {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.light {
    position: absolute;
    width: 42vmax;
    height: 42vmax;
    border-radius: 50%;
    background: radial-gradient(circle, var(--glow-1) 0%, transparent 70%);
    filter: blur(60px);
    animation: light-drift 18s ease-in-out infinite alternate;
}

.light-1 {
    top: -12%;
    left: -8%;
}

.light-2 {
    right: -10%;
    bottom: -15%;
    background: radial-gradient(circle, var(--glow-2) 0%, transparent 70%);
    animation-duration: 22s;
    animation-delay: -6s;
}

@keyframes light-drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(12vw, 8vh) scale(1.15);
    }

    100% {
        transform: translate(-6vw, 14vh) scale(0.95);
    }
}

/* Faixa que atravessa a tela em loop, como carrossel */
.marquee-band {
    position: relative;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marquee 28s linear infinite;
}

.marquee-group {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    padding-right: 2.5rem;
}

.marquee-group span {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.marquee-group .marquee-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--primary);
}

.marquee-band:hover .marquee-track {
    animation-play-state: paused;
}

@keyframes marquee {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

/* Selo de projeto em destaque */
.featured-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--primary);
    color: var(--on-primary);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.featured-badge::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}

/* Snapshot: ao passar o mouse, a "página" desce de cima pra baixo */
.snapshot {
    position: relative;
    overflow: hidden;
}

.snapshot-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    transition: transform 4.5s cubic-bezier(0.45, 0, 0.55, 1);
}

.snapshot:hover .snapshot-media {
    transform: translateY(-50%);
}

.snapshot-half {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50%;
    font-size: 0.875rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.snapshot-half-alt {
    background: repeating-linear-gradient(to bottom, transparent 0 22px, var(--border) 22px 23px);
    opacity: 0.6;
}

.snapshot-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

/* Imagem longa (capa completa): mostra do topo e rola até o fim no hover.
   A altura vem da própria imagem; o deslocamento é (altura da imagem − altura do card). */
.snapshot:has(.snapshot-media--img),
.snapshot:has(.snapshot-media > img) {
    container-type: size;
}

.snapshot-media--img,
.snapshot-media:has(> img) {
    height: auto;
    transition: transform 0.6s ease;
}

.snapshot-media--img img,
.snapshot-media:has(> img) img {
    height: auto;
    object-fit: initial;
}

.snapshot:hover .snapshot-media--img,
.snapshot:hover .snapshot-media:has(> img) {
    transform: translateY(calc(-100% + 100cqh));
    transition-duration: var(--snap-duration, 8s);
    transition-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}

/* Botões: halo de blur discreto ao passar o mouse */
a.bg-primary,
button.bg-primary {
    position: relative;
    isolation: isolate;
}

a.bg-primary::before,
button.bg-primary::before {
    content: "";
    position: absolute;
    inset: -4px;
    z-index: -1;
    border-radius: inherit;
    background: var(--primary);
    filter: blur(12px);
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

a.bg-primary:hover::before,
button.bg-primary:hover::before {
    opacity: 0.35;
    transform: scale(1);
}

/* ============ Leitor de PDF (branding books) ============ */
.reader-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    color: var(--text);
    background: transparent;
    transition: background-color .2s ease, opacity .2s ease;
}

.reader-btn:hover:not(:disabled) {
    background: var(--surface-2);
}

.reader-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.reader-btn[aria-pressed="true"] {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.reader button:focus-visible,
.reader a:focus-visible,
.reader input:focus-visible,
.reader-stage:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.page-input {
    width: 3.5rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    -moz-appearance: textfield;
}

.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Barra de progresso (range) */
.reader-slider {
    --pct: 0%;
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 1.25rem;
    background: transparent;
    cursor: pointer;
}

.reader-slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--primary) var(--pct), var(--border) var(--pct));
}

.reader-slider::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: var(--border);
}

.reader-slider::-moz-range-progress {
    height: 4px;
    border-radius: 999px;
    background: var(--primary);
}

.reader-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--primary);
}

.reader-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Corpo do leitor */
.reader-body {
    display: flex;
    height: min(78vh, 820px);
    min-height: 420px;
}

.reader-thumbs {
    flex: 0 0 9.5rem;
    overflow-y: auto;
    padding: 0.75rem;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.reader-thumbs[hidden] {
    display: none;
}

.thumb {
    display: block;
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
    text-align: center;
    transition: border-color .2s ease, background-color .2s ease;
}

.thumb:hover {
    background: var(--surface-2);
}

.thumb.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.thumb canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    border-radius: 0.25rem;
}

.thumb-ph {
    width: 100%;
    background: var(--surface-2);
    border-radius: 0.25rem;
}

.thumb span {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.thumb.is-active span {
    color: var(--text);
}

.reader-stage-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
}

.reader-stage {
    position: absolute;
    inset: 0;
    overflow: auto;
    padding: 1.5rem;
    display: flex;
    outline: none;
}

.reader-page-holder {
    margin: auto;
    flex: none;
}

.reader-canvas {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    transition: opacity .15s ease;
}

.reader-canvas.is-loading {
    opacity: 0.45;
}

/* Setas laterais sobre a página */
.reader-side {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-top: -1.375rem;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
}

.reader-side-left {
    left: 0.75rem;
}

.reader-side-right {
    right: 0.75rem;
}

.reader-stage-wrap:hover .reader-side:not(:disabled),
.reader-side:focus-visible {
    opacity: 0.9;
}

.reader-side:hover:not(:disabled) {
    transform: scale(1.08);
}

.reader-side:disabled {
    opacity: 0 !important;
    pointer-events: none;
}

@media (hover: none) {
    .reader-side:not(:disabled) {
        opacity: 0.7;
    }
}

.reader-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--surface-2);
}

.reader-overlay[hidden] {
    display: none;
}

.reader-spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: reader-spin 0.8s linear infinite;
}

@keyframes reader-spin {
    to {
        transform: rotate(360deg);
    }
}

.reader-kbd {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0.05rem 0.35rem;
    text-align: center;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.3rem;
}

/* Tela cheia */
.reader:fullscreen {
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border: 0;
    background: var(--surface);
}

.reader:fullscreen .reader-body {
    flex: 1;
    height: auto;
}

/* Mobile: miniaturas viram gaveta sobre a página */
@media (max-width: 767px) {
    .reader-body {
        position: relative;
        height: min(72vh, 680px);
    }

    .reader-thumbs {
        position: absolute;
        inset: 0 auto 0 0;
        z-index: 5;
        width: 8.5rem;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.18);
    }

    .reader-stage {
        padding: 0.75rem;
    }
}

/* Respeita quem prefere menos movimento */
@media (prefers-reduced-motion: reduce) {

    .reader-spinner {
        animation-duration: 2s;
    }

    .light,
    .marquee-track,
    .featured-badge::before {
        animation: none;
    }

    .snapshot-media,
    .snapshot-media--img,
    .snapshot-media:has(> img),
    .snapshot:hover .snapshot-media--img,
    .snapshot:hover .snapshot-media:has(> img),
    .snapshot:hover .snapshot-media {
        transition: none;
        transform: none;
    }
}

/* ============ Redesign: alternância Antes / Depois ============ */
.compare-tabs {
    display: inline-flex;
    flex: none;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg);
}

.compare-tabs button {
    min-width: 6rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: background-color .25s ease, color .25s ease;
}

.compare-tabs button:hover {
    color: var(--text);
}

.compare-tabs button[aria-selected="true"] {
    background: var(--primary);
    color: var(--on-primary);
}

.compare-tabs button:focus-visible,
.compare-pane:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (max-width: 767px) {
    .compare-tabs {
        display: flex;
    }

    .compare-tabs button {
        flex: 1;
    }
}

/* Moldura de navegador */
.compare-frame {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg);
}

.compare-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.compare-dots {
    display: flex;
    gap: 0.35rem;
}

.compare-dots i {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--border);
    box-shadow: inset 0 0 0 1px var(--text-muted);
    opacity: 0.7;
}

.compare-url {
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
}

.compare-hint {
    display: none;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (min-width: 640px) {
    .compare-hint {
        display: inline-flex;
    }
}

.compare-progress {
    height: 2px;
    background: var(--border);
}

.compare-progress span {
    display: block;
    height: 100%;
    width: 100%;
    background: var(--primary);
    transform-origin: left;
    transform: scaleX(0);
}

.compare-viewport {
    position: relative;
    height: min(70vh, 640px);
}

.compare-pane {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    outline: none;
    background: var(--bg);
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.compare-pane[hidden] {
    display: none;
}

.compare-pane.is-entering {
    animation: compare-in .35s ease;
}

.compare-pane img {
    display: block;
    width: 100%;
    height: auto;
}

@keyframes compare-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .compare-pane.is-entering {
        animation: none;
    }
}

/* Dica: halo "blur grow" pulsando no botão que ainda não foi visto */
.compare-tabs button {
    position: relative;
    isolation: isolate;
}

.compare-tabs.is-hint button[aria-selected="false"]::before {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: -1;
    border-radius: inherit;
    background: var(--primary);
    filter: blur(10px);
    opacity: 0;
    animation: tab-grow 1.8s ease-in-out infinite;
    pointer-events: none;
}

.compare-tabs.is-hint button[aria-selected="false"] {
    color: var(--text);
}

@keyframes tab-grow {
    0%, 100% {
        opacity: 0;
        transform: scale(0.9);
    }

    50% {
        opacity: 0.45;
        transform: scale(1.18);
    }
}

@media (prefers-reduced-motion: reduce) {
    .compare-tabs.is-hint button[aria-selected="false"]::before {
        animation: none;
        opacity: 0.3;
        transform: scale(1.1);
    }
}
