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

.wheat {
  width: 20px;
  vertical-align: -8px;
  margin-left: -3px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--primary-color, #00737d);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 600;
  z-index: 1000;
  border-radius: 0 0 4px 0;
}

.skip-link:focus,
.skip-link:focus-visible {
  left: 0;
  top: 0;
}

:root {
  --primary-color: #00737d;
  --primary-light: #eee;
  --secondary-color: #ff6b35;
  --text-dark: #2f333b;
  --text-light: #666;
  --bg-light: #f8f9fa;
  --border-color: #e0e0e0;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-dark);
  background-color: var(--bg-light);
}

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

/* Navigation */
.navbar {
  background-color: var(--white);
  box-shadow: var(--shadow);
  padding: 0.75rem 0 1rem 0;
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  padding-right: 0;
}

.nav-brand {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 1.75rem;
  font-weight: normal;
  letter-spacing: 0.5px;
  color: var(--text-dark);
  text-align: center;
  text-decoration: none;
  transition: color 0.3s;
}

.nav-brand:hover {
  color: var(--primary-color);
}

/* Filters */
.filters {
  background: var(--white);
  padding: 1.5rem;
  border-radius: 12px;
  /* box-shadow: var(--shadow); */
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: border-color 0.3s;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.3s;
  text-transform: lowercase;
  color: var(--text-light);
}

.filter-btn:hover,
.filter-btn:focus-visible {
  outline: none;
  background: var(--bg-light);
  border-color: var(--primary-color);
  color: var(--text-dark);
}

.filter-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--white);
}

/* Recipe Grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}

.recipe-card {
  background: var(--white);
  border-radius: 8px;
  overflow: hidden;
  /* box-shadow: var(--shadow); */
  border: 1px solid var(--border-color);
  transition: outline 0s;
  display: flex;
  flex-direction: column;
}

.recipe-card:hover {
  outline: 1px solid var(--primary-color);
  outline-offset: -2px;
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: 12px;
  outline: none;
}

.recipe-card:has(.card-link:focus-visible) {
  outline: 1px solid var(--primary-color);
  outline-offset: -2px;
}

.card-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.no-image {
  color: var(--text-light);
  font-style: italic;
}

.card-content {
  padding: 0.875rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-content h2 {
  font-size: 1.125rem;
  margin-bottom: 0.375rem;
  color: var(--primary-color);
  line-height: 1.3;
}

.card-description {
  color: var(--text-light);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.category {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  background: var(--primary-light);
  color: var(--text-dark);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
  font-size: 1.125rem;
}

/* Recipe Detail Page */
.recipe-detail {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  margin-bottom: 3rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.recipe-header {
  margin-bottom: 2rem;
}

.recipe-header h1 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.print-controls {
  display: flex;
  gap: 0.5rem;
  margin-right: 60px; /* Space for hamburger menu */
}

.print-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.print-btn:hover {
  background: var(--primary-color);
  color: var(--white);
}

.print-btn svg {
  flex-shrink: 0;
}

.print-btn-text {
  display: inline;
}

.print-btn-card {
  background: transparent;
}

.print-btn-card:hover {
  background: var(--secondary-color);
  border-color: var(--secondary-color);
  color: var(--white);
}

.description {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.recipe-image {
  margin-bottom: 2rem;
  border-radius: 12px;
  overflow: hidden;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.recipe-image img {
  width: 100%;
  height: auto;
  display: block;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 1.5rem;
  background: var(--bg-light);
  border-radius: 8px;
  margin-bottom: 2rem;
}

.meta-item {
  font-size: 0.9375rem;
}

.meta-item strong {
  color: var(--primary-color);
  margin-right: 0.5rem;
}

.recipe-section {
  margin-bottom: 2.5rem;
}

.recipe-section h2 {
  font-size: 1.75rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-color);
}

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

.ingredient-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  width: 100%;
}

.ingredient-checkbox input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 0.75rem;
  accent-color: var(--primary-color);
}

.ingredient-checkbox input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  color: var(--text-light);
  opacity: 0.7;
}

.ingredient-checkbox span {
  flex: 1;
  transition: all 0.3s;
}

/* Regular unordered lists (but not ingredients) */
.recipe-section ul:not(.ingredients-list) {
  list-style: disc;
  padding-left: 2rem;
  margin-bottom: 1rem;
}

.recipe-section ul:not(.ingredients-list) li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* Ingredients list */
.ingredients-list {
  list-style: none;
  padding: 0;
}

/* Numbered instruction lists */
.instructions-list {
  list-style: none;
  counter-reset: step-counter;
  padding: 0;
}

.instructions-list li {
  counter-increment: step-counter;
  margin-bottom: 1.5rem;
  padding-left: 3rem;
  position: relative;
}

.instructions-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  background: var(--primary-color);
  color: var(--white);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.instructions-list li p {
  margin: 0;
  line-height: 1.6;
}

.notes {
  background: #fffbea;
  padding: 1.5rem;
  border-radius: 8px;
  border-left: 4px solid var(--secondary-color);
}

.notes h2 {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark);
}

