/* ===================================================
   1. GLOBAL RESET & BASE STYLES
   =================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.fig {
    scroll-margin-top: 100px;
}

html {
    font-size: 100%;
    scroll-behavior: smooth;
}

/* Variables */
:root {
    --text-main: #333;
    --text-muted: #333;
    --text-light: #333;
    --accent: #800;

    /* Spacing scale */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;

    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-light);

    -webkit-font-smoothing: antialiased;
}


/* ===================================================
   2. TYPOGRAPHY & MEDIA
   =================================================== */

img,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

h1,
h2,
h3 {
    font-weight: 400;
    line-height: 1.25;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

h1 {
    font-size: clamp(2rem, 4vw, 2.5rem);
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2rem);
}

h3 {
    font-size: clamp(1.25rem, 2.2vw, 1.5rem);
}

p {
    margin-bottom: var(--space-md);
}

h1:first-child,
h2:first-child,
h3:first-child {
    margin-top: 0;
}

h1.page-title {
    text-align: center;
    margin-bottom: var(--space-md);
}

/* Links */
a {
    color: var(--text-main);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    text-decoration-thickness: 1px;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
    color: #500;
    text-decoration: none;
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a:active {
    color: #300;
}


/* ===================================================
   3. LAYOUT CONTAINERS & STRUCTURE
   =================================================== */

main {
    flex: 1;
    width: 100%;
}

.parent {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);

    width: 90%;
    max-width: 1440px;
    margin: 0 auto;
}

.image-container {
    display: flex;
    flex-direction: column;
    align-items: center;

    width: 90%;
    max-width: 1140px;
    margin: 0 auto;
    padding: var(--space-md) 2vw;
    gap: var(--space-lg);

    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    justify-content: center;
    /* Keeps the footer from jumping up if images take a second to load */
    min-height: 80vh; 
}

figure {
    display: table;
    margin: 0 auto var(--space-md);
    max-width: 1000px;
}

figure a {
    color: black;
}

figure a:hover {
    color: maroon;
    text-decoration: none;
}

figure img {
    display: block;
    max-width: 100%;
    height: auto;
    border: 2px solid black;
}

figcaption {
    display: table-caption;
    caption-side: bottom;
    text-align: center;

    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--text-muted);

    margin-top: var(--space-sm);
}

.inner-text-wrap {
    max-width: 950px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}


/* ===================================================
   4. HEADER & NAVIGATION
   =================================================== */

.site-header {
    display: flex;
    align-items: center;

    max-width: 1440px;
    margin: 0 auto var(--space-xl);
    padding: var(--space-lg) 5vw;
    gap: var(--space-lg);

    border-bottom: 2px solid #ddd;
}

.site-header a {
    color: inherit;
    text-decoration: none;
}

.site-header a:hover {
    color: var(--accent);
}

.logo {
    border: 1px solid black;
    max-height: 100px;
}

.nav-menu ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;

    list-style: none;
    margin: 0 auto;
    max-width: 90%;
    gap: var(--space-lg);
}

.nav-menu a {
    font-size: 1.6rem;
    color: var(--text-main);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.nav-menu a:hover {
    color: var(--accent);
    text-decoration: none;
}


/* ===================================================
   5. FOOTER
   =================================================== */

hr {
    border: none;
    height: 2px;
    background: #ddd;
    width: 25%;
    margin: var(--space-xl) auto var(--space-sm);
}

footer {
    text-align: center;
    width: 100%;
    padding: var(--space-xs) var(--space-md);
}

footer p {
    max-width: 90%;
    margin: 0 auto var(--space-md);
}

.nav-menu-footer ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    list-style: none;
    width: 100%;
    max-width: 700px;
    margin: 0 auto var(--space-lg);
    gap: var(--space-sm);
}

.nav-menu-footer a {
    font-size: 1.3rem;
    color: var(--text-main);
    margin: 0 0.2em;

    text-decoration: underline;
    transition: color 0.2s ease;
}

.nav-menu-footer a:hover {
    color: var(--accent);
    text-decoration: none;
}

.small-logo {
    border: 1px solid black;
    max-height: 60px;
}


/* ===================================================
   6. CONTACT FORM
   =================================================== */

.contact-form {
    margin: var(--space-lg) auto;
    width: 100%;
    max-width: 500px;
    padding: var(--space-md);
}

