
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background: #171717;
    color: #eee;
    font-family: Arial, sans-serif;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.site-header {
    position: fixed;
    top: 28px;
    left: 25px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.brand-name {
    font-size: 40px;
    letter-spacing: 2px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    color: #FFCE34
}

.instructions {
    position: fixed;
    top: 28px;
    right: 35px;
    z-index: 5;
    color: #888;
    font-size: 10px;
}

.mobile-instructions,
.mobile-carousel-controls {
    display: none;
}

.counter {
    position: fixed;
    bottom: 35px;
    left: 35px;
    z-index: 5;
    color: #888;
    font-size: 10px;
}

.preview {
    position: fixed;
    right: 38px;
    bottom: 35px;
    width: 450px;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
    transition: .4s ease;
}

.preview.visible {
    opacity: 1;
    transform: translateY(0);
}

#previewImage {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
}

/* Fotografias horizontais */
#previewImage.horizontal {
    max-width: 100%;
    max-height: 75vh;
}

/* Fotografias verticais */
#previewImage.vertical {
   transform: translateX(100px);
    max-height: 55vh;
    max-width: 350px;
}

/* Fotografias quadradas */
#previewImage.quadrada {
    max-height: 60vh;
    max-width: 350px;
}

.preview h2 {
    margin: 12px 0 5px;
    font-size: 14px;
    font-weight: normal;
}

.preview p {
    margin: 0;
    color: #aaa;
    font-size: 10px;
    line-height: 1.6;
}

@media (max-width: 700px) {
    .preview {
        width: 180px;
        right: 18px;
        bottom: 65px;
    }
}

#scene {
    position: fixed;
    top: 0;
    left: 0;
    width: calc(100vw - 230px);
    height: 100vh;
}

.view-navigation {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 30px;
}

.collection-menu-toggle {
    display: none;
}

.view-tab {
    padding: 5px 0;
    border: 0;
    background: transparent;
    color: #777;
    font-size: 8px;
    letter-spacing: .5px;
    cursor: pointer;
    transition: color .2s ease;
}

.view-tab:hover,
.view-tab.active {
    color: #FFCE34;
}

.collection-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-color: #555 #171717;
    scrollbar-width: thin;
}

.collection-list::-webkit-scrollbar {
    width: 6px;
}

.collection-list::-webkit-scrollbar-track {
    background: #171717;
}

.collection-list::-webkit-scrollbar-thumb {
    border: 1px solid #171717;
    border-radius: 6px;
    background: #555;
}

.collection-list::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.project-viewer {
    display: none;
}

.alternate-view {
    position: fixed;
    top: 0;
    left: 230px;
    display: none;
    width: calc(100vw - 230px);
    height: 100vh;
    box-sizing: border-box;
    padding: 105px 40px 35px;
}

body.color-gallery-expanded #colorView {
    left: var(--color-gallery-sidebar-width);
    width: calc(100vw - var(--color-gallery-sidebar-width));
}

body[data-view="color"] #scene,
body[data-view="bio"] #scene,
body[data-view="color"] .project-viewer,
body[data-view="bio"] .project-viewer,
body[data-view="color"] .preview,
body[data-view="bio"] .preview,
body[data-view="color"] .counter,
body[data-view="bio"] .counter,
body[data-view="color"] .description,
body[data-view="bio"] .description,
body[data-view="color"] .instructions,
body[data-view="bio"] .instructions {
    display: none !important;
}

body[data-view="color"] #colorView,
body[data-view="bio"] #bioView {
    display: flex;
}