.notes p {
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.notes p:last-child {
  margin-bottom: 0;
}

.recipe-footer {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border-color);
  color: var(--text-light);
}

.recipe-footer p {
  margin-bottom: 0.5rem;
}

.recipe-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.recipe-footer a:hover {
  text-decoration: underline;
}

/* General focus styles for better keyboard navigation */
button:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* Text inputs get a special focus style (border instead of outline) */
input[type="text"]:focus-visible,
input[type="search"]:focus-visible,
.search-input:focus-visible {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 115, 125, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
  .recipe-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }

  .recipe-detail {
    padding: 1.5rem;
  }

  .recipe-header h1 {
    font-size: 2rem;
  }

  .recipe-meta {
    gap: 1rem;
  }

  .filter-btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
  }

  .print-btn-text {
    display: none;
  }

  .print-btn {
    padding: 0.5rem 0.75rem;
  }

  .print-controls {
    gap: 0.375rem;
  }
}

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

  .navbar {
    padding: 0.75rem 0;
  }

  .nav-brand {
    font-size: 1.25rem;
  }

  .filters {
    padding: 1rem;
  }

  .recipe-detail {
    padding: 1rem;
  }

  .recipe-header h1 {
    font-size: 1.75rem;
  }

  .instructions-list li {
    padding-left: 2.5rem;
  }

  .instructions-list li::before {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.875rem;
  }
}

/* Hamburger Menu */
#hamburgerMenu {
  position: fixed;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 20px;
  cursor: default;
}

.hamburger-icon {
  width: 30px;
  height: 25px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 201;
}

.hamburger-icon span {
  display: block;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger-dropdown {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100vh;
  background-color: var(--white);
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
  transition: right 0.3s ease;
  z-index: 199;
  padding-top: 80px;
  overflow-y: auto;
}

.hamburger-dropdown .menu {
  position: relative;
  display: block;
  height: auto;
  font-family: sans-serif;
  font-weight: normal;
  white-space: nowrap;
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
  padding: 15px 20px;
}

.hamburger-dropdown .menu:last-child {
  border-bottom: 0;
}

.hamburger-dropdown .menu a {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--text-dark);
  font-size: 16px;
  text-decoration: none;
  margin: 0;
  padding: 0;
}

.hamburger-dropdown .menu:hover {
  background-color: var(--primary-light);
  cursor: pointer;
}

/* Show dropdown when toggled */
#hamburgerMenu.active .hamburger-dropdown {
  right: 0;
}

/* Animate hamburger icon when active */
#hamburgerMenu.active .hamburger-icon span:nth-child(1) {
  transform: translateY(11px) rotate(45deg);
}

#hamburgerMenu.active .hamburger-icon span:nth-child(2) {
  opacity: 0;
}

#hamburgerMenu.active .hamburger-icon span:nth-child(3) {
  transform: translateY(-11px) rotate(-45deg);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #006064;
    --text-dark: #000000;
    --text-light: #333333;
    --border-color: #eaeaea;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.4);
  }

  .recipe-card {
    border: 2px solid var(--border-color);
  }

  .filter-btn {
    border: 2px solid var(--border-color);
  }

  .filter-btn.active {
    border: 3px solid var(--primary-color);
    font-weight: 700;
  }

  button:focus-visible,
  input:focus-visible {
    outline: 4px solid var(--primary-color);
    outline-offset: 3px;
  }

  .category {
    border: 1px solid var(--text-dark);
  }
}

