﻿/* RESET & BASE */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    /* Replica-like base */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #373636;
    background: #fff;
    overflow: hidden;
}

/* Strong emphasis uses Manrope for a crisper bold */
strong, b, .strong {
    font-family: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-weight: 700;
}

/* Logo and headers: Manrope for subtle contrast */
header .logo {
    font-family: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* Primary nav keeps Inter */
#menu { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* Headings can use Montserrat Bold when needed */
h1 {
    font-family: 'Montserrat', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-weight: 700;
}

a { color: #373636; text-decoration: none; transition: opacity 0.3s; }
a:hover { opacity: 0.7; }

/* GRID SYSTEM per pagine interne */
#container, #container-fluid {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: row;
}

.col-4 { 
    width: 33.33%; 
    min-width: 300px;
    max-width: 400px;
}

.col-6 { width: 50%; }

.col-8 { 
    width: 66.67%; 
    flex: 1;
}

.col-12 { width: 100%; }

/* HEADER - Sidebar sinistra */
body.has-sidebar header {
    position: relative; /* non fixed: resta nella col-4 del flex container */
    width: 33.33%;
    min-width: 300px;
    max-width: 400px;
    height: 100vh;
    padding: 30px;
    overflow-y: auto;
    background: #f1f1f1;
    z-index: 10;
}

/* MAIN - Area contenuto destra */
body.has-sidebar main {
    /* niente margin-left: il container flex gestisce le colonne */
    min-height: 100vh;
    width: 66.67%; /* col-8 */
    flex: 1 1 auto; /* permette di espandersi quando la sidebar è più stretta */
    padding: 0;
    background: #fff;
}

@media (min-width: 1200px) {
    body.has-sidebar header {
        width: 400px;
        max-width: 400px;
    }
    body.has-sidebar main {
        width: calc(100% - 400px); /* si adatta alla larghezza effettiva sidebar */
    }
}

/* HEADER - Solo angolo in alto a sinistra sulla home */
header {
    position: fixed;
    left: 0;
    top: 0;
    padding: 30px;
    z-index: 1001;
    background: transparent;
}

header .logo {
    display: block;
    font-size: 18px;
    margin-bottom: 15px;
    cursor: pointer;
    background: rgba(255,255,255,0.9);
    padding: 5px 10px;
    display: inline-block;
}

#menu { 
    display: none;
    background: rgba(255,255,255,0.9);
    padding: 10px;
}

#menu a {
    display: block;
    font-size: 16px;
    margin: 6px 0;
    color: #666; /* darker neutral vs bootstrap blue */
    font-weight: 400;
    text-decoration: none;
    position: relative;
    padding: 2px 0;
}

#menu a.selected,
#menu a:hover {
    color: #373636; 
    font-weight: 600;
}

/* Inline menu variant when we force visibility (About/no-layout pages) */
#menu.menu-inline { 
    display: block; 
    background: transparent; 
    padding: 0; 
}

#menu.menu-inline a { 
    margin: 4px 0; 
}

.admin-submenu a {
    font-size: 14px;
    color: #aaa;
    margin: 5px 0;
}

.admin-submenu a:hover {
    color: #666;
}

/* MAIN CONTENT */
main {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Per pagine interne con sidebar */
body.has-sidebar header {
    position: relative; /* rimuove sovrapposizione: parte del flusso flex */
    left: auto;
    top: auto;
    bottom: auto;
    width: 33.33%;
    padding: 40px 30px;
    background: #f5f5f5;
}

/* Works header internal layout */
.works-header .menu-filters {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.works-header #menu.primary a {
    margin: 6px 0;
}

.filters-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.filters-list a {
    font-size: 14px;
    color: #999;
    line-height: 1.2rem;
}

.filters-list a:hover,
.filters-list a.selected-filter {
    color: #373636;
    font-weight: bold;
    text-decoration: underline;
}

body.has-sidebar header .logo {
    background: transparent;
    padding: 0;
}

body.has-sidebar #menu {
    background: transparent;
    padding: 0;
}

body.has-sidebar .admin-submenu a {
    color: #999;
}

body.has-sidebar .admin-submenu a:hover {
    color: #373636;
}

body.has-sidebar main {
     background: #fff;
}

/* Admin pages: ensure content does not hide under fixed header variants */
body.admin-page #container { min-height: 100vh; }
body.admin-page .content { padding: 16px; overflow-y: auto; height: 100%; }

.content { 
    padding: 40px;
    height: 100%;
    overflow-y: auto;
}
/* ABOUT PAGE tweaks */
#about img { max-width: 100%; height: auto; display: block; border: 1px solid #eee; }
#about .contact p, #about .studio p, #about .description p { margin: 0 0 10px 0; }
#about h1 { font-size: 18px; margin: 10px 0; }

