/* ==========================================================================
   Autumn Harvest — Main Stylesheet
   Lives in the theme's assets/ dir so Hugo can fingerprint it
   (cache-busting). Published as /css/main.<hash>.css via head.html.
   ========================================================================== */

:root {
  /* Palette — Autumn natural */
  --color-primary: #4a7c59;        /* Sage green */
  --color-primary-dark: #3a6346;
  --color-secondary: #c17c4f;      /* Terracotta */
  --color-accent: #d4a86b;         /* Warm amber */

  /* Background tones (light) */
  --color-bg: #fdfcf8;
  --color-bg-alt: #f4f1eb;
  --color-bg-overlay: rgba(253, 252, 248, 0.95);

  /* Text */
  --color-text: #2a2a2a;
  --color-text-muted: #5c5c5c;
  --color-text-light: #8c8c8c;
  --color-link: #4a7c59;
  --color-link-hover: #c17c4f;

  /* Borders & shadows */
  --color-border: #e4ded5;
  --color-shadow: rgba(0, 0, 0, 0.08);

  /* States */
  --color-focus: #4a7c59;
  --color-error: #b83b3b;
  --color-success: #4a7c59;

  /* Typography */
  --font-heading: 'Georgia', 'Cambria', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-size-base: 18px;
  --font-size-sm: 16px;
  --font-size-lg: 20px;
  --font-size-xl: 24px;
  --font-size-xxl: 32px;
  --font-size-xxxl: 40px;
  --line-height-tight: 1.2;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --spacing-xxl: 4rem;

  /* Layout */
  --container-max: 680px;
  --container-wide: 1120px;
  --sidebar-width: 290px;
  --nav-height: 64px;
  --touch-target: 48px;
}

/* ==========================================================================
   Theme modes (classes applied to <html> by theme-toggle.js)
   ========================================================================== */

.dark-mode {
  --color-bg: #1a1c18;
  --color-bg-alt: #232621;
  --color-bg-overlay: rgba(26, 28, 24, 0.95);
  --color-text: #ecece4;
  --color-text-muted: #a8a898;
  --color-text-light: #7c7c6c;
  --color-border: #3a3f35;
  --color-shadow: rgba(0, 0, 0, 0.3);
  --color-link: #8cb394;
  --color-link-hover: #e0a074;
  --color-focus: #8cb394;
}

.light-mode {
  --color-bg: #fdfcf8;
  --color-bg-alt: #f4f1eb;
  --color-bg-overlay: rgba(253, 252, 248, 0.95);
  --color-text: #2a2a2a;
  --color-text-muted: #5c5c5c;
  --color-text-light: #8c8c8c;
  --color-border: #e4ded5;
  --color-shadow: rgba(0, 0, 0, 0.08);
  --color-link: #4a7c59;
  --color-link-hover: #c17c4f;
  --color-focus: #4a7c59;
}

/* High contrast: same palette, maxed-out contrast + visible outlines */
.high-contrast {
  --color-primary: #14532d;
  --color-primary-dark: #0f3d20;
  --color-secondary: #8a2d04;
  --color-bg: #ffffff;
  --color-bg-alt: #f0f0f0;
  --color-text: #000000;
  --color-text-muted: #1a1a1a;
  --color-text-light: #333333;
  --color-border: #000000;
  --color-link: #0b4fa2;
  --color-link-hover: #8a2d04;
  --color-focus: #000000;
  --color-shadow: rgba(0, 0, 0, 0.25);
}

.dark-mode.high-contrast {
  --color-primary: #7ee2a8;
  --color-primary-dark: #5ccc8d;
  --color-secondary: #ffb37e;
  --color-bg: #000000;
  --color-bg-alt: #111111;
  --color-text: #ffffff;
  --color-text-muted: #eaeaea;
  --color-text-light: #cccccc;
  --color-border: #ffffff;
  --color-link: #8fd3ff;
  --color-link-hover: #ffb37e;
  --color-focus: #ffffff;
}

