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

:root {
    --primary-color: #346d93;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --text-color: #333;
    --light-bg: #f8f9fa;
    --border-color: #ddd;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1.4rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    min-height: 42px;
    margin-bottom: 1.5rem;
    position: relative;
}

header .container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.header-logo {
    max-height: 56px;
    height: auto;
    width: auto;
    object-fit: contain;
}

.header-contact {
    color: #1a4d6d;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.info-link {
    color: #1a4d6d;
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    background-color: transparent;
    border-radius: 12px;
    font-size: 0.75rem;
    transition: background-color 0.3s, transform 0.2s;
    white-space: nowrap;
}

.info-link:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

nav a:hover {
    color: var(--secondary-color);
}

.lang-switcher {
    display: flex;
    gap: 10px;
    align-items: center;
}

.lang-flag {
    font-size: 1.8rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s, transform 0.2s;
    user-select: none;
}

.lang-flag:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

.lang-flag.active {
    opacity: 1;
    transform: scale(1.2);
}

main {
    padding: 1rem 0 2rem 0;
    min-height: calc(100vh - 200px);
}

.filters {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: white;
    padding: 0.6rem 0;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.category-filters {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.category-btn {
    padding: 0.3rem 0.7rem;
    border: 1.5px solid var(--primary-color);
    background-color: white;
    color: var(--primary-color);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    white-space: nowrap;
}

.category-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.category-btn.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.gallery-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.gallery-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.gallery-item-info {
    padding: 1rem;
}

.gallery-item-info h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.gallery-item-info p {
    font-size: 0.9rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #999;
}

.painting-date {
    font-style: italic;
}

.painting-ref {
    font-weight: 500;
    color: #666;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #666;
    font-size: 1.2rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    background-color: white;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    overflow: auto;
    position: relative;
}

.modal-body {
    display: flex;
    min-height: 100vh;
    padding: 3rem;
    gap: 2rem;
}

/* Portrait and Square: side-by-side layout */
.modal-body.layout-side {
    flex-direction: row;
    align-items: center;
}

.modal-body.layout-side img {
    max-width: 60%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.modal-body.layout-side .modal-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    padding-left: 2rem;
}

/* Landscape: stacked layout */
.modal-body.layout-bottom {
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.modal-body.layout-bottom img {
    max-width: 90%;
    max-height: 60vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.modal-body.layout-bottom .modal-info {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 2rem;
}

.modal-info h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.modal-info #modal-medium {
    font-size: 1.1rem;
    color: #666;
}

.modal-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.modal-details p {
    margin-bottom: 0.5rem;
}

.close {
    position: fixed;
    top: 20px;
    right: 30px;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    font-size: 36px;
    font-weight: bold;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    line-height: 1;
}

.close:hover,
.close:focus {
    background-color: var(--accent-color);
    color: white;
}

.modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 3rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    z-index: 1001;
    transition: background-color 0.3s;
    border-radius: 4px;
}

.modal-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

/* Swipe hint notification */
.swipe-hint {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 30px;
    z-index: 1003;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideUpFadeIn 0.4s ease-out;
}

.swipe-hint-text {
    font-size: 0.95rem;
}

.swipe-hint-close {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s;
}

.swipe-hint-close:hover {
    background-color: var(--accent-color);
}

.swipe-hint.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Information modal */
.info-modal {
    display: none;
    position: fixed;
    z-index: 1100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
}

.info-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 1.5rem;
    border-radius: 10px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}

.info-modal .close {
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--text-color);
    background-color: transparent;
    font-size: 28px;
    font-weight: bold;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1101;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, color 0.3s;
}

.info-modal .close:hover {
    background-color: var(--accent-color);
    color: white;
}

.info-modal h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.info-modal p {
    margin-bottom: 0.8rem;
    line-height: 1.6;
    color: var(--text-color);
    font-size: 0.9rem;
}

.info-modal .highlight {
    background-color: #fff3cd;
    padding: 0.7rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    margin: 0.8rem 0;
}

.info-modal .highlight p {
    margin-bottom: 0.5rem;
}

.info-modal .highlight strong {
    color: var(--primary-color);
}

.info-modal ul {
    font-size: 0.9rem;
    line-height: 1.6;
}

.info-modal ul li {
    margin-bottom: 0.4rem;
}

