/* Structural tokens (spacing, radii, transitions) */
:root {
  --space-xxs: 0.25rem; /*4px*/
  --space-xs: 0.5rem; /*8px*/
  --space-sm: 0.625rem; /*10px*/
  --space-md: 1rem; /*16px*/
  --radius: 0.375rem; /*6px*/
  --transition-fast: 200ms;
}

/* ============================================
   GLOBAL RESET & STRUCTURE
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
  font-size: 16px; /* use rems consistently */
}

/* Smooth transitions (respects reduced-motion) */
@media (prefers-reduced-motion: no-preference) {
  * {
    transition:
      background-color var(--transition-fast),
      color var(--transition-fast),
      border-color var(--transition-fast),
      box-shadow var(--transition-fast);
  }
}

/* Helper: hide scrollbars when applied to overflow containers */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ============================================
   BASE STYLES
   ============================================ */

body {
  margin: 0;
  background-color: var(--bg-dark);
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 1em;
  min-width: 350px;
}

/* ============================================
   MASTHEAD
   ============================================ */

#masthead {
  padding: 0.25em;
  background-color: var(--masthead-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

#masthead a {
  color: var(--text-med);
  text-decoration: none;
}

#masthead h1 {
  flex: 1;
  margin: 0;
}

/* Dark mode toggle in masthead */
#masthead #dark-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius);
  color: var(--text-med);
  width: 40px;
  height: 40px;
  transition: background-color var(--transition-fast);
  font-size: 1rem;
  position: absolute;
  left: 0.5rem;
}

#masthead #dark-mode-toggle:hover {
  background-color: var(--overlay-hover);
}

#masthead #dark-mode-toggle:focus {
  outline: 2px solid var(--text-dark);
  outline-offset: 2px;
}

#masthead #dark-mode-toggle svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

/* Show appropriate icon based on theme */
#masthead #dark-mode-toggle .icon-light {
  display: none;
}

#masthead #dark-mode-toggle .icon-dark {
  display: block;
}

html[data-theme='dark'] #masthead #dark-mode-toggle .icon-light {
  display: block;
}

html[data-theme='dark'] #masthead #dark-mode-toggle .icon-dark {
  display: none;
}

/* ============================================
   NAVIGATION (MODERN + RESPONSIVE + STICKY)
   ============================================ */

#navigation {
  background-color: var(--nav-bg);
  padding: 0.25em;
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px var(--shadow-2);
}

/* NAV LINKS */
#nav-links ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: flex-start;
}

#nav-links li {
  position: relative;
  padding: 0.25em 0.75em;
}

#nav-links a {
  text-decoration: none;
  color: var(--text-med);
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast);
}

/* DIVIDERS BETWEEN LINKS */
#nav-links ul li:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background-color: var(--divider);
}

/* SEARCH BAR */
#nav-search {
  margin-top: 0.5em;
}

#site-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

#site-search input[type='text'] {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background-color: var(--bg-light);
  color: var(--text-dark);
  font-size: 0.875rem; /* 14px */
  transition: all var(--transition-fast) ease-in-out;
}

#site-search input[type='text']:focus {
  outline: none;
  border-color: var(--text-med);
  background-color: var(--masthead-bg);
}

#site-search button {
  padding: 0.25rem 0.625rem;
  background-color: var(--nav-bg);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-dark);
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
}

#site-search button:hover,
#site-search button:focus {
  background-color: var(--masthead-bg);
}

/* Brighten the search button in light mode so it reads as a primary action. */
html:not([data-theme='dark']) #site-search button {
  background-color: var(--bg-light);
  border: 1px solid var(--divider);
  box-shadow: none;
}

html:not([data-theme='dark']) #site-search button:hover,
html:not([data-theme='dark']) #site-search button:focus {
  background-color: var(--masthead-bg);
}

/* Ensure light-mode button hover differs from default so transition is visible */
html:not([data-theme='dark']) #site-search button:hover {
  background-color: var(--masthead-bg);
}

/* DESKTOP NAV LAYOUT */
@media (min-width: 801px) {
  #navigation {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  #nav-search {
    margin-top: 0;
    margin-left: auto;
  }
}

/* ============================================
   MOBILE NAV LAYOUT — HORIZONTAL SCROLL
   ============================================ */
@media (max-width: 800px) {
  #navigation {
    text-align: center;
  }

  /* Horizontal scroll for nav links */
  #nav-links ul {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    /* hide native scrollbars but keep scrolling behavior */
    -ms-overflow-style: none; /* IE/Edge */
  }

  #nav-links ul::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }

  #nav-links li {
    flex: 0 0 auto;
  }

  /* Remove dividers on mobile */
  #nav-links ul li::after {
    display: none;
  }

  /* Search bar full width */
  #nav-search {
    margin-top: 0.75em;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  #site-search {
    width: 90%;
    justify-content: center;
  }

  #site-search input[type='text'] {
    flex: 1;
  }
}
/* ============================================
   MOBILE LANDSCAPE — HIDE HEADER ON SCROLL
   ============================================ */
