* {
    margin: 0;
    padding: 0;
    border: 0;
    box-sizing: border-box; /* Added for consistent box modeling in media queries */
}

body {
    background-image: url(Images/Grass.jpg);
    font-size: 16px; /* Added base font size for rem units */
    line-height: 1.6; /* Added default line height for better readability */
    color:#000; /* Added a default text color with good contrast */
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: brown;
    border-bottom: 3px solid tan; /* Corrected CSS property */
    height: 60px;
}

h1 {
    color: tan;
    display: inline-block;
    vertical-align: middle;
    margin: 10px 4px;
}

h2 {
    border-bottom: 3px solid black;
    margin-bottom: 15px;
    color:#000; /* Ensures good contrast */
}

p {
    margin-bottom: 15px; /* Increased margin for space between the new boxes */
    line-height: 1.5em;
    border: 1px solid #ccc; /* Added border */
    padding: 10px; /* Added padding between text and border */
    background-color: #fcf0de; 
    color: #000 /* Ensures good contrast */
}

nav {
    display: inline-block;
    vertical-align: middle;
    align-items: center;
    margin: 20px;
}

nav a {
    color: tan;
    font-size: 1.25rem; /* Used rem for better user scalability */
    text-decoration: none;
    font-weight: bold;
    margin-left: 20px;
    /* Added focus styles for keyboard navigation */
    outline: none;
}

nav a:focus {
    outline: 3px solid green;
    background-color: tan;
    color: green;
    text-decoration: underline;
}

.container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    max-width: 900px;
    margin: 0 auto;
}

main.container {
    margin: 30px auto;
}

section {
    display: flex;
    flex-direction: column;
    width: 600px;
    padding: 20px;
    background-color: white;
    color:#000;
}

section a {
    color: black; /* provides strong contrast on a white background */
    text-decoration: underline; /* Added underline to distinguish links clearly from text */
}

section a:hover, section a:focus {
    color: #006400; /* Dark green on hover/focus */
    text-decoration: none;
}

section img {
    float: left;
    margin: 0 20px 20px 0;
    width: 30%;
}

aside {
    display: inline-block;
    flex-direction: column;
    order: 2;
    width: 200px;
    padding-bottom: 20px;
    padding-top: 20px;
    background: white;
    text-align: center;
    color:#000; /* Ensures good contrast */
}

aside a {
    text-decoration: none;
    color: brown; /* Ensures good contrast against white backdrop */
}

aside a:focus {
    outline: 2px solid brown;
    text-decoration: underline;
}

footer {
    background-color: brown;
    border-top: 3px solid tan;
    padding: 10px 0;
    text-align: center;
    color: tan; /* Changed color from 'brown' to 'tan' for contrast on 'brown' background */
    font-size: 1.5rem; /* Used rem for better readability */
    font-weight: bold;
}

nav a:hover {
    color: green;
    background-color: tan;
    text-decoration: none;
}

@media screen and (max-width: 768px) {
    .container {
        flex-direction: column; /* Stacks the header items vertically */
        align-items: center; /* Centers items in the header */
        max-width: 100%; /* Allows container to use full width */
        padding: 0 10px; /* Adds some padding to the sides */
    }

    header .container {
        height: auto; /* Allow header to adjust height based on content */
        padding: 10px;
    }

    h1 {
        margin: 10px 0; /* Adjust margin for stacking */
    }

    nav {
        margin: 10px 0; /* Adjust margin for stacking */
        display: flex;
        flex-direction: column; /* Stack navigation links vertically */
        align-items: center;
        width: 100%;
    }

    nav a {
        margin: 5px 0; /* Add spacing between vertical links */
    }

    main.container {
        flex-direction: column; /* Stacks the section and aside vertically */
        margin: 15px auto;
    }

    section, aside {
        width: 100%; /* Makes the section and aside take full width */
        padding: 15px; /* Adjust padding */
    }
    
    section img {
        width: 50%; /* Make image a bit larger on small screens */
        float: none; /* Remove float for better centering/flow on mobile */
        margin: 0 auto 15px auto; /* Center the image */
        display: block;
    }

    .character-grid {
        grid-template-columns: 1fr; /* Display one card per row on mobile */
    }
    
    .card {
        width: 90%; /* Adjust card width for mobile view */
        margin: 0 auto;
    }
}

