/* --- General Page Setup --- */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden; 
    background: linear-gradient(
        135deg, 
        mediumturquoise 35%, 
        white 50%, 
        mediumturquoise 65%
    );
    background-attachment: fixed;
}

/* --- Header Section (Flexbox) --- */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px 20px 0; 
}

.right-group {
    display: flex;
    gap: 30px;
}

.box {
    display: flex;
    justify-content: center; 
    align-items: center;
    position: relative;
    min-width: 160px; 
    padding: 12px 30px;
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.2s ease-in-out;
    border: none;
    z-index: 1; 
}

/* Layered Header Borders */
.right-group .box::before {
    content: "";
    position: absolute;
    bottom: -4px;
    right: -2px;
    height: 4px;
    background-color: black;
    z-index: -1;
    width: calc(100% - 5px);
}

.box::after {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -4px;
    width: 2px;
    height: calc(100% - 5px);
    background-color: black;
    z-index: -1;
}

/* --- MODULE Tilted Box --- */
.tilted-box {
    margin-left: -5px;
    transform: rotate(-3deg);
    transform-origin: left center;
    justify-content: flex-end; 
    padding-right: 20px;
    background-color: #7cfc00;
}

.tilted-box::before {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: black;
    z-index: -1;
}

.forest-green { background-color: #014421; color: white; }
.orange { background-color: #ff4500; color: white; }

/* --- Navigation Grid Setup --- */
.layout-nav {
    display: flex;
    justify-content: center;
    padding-top: 60px;
    padding-bottom: 120px;
}

.layout-nav ul {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 20px; 
    row-gap: 75px; 
}

.layout-nav li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease;
}

.layout-nav li:hover {
    transform: scale(1.25);
}

.layout-title {
    font-weight: bold;
    color: #333;
    font-size: 0.9rem;
    text-transform: lowercase;
}

/* --- Layout Boxes Base --- */
.red-box {
    display: block;
    position: relative; 
    background-color: #d9534f; 
    padding: 62px 62px; 
    min-width: 125px;
    border-radius: 5px; 
    text-decoration: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.3s ease, filter 0.3s ease, background-color 0.3s ease;
    overflow: hidden; 
}

/* --- Layouts 1 & 2 --- */
.layout-nav li:nth-child(1) .red-box,
.layout-nav li:nth-child(2) .red-box { background-color: #A52A2A; }

.layout-nav li:nth-child(1) .red-box::before {
    content: ""; position: absolute; top: 25%; left: 0; width: 100%; height: 50%;
    background-color: #FFD1DC; 
}

.layout-nav li:nth-child(2) .red-box::before {
    content: ""; position: absolute; top: 25%; left: 0; width: 100%; height: 50%;
    background: linear-gradient(to right, #FFF9C4 33.33%, #4B0082 33.33%, #4B0082 66.66%, #B2DFDB 66.66%);
}

/* --- Layouts 3, 4, & 5 --- */
.layout-nav li:nth-child(3) .red-box,
.layout-nav li:nth-child(4) .red-box,
.layout-nav li:nth-child(5) .red-box {
    background: linear-gradient(to right, #90EE90 50%, #228B22 50%);
}

.layout-nav li:nth-child(4) .red-box::before {
    content: ""; position: absolute; top: 10px; left: 10px; width: 80px; height: 20px;
    background-color: #A52A2A;
}

.layout-nav li:nth-child(5) .red-box::before {
    content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 80px; height: 20px;
    background-color: #A52A2A;
}

/* --- Layout 6 --- */
.layout-nav li:nth-child(6) .red-box { background-color: #FFD1DC; } 
.layout-nav li:nth-child(6) .red-box::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 16.66%; 
    background-color: #0077be; 
}

/* --- Layout 7 --- */
.layout-nav li:nth-child(7) .red-box { background-color: #FFD1DC; } 
.layout-nav li:nth-child(7) .red-box::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 16.66%;
    background-color: #0077be; 
}
.layout-nav li:nth-child(7) .red-box::after {
    content: ""; position: absolute; top: 16.66%; left: 0; width: 100%; height: 16.66%;
    background-color: #DAA520; 
}

/* --- Layout 8 --- */
.layout-nav li:nth-child(8) .red-box { background-color: #FFD1DC; }
.layout-nav li:nth-child(8) .red-box::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 12.5%; 
    background-color: #0077be;
}
.layout-nav li:nth-child(8) .red-box::after {
    content: ""; position: absolute; top: 12.5%; left: 0; width: 100%; height: 25%; 
    background-color: #DAA520;
}

/* --- Layout 9 (Resized and Swapped) --- */
.layout-nav li:nth-child(9) .red-box { background-color: #FFD1DC; }
.layout-nav li:nth-child(9) .red-box::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; 
    height: 21.5%; /* Swapped size: Smaller box now on top */
    background-color: #DAA520;
}
.layout-nav li:nth-child(9) .red-box::after {
    content: ""; position: absolute; 
    top: 21.5%; /* Starts where top box ends */
    left: 0; width: 100%; 
    height: 50%; /* Swapped size: Larger box now on bottom */
    background-color: #0077be;
}

/* Hover Feedback */
.layout-nav li:hover .red-box {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
    cursor: pointer;
}

/* --- Responsiveness --- */
@media (max-width: 900px) {
    .layout-nav ul { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .layout-nav ul { grid-template-columns: 1fr; }
    .top-header { flex-direction: column; gap: 20px; padding-right: 0; }
}