/*
 * Improved stylesheet for Embers.fyi
 * Enhanced with proper image sizing, better quote context styling, and refined layouts
 */

:root {
  --primary-color: #D35400;
  --primary-dark: #A04000;
  --primary-light: #E67E22;
  --text-dark: #2C3E50;
  --text-light: #555;
  --text-lighter: #777;
  --bg-light: #F8F9FA;
  --bg-white: #FFFFFF;
  --header-dark: #1a1a1a;
  --success-color: #27AE60;
  --success-light: #2ECC71;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --transition: all 0.3s ease;
  --focus-outline: 3px solid #4A90E2;
  --focus-outline-offset: 3px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.7;
  color: var(--text-dark);
  background-color: var(--bg-white);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.menu-open {
  overflow: hidden;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--primary-color);
  color: white;
  padding: 12px 20px;
  text-decoration: none;
  font-weight: 600;
  z-index: 10000;
  border-radius: 0 0 8px 0;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header - Dark Background */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
  background-color: var(--header-dark);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  transition: var(--transition);
}

header .logo-container {
  flex-shrink: 0;
}

header .logo {
  height: 55px;
  width: auto;
  transition: var(--transition);
}

/* Navigation */
nav.nav-menu {
  display: flex;
  gap: 25px;
  align-items: center;
}

nav a {
  color: #FFFFFF;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
  position: relative;
  padding: 5px 0;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--primary-color);
  transition: width 0.3s ease;
}

nav a:hover,
nav a:focus {
  color: var(--primary-light);
  outline: none;
}

nav a:focus::after,
nav a:hover::after {
  width: 100%;
}

/* Hamburger Menu */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  z-index: 1001;
  transition: var(--transition);
  border-radius: 4px;
}

.hamburger:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.hamburger:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

.hamburger-line {
  width: 28px;
  height: 3px;
  background-color: #FFFFFF;
  border-radius: 3px;
  transition: var(--transition);
}

.hamburger.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(8px, 8px);
  background-color: var(--primary-color);
}

.hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(8px, -8px);
  background-color: var(--primary-color);
}

/* Hero Section */
.hero {
  position: relative;
  height: 65vh;
  min-height: 450px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(211, 84, 0, 0.3));
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  padding: 0 20px;
  animation: fadeInUp 1s ease-out;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin: 0 0 20px 0;
  font-weight: 700;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: -1px;
}

.hero p {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  margin-top: 10px;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
  font-weight: 300;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Section Styles */
.section {
  padding: 80px 20px;
  position: relative;
}

.section:nth-child(even) {
  background: var(--bg-light);
}

.section h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin: 0 0 40px 0;
  color: var(--primary-color);
  font-weight: 700;
  position: relative;
  padding-bottom: 15px;
}

.section h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  border-radius: 2px;
}

.section h3 {
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  margin: 30px 0 20px 0;
  color: var(--text-dark);
  font-weight: 700;
}

.section .content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

.section .content .text,
.section .content .image {
  min-width: 0;
}

.section .content .text {
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  line-height: 1.8;
  color: var(--text-light);
}

.section .content .text p {
  margin-bottom: 20px;
}

.section .content .text ul {
  margin: 20px 0;
  padding-left: 25px;
  list-style-type: disc;
}

.section .content .text li {
  margin-bottom: 15px;
  line-height: 1.8;
}

.section .content .text strong {
  color: var(--text-dark);
  font-weight: 700;
}

/* Images within content grid - NOT full width */
.section .content img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  object-fit: cover;
}

.section .content img:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
}

.section .content img:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Full-width contextual images with captions - CONSTRAINED width */
.image-with-caption {
  margin: 50px auto;
  max-width: 900px;
  text-align: center;
}

.image-with-caption img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  object-fit: cover;
}

.image-with-caption img:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}

.image-with-caption figcaption {
  margin-top: 15px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-light);
  font-style: italic;
  text-align: left;
  padding: 0 20px;
}