input,
textarea {
    font-family: sans-serif;
    font-size: 1rem;
    padding: var(--space-sm);
    width: 100%;
}

label {
    display: block;
    margin-top: var(--space-md);
}

.my-button {
    background-color: #ccc;
    border: 1px solid #bbb;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    text-align: center;
    text-decoration: none;
    text-transform: lowercase;
    font-variant: small-caps;

    display: inline-block;
    font-size: 0.8rem;
    cursor: pointer;
}

.my-button:hover {
    background-color: #ddd;
    border-color: #ccc;
    color: maroon;
}

/* Honeypot field */
.hidden {
    display: none;
}


/* ===================================================
   7. UTILITIES & IMAGE PROTECTION
   =================================================== */

.center-something {
    display: flex;
    justify-content: center;

    max-width: 90%;
    margin: 0 auto var(--space-md);
    padding: var(--space-md) 0;
}

.small-text {
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
}

.img-protect {
    position: relative;
}

/* Invisible overlay */
.img-protect::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 10;
}

.img-protect img {
    width: 100%;
    height: auto;

    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

picture img {
    display: block;
    margin: 0 auto;
}


/* ===================================================
   8. SEARCH
   =================================================== */

<div class="search-wrapper">
    <div class="header-wrapper">
        <h1 class="page-title">Photo Search</h1>
        <div class="search-row">
            <input type="search" id="searchInput" placeholder="Enter state or park..." onkeydown="checkEnter(event)" style="padding: 10px; width: 60%;">
            <button type="button" class="my-button" onclick="handleSearch()">Search</button>
        </div>
    </div>

    <div id="photoGallery"></div>
</div>

/* Sanity Check: Sticky Footer Fix */
.search-wrapper {
	display: flex;
    flex-direction: column;
    /* Adjust 250px to match your header+footer total height */
    min-height: calc(100vh - 250px); 
    padding: 20px;
 }
	
.header-wrapper {
    /* Bump the search bar down a bit */
    margin-top: 15vh; 
    text-align: center;
}

.search-row {
    /* Layout & Alignment */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    
    /* Box Styling */
    background: #999;
    max-width: 740px;
    width: 100%;
    margin: 0 auto 30px auto; /* Centered, with 30px bottom margin */
    padding: var(--space-md) 2vw;
    border-radius: 10px;
}

#searchInput {
    flex: 1;
    min-width: 200px;
    padding: var(--space-sm);
}

#photoGallery {
    width: 100%;
    max-width: 800px;
    margin: var(--space-lg) auto 0 auto;
    position: relative;
    
    /* The Magic Sauce */
    min-height: calc(100vh - 250px); 
    
    /* Change this to move messages UP */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Aligns content to the top of the container */
    padding-top: 20px;          /* Adds just a small, natural gap below the search bar */
    
    flex-grow: 1;
}

/*
#photoGallery {
    /* Layout & Dimensions 
    width: 100%;
    max-width: 800px;
    margin: var(--space-lg) auto 0 auto;
    position: relative;
    
    /* The Magic Sauce: Keeps footer down when results are empty  
    min-height: calc(100vh - 250px); 
    
    /* Centering the search bar/instruction text  
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}  */

.results-header {
    color: red;
    font-size: 1.1rem;
    text-align: center;
}

.results-container {
    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #777;
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.close-x {
    cursor: pointer;
    line-height: 1;
}

.result-thumb {
    max-width: 99%;
    height: auto;
    border: 2px solid #444;
}

.btn-group {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

    .search-result-item {
        display: flex;
        gap: 20px;
        margin-bottom: 20px;
        border-bottom: 1px solid #eee;
        padding-bottom: 20px;
        align-items: center;
    }

 .result-thumb {
        width: 150px;
        height: auto;
        border-radius: 4px;
    }	



/* ===================================================
   9. RESPONSIVE DESIGN
   =================================================== */

@media (max-width: 768px) {
    .site-header {
        flex-direction: column;
        text-align: center;

        padding: var(--space-lg) var(--space-md);
        margin-bottom: var(--space-lg);
    }

    .nav-menu ul {
        justify-content: center;
        max-width: 100%;
    }

    .logo {
        max-height: 80px;
    }

    .small-logo {
        display: none;
    }

    .nav-menu a,
    .nav-menu-footer a,
    p,
    .site-title {
        font-size: 1rem;
    }

    h1.page-title {
        font-size: 1.25rem;
        margin-bottom: 0;
    }
}