/* Print Styles */
@media print {
  /* Hide non-essential elements */
  .navbar,
  .filters,
  .print-btn,
  .skip-link,
  .categories,
  #hamburgerMenu {
    display: none !important;
  }

  /* Reset page styles */
  body {
    background: white;
  }

  .recipe-detail {
    box-shadow: none;
    padding: 0;
    max-width: 100%;
  }

  .recipe-card {
    break-inside: avoid;
  }

  /* Make recipe title more prominent */
  .recipe-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: black;
  }

  /* Enhance recipe meta for print */
  .recipe-meta {
    background: #f5f5f5;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .recipe-meta strong {
    color: black;
  }

  /* Optimize images for print */
  .recipe-image {
    max-width: 300px;
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
  }

  /* Section headings */
  .recipe-section h2 {
    color: black;
    border-bottom: 2px solid #333;
    padding-bottom: 0.25rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    page-break-after: avoid;
  }

  /* Ingredients list */
  .ingredients-list {
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
  }

  .ingredients-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #ddd;
  }

  /* Print checkboxes as empty boxes */
  .ingredient-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid #333;
    background: white;
    flex-shrink: 0;
  }

  .ingredient-checkbox input[type="checkbox"]:checked {
    background: white;
  }

  .ingredient-checkbox input[type="checkbox"]:checked + span {
    text-decoration: none;
    color: black;
    opacity: 1;
  }

  /* Instructions */
  .instructions-list li {
    page-break-inside: avoid;
    margin-bottom: 1rem;
  }

  .instructions-list li::before {
    background: #333;
    color: white;
  }

  /* Notes section */
  .notes {
    background: #f9f9f9;
    border-left: 4px solid #666;
    page-break-inside: avoid;
  }

  .notes h2 {
    color: black;
  }

  /* Footer */
  .recipe-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #ccc;
    font-size: 0.9rem;
    page-break-inside: avoid;
  }

  /* Ensure good link visibility in print */
  a {
    color: black;
    text-decoration: underline;
  }

  /* Categories */
  .category {
    background: #e0e0e0;
    color: black;
    border: 1px solid #999;
  }
}

/* Recipe Card Print Mode - activated when body has .print-card-mode class */
/* Note: @page size will be injected via JavaScript when card mode is active */
@media print {
  body.print-card-mode {
    font-size: 8pt;
    line-height: 1.2;
  }

  /* Hide elements not needed on card */
  body.print-card-mode .recipe-image,
  body.print-card-mode .description,
  body.print-card-mode .notes,
  body.print-card-mode .categories {
    display: none !important;
  }

  body.print-card-mode .recipe-detail {
    padding: 0 !important;
    margin: 0 !important;
  }

  body.print-card-mode .container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }

  /* Card front - title and ingredients */
  body.print-card-mode .recipe-header {
    margin-bottom: 0.05in !important;
  }

  body.print-card-mode .recipe-header h1 {
    font-size: 12pt !important;
    font-weight: bold !important;
    margin: 0 0 0.04in 0 !important;
    border-bottom: 1pt solid black !important;
    padding-bottom: 0.02in !important;
    line-height: 1.1 !important;
    color: black !important;
  }

  body.print-card-mode .recipe-meta {
    padding: 0 !important;
    margin: 0.04in 0 !important;
    background: none !important;
    border: none !important;
    font-size: 7pt !important;
    gap: 0.08in !important;
  }

  body.print-card-mode .recipe-meta .meta-item {
    font-size: 7pt !important;
  }

  body.print-card-mode .recipe-meta strong {
    font-weight: normal !important;
  }

  body.print-card-mode .recipe-section {
    margin-bottom: 0.05in !important;
  }

  body.print-card-mode .recipe-section h2 {
    font-size: 10pt !important;
    font-weight: bold !important;
    border-bottom: 1pt solid black !important;
    padding-bottom: 0.02in !important;
    margin: 0 0 0.04in 0 !important;
    color: black !important;
  }

  body.print-card-mode .ingredients-list {
    margin: 0 !important;
    padding: 0 !important;
  }

  body.print-card-mode .ingredients-list li {
    padding: 0.02in 0 !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
    border-bottom: none !important;
  }

  body.print-card-mode .ingredient-checkbox {
    margin-bottom: 0 !important;
  }

  body.print-card-mode .ingredient-checkbox input[type="checkbox"] {
    width: 0.11in !important;
    height: 0.11in !important;
    border: 1pt solid black !important;
    margin-right: 0.06in !important;
    margin-top: 0.01in !important;
  }

  /* Card back - instructions (force to new page) */
  body.print-card-mode .recipe-section:has(#instructions-heading) {
    page-break-before: always !important;
    margin-top: 0 !important;
  }

  /* Plain numbered list - no fancy circles, COMPACT */
  body.print-card-mode .instructions-list {
    list-style: decimal !important;
    counter-reset: none !important;
    padding-left: 0.15in !important;
    margin: 0 !important;
  }

  body.print-card-mode .instructions-list li {
    margin-bottom: 0.03in !important;
    padding-left: 0 !important;
    font-size: 7pt !important;
    line-height: 1.15 !important;
    position: static !important;
  }

  body.print-card-mode .instructions-list li::before {
    display: none !important;
  }

  body.print-card-mode .instructions-list li p {
    margin: 0 !important;
    display: inline !important;
  }

  /* Footer on back of card - minimal */
  body.print-card-mode .recipe-footer {
    margin-top: 0.06in !important;
    padding-top: 0.03in !important;
    border-top: 0.5pt solid #999 !important;
    font-size: 5pt !important;
  }

  body.print-card-mode .recipe-footer p {
    margin-bottom: 0.01in !important;
    line-height: 1.1 !important;
  }

  body.print-card-mode .recipe-footer strong {
    font-weight: normal !important;
  }
}