.exhibit-image {
    width: 100%;
    max-width: 320px;
    margin: 0.8rem auto;
    display: block;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.no-spam-text {
    font-style: italic;
    color: #666;
    font-size: 0.75rem !important;
}

.info-form {
    margin-top: 1rem;
}

.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.info-form input[type="email"] {
    flex: 1;
    padding: 0.65rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.info-form input[type="email"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.info-form button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    padding: 0.65rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.info-form button[type="submit"]:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.info-form button[type="submit"]:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.form-message {
    margin-top: 0.6rem;
    padding: 0.6rem;
    border-radius: 6px;
    display: none;
    font-size: 0.8rem;
}

.form-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.form-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 3rem;
}

footer p {
    margin: 0.5rem 0;
}

footer .footer-link {
    color: white;
    text-decoration: underline;
    opacity: 0.8;
    font-size: 0.9rem;
}

footer .footer-link:hover {
    opacity: 1;
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    header .container {
        justify-content: center;
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    nav a {
        font-size: 0.9rem;
    }

    .lang-flag {
        font-size: 1.5rem;
    }

    .header-contact {
        font-size: 0.8rem;
    }

    .filters {
        padding: 0.5rem 0;
    }

    .category-filters {
        gap: 0.4rem;
    }

    .category-btn {
        padding: 0.25rem 0.6rem;
        font-size: 0.75rem;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .gallery-item img {
        height: 200px;
    }

    .gallery-item-info h3 {
        font-size: 0.9rem;
    }

    .gallery-item-info p {
        font-size: 0.85rem;
    }

    .gallery-item-meta {
        font-size: 0.75rem;
    }

    .modal-body {
        flex-direction: column !important;
        padding: 1.5rem;
        min-height: 100vh;
    }

    .modal-body.layout-side img,
    .modal-body.layout-bottom img {
        max-width: 100%;
        max-height: 50vh;
    }

    .modal-body.layout-side .modal-info {
        padding-left: 0;
        padding-top: 1rem;
    }

    .modal-body.layout-bottom .modal-info {
        padding-top: 1rem;
    }

    .modal-info h2 {
        font-size: 1.2rem;
    }

    .modal-info #modal-medium {
        font-size: 1rem;
    }

    .close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .modal-nav {
        font-size: 2rem;
        padding: 0.5rem 1rem;
    }

    .modal-prev {
        left: 5px;
    }

    .modal-next {
        right: 5px;
    }

    .swipe-hint {
        bottom: 60px;
        padding: 0.8rem 1.2rem;
        max-width: 90%;
    }

    .swipe-hint-text {
        font-size: 0.85rem;
    }

    .swipe-hint-close {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }

    /* Info modal mobile adjustments */
    .info-modal-content {
        margin: 2% auto;
        padding: 1rem;
        width: 95%;
        max-height: 92vh;
        border-radius: 8px;
    }

    .info-modal h2 {
        font-size: 1.1rem;
        margin-bottom: 0.7rem;
        margin-top: 0.3rem;
    }

    .info-modal p {
        font-size: 0.8rem;
        margin-bottom: 0.6rem;
        line-height: 1.5;
    }

    .info-modal .highlight {
        padding: 0.6rem;
        margin: 0.7rem 0;
    }

    .info-modal .highlight p {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
    }

    .info-modal ul {
        margin-left: 1.3rem !important;
        margin-bottom: 0.8rem !important;
    }

    .info-modal ul li {
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .info-modal .close {
        top: 6px;
        right: 6px;
        width: 32px;
        height: 32px;
        font-size: 24px;
    }

    .no-spam-text {
        font-size: 0.7rem !important;
    }

    .info-form {
        margin-top: 0.8rem;
    }

    .form-inline {
        gap: 0.4rem;
    }

    .info-form input[type="email"] {
        padding: 0.55rem;
        font-size: 0.8rem;
    }

    .info-form button[type="submit"] {
        padding: 0.55rem 0.9rem;
        font-size: 0.8rem;
    }

    .form-message {
        margin-top: 0.6rem;
        padding: 0.6rem;
        font-size: 0.8rem;
    }

    .exhibit-image {
        max-width: 240px;
        margin: 0.6rem auto;
        border-radius: 5px;
    }

    /* Info link mobile adjustments */
    .header-contact {
        gap: 0.5rem;
        font-size: 0.75rem;
    }

    .info-link {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}