/* Erika Section */

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    max-width: 1100px;
    margin: 40px auto;
    padding: 1rem;
    box-sizing: border-box;
    justify-items: center;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 220px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border 0.3s ease, background-color 0.3s ease;
    padding: 10px;
    border: 2px solid transparent;
}

@keyframes popBounce {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    70% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1.05);
    }
}

.card:hover img {
    animation: popBounce 0.75s ease forwards;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid tan;
    background-color: #ffead9;
}

.card img {
    width: 100%;
    height: auto;
    max-height: 160px;
    object-fit: contain;
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
    display: block;
    margin-left: auto;
    margin-right: auto;
    transition: transform 0.3s ease;
}

.card-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.card h2 {
    color: brown;
    margin: 0.5rem 0;
    font-size: 1.1rem;
    font-weight: bold;
}

.card p {
    font-size: 0.9rem;
    line-height: 1.4em;
    color: black;
    margin-top: 0.5rem;
}

.card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

@media (max-width: 500px) {
    header {
        height: auto;
        text-align: center;
    }
}

nav {
    flex-direction: column;
    align-items: center;
}


/* RACQUEL */

.cast-section {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 60px auto;
    padding: 30px 40px;
    background-color: transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
}

.cast-section__text-container {
    background-color: #fff;
    padding: 20px
}

.cast-section h2 {
    position: relative;
    display: inline-block;
    font-size: 2rem;
    color: #000;
    transition: all 0.3s ease;
    cursor: pointer;
}

.cast-section p {
    font-size: 1.2rem;
    color: #333;
    line-height: 1.6em;
}


/* Link to IMDB animation */
.cast-section h2 a {
    text-decoration: none;
    color: inherit;
    padding: 10px 25px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.cast-section h2 a:hover {
    background-color: #8b2d2d;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Cast section FLIPCARDS */

.cast-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    width: 100%;
    background-color: transparent;
    justify-items: center;
    max-width: 1100px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.flipcard {
    width: 360px;
    height: 420px;
    perspective: 1000px;
}

.flipcard section {
    padding: 0%;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s ease;
    animation: flipBack 0.8s ease-in-out;
}

.flipcard:hover .card-inner {
    animation: flip 0.8s ease-in-out forwards;
}

.card-front {

    width: 100%;
    height: 100%;
    border-radius: 12px;
    background-color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    padding: 15px;
    backface-visibility: hidden;
    overflow: hidden;
}

.card-front img {
    width: 100%;
    object-fit: contain;
    max-height: 280px;
}

.card-front h3 {
    color: #8b2d2d;
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.card-front p {
    font-size: 1rem;
    padding: 0 20px;
    text-align: center;
    line-height: 1.6em;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front p {
    white-space: normal;
    overflow-wrap: break-word;
}


.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    background-color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
    transform: rotateY(180deg);
}


.card-back h3 {
    color: #8b2d2d;
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.card-back img {
    width: 110%;
    height: 200%;
    object-fit: contain;
    align-items: center;
    max-height: 300px;
    padding-top: 30px;
}

.card-front,
.card-back {
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}


@keyframes flip {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(180deg);
    }
}

@keyframes flipBack {
    from {
        transform: rotateY(180deg);
    }

    to {
        transform: rotateY(0deg);
    }
}

/* --- Responsive Design Media Query --- */
@media screen and (max-width: 768px) {
    .cast-section {
        padding: 20px; /* Smaller padding on smaller screens */
        margin-bottom: 30px;
    }

    .cast-section p {
        font-size: 1rem; /* Smaller font size for readability */
    }

    .cast-cards {
        /* On screens up to 768px wide, stack cards in a single column */
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .flipcard {
        width: 100%; /* Make flipcards take full width of container */
        max-width: 360px; /* Keep max width to maintain aspect ratio */
    }
}