@media (orientation: landscape) and (max-width: 900px) {
  /* provide smooth hide/ show transforms when scrolling */
  #masthead,
  #navigation {
    will-change: transform;
    transition: transform 220ms ease-in-out;
  }

  /* when JS toggles this class on body, move header and nav out of view */
  body.hide-header #masthead,
  body.hide-header #navigation {
    transform: translateY(-100%);
  }
}

/* If the search bar doesn't fit in short landscape, hide it. */
@media (orientation: landscape) and (max-width: 900px) {
  #nav-search {
    display: none;
  }
}

/* ============================================
   BREADCRUMB
   ============================================ */

#breadcrumb {
  background-color: var(--masthead-bg);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--divider);
}

@media (min-width: 768px) {
  #breadcrumb {
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
  }
}

#breadcrumb ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
}

#breadcrumb ol::-webkit-scrollbar {
  display: none;
}

#breadcrumb li {
  white-space: nowrap;
  color: var(--text-med);
}

#breadcrumb li:not(:last-child)::after {
  content: '\203A';
  margin-left: 0.25rem;
  color: var(--divider);
}

#breadcrumb li:last-child {
  color: var(--text-dark);
  font-weight: 600;
}

#breadcrumb a {
  color: var(--text-med);
  text-decoration: none;
}

#breadcrumb a:hover {
  text-decoration: underline;
}

/* ============================================
   CONTENT
   ============================================ */

#content_container {
  background-color: var(--bg-light);
  position: relative;
}

#page_title {
  padding: 0.5em;
  clear: both;
  text-align: center;
}

#page_desc {
  padding: 0.5em;
  max-width: 1000px;
  text-align: center;
  margin: auto;
}

#page_desc p {
  margin: 0;
  color: var(--text-med);
}

/* ============================================
   PHOTO GRID (UNIFORM, CENTERED, FULL IMAGE)
   ============================================ */

#photos {
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
}

/* Each photo tile */
#photos .img,
#photos .img2_big {
  width: 300px;
  background-color: var(--masthead-bg);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 0.5em;
  box-shadow: 0 2px 4px var(--shadow-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s ease-in-out;
}

/* Hover glow around the whole tile */
#photos .img:hover,
#photos .img2_big:hover {
  box-shadow: 0 4px 10px var(--shadow-3);
  transform: translateY(-2px);
}

/* Image wrapper */
#photos .img a,
#photos .img2_big a {
  width: 100%;
  height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--masthead-bg);
  border-radius: 4px;
  transition: all 0.2s ease-in-out;
}

/* Subtle highlight around the image */
#photos .img a:hover,
#photos .img2_big a:hover {
  box-shadow: 0 0 8px var(--photo-highlight-shadow);
}

/* The image itself */
#photos .img img,
#photos .img2_big img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  border: 0;
  display: block;
}

/* Caption */
#photos .desc2,
#photos .desc {
  margin-top: 0.25em;
  text-align: center;
}

#photos .desc2 p,
#photos .desc2 a,
#photos .desc p,
#photos .desc a {
  margin: 0;
  padding: 0.25em 0;
  font-size: 0.9em;
  color: var(--text-dark);
  text-decoration: none;
  display: block;
  line-height: 1.2;
}

/* ensure link captions never stretch vertically */
#photos .desc2 a,
#photos .desc a {
  min-height: 0;
  height: auto;
}

#photos .desc2 a:hover,
#photos .desc a:hover {
  color: var(--desc-hover);
  text-decoration: underline;
}

/* ============================================
   GALLERY LIST (TEXT LINKS ONLY)
   ============================================ */

#gallery_list {
  padding: 0.9em 0.9em 0.6em;
  height: 100%;
}

/* Weather widget floating in upper-right of content container */
.weather-float {
  float: right;
  margin: 0.75rem 0.75rem 0.5rem 0.75rem;
  display: block;
  box-sizing: border-box;
  text-decoration: none;
  color: inherit;
  z-index: 150;
}

@media (max-width: 700px) {
  .weather-float {
    display: none;
  }
}

/* Weather widget internal styling */
.mw-widget {
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial;
  margin: 0;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--bg-light);
  color: var(--mw-widget-color);
  border: 1px solid var(--divider);
  box-shadow: 0 2px 6px var(--shadow-2);
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.mw-icon {
  width: auto;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  flex-shrink: 0;
  align-self: center;
}

.mw-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  line-height: 1.35;
  min-width: 0;
}