.alternate-heading {
    display: flex;
    flex: none;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.alternate-heading h1,
.bio-copy h1 {
    margin: 0;
    color: #eee;
    font-size: 18px;
    font-weight: normal;
    letter-spacing: 2px;
}

.alternate-heading p,
.view-hint {
    margin: 8px 0 0;
    color: #777;
    font-size: 10px;
    letter-spacing: .5px;
}

.color-view,
.bio-view {
    flex-direction: column;
    color: #eee;
}

.color-view .alternate-heading {
    align-items: flex-start;
}

.color-explorer {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    min-height: 0;
}

.color-photos-panel {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 14px;
}

.color-photos-panel[hidden] {
    display: none;
}

.color-photos-header {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
}

.color-selection-swatch {
    width: 30px;
    height: 30px;
    flex: none;
    border: 1px solid rgba(255, 255, 255, .45);
}

.color-selection-info {
    min-width: 0;
    flex: 1;
}

.color-selection-info h2 {
    margin: 0;
    color: #eee;
    font-size: 11px;
    font-weight: normal;
    letter-spacing: 1px;
}

.color-selection-info p {
    margin: 5px 0 0;
    color: #888;
    font-size: 9px;
}

.color-panel-close {
    width: 28px;
    height: 28px;
    flex: none;
    border: 1px solid #444;
    background: transparent;
    color: #bbb;
    font-size: 18px;
    cursor: pointer;
}

.color-panel-close:hover {
    border-color: #FFCE34;
    color: #FFCE34;
}

.color-photos-grid {
    display: grid;
    min-height: 0;
    flex: 1;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    align-content: start;
    gap: 8px;
    overflow-y: auto;
    scrollbar-color: #555 #171717;
    scrollbar-width: thin;
}

.color-gallery-photo {
    display: block;
    aspect-ratio: 1;
    padding: 0;
    overflow: hidden;
    border: 1px solid #333;
    background: #222;
    cursor: zoom-in;
}

.color-gallery-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.color-wheel-viewport {
    display: grid;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    place-items: center;
}

.color-wheel {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
}

.color-wheel::before {
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .24);
    background:
        linear-gradient(
            90deg,
            transparent calc(50% - 1px),
            #888 calc(50% - 1px),
            #888 calc(50% + 1px),
            transparent calc(50% + 1px)
        ),
        linear-gradient(
            0deg,
            transparent calc(50% - 1px),
            #888 calc(50% - 1px),
            #888 calc(50% + 1px),
            transparent calc(50% + 1px)
        ),
        radial-gradient(circle, #f2f2f2 5%, #858585 30%, #222 70%);
    content: "";
}

.color-wheel-photos {
    position: absolute;
    inset: 0;
}

.color-swatch {
    position: absolute;
    z-index: 1;
    display: block;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .65);
    border-radius: 3px;
    background: var(--average-color);
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: z-index .1s, transform .15s, box-shadow .15s;
}

.color-swatch:hover,
.color-swatch[aria-pressed="true"] {
    z-index: 5;
    box-shadow: 0 0 0 2px #fff, 0 0 14px #000;
    transform: translate(-50%, -50%) scale(1.3);
}

.bio-card {
    display: grid;
    width: min(900px, 100%);
    grid-template-columns: minmax(220px, .8fr) 1.2fr;
    align-items: center;
    gap: clamp(30px, 8vw, 100px);
    margin: auto;
}

.bio-portrait {
    display: grid;
    position: relative;
    overflow: visible;
    min-height: 360px;
    place-items: center;
    border: 1px solid #383838;
    background: linear-gradient(145deg, #242424, #191919 55%, #252525);
    color: #777;
    font-size: 12px;
    letter-spacing: 3px;
}

.bio-portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bio-portrait-label {
    display: none;
}

.bio-copy {
    max-width: 440px;
}

.bio-mobile-eyebrow {
    display: block;
}

.bio-eyebrow {
    margin: 0 0 16px;
    color: #FFCE34;
    font-size: 9px;
    letter-spacing: 2px;
}

.bio-copy h1 {
    margin-bottom: 20px;
    font-size: 24px;
}

.bio-copy > p:last-child {
    color: #999;
    font-size: 13px;
    line-height: 1.8;
}

@media (min-width: 701px) {
    .bio-card {
        width: min(740px, 100%);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
        gap: clamp(32px, 5vw, 60px);
    }

    .bio-portrait {
        min-height: 0;
        aspect-ratio: 1;
    }

    .bio-copy {
        align-self: start;
        display: grid;
        width: 100%;
        max-width: none;
        height: auto;
        min-height: 0;
        aspect-ratio: 1;
        padding: 0 12px;
        grid-template-columns: minmax(0, 1fr);
        align-content: start;
        gap: 12px;
        border: 0;
    }

    .bio-copy h1 {
        align-self: start;
        margin: 0;
        font-size: clamp(16px, 2.4vw, 28px);
        font-weight: bold;
        line-height: 1.1;
    }

    .bio-copy > p:last-child {
        align-self: start;
        margin: 0;
        font-size: clamp(10px, 1.1vw, 13px);
        line-height: 1.45;
        text-align: justify;
    }

    .bio-mobile-eyebrow {
        display: none;
    }

    .bio-portrait-label {
        position: absolute;
        top: 0;
        right: auto;
        left: calc(100% + 6px);
        z-index: 1;
        display: block;
        margin: 0;
        color: #FFCE34;
        font-size: clamp(21px, calc(5.86vw - 19.7px), 42px);
        letter-spacing: 1.5px;
        white-space: nowrap;
        writing-mode: vertical-rl;
    }
}

@media (min-width: 701px) and (max-width: 760px) {
    .bio-copy {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .bio-copy h1 {
        font-size: 16px;
    }

    .bio-copy > p:last-child {
        font-size: 9px;
        line-height: 1.35;
    }
}

@media (min-width: 701px) and (max-width: 800px) {
    .bio-portrait-label {
        font-size: clamp(21px, calc(5.93vw - 20.4px), 27px);
    }
}

body.project-mode #scene {
    display: none;
}

body.project-mode .project-viewer {
    position: fixed;
    top: 0;
    left: 230px;
    display: flex;
    width: calc(100vw - 230px);
    height: 100vh;
    align-items: center;
    justify-content: center;
    perspective: 1400px;
}

body.project-mode .preview {
    display: none;
}

body.project-mode .instructions {
    right: 35px;
}

.project-stage {
    position: relative;
    width: min(78vw, 1100px);
    height: 82vh;
    transform-style: preserve-3d;
}

.project-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    backface-visibility: hidden;
}

