/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Literata:opsz,wght@7..72,200..900&family=Source+Sans+3:wght@200..900&display=swap');

/* Core color palette used across the application */
:root {
    --green: #4d8b60;
    --green-deep: #2f6943;
    --green-bright: #69a97d;
    --green-soft: #dcebdd;
    --green-mist: #eff7ef;
    --cream: #faf6f0;
    --cream-deep: #f1e7d6;
    --cream-soft: #f7efe3;
    --brown: #81694a;
    --taupe: #9a8668;
    --sky-soft: #dceef3;
    --sky-mist: #edf7fb;
    --sky-border: rgba(111, 160, 183, 0.2);
    --dark-gray: #2e3230;
    --white: #ffffff;
    --surface-main: linear-gradient(145deg, rgba(250, 246, 240, 0.98), rgba(242, 235, 225, 0.95));
    --surface-soft: linear-gradient(145deg, rgba(252, 248, 243, 0.96), rgba(244, 238, 229, 0.9));
    --surface-raised: rgba(255, 252, 247, 0.74);
    --border-soft: rgba(129, 105, 74, 0.14);
    --border-green: rgba(34, 82, 50, 0.52);
    --border-green-strong: rgba(34, 82, 50, 0.72);
    --shadow-soft: 0 18px 40px rgba(63, 53, 40, 0.07);
    --shadow-medium: 0 14px 28px rgba(63, 53, 40, 0.09);
    --text-hero: 2.3rem;
    --text-section: 1.9rem;
    --text-card-title: 1.45rem;
    --text-body: 1rem;
    --text-small: 0.95rem;
    --text-caption: 0.88rem;
    --line-heading: 1.15;
}

/* Resets default browser styling and applies border-box sizing to all elements */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; 
}

/* Sets the foundation for typography and page background */
body {
    font-family: 'Source Sans 3', sans-serif;
    background:
        radial-gradient(circle at top, rgba(255, 249, 240, 0.78), transparent 34%),
        linear-gradient(180deg, #f6eee2 0%, #f3ebdf 44%, #f1e8db 100%);
    color: var(--dark-gray);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Keep page content above the texture layer */
body > * {
    position: relative;
    z-index: 1;
}

main {
    width: 100%;
    flex: 1 0 auto;
}

/* Soft page texture that sits behind the main content */
body:not(#countryBody)::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.38;
    background:
        repeating-linear-gradient(135deg, rgba(46, 50, 48, 0.06) 0 2px, transparent 2px 12px),
        repeating-linear-gradient(45deg, rgba(74, 124, 89, 0.04) 0 1px, transparent 1px 16px),
        linear-gradient(180deg, rgba(250, 246, 240, 0.03), rgba(46, 50, 48, 0.02));
    mix-blend-mode: multiply;
}

body:not(#countryBody)::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 18% 24%, rgba(46, 50, 48, 0.08) 0 1px, transparent 1.5px),
        radial-gradient(circle at 66% 46%, rgba(46, 50, 48, 0.07) 0 1px, transparent 1.5px),
        radial-gradient(circle at 40% 72%, rgba(46, 50, 48, 0.08) 0 1px, transparent 1.5px),
        radial-gradient(circle at 82% 78%, rgba(46, 50, 48, 0.07) 0 1px, transparent 1.5px),
        repeating-linear-gradient(0deg, rgba(46, 50, 48, 0.045) 0 1px, transparent 1px 34px),
        repeating-linear-gradient(90deg, rgba(46, 50, 48, 0.03) 0 1px, transparent 1px 34px);
    background-size: 150px 150px;
    opacity: 0.42;
    pointer-events: none;
    z-index: 0;
}

body:not(#countryBody)::before,
body:not(#countryBody)::after {
    transition: opacity 0.25s ease;
}

/* Applies the specific serif font and primary color to all headings */
h1, h2, h3 {
    font-family: 'Literata', serif;
    color: var(--green);
    line-height: var(--line-heading);
    font-weight: 800;
}

/* Flexbox container for the main header */
.menu {
    padding: 18px 24px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background:
        linear-gradient(90deg, #245338 0%, var(--green-deep) 24%, var(--green) 62%, var(--green-bright) 100%);
    border-bottom: 1px solid rgba(241, 231, 214, 0.22);
    box-shadow: 0 14px 34px rgba(28, 46, 35, 0.16);
    position: relative;
    overflow: hidden;
}

.menu::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.08));
}

.logo {
    justify-self: start;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--cream);
}

.logo-mark {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    line-height: 1;
    color: var(--cream);
    background: transparent;
    transform: translateY(7px);
    flex-shrink: 0;
}

/* Logo text styling inside the menu */
.menu h1 {
    color: var(--cream);
    letter-spacing: -0.02em;
    font-size: 2.2rem;
    text-shadow: 0 2px 14px rgba(19, 35, 26, 0.16);
}

/* Removes default underline from all links in the menu */
.menu a {
    text-decoration: none;
}

/* Buttons */
/* Default solid primary button style */
.button {
    background-color: var(--green);
    color: var(--cream);
    padding: 11px 22px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-size: var(--text-body);
    font-weight: bold;
    box-shadow: 0 10px 20px rgba(53, 91, 65, 0.14);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    background-color: var(--green-deep);
    box-shadow: 0 14px 24px rgba(53, 91, 65, 0.18);
}

/* Visual state for buttons when they are disabled (e.g., during loading) */
.button:disabled {
    background-color: #a9bcae; /* Light green */
    cursor: not-allowed;
    box-shadow: none;
}

