/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #3d2817;
    padding-top: 80px;
    overflow-x: hidden;
}

/* Fixed Transparent Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(61, 40, 23, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-title {
    flex: 1;
    text-align: center;
    color: #f4e4c1;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Burger Menu Button */
.burger-menu {
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.burger-menu span {
    display: block;
    width: 30px;
    height: 3px;
    background-color: #f4e4c1;
    margin: 6px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.burger-menu.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-6px, 6px);
}

.burger-menu.active span:nth-child(2) {
    opacity: 0;
}

.burger-menu.active span:nth-child(3) {
    transform: rotate(45deg) translate(-6px, -6px);
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 70px;
    left: -300px;
    width: 280px;
    height: calc(100vh - 70px);
    background: rgba(33, 23, 15, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: left 0.3s ease;
    z-index: 999;
    padding: 30px 20px;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
}

.menu-overlay.active {
    left: 0;
}

.menu-overlay nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.menu-overlay a,
.menu-overlay button {
    display: block;
    padding: 16px 15px;
    color: #f4e4c1;
    text-decoration: none;
    font-size: 14px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(244, 228, 193, 0.1);
    font-family: Arial, sans-serif;
}

.menu-overlay a:hover,
.menu-overlay button:hover {
    background: rgba(244, 228, 193, 0.1);
    padding-left: 20px;
}

.menu-overlay a.active,
.menu-overlay button.active {
    background: rgba(244, 228, 193, 0.15);
    border-left: 3px solid #2185d0;
}

/* Menu Backdrop */
.menu-backdrop {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 998;
}

.menu-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* View Container */
.view-container {
    min-height: calc(100vh - 80px);
}

/* Gallery View (Single Page) */
.gallery-view {
    display: none;
}

.gallery-view.active {
    display: block;
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 20px;
}

.gallery img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.gallery img:not(.locked) {
    cursor: pointer;
}

.gallery img:not(.locked):hover {
    transform: translate(-8px, -10px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

.gallery img.locked {
    filter: blur(25px);
    opacity: 0.6;
}

/* Carousel View (Swiper Cube) */
.carousel-view {
    display: none;
    padding: 60px 20px;
}

.carousel-view.active {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 140px);
}

/* Swiper Container */
.swiper {
    width: 300px;
    height: 300px;
    margin-bottom: 30px;
    position: relative;
}

.swiper-slide {
    background-position: center;
    background-size: cover;
    position: relative;
}

.swiper-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 1 / 1;
}

/* External Slide Info (beside cube) */
.slide-info-external {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(33, 23, 15, 0.8);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    position: relative;
}

.slide-info-external h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #f4e4c1;
    font-weight: bold;
}

.slide-info-external p {
    font-size: 14px;
    color: #2185d0;
    word-break: break-all;
}

.slide-info-external .no-info {
    color: #888;
    font-style: italic;
}

/* Drag Handles - only visible on hover */
.drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(33, 133, 208, 0.9);
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.2s ease;
    z-index: 100;
    user-select: none;
    font-size: 18px;
    color: white;
}

/* Show handles only in edit mode */
.edit-mode .drag-handle {
    display: flex;
}

.drag-handle:hover {
    background: rgba(33, 133, 208, 1);
}

.drag-handle.grabbing {
    cursor: grabbing;
}

.edit-mode .swiper:hover .drag-handle,
.edit-mode .slide-info-external:hover .drag-handle,
.edit-mode .logo-container:hover .drag-handle,
.edit-mode .message-area:hover .drag-handle {
    opacity: 1;
}

/* Edit mode: Show editable areas with subtle glow */
.edit-mode .swiper,
.edit-mode .slide-info-external,
.edit-mode .logo-container,
.edit-mode .message-area {
    box-shadow: 0 0 15px rgba(33, 133, 208, 0.2);
}

.edit-mode .swiper:hover,
.edit-mode .slide-info-external:hover,
.edit-mode .logo-container:hover,
.edit-mode .message-area:hover {
    box-shadow: 0 0 20px rgba(33, 133, 208, 0.4);
}

/* When dragged, elements become fixed */
.swiper.dragged,
.slide-info-external.dragged {
    position: fixed;
    margin: 0;
}

.carousel-view.has-dragged {
    display: block;
    justify-content: flex-start;
    align-items: flex-start;
}

/* Logo Container - Draggable & Resizable */
.logo-container {
    position: fixed;
    user-select: none;
    transition: box-shadow 0.3s ease;
    z-index: 1100;
}

.logo-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* FOSSEAM Logo - round */
.logo-fosseam img {
    border-radius: 50%;
}

/* c3hamm Logo - rounded corners like inner white */
.logo-c3hamm img {
    border-radius: 20px;
}

/* Resize Handle - bottom right corner */
.resize-handle {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(33, 133, 208, 0.9);
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.2s ease;
    z-index: 1102;
    user-select: none;
    font-size: 14px;
    color: white;
}

/* Show resize handles only in edit mode */
.edit-mode .resize-handle {
    display: flex;
}

.resize-handle:hover {
    background: rgba(33, 133, 208, 1);
}

.resize-handle.resizing {
    cursor: nwse-resize;
}

.edit-mode .logo-container:hover .resize-handle {
    opacity: 1;
}

/* Drag handle needs higher z-index than resize */
.logo-container .drag-handle {
    z-index: 1103;
}

/* Mastodon Message-Area - Draggable */
.message-area {
    position: fixed;
    user-select: none;
    transition: box-shadow 0.3s ease;
    z-index: 1100;
    background: rgba(33, 23, 15, 0.9);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.message-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow: hidden;
}