/* Admin modal for project editor */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000; /* ensure above TinyMCE panels */
}
.modal-overlay.hidden { display: none; }
.modal-panel {
    width: min(1100px, 92vw);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 20px 24px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    position: relative;
    z-index: 5010; /* above overlay base */
}
.modal-panel .tox-tinymce { z-index: 5020 !important; }
.modal-panel .tox-tinymce-aux, .modal-panel .tox-tinymce-inline { z-index: 5030 !important; }

/* Drag handle + previews */
.drag-handle {
    width: 16px; height: 16px;
    display: inline-grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    cursor: grab;
}
.drag-handle span {
    width: 6px; height: 6px;
    background: #bbb;
    display: block;
    border-radius: 1px;
}
.project-item, .media-item { cursor: grab; }
.media-thumb {
    width: 64px; height: 48px;
    object-fit: cover;
    border: 1px solid #eee;
}

/* CANVAS - fullscreen sulla home */
canvas.sketch {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 1;
}

/* PROJECTS GRID */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px 0;
}

@media (min-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .projects-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.project-card {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #fafafa;
    display: block;
}

.project-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.project-card .overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.0);
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 20px;
    text-align: center;
}

.project-card .overlay .caption {
    background: rgba(255,255,255,0.9);
    padding: 8px 12px;
    font-size: 14px;
    color: #373636;
}

.project-card:hover img {
    filter: brightness(0.65);
    transform: scale(1.02);
}

.project-card:hover .overlay { opacity: 1; }

.project-card:hover .overlay { opacity: 1; }

/* NEWS GRID */
.news-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    padding: 20px 0;
}

.news-item {
    border: 1px solid #e0e0e0;
    padding: 20px;
    min-height: 200px;
    background: #fff;
}

/* FOOTER */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 30px;
    background: rgba(245,245,245,0.95);
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
    text-align: center;
    z-index: 999;
}

footer a {
    margin: 0 15px;
    color: #999;
}

/* UTILITIES (avoid redefining Bootstrap classes) */
.text-danger { color: #d9534f; }

/* RESPONSIVE */
@media (max-width: 1024px) {
    .col-4, .col-6 { width: 100%; }
    
    header,
    body.has-sidebar header { 
        position: relative; 
        width: 100%; 
        padding: 20px;
        height: auto; /* reduce from 100vh */
    }
    
    main,
    body.has-sidebar main { 
        margin-left: 0; 
        width: 100%; /* Ensure main spans full width below header */
        min-height: auto;
    }

    #container, #container-fluid { 
        flex-direction: column; 
        height: auto; 
        min-height: 100vh; 
    }

    html, body { overflow: auto; }

    .works-header .menu-filters { 
        flex-direction: column; 
        gap: 15px; 
    }
    .filters-list { flex-direction: row; flex-wrap: wrap; }
    .filters-list a { flex: 1 1 45%; }
    
    .projects-grid, 
    .news-grid { 
        grid-template-columns: 1fr; 
    }
}

/* PROJECT DETAIL PAGE */
#work-details {
    margin-top: 40px;
    font-size: 15px;
    letter-spacing: 0.05rem;
    line-height: 1.3rem;
}

#work-details h1 {
    font-size: 18px;
    margin-bottom: 20px;
}

#work-details p {
    margin-bottom: 15px;
    line-height: 1.5;
}

#work-details .description {
    margin-top: 20px;
}

#work {
    width: 100%;
    padding: 0;
}

/* CAROUSEL */
.carousel {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #000;
}

.carousel-slide {
    display: none;
    width: 100%;
    height: 100vh;
    position: relative;
}

.carousel-slide img,
.carousel-slide video {
    width: 100%;
    height: 100vh;
    display: block;
    object-fit: contain;
    object-position: center;
    background: #000;
}

.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(55, 54, 54, 0.8);
    color: white;
    border: none;
    font-size: 40px;
    padding: 20px 24px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
    line-height: 1;
    border-radius: 4px;
}

.carousel-prev:hover,
.carousel-next:hover {
    background-color: rgba(55, 54, 54, 1);
    transform: translateY(-50%) scale(1.1);
}

.carousel-prev {
    left: 40px;
}

.carousel-next {
    right: 40px;
}

@media (max-width: 1024px) {
    .carousel-prev {
        left: 20px;
    }
    
    .carousel-next {
        right: 20px;
    }
    
    .carousel-prev,
    .carousel-next {
        font-size: 30px;
        padding: 15px 18px;
    }
    
    body.has-sidebar header {
        position: relative;
        width: 100%;
        max-width: 100%;
        height: auto;
    }
    
    body.has-sidebar main {
        margin-left: 0;
        width: 100%;
    }

    /* Detail page stacking and carousel sizing on mobile */
    .detail-header { height: auto; }
    .detail-main .carousel { height: 70vh; }
    .detail-main .carousel-slide,
    .detail-main .carousel-slide img,
    .detail-main .carousel-slide video { height: 70vh; }
}