.project-image-incoming {
    visibility: hidden;
}

.project-image-incoming.turning-next,
.project-image-incoming.turning-previous,
.project-image-current.leaving-next,
.project-image-current.leaving-previous {
    visibility: visible;
    animation-duration: 750ms;
    animation-timing-function: cubic-bezier(.22, .68, 0, 1);
    animation-fill-mode: both;
}

.project-image-incoming.turning-next {
    animation-name: wheel-enter-next;
}

.project-image-incoming.turning-previous {
    animation-name: wheel-enter-previous;
}

.project-image-current.leaving-next {
    animation-name: wheel-leave-next;
}

.project-image-current.leaving-previous {
    animation-name: wheel-leave-previous;
}

@keyframes wheel-enter-next {
    from { transform: translateY(85%) rotateX(-65deg) scale(.8); opacity: .25; }
    to { transform: translateY(0) rotateX(0) scale(1); opacity: 1; }
}

@keyframes wheel-enter-previous {
    from { transform: translateY(-85%) rotateX(65deg) scale(.8); opacity: .25; }
    to { transform: translateY(0) rotateX(0) scale(1); opacity: 1; }
}

@keyframes wheel-leave-next {
    from { transform: translateY(0) rotateX(0) scale(1); opacity: 1; }
    to { transform: translateY(-85%) rotateX(65deg) scale(.8); opacity: .25; }
}

@keyframes wheel-leave-previous {
    from { transform: translateY(0) rotateX(0) scale(1); opacity: 1; }
    to { transform: translateY(85%) rotateX(-65deg) scale(.8); opacity: .25; }
}

.project-nav {
    position: absolute;
    z-index: 2;
    top: 50%;
    width: 48px;
    height: 64px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 50px;
    font-weight: 200;
    line-height: 1;
    cursor: pointer;
    opacity: .65;
    transform: translateY(-50%);
    transition: opacity .2s ease;
}

.project-nav:hover {
    opacity: 1;
}

.project-nav-previous {
    left: 28px;
}

.project-nav-next {
    right: 28px;
}

.project-caption {
    position: absolute;
    bottom: 32px;
    left: 50%;
    color: #aaa;
    font-size: 11px;
    letter-spacing: 1px;
    transform: translateX(-50%);
}

body.project-mode .counter {
    left: 260px;
}

.collection-group {
    margin-bottom: 18px;
}

.collection-group-title {
    width: 100%;
    padding: 0 0 9px;
    border: none;
    border-bottom: 1px solid #444;
    background: transparent;
    color: #777;
    font-size: 9px;
    letter-spacing: 1.8px;
    text-align: left;
    cursor: pointer;
}