/* Enhanced Quote Styles with Author Context */
.quote {
  margin-top: 30px;
  padding: 25px 30px;
  border-left: 5px solid var(--primary-color);
  background: linear-gradient(135deg, #FFF5EE 0%, #FFF 100%);
  position: relative;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.quote:hover,
.quote:focus-within {
  box-shadow: var(--shadow-md);
  transform: translateX(5px);
}

.quote::before {
  content: '"';
  font-size: 4rem;
  position: absolute;
  top: -15px;
  left: 10px;
  color: var(--primary-light);
  opacity: 0.3;
  font-family: Georgia, serif;
  line-height: 1;
  pointer-events: none;
}

.quote blockquote {
  margin: 0;
  padding: 0;
  border: none;
}

.quote p {
  margin: 0;
  font-size: clamp(0.95rem, 1.5vw, 1.05rem);
  color: var(--text-dark);
  position: relative;
  z-index: 1;
  font-style: italic;
}

.quote .author {
  margin-top: 20px;
  font-weight: 700;
  display: block;
  text-align: left;
  color: var(--primary-dark);
  font-style: normal;
  font-size: clamp(0.9rem, 1.3vw, 1rem);
  line-height: 1.6;
  border-top: 1px solid rgba(211, 84, 0, 0.2);
  padding-top: 15px;
}

.quote .author strong {
  display: block;
  font-size: 1.05em;
  margin-bottom: 3px;
}

.quote .author-context {
  display: block;
  font-weight: 400;
  font-size: 0.9em;
  color: var(--text-light);
  margin-top: 8px;
  font-style: italic;
  line-height: 1.6;
}

/* Quick Facts Box */
.facts-box {
  background: linear-gradient(135deg, #FFF5E6 0%, #FFF8E8 100%);
  border-left: 5px solid var(--primary-color);
  padding: 25px 30px;
  margin: 30px 0;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.facts-box:hover {
  box-shadow: var(--shadow-md);
}

.facts-box h3 {
  margin: 0 0 15px 0;
  font-size: 1.3rem;
  color: var(--primary-dark);
  font-weight: 700;
}

.facts-box ul {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
  color: var(--text-dark);
}

.facts-box li {
  margin-bottom: 12px;
  padding-left: 30px;
  position: relative;
  line-height: 1.7;
}

.facts-box li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success-color);
  font-weight: bold;
  font-size: 1.2em;
}

.facts-box li:last-child {
  margin-bottom: 0;
}

/* Footer */
.footer {
  background: linear-gradient(135deg, #2C3E50 0%, #34495E 100%);
  color: #ECF0F1;
  padding: 50px 20px 30px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 40px;
  margin-bottom: 30px;
}

.footer-section h3 {
  font-size: 1.3rem;
  margin-bottom: 15px;
  color: var(--primary-light);
  font-weight: 700;
}

.footer-section p {
  margin-bottom: 15px;
  line-height: 1.7;
  font-size: 0.95rem;
}

.footer-section ul {
  list-style-type: none;
  padding-left: 0;
  margin: 15px 0;
}

.footer-section li {
  margin-bottom: 8px;
  padding-left: 20px;
  position: relative;
}

.footer-section li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success-light);
  font-weight: bold;
}

.footer-section abbr {
  text-decoration: none;
  border-bottom: 1px dotted #ECF0F1;
  cursor: help;
}

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid rgba(236, 240, 241, 0.2);
}

.footer-bottom p {
  margin: 0;
  font-size: 0.95rem;
}

.footer a {
  color: var(--primary-light);
  text-decoration: underline;
  transition: var(--transition);
  font-weight: 600;
}

.footer a:hover,
.footer a:focus {
  color: #ECF0F1;
  outline: none;
  text-decoration: none;
}

/* Focus styles */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Selection */
::selection {
  background-color: var(--primary-color);
  color: white;
}

::-moz-selection {
  background-color: var(--primary-color);
  color: white;
}

/* Tablet Styles */
@media (max-width: 1024px) {
  header {
    padding: 12px 25px;
  }
  
  nav.nav-menu {
    gap: 20px;
  }
  
  nav a {
    font-size: 0.9rem;
  }
  
  .section {
    padding: 60px 20px;
  }
  
  .section .content {
    gap: 30px;
  }
  
  .image-with-caption {
    max-width: 800px;
    margin: 40px auto;
  }
  
  .footer-content {
    gap: 30px;
  }
}

