/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

/* Header */
header {
    /* Use scenic photo with a subtle dark overlay so white text remains readable */
    background: linear-gradient(rgba(16,32,64,0.45), rgba(16,32,64,0.25)), url('assets/images/snoq_pass_view.JPG');
    background-size: cover;
    background-position: center center;
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    /* ensure the header is tall enough to show the image nicely */
    min-height: 160px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Navigation */
nav {
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0;
}

nav li {
    margin: 0;
    position: relative;
}

nav a {
    display: block;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: background-color 0.3s, color 0.3s;
}

nav a:hover,
nav a.active {
    background-color: #2a5298;
    color: white;
}

.nav-item.dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #ffffff;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    padding: 0.25rem 0;
    display: none;
    z-index: 120;
}

.nav-item.dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-caret {
    display: inline-block;
    transition: transform 0.25s ease;
}

.nav-item.dropdown.open .dropdown-caret {
    transform: rotate(180deg);
}

.dropdown-menu li a {
    padding: 0.6rem 1.25rem;
    white-space: nowrap;
}

/* Mobile nav toggle (hamburger) */
.nav-toggle {
    display: none;
    position: fixed;
    left: 50%;
    top: 13rem;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: none;
    background: rgba(0, 0, 0, 0.75);
    cursor: pointer;
    z-index: 150;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nav-toggle.scrolled {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.nav-toggle:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.nav-toggle-bar {
    position: absolute;
    left: 50%;
    width: 22px;
    height: 2px;
    background: #ffffff;
    border-radius: 1px;
    transition: transform 0.25s ease, opacity 0.25s ease, top 0.25s ease;
}

.nav-toggle-bar:nth-child(1) {
    top: 13px;
    transform: translateX(-50%);
}

.nav-toggle-bar:nth-child(2) {
    top: 19px;
    transform: translateX(-50%);
}

.nav-toggle-bar:nth-child(3) {
    top: 25px;
    transform: translateX(-50%);
}

/* When nav is open, morph bars into an X */
nav.open .nav-toggle-bar:nth-child(1) {
    top: 19px;
    transform: translateX(-50%) rotate(45deg);
}

nav.open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

nav.open .nav-toggle-bar:nth-child(3) {
    top: 19px;
    transform: translateX(-50%) rotate(-45deg);
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

section {
    background: white;
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    color: #1e3c72;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    border-bottom: 3px solid #2a5298;
    padding-bottom: 0.5rem;
}

h3 {
    color: #2a5298;
    margin-bottom: 1rem;
}

/* Hero Section */
/* .hero {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
} */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem; /* space between figures */
}

.hero figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.post-preview h3 a {
    color: #1e3c72;
    text-decoration: none;
}

.post-preview h3 a:hover {
    color: #2a5298;
    text-decoration: underline;
}

.post-date {
    color: #666;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.post-summary {
    margin: 1rem 0;
    line-height: 1.8;
}

.read-more {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background-color: #2a5298;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.3s;
}

.read-more:hover {
    background-color: #1e3c72;
}

/* Ski Areas Grid */
.area-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.area-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e3f2fd 100%);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #2a5298;
    transition: transform 0.3s, box-shadow 0.3s;
}

.area-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.area-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.elevation {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

/* About Section */
.about p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

/* Recent Posts */
.post-list {
    list-style: none;
}

.post-list li {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.post-list li:last-child {
    border-bottom: none;
}

.post-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: #333;
    transition: color 0.3s;
    gap: 1rem;
}

.post-list a:hover {
    color: #2a5298;
}

.post-list .post-date {
    flex-shrink: 0;
    font-weight: 600;
    color: #2a5298;
}

/* Make post dates larger and more legible; include a slightly smaller size on narrow screens */
@media (min-width: 480px) {
    .post-list .post-date {
        font-size: 1.05rem;
    }
}
@media (max-width: 479px) {
    .post-list .post-date {
        font-size: 0.98rem;
    }
}

.post-list .post-title {
    flex-grow: 1;
}

/* Footer */
footer {
    background-color: #1e3c72;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

footer p {
    margin: 0.5rem 0;
    opacity: 0.9;
}

/* Responsive navigation: collapse to hamburger on smaller screens */
@media (max-width: 768px) {
    nav {
        position: sticky;
        top: 0;
    }

    nav ul {
        flex-direction: column;
        align-items: stretch;
        display: none;
        width: 100%;
    }

    nav.open ul {
        display: flex;
    }

    nav li {
        border-top: 1px solid #e0e0e0;
    }

    nav a {
        padding: 0.85rem 1.25rem;
    }

    .nav-toggle {
        display: block;
    }
}

.PlotFormat,
figure img {
    display: block;
    width: 100%;      /* Fill parent grid cell */
    max-width: 100%;  /* Prevent overflow */
    height: auto;     /* Maintain aspect ratio */
    margin: 0.75rem auto;
}

/* Responsive figure sizing: make large figures occupy ~80% of the viewport width
     but clamp to reasonable min/max sizes so they remain legible. Images are
     centered and keep their aspect ratio. */
.UtahSnowEnsemble,
.PlotFormat,
figure img {
    display: block;
    /* width: clamp(320px, 70vw, 1200px); dynamic: min 320px, ideal 80% viewport, max 1200px */
    max-width: 100%;
    height: auto;
    margin: 0.75rem auto;
}

/* Synoptic tools grid: two columns (GFS left, ECMWF right) with multiple rows.
     Each .tool-card holds a product title and an image. On narrow screens the
     layout collapses to a single column. */
.synoptic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 2rem;
    align-items: start;
}
.tool-card {
    background: #fff;
    left: auto !important;
    right: 0% !important;
    top: 10% !important;
    padding: 0.5rem;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    text-align: center;
    position: relative; /* for any future absolute children */
}
/* Stronger selector for right column flipping */
.tool-card.centered > .info-popup,
.tool-card.centered .info-popup {
  left: auto !important;
  right: 0% !important;
  top: 10% !important;
}
.tool-card .tool-title {
    font-weight: 700;
    color: #1e3c72;
    margin: 0.25rem 0 0.5rem 0;
}

@media (max-width: 900px) {
    .synoptic-grid { grid-template-columns: 1fr; }
}

/* create a new figure class for synoptic plots that are slightly smaller */
.SynopticPlot,
figure .SynopticPlot img {
    display: block;
    width: clamp(280px, 50vw, 1000px); /* dynamic: min 280px, ideal 60% viewport, max 1000px */
    max-width: 100%;
    height: auto;
    margin: 0.75rem auto;
}
/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    nav ul {
        flex-direction: column;
    }
    
    nav a {
        text-align: center;
    }
    
    .area-grid {
        grid-template-columns: 1fr;
    }
    
    .post-list a {
        flex-direction: column;
        align-items: flex-start;
    }
}