.collection-group-title::after {
    content: "\2212";
    float: right;
    color: #aaa;
}

.collection-group.collapsed .collection-group-items {
    display: none;
}

.collection-group.collapsed .collection-group-title::after {
    content: "+";
}

.collection-button {
    display: block;
    width: 100%;
    padding: 10px 0;
    border: none;
    border-bottom: 1px solid #2d2d2d;
    background: transparent;
    color: #888;
    font-size: 11px;
    letter-spacing: 1px;
    text-align: left;
    cursor: pointer;
}

.collection-button:hover,
.collection-button.active {
    color: #fff;
}

.collection-button.active {
    font-weight: bold;
}
/* Foto pequena clicável */
.preview.visible #previewImage {
    pointer-events: auto;
    cursor: zoom-in;
}

/* Foto em grande, no centro do ecrã */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0075AB;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
    touch-action: pan-y;
}

.lightbox.open {
    opacity: 1;
    pointer-events: auto;
}

.lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
}
/* Descrição da coleção */
.description {
    position: fixed;
    top: 65px;
    right: 35px;
    width: 320px;
    max-height: 30vh;
    overflow-y: auto;
    z-index: 5;
    color: #bbb;
    font-size: 12px;
    line-height: 1.7;
    text-align: right;
    white-space: pre-line;
}

.description:empty {
    display: none;
}