/* Inputs */
/* Default styling for text input fields */
input {
    background-color: rgba(255, 252, 247, 0.94);
    border: 1px solid rgba(129, 105, 74, 0.28);
    border-radius: 14px;
    padding: 11px 12px;
    font-size: var(--text-body);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus {
    border-color: rgba(111, 160, 183, 0.42);
    box-shadow:
        0 0 0 4px rgba(190, 224, 236, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

/* Container for the page links in the header menu */
.menu-links {
    display: flex;
    gap: 14px; /* Horizontal spacing between each link */
    align-items: center;
    justify-self: center;
    flex-wrap: wrap;
    justify-content: center;
}

/* Styling for the individual page links */
.menu-links a {
    color: rgba(250, 246, 240, 0.94);
    font-size: 1.06rem;
    font-weight: bold;
    padding: 10px 16px;
    border-radius: 999px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

/* Adds soft highlight when hovering over menu links */
.menu-links a:hover {
    color: var(--white);
    background: rgba(250, 246, 240, 0.15);
    transform: translateY(-1px);
}

.menu-links a[aria-current="page"] {
    color: var(--green-deep);
    background: linear-gradient(180deg, rgba(254, 250, 245, 0.98), rgba(241, 232, 219, 0.96));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.26),
        0 10px 20px rgba(22, 40, 29, 0.1);
}

/* Container for the right-side buttons (Search, Sign Up) */
.menu-actions {
    display: flex;
    gap: 12px; /* Horizontal spacing between buttons */
    align-items: center;
    justify-self: end;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Secondary button style */
.button-light {
    background-color: rgba(250, 246, 240, 0.96);
    color: var(--green);
    padding: 11px 20px;
    border: 1px solid rgba(241, 231, 214, 0.48);
    border-radius: 14px;
    cursor: pointer;
    font-size: var(--text-body);
    font-weight: bold;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 18px rgba(33, 48, 38, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.button-light:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(33, 48, 38, 0.14);
}

.menu-actions .button-light:first-child {
    background: linear-gradient(180deg, rgba(250, 246, 240, 0.98), rgba(238, 229, 216, 0.96));
}

.menu-actions .button-light:last-child {
    background: transparent;
    color: var(--cream);
    border-color: rgba(250, 246, 240, 0.3);
    box-shadow: none;
}

.menu-actions .button-light:last-child:hover {
    background: rgba(250, 246, 240, 0.1);
    color: var(--white);
}

/* Transparent button style */
.button-text {
    background-color: transparent;
    color: var(--cream);
    padding: 10px 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Slightly scales up the element when hovered */
.button-text:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.menu-logout-button {
    font-size: var(--text-body);
    font-weight: bold;
}

@media (max-width: 980px) {
    .menu {
        grid-template-columns: 1fr;
        gap: 16px;
        justify-items: center;
        text-align: center;
        padding: 18px;
    }

    .logo,
    .menu-links,
    .menu-actions {
        justify-self: center;
    }

    .logo-link,
    .menu-actions {
        justify-content: center;
    }
}

/* Rules applied only to screens 768px wide or smaller (Tablets and Phones) */
@media (max-width: 768px) {
    .menu {
        flex-direction: column; /* Stacks the logo, links, and buttons vertically */
        display: flex;
        gap: 20px;
        text-align: center;
    }
    /* Allows links and buttons to wrap to the next line if they don't fit horizontally */
    .menu-links, .menu-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .menu h1 {
        font-size: 1.95rem;
    }

    .logo-link {
        gap: 10px;
    }

    .logo-mark {
        width: 30px;
        height: 30px;
        font-size: 1.7rem;
        transform: translateY(5px);
    }
}

/* Styling for the standalone, rounded footer box at the bottom of the page */
.footer {
    background:
        linear-gradient(135deg, #26543a 0%, var(--green-deep) 28%, var(--green) 72%, #5f9472 100%);
    color: var(--cream); 
    padding: 42px 24px 46px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 56px;
    border-top: 1px solid rgba(241, 231, 214, 0.18);
    box-shadow: 0 -14px 34px rgba(34, 51, 40, 0.09);
    position: relative;
}

.footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: min(88%, 980px);
    height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0));
}

.footer::after {
    content: "";
    position: absolute;
    inset: auto 50% 18px auto;
    width: min(180px, 34%);
    height: 1px;
    transform: translateX(50%);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
}

.footer-text {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    color: rgba(250, 246, 240, 0.94);
    font-size: 1.02rem;
    letter-spacing: 0.01em;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 18px;
}

.footer-text span:first-child {
    justify-self: start;
    color: rgba(250, 246, 240, 0.72);
    font-size: 0.95rem;
}

.footer-text span:nth-child(2) {
    justify-self: center;
}

.footer-text span:last-child {
    justify-self: end;
    color: rgba(250, 246, 240, 0.72);
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .footer-text {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 8px;
    }

    .footer-text span:first-child,
    .footer-text span:nth-child(2),
    .footer-text span:last-child {
        justify-self: center;
    }
}

@media (max-width: 480px) {
    .menu {
        padding: 16px 14px;
        gap: 14px;
    }

    .menu h1 {
        font-size: 1.72rem;
    }

    .menu-links {
        gap: 8px;
    }

    .menu-links a,
    .button-light {
        padding: 10px 14px;
        font-size: 0.96rem;
    }

    .logo-link {
        gap: 10px;
    }

    .logo-mark {
        width: 28px;
        height: 28px;
        font-size: 1.55rem;
        transform: translateY(4px);
    }
}