/* High-contrast element reinforcement */
.high-contrast a { text-decoration: underline; text-decoration-thickness: 2px; }
.high-contrast .recipe-card,
.high-contrast .blog-card,
.high-contrast .ingredients-panel,
.high-contrast .info-sidebar { border-width: 2px; }
.high-contrast .meta-item,
.high-contrast .recipe-card-more,
.high-contrast .read-more,
.high-contrast .made-this-button { outline: 2px solid #000; }
.dark-mode.high-contrast .meta-item,
.dark-mode.high-contrast .recipe-card-more,
.dark-mode.high-contrast .read-more,
.dark-mode.high-contrast .made-this-button { outline-color: #fff; }

/* ==========================================================================
   Base
   ========================================================================== */

* { box-sizing: border-box; }

html { font-size: var(--font-size-base); }

body {
  margin: 0;
  padding: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: var(--font-body);
  line-height: var(--line-height-normal);
  transition: background-color 0.2s ease, color 0.2s ease;
}

img { max-width: 100%; height: auto; }

/* Visually hidden (screen readers only) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link: completely hidden until keyboard-focused */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 8px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  background: var(--color-primary);
  color: #fff;
  z-index: 100;
}

.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Focus visibility (keyboard only) */
:focus:not(:focus-visible) { outline: none; }

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

/* Homepage recipe banners (Featured + Latest may be stacked) */
.home-recipe-banner {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* When two banners are stacked, pull the second one closer to the first */
.home-recipe-banner + .home-recipe-banner {
  margin-top: calc(var(--spacing-sm) - var(--spacing-lg));
}

.banner-thumb {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
}

.banner-text {
  flex: 1;
  min-width: 0;
}

.banner-btn {
  flex-shrink: 0;
  display: inline-block;
  padding: 10px 18px;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: var(--font-size-sm);
  transition: background 0.2s ease;
}

.banner-btn:hover { background: var(--color-primary-dark); }

/* Small screens: drop the thumb so text + button fit */
@media (max-width: 480px) {
  .banner-thumb { display: none; }
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: var(--line-height-tight);
  margin: 0 0 var(--spacing-sm);
  color: var(--color-text);
}

h1 { font-size: var(--font-size-xxxl); }
h2 { font-size: var(--font-size-xxl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p { margin: 0 0 var(--spacing-md); }

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-link-hover);
  text-decoration-thickness: 2px;
}

.intro {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-lg);
}

/* ==========================================================================
   Layout container — two-column grid when a sidebar is present
   ========================================================================== */

.container {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-md);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  gap: var(--spacing-lg);
  align-items: start;
}

/* Pages without a sidebar (home, blog, about, privacy) stay single-column */
.container:not(:has(> .sidebar)) {
  display: block;
  max-width: var(--container-max);
}

.main-content { order: 1; min-width: 0; }
.sidebar { order: 2; }

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
  position: sticky;
  top: 0;
  height: var(--nav-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--spacing-md);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: 700;
  text-decoration: none;
  color: var(--color-text);
}

.navbar-logo img { height: 56px; width: auto; }

.logo-byline {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Mobile nav (hidden until hamburger .active) */
.navbar-nav {
  display: none;
  flex-direction: column;
  position: absolute;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: var(--spacing-sm);
}

.navbar-nav.active { display: flex; }

.navbar-nav a {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  min-height: var(--touch-target);
  line-height: 1.4;
}

.hamburger {
  display: block;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--spacing-xs);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border-radius: 6px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  margin: 5px 0;
  transition: 0.3s;
}

.hamburger:hover span,
.hamburger:focus-visible span { background: var(--color-primary); }

/* Desktop nav: horizontal, no hamburger */
@media (min-width: 769px) {
  .hamburger { display: none; }

  .navbar-nav {
    display: flex;
    flex-direction: row;
    position: static;
    background: none;
    border: none;
    padding: 0;
    gap: var(--spacing-md);
  }

  .navbar-nav a {
    display: inline;
    padding: 0;
    min-height: 0;
    line-height: inherit;
    min-width: 0;
  }
}

/* ==========================================================================
   Shared card components (used by blog cards AND recipe cards)
   ========================================================================== */

/* Common outer grid for both card types */
.card-list {
  display: grid;
  gap: var(--spacing-md);
}

.blog-card,
.recipe-card {
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-alt);
  transition: box-shadow 0.2s ease;
}

.blog-card:hover,
.recipe-card:hover { box-shadow: 0 4px 12px var(--color-shadow); }

.card-thumbnail {
  margin: 0 0 var(--spacing-sm);
  overflow: hidden;
  border-radius: 6px;
}

.card-thumbnail img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
}

.card-title {
  margin-bottom: var(--spacing-xs);
  font-size: var(--font-size-xl);
  line-height: 1.3;
}