@media (max-width: 700px) {
    :root {
        --mobile-dock-height: clamp(170px, 30vh, 250px);
        --mobile-dock-height: clamp(170px, 30dvh, 250px);
    }

    body[data-view="collections"] {
        --mobile-dock-height: calc(62px + env(safe-area-inset-bottom, 0px));
    }

    body[data-view="collections"].collection-menu-open {
        --mobile-dock-height: calc(min(45vh, 360px) + env(safe-area-inset-bottom, 0px));
        --mobile-dock-height: calc(min(45dvh, 360px) + env(safe-area-inset-bottom, 0px));
    }

    .site-header {
        top: 18px;
        left: 18px;
        gap: 8px;
    }

    .brand-logo {
        width: 28px;
        height: 28px;
    }

    .brand-name {
        font-size: 10px;
        letter-spacing: 1.5px;
    }

    .instructions {
        display: none;
    }

    .mobile-instructions {
        position: fixed;
        top: 27px;
        right: 18px;
        z-index: 5;
        display: block;
        color: #888;
        font-size: 9px;
        letter-spacing: .3px;
    }

    .mobile-carousel-controls {
        position: fixed;
        top: calc((100dvh - var(--mobile-dock-height)) / 2);
        right: 8px;
        left: 8px;
        z-index: 8;
        display: flex;
        align-items: center;
        justify-content: space-between;
        pointer-events: none;
        transform: translateY(-50%);
    }

    .mobile-carousel-controls button {
        display: grid;
        width: 44px;
        height: 44px;
        padding: 0;
        place-items: center;
        border: 0;
        background: transparent;
        color: rgba(238, 238, 238, .6);
        font-size: 25px;
        line-height: 1;
        opacity: .8;
        pointer-events: auto;
        touch-action: manipulation;
        transition: color .2s ease, opacity .2s ease;
    }

    .mobile-carousel-controls button:hover,
    .mobile-carousel-controls button:active {
        color: #FFCE34;
        opacity: 1;
    }

    body.project-mode .mobile-carousel-controls,
    body[data-view="color"] .mobile-carousel-controls,
    body[data-view="bio"] .mobile-carousel-controls {
        display: none;
    }

    body.project-mode .mobile-instructions,
    body[data-view="color"] .mobile-instructions,
    body[data-view="bio"] .mobile-instructions {
        display: none;
    }

    .description {
        width: 200px;
        right: 18px;
    }

    body.project-mode .project-viewer {
        left: 230px;
        width: calc(100vw - 230px);
    }

    .project-stage {
        width: calc(100% - 48px);
        height: 72vh;
    }

    .project-nav-previous {
        left: 0;
    }

    .project-nav-next {
        right: 0;
    }

    body.project-mode .counter {
        left: 245px;
    }

    .alternate-view {
        padding: 82px 16px 20px;
    }

    .alternate-heading {
        margin-bottom: 14px;
    }

    .alternate-heading h1 {
        font-size: 15px;
    }

    .view-hint {
        max-width: 150px;
        text-align: right;
    }

    .bio-card {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
        margin: 0 auto;
    }

    .bio-portrait {
        min-height: min(32vh, 220px);
    }

    .bio-copy h1 {
        font-size: 19px;
    }

    .collection-sidebar {
        top: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: var(--mobile-dock-height) !important;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
        border-top: 1px solid #383838;
        background: #171717 !important;
    }

    .view-navigation {
        position: fixed;
        top: calc(58px + env(safe-area-inset-top, 0px));
        left: 50%;
        z-index: 22;
        width: max-content;
        justify-content: center;
        gap: 4px;
        margin: 0;
        padding: 2px 6px;
        border: 1px solid #383838;
        border-radius: 24px;
        background: rgba(23, 23, 23, .92);
        transform: translateX(-50%);
    }

    .view-tab {
        padding: 0 12px;
    }

    .collection-menu-toggle {
        display: block;
        flex: none;
        min-height: 40px;
        padding: 0;
        border: 0;
        background: transparent;
        color: #bbb;
        font-size: 10px;
        letter-spacing: 1px;
        text-align: left;
        cursor: pointer;
    }

    .collection-menu-toggle::after {
        content: "+";
        float: right;
        color: #FFCE34;
        font-size: 16px;
        line-height: 1;
    }

    .collection-sidebar.collection-menu-open .collection-menu-toggle::after {
        content: "\2212";
    }

    .collection-sidebar:not(.collection-menu-open) .collection-list {
        display: none;
    }

    body[data-view="color"] .collection-menu-toggle,
    body[data-view="bio"] .collection-menu-toggle {
        display: none;
    }

    body[data-view="bio"],
    body[data-view="color"]:not(.color-gallery-expanded) {
        --mobile-dock-height: calc(61px + env(safe-area-inset-bottom, 0px));
    }

    .view-tab {
        min-height: 40px;
        font-size: 10px;
    }

    .collection-group {
        margin-bottom: 10px;
    }

    .collection-group-title {
        padding: 8px 0;
    }

    .collection-button {
        min-height: 40px;
        padding: 9px 0;
    }

    #scene {
        left: 0;
        width: 100vw;
        height: calc(100vh - var(--mobile-dock-height));
        height: calc(100dvh - var(--mobile-dock-height));
    }

    body.project-mode .project-viewer {
        top: 0;
        left: 0;
        width: 100vw;
        height: calc(100vh - var(--mobile-dock-height));
        height: calc(100dvh - var(--mobile-dock-height));
    }

    .project-stage {
        width: calc(100vw - 28px);
        height: min(62vh, calc(100dvh - var(--mobile-dock-height) - 140px));
        min-height: 170px;
        touch-action: pan-y;
    }

    .project-nav-previous {
        left: 0;
    }

    .project-nav-next {
        right: 0;
    }

    .project-caption {
        bottom: 16px;
        font-size: 10px;
    }

    body.project-mode .instructions {
        display: none;
    }

    .counter {
        bottom: calc(var(--mobile-dock-height) + 10px);
        left: 14px;
    }

    body.project-mode .counter {
        left: 14px;
    }

    .description {
        top: calc(112px + env(safe-area-inset-top, 0px));
        right: 12px;
        width: min(55vw, 230px);
        max-height: 15vh;
        font-size: 10px;
    }

    .preview {
        right: 12px;
        bottom: calc(var(--mobile-dock-height) + 12px);
        width: min(44vw, 180px);
    }

    #previewImage,
    #previewImage.vertical,
    #previewImage.quadrada {
        max-width: 100%;
        max-height: 24vh;
        transform: none;
    }

    .alternate-view,
    body.color-gallery-expanded #colorView {
        top: 0;
        left: 0 !important;
        width: 100vw !important;
        height: calc(100vh - var(--mobile-dock-height));
        height: calc(100dvh - var(--mobile-dock-height));
        padding: 112px 14px 14px;
    }

    .alternate-heading {
        gap: 10px;
    }

    .view-hint {
        max-width: 52%;
    }

    .color-photos-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .bio-view {
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .bio-card {
        gap: 16px;
    }

    .bio-portrait {
        height: clamp(150px, 30dvh, 220px);
        min-height: 0;
    }
}