.PlotTitle {
    font-size: 3em;
    font-weight: bold;
    margin-top: 0.5em;
}



/* Align dropdown label and caret with other nav items */
/* Ensure the dropdown toggle matches the nav link sizing so it aligns vertically */
nav a,
.nav-item.dropdown > .dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1;
    vertical-align: middle;
    padding: 1rem 1.5rem; /* match `nav a` padding for consistent height */
}

/* If you previously set larger padding or a different font-size for .dropdown-toggle, override here */
.dropdown-toggle {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  margin: 0;                   /* ensure no top/bottom offsets */
}

/* Optional: if the caret glyph still looks slightly off, reduce its size or nudge it */
.dropdown-toggle .nav-caret,
.dropdown-toggle::after {
  display: inline-block;
  transform: translateY(0);    /* tweak to e.g. -1px or 0.05em if needed to nudge */
  font-size: 0.9em;            /* slightly smaller caret helps visual alignment */
  line-height: 1;
}

/* Dropdown menu: hidden by default */
.dropdown-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 2px); /* small gap so menu doesn't overlap the toggle */
    min-width: 200px;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(2,6,23,0.06);
    padding: 0.25rem 0;
    display: none;
    z-index: 40;
    pointer-events: auto;
}

/* Menu items */
.dropdown-menu li { list-style: none; }
.dropdown-menu a {
    display: block;
    padding: 0.65rem 1rem; /* larger click/tap area */
    color: #0f172a;
    text-decoration: none;
    font-size: 0.98rem;
}
.dropdown-menu a:hover,
.dropdown-menu a:focus {
  background: rgba(37,99,235,0.06);
  outline: none;
}

.nav-item.dropdown {
    position: relative;
    display: inline-block;
}

.nav-item.dropdown > .dropdown-menu {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    top: calc(100% + 2px); /* keep consistent small gap */
}

/* Show dropdown only when .open class is present (controlled by JavaScript) */
.nav-item.dropdown.open .dropdown-menu {
    display: block;
}

/* On small / touch screens: keep menu hidden (no hover available) */
/* This prevents the dropdown from opening on taps — users should navigate to model-tools.html */
@media (max-width: 800px) {
    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        padding: 0;
        margin-top: 0.25rem;
        min-width: auto;
        display: none;
    }
  .dropdown-menu a {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  /* If your mobile nav is vertical, ensure overall nav layout adapts, but submenu will remain hidden */
  .main-nav { flex-direction: column; align-items: stretch; gap: 0; }
}

.data-sources {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Reduced from 24px */
    max-width: 400px;
    margin: 32px auto;
  }
  .data-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0; /* Reduced from 18px 0 */
    border-bottom: 1px solid #eee;
  }
  .value {
    font-size: 2.2em;
    font-weight: bold;
    margin-bottom: 2px; /* Reduced from 6px */
  }
  .label {
    font-size: 1em;
    color: #555;
  }
  .data-row:last-child {
    border-bottom: none;
  }

  .info-icon {
    display: inline-block;
    cursor: pointer;
    margin-left: 6px;
    font-weight: bold;
    color: #0074D9;
    border-radius: 50%;
    background: #eaf6ff;
    width: 18px;
    height: 18px;
    text-align: center;
    line-height: 18px;
    font-size: 14px;
  }
  .info-popup {
    display: none; /* Show with JS */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(255,255,255,0.95);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
    padding: 2rem 2rem 1rem 1rem;
    box-sizing: border-box;
  }
  .close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: #eee;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 18px;
    font-weight: bold;
    color: #0074D9;
    cursor: pointer;
    line-height: 20px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: background 0.2s;
  }
  .close-btn:hover {
    background: #0074D9;
    color: #fff;
  }

  .contact-form {
    max-width: 500px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  
  .contact-form label {
    font-weight: 600;
  }
  
  .contact-form input,
  .contact-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
  }
  
  .contact-form textarea {
    min-height: 120px;
  }
  
  .contact-form button {
    background: #1e293b;
    color: white;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }
  
  .contact-form button:hover {
    background: #0f172a;
  }