.card-title a { color: inherit; }
.card-title a:hover { color: var(--color-primary); text-decoration: none; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.card-excerpt {
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

/* Generic action button ("Read Story" / "View Recipe") */
.card-action {
  display: inline-block;
  padding: 12px 24px;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  min-height: var(--touch-target);
  transition: background 0.2s ease;
}

.card-action:hover {
  background: var(--color-primary-dark);
  color: #fff;
  text-decoration: none;
}

/* Legacy aliases so old templates keep working unchanged */
.blog-list, .recipe-list { display: grid; gap: var(--spacing-md); }
.blog-card-title, .recipe-card-title { margin-bottom: var(--spacing-xs); font-size: var(--font-size-xl); line-height: 1.3; }
.blog-card-meta, .recipe-card-meta { display: flex; flex-wrap: wrap; gap: var(--spacing-xs) var(--spacing-sm); font-size: var(--font-size-sm); color: var(--color-text-muted); margin-bottom: var(--spacing-sm); }
.blog-card-excerpt, .recipe-card-excerpt { color: var(--color-text); margin-bottom: var(--spacing-sm); }
.read-more, .recipe-card-more {
  display: inline-block;
  padding: 12px 24px;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  min-height: var(--touch-target);
  transition: background 0.2s ease;
}
.read-more:hover, .recipe-card-more:hover {
  background: var(--color-primary-dark);
  color: #fff;
  text-decoration: none;
}
.blog-thumbnail, .recipe-thumbnail { margin: 0 0 var(--spacing-sm); overflow: hidden; border-radius: 6px; }
.blog-thumbnail img, .recipe-thumbnail img { width: 100%; max-height: 260px; object-fit: cover; display: block; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.pagination a {
  padding: 12px 20px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
}

.pagination a:hover {
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
}

/* Tag chips (shown on cards and single pages) */
.tag {
  background: var(--color-bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--color-border);
  text-decoration: none;
}

.tag:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ==========================================================================
   Single blog post
   ========================================================================== */

.blog-post { margin-bottom: var(--spacing-xl); }

.blog-post header { margin-bottom: var(--spacing-lg); }

.blog-content { line-height: var(--line-height-relaxed); }

.blog-content img {
  max-width: 100%;
  height: auto;
  margin: var(--spacing-md) 0;
  border-radius: 8px;
}

.blog-post .tags { display: flex; flex-wrap: wrap; gap: var(--spacing-xs); margin-top: var(--spacing-sm); }

/* Embedded recipe (shortcode inside blog posts) */
.embedded-recipe {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
}

.embedded-recipe h4 { margin-top: 0; }

.view-full-recipe { font-weight: 600; }

.embedded-recipe .error { color: var(--color-error); }

/* ==========================================================================
   Single recipe page
   ========================================================================== */

.recipe-page { margin-bottom: var(--spacing-xl); }

.hero-image {
  margin: 0 0 var(--spacing-lg);
  overflow: hidden;
  border-radius: 8px;
}

.hero-image img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

.recipe-header { margin-bottom: var(--spacing-lg); }

.recipe-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  margin: 0 0 var(--spacing-sm);
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.recipe-meta .meta-item {
  padding: 6px 12px;
  background: var(--color-bg-alt);
  border-radius: 4px;
}

.recipe-content { line-height: var(--line-height-relaxed); }

/* Recipe details grid: ingredients + info sidebar */
.recipe-details { margin: var(--spacing-lg) 0; }

.details-grid {
  display: grid;
  gap: var(--spacing-lg);
  grid-template-columns: 1fr;
}

.ingredients-panel {
  padding: var(--spacing-md);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.ingredients-panel h2,
.ingredients-panel h3 { margin-top: 0; }

.ingredients-panel ul { padding-left: var(--spacing-md); }
.ingredients-panel li { padding: var(--spacing-xs) 0; }

.info-sidebar {
  background: var(--color-bg-alt);
  padding: var(--spacing-md);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.nutrition-card,
.tips-card,
.alternatives-card,
.protein-card {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px dashed var(--color-border);
}

.nutrition-card:last-child,
.tips-card:last-child,
.alternatives-card:last-child,
.protein-card:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.nutrition-card h3,
.tips-card h3,
.alternatives-card h3,
.protein-card h3 { margin-bottom: var(--spacing-sm); }

.nutrition-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--spacing-xs);
  margin: 0;
}

.nutrition-card dt { font-weight: 600; color: var(--color-text-muted); }
.nutrition-card dd { margin: 0; text-align: right; }

.tips-card ul,
.alternatives-card ul {
  margin: 0;
  padding-left: var(--spacing-md);
}

.tips-card li,
.alternatives-card li { margin-bottom: var(--spacing-xs); }

/* Numbered method steps */
.method-steps {
  counter-reset: step-counter;
  list-style: none;
  padding: 0;
}

.method-steps li {
  position: relative;
  padding-left: calc(var(--spacing-xl) + 12px);
  margin-bottom: var(--spacing-md);
  counter-increment: step-counter;
  line-height: var(--line-height-relaxed);
}

.method-steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 2px;
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
}

/* ==========================================================================
   Rating / "I made this" / personal notes (recipes only)
   ========================================================================== */

.rating-section {
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.rating-stars {
  display: flex;
  gap: var(--spacing-xs);
  justify-content: center;
  margin-bottom: var(--spacing-sm);
}

.rating-stars button {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  color: var(--color-border);
  transition: color 0.2s;
}

.rating-stars button:hover,
.rating-stars button.filled,
.rating-stars button.hover-fill { color: var(--color-secondary); }

.made-this-button {
  background: var(--color-primary);
  color: #fff;
  padding: 12px var(--spacing-lg);
  border: none;
  border-radius: 6px;
  font-size: var(--font-size-base);
  font-family: var(--font-body);
  min-height: var(--touch-target);
  cursor: pointer;
  transition: background 0.2s;
}

.made-this-button:hover { background: var(--color-primary-dark); }

.notes-wrapper {
  max-width: 560px;
  margin: var(--spacing-lg) auto 0;
  text-align: left;
}

.notes-wrapper label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.personal-notes {
  width: 100%;
  padding: var(--spacing-sm);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  resize: vertical;
}

.personal-notes:focus {
  outline: 3px solid var(--color-focus);
  outline-offset: 1px;
}

.notes-local-note {
  margin-top: var(--spacing-xs);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.notes-hint { color: var(--color-success); font-weight: 600; }

/* ==========================================================================
   Related & share
   ========================================================================== */

.related-recipes,
.social-share {
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

.related-recipes ul { padding-left: var(--spacing-md); }
.related-recipes li { margin-bottom: var(--spacing-xs); }

.share-buttons {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.share-buttons a {
  padding: 10px 16px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
}

.share-buttons a:hover {
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  padding: 0;
  position: sticky;
  top: calc(var(--nav-height) + var(--spacing-sm));
  align-self: start;
  min-width: 0;
}

.sidebar-section { margin-bottom: var(--spacing-lg); }

.sidebar-section h3 {
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-lg);
}

.sidebar-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-section li { margin-bottom: var(--spacing-xs); }

/* ==========================================================================
   Archives
   ========================================================================== */

.archive-month { margin-bottom: var(--spacing-lg); }

.archive-month h2 {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
}

.archive-list { list-style: none; padding: 0; margin: 0; }

.archive-list li {
  padding: var(--spacing-xs) 0;
  border-bottom: 1px dashed var(--color-border);
}

.archive-list time { color: var(--color-text-light); font-size: var(--font-size-sm); }

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  text-align: center;
  padding: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
  margin-top: var(--spacing-xl);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.footer-social {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 50%;
  background: var(--color-bg-alt);
  color: var(--color-text);
  text-decoration: none;
}

.footer-social a:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ==========================================================================
   Floating elements: back-to-top + theme toggles
   ========================================================================== */

.back-to-top {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: var(--color-primary);
  color: #fff;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 40;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  color: #fff;
  transform: translateY(-4px);
}

.theme-toggle,
.contrast-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
  z-index: 50;
  font-size: 20px;
  color: #fff;
}

.contrast-toggle {
  right: calc(var(--touch-target) + 32px);
  background: var(--color-secondary);
}

.theme-toggle:hover,
.contrast-toggle:hover {
  transform: translateY(-2px);
}

/* ===== Sticky footer (short pages: privacy, about, search) ===== */
/* body becomes a full-height column; footer is pushed to the
   bottom with margin-top:auto while long pages simply fill
   and scroll naturally. Everything else in body (navbar,
   container, floating toggles) is unaffected apart from
   becoming flex items, which behave identically for blocks. */
html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.footer {
  margin-top: auto;
}

/* Matomo opt-out box */
#matomo-opt-out {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  padding: var(--spacing-md) var(--spacing-lg);
  margin: var(--spacing-lg) 0;
}
#matomo-opt-out p { margin-bottom: var(--spacing-sm); }
#matomo-opt-out label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  cursor: pointer;
  font-weight: 600;
}

/* ==========================================================================
   Responsive breakpoints
   ========================================================================== */

/* Tablet: 2-column recipe details */
@media (min-width: 481px) and (max-width: 768px) {
  .details-grid { grid-template-columns: 1fr 1fr; }
  .hero-image img { max-height: 320px; }
}

/* Desktop: side-by-side recipe details */
@media (min-width: 769px) {
  .details-grid { grid-template-columns: 1fr 350px; }
  .hero-image img { max-height: 380px; }
}

/* Large screens */
@media (min-width: 1400px) {
  .container { max-width: 1240px; }
  .details-grid { grid-template-columns: 1fr 330px; }
}

/* Narrow screens: stack sidebar below content */
@media (max-width: 999px) {
  .container {
    grid-template-columns: 1fr;
    max-width: var(--container-max);
  }
  .sidebar {
    position: static;
    order: 2;
    padding: 0;
  }
  .main-content { order: 1; }
}

/* ==========================================================================
   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;
  }
}