.message-content h3 {
    margin: 0 0 10px 0;
    color: #f4e4c1;
    font-size: 18px;
    text-align: center;
    flex-shrink: 0;
}

.iframe-wrapper {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.message-content iframe {
    width: 100%;
    background: white;
    border: none;
    display: block;
    /* No fixed height - let content determine size, wrapper will scroll */
}

/* Custom Scrollbar Styling */
.iframe-wrapper::-webkit-scrollbar {
    width: 8px;
}

.iframe-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.iframe-wrapper::-webkit-scrollbar-thumb {
    background: rgba(33, 133, 208, 0.7);
    border-radius: 4px;
}

.iframe-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(33, 133, 208, 0.9);
}

/* Firefox Scrollbar */
.iframe-wrapper {
    scrollbar-width: thin;
    scrollbar-color: rgba(33, 133, 208, 0.7) rgba(0, 0, 0, 0.2);
}

.message-content .placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 24px;
    font-style: italic;
}

/* Edit mode support for message-area */
.edit-mode .message-area {
    box-shadow: 0 0 15px rgba(33, 133, 208, 0.2);
}

.edit-mode .message-area:hover {
    box-shadow: 0 0 20px rgba(33, 133, 208, 0.4);
}

/* Slide Animations for Mastodon Posts */
@keyframes slideOutLeft {
    from { 
        transform: translateX(0);
        opacity: 1;
    }
    to { 
        transform: translateX(-100%);
        opacity: 0;
    }
}

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

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

@keyframes slideInLeft {
    from { 
        transform: translateX(-100%);
        opacity: 0;
    }
    to { 
        transform: translateX(0);
        opacity: 1;
    }
}

.iframe-wrapper.slide-out-left {
    animation: slideOutLeft 0.3s ease forwards;
}

.iframe-wrapper.slide-in-right {
    animation: slideInRight 0.3s ease forwards;
}

.iframe-wrapper.slide-out-right {
    animation: slideOutRight 0.3s ease forwards;
}

.iframe-wrapper.slide-in-left {
    animation: slideInLeft 0.3s ease forwards;
}

/* Swiper Navigation */
.swiper-button-next,
.swiper-button-prev {
    color: #f4e4c1;
    background: rgba(61, 40, 23, 0.8);
    padding: 25px;
    border-radius: 50%;
    backdrop-filter: blur(10px);
    z-index: 200;
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 20px;
    font-weight: bold;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: rgba(61, 40, 23, 1);
}

/* Position arrows beside the cube */
.swiper-button-prev {
    left: -80px;
}

.swiper-button-next {
    right: -80px;
}

/* Swiper Pagination */
.swiper-pagination {
    bottom: 10px !important;
    z-index: 200;
}

.swiper-pagination-bullet {
    background: #f4e4c1;
    opacity: 0.5;
    width: 10px;
    height: 10px;
}

.swiper-pagination-bullet-active {
    opacity: 1;
    background: #2185d0;
    width: 12px;
    height: 12px;
}

/* Keyboard Hint */
.keyboard-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #f4e4c1;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 100;
}

.keyboard-hint.show {
    opacity: 1;
}

/* Info Box (Bottom Right) */
.info-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(33, 23, 15, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 15px 20px;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(244, 228, 193, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1001;
}

.info-box.visible {
    opacity: 1;
    visibility: visible;
}

.info-box .title {
    color: #f4e4c1;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.info-box .url {
    color: #2185d0;
    font-size: 13px;
    word-break: break-all;
    font-family: monospace;
}

/* Codeberg Ribbon */
.codeberg-ribbon {
    position: fixed;
    top: 0;
    right: 0;
    width: 200px;
    height: 200px;
    overflow: hidden;
    z-index: 1000;
    text-decoration: none;
}

.codeberg-ribbon span {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 300px;
    padding: 18px 0;
    background-color: #2185d0;
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    justify-content: center;
    transform: rotate(45deg);
    top: 50px;
    right: -75px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s ease;
}

.codeberg-ribbon:hover span {
    background-color: #1678c2;
}

.codeberg-ribbon img {
    width: 26px;
    height: 26px;
    filter: brightness(0) invert(1);
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-title {
        font-size: 16px;
    }

    .menu-overlay {
        width: 250px;
        left: -250px;
    }

    .gallery img {
        width: 150px;
        height: 150px;
    }
    
    .swiper {
        width: 260px;
        height: 260px;
    }

    .slide-info-external h3 {
        font-size: 18px;
    }

    .slide-info-external p {
        font-size: 13px;
    }

    .swiper-button-next,
    .swiper-button-prev {
        padding: 20px;
    }

    .swiper-button-prev {
        left: -70px;
    }

    .swiper-button-next {
        right: -70px;
    }
    
    .info-box {
        max-width: calc(100vw - 40px);
        left: 20px;
        right: 20px;
    }

    .drag-handle {
        opacity: 0.7;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 14px;
        letter-spacing: 0.5px;
    }

    .gallery {
        padding: 10px;
    }

    .gallery img {
        width: calc(50vw - 10px);
        height: calc(50vw - 10px);
    }
    
    .swiper {
        width: 220px;
        height: 220px;
    }

    .slide-info-external {
        padding: 15px;
    }

    .slide-info-external h3 {
        font-size: 16px;
    }

    .slide-info-external p {
        font-size: 12px;
    }

    .drag-handle {
        opacity: 0.7;
    }
}