/* CSS Custom Properties for better maintainability */
:root {
  --color-white: #ffffff;
  --color-dark: #263238;
  --color-overlay: rgba(0, 0, 0, 0.4);
  --color-text-overlay: rgba(255, 255, 255, 0.5);
  --font-primary: 'Roboto', system-ui, -apple-system, sans-serif;
  --font-secondary: 'Lato', system-ui, -apple-system, sans-serif;
  --min-touch-target: 44px;
}

/* Modern CSS Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html body {
  margin: 0;
  min-width: 300px;
  min-height: 480px;
  line-height: 1.5;
}

/* Updated selector to match HTML */
body#background {
  background: url('https://farm3.staticflickr.com/2134/2254617949_297f28d9a4_z.jpg') no-repeat center center fixed; 
  background-size: cover;
}

.fullwidth {
  position: relative;
  margin: 0;
  padding: 0;
  contain: layout style;
}

.image-container {
  position: relative;
  display: block;
  margin-bottom: 2px;
}

.image-container picture img {
  vertical-align: top;
  content-visibility: auto;
  width: 100%;
  height: auto;
  display: block;
}

.image-container figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: var(--color-white);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 300;
  margin: 0;
  backdrop-filter: blur(2px);
}

.image-container figcaption a {
  color: var(--color-white);
  text-decoration: none;
  transition: opacity 0.3s ease;
}

.image-container figcaption a:hover,
.image-container figcaption a:focus {
  opacity: 0.8;
  text-decoration: underline;
}

a {
  color: inherit;
  text-decoration: none;
  outline-offset: 2px;
}

a:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 2px;
}

.title {
  position: fixed;
  min-width: 300px;
  width: min(250px, 90vw);
  top: 10%;
  right: 10%;
  left: auto;
  padding: 12px;
  background-color: var(--color-overlay);
  font-family: var(--font-primary);
  color: var(--color-white);
  font-size: 16px;
  backdrop-filter: blur(10px);
  max-height: 80vh;
  overflow-y: auto;
}

.title #header {
  text-transform: uppercase;
  font-size: 24px;
  margin: 0 0 1rem 0;
}

.title #logo {
  opacity: 0.7;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.title #logo a {
  display: inline-block;
  min-width: var(--min-touch-target);
  min-height: var(--min-touch-target);
}

.copyright {
  width: 100%;
  opacity: 0.5;
  padding: 2px 12px;
  font-family: var(--font-secondary);
  color: var(--color-white);
  font-size: 12px;
  margin-top: 1rem;
}

.modernization-note {
  font-size: 0.7em !important;
  color: rgba(255, 255, 255, 0.6) !important;
  margin-top: 1em !important;
}

/* Modern responsive design with improved breakpoints */
@media only screen and (min-width: 600px) {
  body#background {
    background: url('https://farm3.staticflickr.com/2134/2254617949_297f28d9a4_b.jpg') no-repeat center center fixed;
    background-size: cover;
  }
  
  .title {
    left: auto;
    padding: 16px;
    width: min(300px, 40vw);
    font-size: 20px;
  }
  
  .title #header {
    font-size: 32px;
  }
  
  .copyright {
    font-size: 14px;
  }
  
  .image-container figcaption {
    padding: 16px 20px;
    font-size: 16px;
  }
}

@media only screen and (min-width: 1200px) {
  body#background {
    background: url('https://farm3.staticflickr.com/2134/2254617949_d52004820d_o.jpg') no-repeat center center fixed;
    background-size: cover;
  }
  
  .title {
    left: auto;
    padding: 32px;
    width: min(450px, 35vw);
    font-size: 28px;
  }
  
  .title #header {
    font-size: 48px;
  }
  
  .copyright {
    padding: 4px 16px;
    font-size: 16px;
  }
  
  .image-container figcaption {
    padding: 20px 24px;
    font-size: 18px;
  }
}

/* Enhanced mobile support */
@media only screen and (max-width: 599px) {
  .title {
    position: fixed;
    top: auto;
    bottom: 5%;
    right: 5%;
    left: 5%;
    width: auto;
    max-width: none;
  }
  
  .image-container figcaption {
    position: static;
    background: rgba(38, 50, 56, 0.95);
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  .title {
    backdrop-filter: none;
  }
  
  .image-container figcaption a {
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .image-container figcaption {
    background: rgba(0, 0, 0, 0.95);
    color: #ffffff;
  }
  
  .title {
    background-color: rgba(0, 0, 0, 0.8);
  }
}

/* Print styles */
@media print {
  body#background {
    background: none !important;
  }
  
  .title {
    position: static;
    background: none;
    color: #000000;
    page-break-inside: avoid;
  }
  
  .image-container figcaption {
    position: static;
    background: none;
    color: #000000;
  }
}