.mw-location {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.mw-temp {
  font-weight: 700;
  font-size: 17px;
}

.mw-desc {
  font-size: 12px;
  color: var(--mw-desc-color);
}

.mw-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.mw-updated {
  font-size: 11px;
  color: var(--mw-desc-color);
  white-space: nowrap;
}

.mw-refresh {
  font-size: 14px;
  text-decoration: none;
  color: var(--mw-desc-color);
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.mw-refresh:hover {
  color: var(--mw-widget-color);
}

.mw-meta {
  font-size: 12px;
  color: var(--mw-meta-color);
  margin-top: 4px;
}

.mw-error {
  color: var(--mw-error-color);
  background: transparent;
  padding: 6px;
  border-radius: 6px;
}

/* Dark mode weather widget styling */
html[data-theme='dark'] .mw-widget {
  background: var(--bg-light);
  color: var(--mw-widget-color);
  box-shadow: 0 1px 3px var(--shadow-4);
}

html[data-theme='dark'] .mw-desc {
  color: var(--text-med);
}

html[data-theme='dark'] .mw-meta {
  color: var(--text-med);
}

html[data-theme='dark'] .mw-error {
  color: var(--mw-error-color);
  background: transparent;
}

/* Make gallery list items inline so they can wrap around the floated widget */
#gallery_list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: block;
}

#gallery_list li {
  display: inline-block;
  margin: 0 0.35em 0.35em 0;
  vertical-align: top;
}

/* Allow gallery headings to flow beside the floated weather widget */
#gallery_list h4 {
  clear: none;
  display: inline-block;
  margin: 0 0.5rem 0 0;
  vertical-align: top;
}

/* Keep links visually similar but a bit tighter; restore original link color */
#gallery_list a {
  text-decoration: none;
  display: inline-block;
  padding: 0.15em 0.3em;
  border-radius: 2px;
  color: var(--text-med);
}

#gallery_list a:hover,
#gallery_list a:focus {
  color: var(--text-med);
  background-color: var(--nav-bg);
  outline: none;
}

/* ============================================
   FOOTER
   ============================================ */

#footer {
  width: 100%;
  padding: 0.25em;
  background-color: var(--nav-bg);
  color: var(--text-med); /* make plain text match link color */
  box-shadow: 0 -2px 4px var(--shadow-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: nowrap;
}

#footer p {
  margin: 0;
}

#footer > p {
  order: 0;
}
#copyright {
  order: 1;
  text-align: right;
}

#footer a {
  color: var(--text-med);
  text-decoration: none;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

#footer a:hover,
#nav-links a:hover,
#nav-links a:focus,
#footer a:focus {
  color: var(--footer-hover-color);
  background-color: var(--footer-hover-bg);
  text-decoration: none;
}

@media (max-width: 700px) {
  #footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
  }

  #footer > p {
    order: 1;
    width: 100%;
  }
  #copyright {
    order: 2;
    width: 100%;
  }
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1 {
  color: var(--text-med);
  font-style: italic;
  font-size: 2.5em;
  margin: 0;
  text-align: right;
}

h2 {
  font-size: 1.5em;
  color: var(--text-dark);
  margin: 0;
}

h3 {
  font-size: 1em;
  color: var(--h3-color);
}

h4 {
  font-size: 1.25em;
  color: var(--text-med);
  margin: 0;
  clear: both;
}

a {
  color: var(--text-med);
}

.style_bold {
  font-weight: bold;
}

.style_italic {
  font-style: italic;
}

/* ============================================
   SEARCH RESULTS (ANIMATIONS + EFFECTS)
   ============================================ */

#search_results {
  max-width: 900px;
  margin: 1em auto;
  padding: 0 1em;
}

#search_sort_form label {
  color: var(--text-dark);
}

#search_sort_form button {
  border: 1px solid var(--divider) !important;
  background: var(--masthead-bg) !important;
  color: var(--text-dark) !important;
}

.search-result {
  background-color: var(--masthead-bg);
  border: 1px solid var(--divider);
  padding: 1em;
  margin-bottom: 1em;
  border-radius: 6px;
  text-align: left;
  box-shadow: 0 2px 4px var(--shadow-2);
  animation: fadeIn 0.4s ease-in-out;
  transition: all 0.2s ease-in-out;
}

.search-result:hover {
  background-color: var(--nav-bg);
  transform: translateY(-2px);
}

.search-result-title {
  font-size: 1.25em;
  font-weight: bold;
  color: var(--text-med);
  text-decoration: none;
}

.search-result-title:hover {
  color: var(--text-dark);
  text-decoration: underline;
}

.search-result-snippet p {
  margin: 0.5em 0 0 0;
  color: var(--text-dark);
  line-height: 1.4em;
  font-size: 0.95em;
}

/* Highlight pulse animation */
mark {
  background-color: var(--highlight);
  padding: 0 2px;
  border-radius: 2px;
  animation: pulseHighlight 1.5s ease-out;
}

@keyframes pulseHighlight {
  0% {
    background-color: var(--pulse-start);
  }
  50% {
    background-color: var(--highlight);
  }
  100% {
    background-color: var(--highlight);
  }
}

/* Fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   IMAGE LINK / TAP HIGHLIGHT FIXES
   ============================================ */

#photos a,
#photos a img {
  -webkit-tap-highlight-color: transparent;
  -ms-touch-action: manipulation;
  touch-action: manipulation;
}

#photos a:focus,
#photos a:active,
#photos a:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
