/* Reset some default styles for consistency across browsers */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    flex-direction: column;
}

header {
    background-color: #02618E;
    color: white;
    padding: 15px 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 10px;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

nav a {
    color: #F8F398;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

nav a:hover,
nav a:focus {
    color: #F8F398;
}

main {
    flex: 1; /* Allows main to grow and fill available space */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px; /* Reduced padding to prevent overflow */
    position: relative;
    overflow: hidden; /* Prevents internal overflow */
}

#flipbook-container {
    position: relative;
    width: 100%;
    max-width: 90vw; /* Ensure it doesn't exceed 90% of viewport width */
    /* Height is dynamically set via JavaScript based on display mode */
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border-radius: 8px;
    transform-origin: center center;
    transition: width 0.3s, height 0.3s; /* Smooth transition on resize */
}

#flipbook {
    width: 100%;
    height: 100%;
}

#flipbook div {
    width: 100%;
    height: 100%;
}

#flipbook img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures images maintain aspect ratio and cover the container */
    display: block;
}

/* Navigation Controls */
.controls {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border-radius: 30px;
}

.controls button {
    background: none;
    border: none;
    color: #02618E;
    font-size: 1.2em;
    cursor: pointer;
    transition: color 0.3s;
}

.controls button:hover,
.controls button:focus {
    color: #02618E;
}

/* Loading Indicator */
#loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px 30px;
    border-radius: 8px;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    color: #555;
    z-index: 1000;
}

/* Feedback Button */
#feedback-button {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #02618E;
    border: none;
    color: white;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: background 0.3s;
    z-index: 1001;
}

#feedback-button:hover,
#feedback-button:focus {
    background: #02618E;
}

/* Feedback Modal */
#imprint-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
}

#feedback-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#feedback-form label {
    font-weight: bold;
}

#feedback-form input,
#feedback-form textarea {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
}

#feedback-form button {
    padding: 10px;
    background-color: #02618E;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
}

#feedback-form button:hover,
#feedback-form button:focus {
    background-color: #02618E;
}

/* Noscript Message */
.noscript-message {
    background-color: #ffdddd;
    color: #900;
    padding: 20px;
    text-align: center;
}

.noscript-message a {
    color: #900;
    text-decoration: underline;
}

footer {
    background-color: #02618E;
    color: white;
    text-align: center;
    padding: 10px 20px;
    font-size: 0.9em;
    flex-shrink: 0; /* Prevents footer from shrinking */
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    #flipbook-container {
        max-width: 90vw;
        /* Height is dynamically set via JavaScript */
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5em;
    }

    nav ul {
        flex-direction: column;
        gap: 10px;
    }

    .controls {
        flex-direction: column;
        gap: 5px;
        padding: 8px 12px;
    }

    .controls button {
        font-size: 1em;
    }

    /* Adjust feedback button for smaller screens */
    #feedback-button {
        top: 10px;
        right: 10px;
        padding: 8px;
        font-size: 1em;
    }

    /* Adjust modal for smaller screens */
    .modal-content {
        margin: 20% auto;
    }
}