/* Mobile Styles */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
  
  header {
    padding: 12px 20px;
  }
  
  header .logo {
    height: 45px;
  }
  
  .hamburger {
    display: flex;
  }
  
  nav.nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 75%;
    max-width: 350px;
    height: 100vh;
    background: linear-gradient(135deg, var(--header-dark) 0%, #2a2a2a 100%);
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 80px 30px 30px 30px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    gap: 0;
    overflow-y: auto;
  }
  
  nav.nav-menu.active {
    right: 0;
  }
  
  nav.nav-menu a {
    width: 100%;
    padding: 18px 0;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
    color: #FFFFFF;
  }
  
  nav.nav-menu a:hover,
  nav.nav-menu a:focus {
    padding-left: 10px;
    color: var(--primary-light);
  }
  
  nav.nav-menu a::after {
    display: none;
  }
  
  .hero {
    height: 50vh;
    min-height: 350px;
    background-attachment: scroll;
  }
  
  .section {
    padding: 50px 20px;
  }
  
  .section .content {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  
  .section .content .text ul {
    padding-left: 20px;
  }
  
  .image-with-caption {
    margin: 35px auto;
  }
  
  .image-with-caption figcaption {
    padding: 0 10px;
    font-size: 0.9rem;
  }
  
  .quote {
    padding: 20px 25px;
    margin-top: 25px;
  }
  
  .quote::before {
    font-size: 3rem;
    top: -10px;
    left: 5px;
  }
  
  .quote .author {
    font-size: 0.9rem;
  }
  
  .facts-box {
    padding: 20px 25px;
    margin: 25px 0;
  }
  
  .facts-box h3 {
    font-size: 1.2rem;
  }
  
  .facts-box li {
    padding-left: 25px;
    font-size: 0.95rem;
  }
  
  .footer {
    padding: 40px 20px 25px;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
  
  header {
    padding: 10px 15px;
  }
  
  header .logo {
    height: 40px;
  }
  
  nav.nav-menu {
    width: 85%;
    padding: 70px 25px 25px 25px;
  }
  
  nav.nav-menu a {
    font-size: 1rem;
    padding: 15px 0;
  }
  
  .hero {
    height: 45vh;
    min-height: 300px;
  }
  
  .section {
    padding: 40px 15px;
  }
  
  .section h2::after {
    width: 60px;
    height: 3px;
  }
  
  .section .content {
    gap: 25px;
  }
  
  .section .content .text li {
    margin-bottom: 12px;
  }
  
  .image-with-caption {
    margin: 30px auto;
  }
  
  .image-with-caption figcaption {
    padding: 0 5px;
  }
  
  .quote {
    padding: 18px 20px;
  }
  
  .quote::before {
    font-size: 2.5rem;
  }
  
  .facts-box {
    padding: 18px 20px;
  }
  
  .footer {
    padding: 35px 15px 20px;
  }
  
  .footer-content {
    gap: 25px;
  }
}

/* Print Styles */
@media print {
  .skip-link,
  .hamburger,
  nav.nav-menu {
    display: none;
  }
  
  header {
    position: relative;
    box-shadow: none;
    background-color: var(--bg-white);
  }
  
  .section {
    page-break-inside: avoid;
  }
  
  .hero {
    height: auto;
    min-height: 200px;
    background-attachment: scroll;
  }
  
  a {
    text-decoration: underline;
  }
  
  .footer {
    page-break-before: always;
  }
  
  .image-with-caption,
  .quote,
  .facts-box {
    page-break-inside: avoid;
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .hero {
    background-attachment: scroll;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #C0392B;
    --text-dark: #000;
    --text-light: #222;
    --focus-outline: 3px solid #000;
  }
  
  .quote,
  .facts-box {
    border-left-width: 6px;
  }
  
  header {
    border-bottom: 2px solid #000;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-white: #1a1a1a;
    --bg-light: #2a2a2a;
    --text-dark: #e0e0e0;
    --text-light: #b0b0b0;
  }
  
  .hero::before {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(211, 84, 0, 0.5));
  }
  
  .quote {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
  }
  
  .image-with-caption figcaption {
    color: var(--text-light);
  }
  
  .facts-box {
    background: linear-gradient(135deg, #2a2a2a 0%, #252525 100%);
    border-left-color: var(--primary-light);
  }
  
  .quote .author-context {
    color: var(--text-light);
  }
}

/* Large Screen Support */
@media (min-width: 1920px) {
  html {
    font-size: 18px;
  }
  
  .container {
    max-width: 1400px;
  }
  
  .image-with-caption {
    max-width: 1100px;
  }
}

/* Touch Device Improvements */
@media (hover: none) and (pointer: coarse) {
  nav a,
  .hamburger {
    min-height: 44px;
    min-width: 44px;
  }
  
  nav.nav-menu a {
    padding: 20px 0;
  }
}