/* Pirates Pantry Foundation Dark Theme - 23-Color Pirate Palette */

/* Standardized 23-Color Pirate Theme Palette */
:root {
  /* Primary Palette */
  --color-pirate-black: #2D2D2D;
  --color-pirate-cream: #F5F1E8;
  --color-pirate-gold: #D4A574;
  --color-pirate-gold-dark: #B8956A;
  --color-pirate-brown: #8B4513;

  /* Nautical Palette */
  --color-ocean-deep: #2E4057;
  --color-ocean-blue: #3B6B8C;
  --color-weathered-teal: #5B8A8A;
  --color-sea-foam: #7A9B9B;
  --color-storm-gray: #4A5568;
  --color-barnacle-blue: #34495E;

  /* Dark Theme */
  --color-bg-dark: #13171F;
  --color-bg-card: #181C25;
  --color-bg-input: #1C212C;
  --color-bg-focused: #2A3242;
  --color-bg-accent: #1A1F28;
  --color-bg-component: #1F242F;
  --color-text-light: #C2C7D0;
  --color-text-muted-dark: #7B8495;
  --color-text-accent-dark: #B8C7D0;
  --color-border-dark: #4A5568;

  /* Utility */
  --color-white: #FFFFFF;
  --color-medium-gray: #6C757D;

  /* Typography */
  --font-display: 'Trade Winds', cursive;
  --font-content: 'Lora', serif;
  --font-ui: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Global Dark Theme Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--color-bg-dark);
  overflow-x: hidden;
}

body {
  background-color: var(--color-bg-dark);
  color: var(--color-text-light);
  font-family: var(--font-content);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-ocean-blue);
  font-family: var(--font-content);
}

h2 {
  color: var(--color-ocean-deep);
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.25px;
}

/* Foundation Override - Global Container */
.grid-container {
  background-color: transparent;
}

/* Header Styling */
header {
  background-color: transparent;
  padding: 1rem 0;
  margin-bottom: 1rem;
}

header .grid-x {
  max-width: 75rem;
  margin: 0 auto;
  
}

header .grid-x:last-child {
  border-bottom: 1px solid var(--color-weathered-teal);
}

header h1 {
  margin: 0;
  display: flex;
  align-items: center;
}

header p {
  font-style: italic;
  font-size: 1.5rem;
  color: var(--color-weathered-teal);
  margin: 0;
  text-shadow: 0 1px 2px rgba(91, 138, 138, 0.3);
  letter-spacing: 0.25px;
  text-align: center;
}

header h1.title-text {
    font-family: var(--font-display);
    font-size: 5.625rem;
    color: var(--color-pirate-cream);
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(212, 165, 116, 0.3);
}

/* Music Control - Fixed Position */
.music-control-fixed {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  background-color: var(--color-ocean-blue);
  color: var(--color-pirate-cream);
  border: 2px solid var(--color-weathered-teal);
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.3s ease;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.music-control-fixed:hover,
.music-control-fixed:focus {
  background-color: var(--color-pirate-gold);
  color: var(--color-pirate-black);
  border-color: var(--color-pirate-gold-dark);
  transform: translateY(-2px);
}

.music-control-fixed.muted {
  opacity: 0.6;
  border-color: var(--color-sea-foam);
  color: var(--color-sea-foam);
}

/* Foundation Override - Search Input */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 0.85rem;
  color: var(--color-text-muted-dark);
  font-size: 1.1rem;
  z-index: 2;
  pointer-events: none;
}

input[type="search"] {
  background-color: var(--color-bg-input);
  color: var(--color-text-light);
  border: 1px solid var(--color-weathered-teal);
  font-family: var(--font-content);
  padding: 1rem 1rem 1rem 3rem;
  font-size: 1.1rem;
  height: 3.2rem;
  width: 100%;
}

input[type="search"]:focus {
  border-color: var(--color-weathered-teal);
  box-shadow: 0 0 0 1px var(--color-weathered-teal);
  background-color: var(--color-bg-input);
  color: var(--color-text-light);
}

input[type="search"]::placeholder {
  color: var(--color-text-muted-dark);
}

/* Foundation Override - Buttons */
.button {
  background-color: var(--color-storm-gray);
  color: var(--color-pirate-cream);
  border: 1px solid var(--color-weathered-teal);
  font-family: var(--font-ui);
  font-weight: 500;
  transition: all 0.2s ease;
}

.button:hover,
.button:focus {
  background-color: var(--color-weathered-teal);
  color: var(--color-pirate-cream);
  border-color: var(--color-weathered-teal);
}

.button:active {
  background-color: var(--color-ocean-deep);
}

.button.current-scale {
  background-color: var(--color-pirate-gold);
  color: var(--color-pirate-black);
  font-weight: 600;
  border-color: var(--color-pirate-gold-dark);
}

.button.alert {
  background-color: var(--color-storm-gray);
  border-color: var(--color-weathered-teal);
  color: var(--color-pirate-cream);
}

.button.clear {
  color: var(--color-weathered-teal);
  border: none;
  background: transparent;
}

.button.clear:hover,
.button.clear:focus {
  color: var(--color-pirate-gold);
  background: transparent;
}

.button.expanded {
  background-color: var(--color-ocean-blue);
  color: var(--color-pirate-cream);
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.button.expanded:hover,
.button.expanded:focus {
  background-color: var(--color-ocean-deep);
}

/* Foundation Override - Callouts */
.callout {
  background-color: var(--color-bg-card);
  border-left: 4px solid var(--color-weathered-teal);
  color: var(--color-text-light);
  border-radius: 4px;
}

.callout.alert {
  background-color: var(--color-bg-accent);
  border-left-color: var(--color-pirate-brown);
  color: var(--color-text-light);
}

.callout.secondary {
  background-color: var(--color-bg-component);
  border-left-color: var(--color-storm-gray);
}

.callout.success {
  background-color: var(--color-bg-accent);
  border-left-color: var(--color-sea-foam);
}

/* Foundation Override - Labels (Tag Chips) */
.label {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 0.675rem;
}

.label.secondary {
  background-color: var(--color-storm-gray);
  color: var(--color-white);
}

/* Recipe Cards */
#recipe-grid .cell {
  margin-bottom: 1.5rem;
}

.recipe-card {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-dark);
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.recipe-card .card-section {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.recipe-tags {
  margin-top: auto;
}

.recipe-card:hover {
  border-color: var(--color-weathered-teal);
  box-shadow: 0 2px 8px rgba(91, 138, 138, 0.2);
}

.recipe-card h3 {
  color: var(--color-pirate-cream);
  font-family: var(--font-content);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.recipe-card h3:hover {
  color: var(--color-pirate-gold);
  transition: color 0.2s ease;
}

.recipe-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted-dark);
  margin-bottom: 1rem;
  font-family: var(--font-content);
  font-weight: 500;
}

.recipe-summary {
  font-size: 1.1rem;
  color: var(--color-text-accent-dark);
  font-style: italic;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-content);
}

.recipe-tags .label {
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.recipe-card:hover .recipe-tags .label {
  opacity: 1;
}

/* Foundation Accordion Override */
.accordion {
  background-color: transparent;
  border: none;
}

.accordion-title {
  background-color: var(--color-storm-gray);
  color: var(--color-pirate-cream);
  border: 1px solid var(--color-weathered-teal);
  font-family: var(--font-display);
  font-size: 1.1rem;
  padding: 1rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.accordion-title:hover,
.accordion-title:focus {
  background-color: var(--color-ocean-deep);
  color: var(--color-pirate-cream);
  text-decoration: none;
}

.accordion-content {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-weathered-teal);
  border-top: none;
  color: var(--color-text-light);
  padding: 0;
}

/* Filter Reset Button */
.filter-reset-container {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-dark);
}

/* Filter Fieldsets using Foundation styling */
.accordion-content fieldset {
  background-color: transparent;
  border: none;
  margin: 0 0 1.5rem 0;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-dark);
}

.accordion-content fieldset:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.accordion-content legend {
  font-family: var(--font-content);
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-ocean-blue);
  background-color: transparent;
  padding: 0 0 0.75rem 0;
  margin-bottom: 0.75rem;
  width: 100%;
  border-bottom: 1px solid var(--color-weathered-teal);
}

/* Foundation Button Group styling for filters */
.accordion-content .grid-x .cell {
  margin-bottom: 0.5rem;
}

.accordion-content label {
  background-color: var(--color-bg-component);
  border: 1px solid var(--color-border-dark);
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-family: var(--font-ui);
  padding: 0.75rem;
  margin: 0;
  border-radius: 4px;
  display: block;
  text-align: center;
  width: 100%;
  font-weight: 500;
}

.accordion-content label:hover {
  background-color: var(--color-weathered-teal);
  color: var(--color-pirate-cream);
  border-color: var(--color-sea-foam);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(91, 138, 138, 0.2);
}

.accordion-content input[type="checkbox"]:checked ~ label,
.accordion-content input[type="radio"]:checked ~ label {
  background-color: var(--color-ocean-blue);
  color: var(--color-pirate-cream);
  border-color: var(--color-ocean-deep);
  box-shadow: 0 2px 8px rgba(59, 107, 140, 0.3);
  font-weight: 600;
}

/* Hide radio buttons and checkboxes - labels act as buttons */
.accordion-content input[type="checkbox"],
.accordion-content input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Foundation input styling fixes for other inputs */
input[type="checkbox"]:not(.accordion-content input),
input[type="radio"]:not(.accordion-content input) {
  margin: 0;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

/* Active Filters Display */
.active-filters-display {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted-dark);
  font-family: var(--font-content);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.active-filters-display:empty {
  display: none;
}

.active-filters-display .filter-items-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-status-item {
  display: inline;
  color: var(--color-text-muted-dark);
  white-space: nowrap;
}

.clear-filters-link {
  background: none;
  border: none;
  color: var(--color-weathered-teal);
  font-size: 0.875rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-left: 0.75rem;
  transition: color 0.2s ease;
  font-family: var(--font-ui);
}

.clear-filters-link:hover,
.clear-filters-link:focus {
  color: var(--color-pirate-gold);
  text-decoration: none;
  background: transparent;
}

/* Foundation Override - Reveal (Modal) */
.reveal {
  background-color: var(--color-bg-card);
  color: var(--color-text-light);
  border: 1px solid var(--color-border-dark);
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  position: relative;
  margin: 2rem auto !important;
  top: 2rem !important;
}

/* Custom scrollbar for modal to match dark theme */
.reveal::-webkit-scrollbar {
  width: 12px;
}

.reveal::-webkit-scrollbar-track {
  background: var(--color-bg-dark);
  border-radius: 6px;
}

.reveal::-webkit-scrollbar-thumb {
  background: var(--color-border-dark);
  border-radius: 6px;
  border: 2px solid var(--color-bg-dark);
}

.reveal::-webkit-scrollbar-thumb:hover {
  background: var(--color-weathered-teal);
}

/* Firefox scrollbar styling */
.reveal {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-dark) var(--color-bg-dark);
}

/* Prevent scroll jumping when modal opens - handled by JavaScript */

.reveal.large {
  width: 100%;
  max-width: 750px !important;
}

.reveal .close-button {
  color: var(--color-text-muted-dark);
  font-size: 2rem;
  position: fixed;
  z-index: 1001;
  background-color: var(--color-bg-card);
  border: 2px solid var(--color-border-dark);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

.reveal .close-button:hover,
.reveal .close-button:focus {
  color: var(--color-weathered-teal);
  background-color: var(--color-bg-focused);
  transform: scale(1.1);
}

/* Recipe Modal Styling */
.recipe-title {
  color: var(--color-pirate-cream);
  font-family: var(--font-display);
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-align: center;
  padding-right: 4rem;
  padding-left: 1rem;
  line-height: 1.2;
  word-wrap: break-word;
  hyphens: auto;
}

.recipe-tags-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.recipe-meta-callout {
  background-color: var(--color-bg-accent);
  border: none;
}

.scaling-controls-callout {
  background-color: var(--color-bg-component);
  border: none;
}

/* Enhanced Scaling Callout */
.scaling-callout {
  background-color: var(--color-bg-component);
  border: none;
  padding: 1.5rem;
}

.scaling-header {
  margin-bottom: 1.25rem;
}

.scaling-header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.scaling-header h6 {
  color: var(--color-pirate-cream);
  font-family: var(--font-content);
  font-weight: 600;
  margin: 0;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.scaling-header h6 i {
  color: var(--color-pirate-gold);
  margin-right: 0.5rem;
}

.scaling-description {
  color: var(--color-text-muted-dark);
  font-size: 0.9rem;
  margin: 0;
  font-style: italic;
  flex: 1;
}

.scaling-controls-unified {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}


.scaling-controls-group {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.scaling-controls-group .button-group.scaling-buttons {
  border: 1px solid var(--color-weathered-teal);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: inline-flex !important;
  width: auto !important;
  flex: none !important;
}

.scaling-buttons .button {
  margin: 0;
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--color-weathered-teal);
}

.scaling-buttons .button:last-child {
  border-right: none;
}

/* Removed .scaling-custom - unused class */

.scaling-custom-input {
  max-width: 100px;
  font-size: 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--color-weathered-teal);
  background-color: var(--color-bg-input);
  color: var(--color-text-light);
  text-align: center;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.scaling-custom-input:focus {
  background-color: var(--color-bg-focused);
  border-color: var(--color-pirate-gold);
  box-shadow: 0 0 0 1px var(--color-pirate-gold);
  outline: none;
}

/* Removed unused legacy scaling controls:
   - .scaling-controls-callout
   - .scaling-label
   These were not referenced in HTML or JavaScript */

.scaling-buttons {
  justify-self: center;
  border: 1px solid var(--color-weathered-teal);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.scaling-buttons .button {
  margin: 0;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  min-width: 3rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.scaling-buttons .button:not(.current-scale) {
  background-color: var(--color-bg-component);
  color: var(--color-text-light);
  border-right: 1px solid var(--color-weathered-teal);
}

.scaling-buttons .button:last-child:not(.current-scale) {
  border-right: none;
}

.scaling-buttons .button:hover:not(.current-scale) {
  background-color: var(--color-weathered-teal);
  color: var(--color-pirate-cream);
}

.scaling-buttons .button.current-scale {
  background-color: var(--color-pirate-gold);
  color: var(--color-pirate-black);
  font-weight: 600;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Removed duplicate .scaling-custom and related input-group selectors - unused classes */


/* Responsive scaling controls - Mobile */
@media screen and (max-width: 640px) {
  .scaling-callout {
    padding: 1rem;
  }


  .scaling-header {
    text-align: center;
  }

  .scaling-label {
    justify-self: center;
  }

  .scaling-buttons {
    justify-self: stretch;
  }

  /* Removed .scaling-custom mobile styles - unused class */
}

.recipe-section {
  margin-bottom: 2rem;
}

.recipe-section h3 {
  color: var(--color-pirate-cream);
  font-family: var(--font-content);
  font-weight: 600;
  border-bottom: 2px solid var(--color-weathered-teal);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  margin-bottom: 1rem;
}

.section-header h3 {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.copy-ingredients-btn {
  color: var(--color-weathered-teal);
  font-size: 0.875rem;
}

.copy-ingredients-btn:hover,
.copy-ingredients-btn:focus {
  color: var(--color-pirate-gold);
}

.recipe-notes-callout {
  background-color: var(--color-bg-accent);
  border: none;
}

/* Foundation Button Group Enhancements */
.reveal .button-group .button.secondary {
  background-color: var(--color-storm-gray);
  color: var(--color-pirate-cream);
  border-color: var(--color-weathered-teal);
}

.reveal .button-group .button.secondary:hover,
.reveal .button-group .button.secondary:focus {
  background-color: var(--color-weathered-teal);
  border-color: var(--color-sea-foam);
}

/* Removed unused Foundation input-group styling - not used in current HTML */

/* Component Styling - Foundation Optimized */
.component-callout {
  background-color: var(--color-bg-accent);
  border: none;
  margin-bottom: 1.5rem;
}

.component-title {
  font-family: var(--font-content);
  font-weight: 600;
  color: var(--color-pirate-cream);
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
}

.component-note {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  background-color: var(--color-bg-accent);
  border: 1px solid var(--color-weathered-teal);
  color: var(--color-text-light);
  font-style: italic;
}

.component-timing {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.component-timing .label {
  font-weight: 500;
  font-size: 0.75rem;
  white-space: nowrap;
}

.component-ingredients {
  margin: 0;
}

.ingredient-item {
  display: grid;
  grid-template-columns: 8rem 1fr;
  grid-gap: 1rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  padding: 0.25rem 0;
}

.ingredient-amount {
  font-weight: 600;
  color: var(--color-pirate-gold);
  text-align: left;
}

.ingredient-name {
  color: var(--color-text-light);
  flex-grow: 1;
}

.component-instructions {
  margin: 0;
  padding-left: 1.5rem;
  counter-reset: instruction-counter;
}

.instruction-step {
  margin-bottom: 1rem;
  line-height: 1.5;
  color: var(--color-text-light);
  padding-left: 0.5rem;
}

/* Scaling Controls */
.scaling-controls label {
  font-family: var(--font-ui);
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--color-text-light);
}

.scaling-controls input[type="number"] {
  background-color: var(--color-bg-input);
  color: var(--color-text-light);
  border: 1px solid var(--color-weathered-teal);
}


/* Recipe Header Actions */
.recipe-actions-compact {
  display: flex;
  gap: 0.25rem;
  margin-top: 1rem;
  justify-content: center;
}

.recipe-actions-compact .button {
  background-color: transparent;
  color: var(--color-weathered-teal);
  border: 1px solid var(--color-weathered-teal);
  border-radius: 4px;
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.2;
  transition: all 0.2s ease;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.recipe-actions-compact .button:hover,
.recipe-actions-compact .button:focus {
  background-color: var(--color-weathered-teal);
  color: var(--color-pirate-cream);
  border-color: var(--color-pirate-gold);
  transform: translateY(-1px);
}


/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-weathered-teal);
  font-family: var(--font-content);
}

.footer-tagline {
  font-style: italic;
  font-size: 1rem;
  color: var(--color-sea-foam);
  margin-bottom: 1rem;
  line-height: 1.5;
}

footer small {
  font-family: var(--font-display);
  font-size: 0.875rem;
  color: var(--color-text-muted-dark);
}

/* Recipe count and status text */
#recipe-count {
  font-family: var(--font-content);
  margin-bottom: 1rem;
  font-weight: 500;
  color: var(--color-text-light);
}


/* Responsive Design */
@media screen and (max-width: 640px) {

  header .logo-icon {
    width: auto;
    height: auto;
    margin: 0 auto;
    display: block;
  }

  header h1.title-text {  
    text-align: center;
  }

  /* Mobile improvements */
  #recipe-grid .cell {
    margin-bottom: 1rem;
  }

  .reveal {
    padding: 1rem;
    margin: 2rem 1rem !important;
    max-height: calc(100vh - 4rem) !important;
    overflow-y: auto;
    width: calc(100vw - 2rem) !important;
    max-width: calc(100vw - 2rem) !important;
    left: 1rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    top: 2rem !important;
  }

  .reveal h2 {
    font-size: 1.5rem;
  }

  /* Adjust close button for mobile */
  .reveal .close-button {
    width: 2rem;
    height: 2rem;
    font-size: 1.5rem;
    top: 0.75rem;
    right: 0.75rem;
  }

  /* Ensure proper spacing for recipe sections on mobile */
  .recipe-section {
    margin-bottom: 1.5rem;
  }

  /* Recipe notes specific mobile styling */
  .recipe-notes-callout {
    margin-bottom: 2rem;
    padding: 1rem;
  }

  .component-section {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

}

/* Back to Top Button */
.back-to-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--color-ocean-blue);
  color: var(--color-pirate-cream);
  border: 2px solid var(--color-weathered-teal);
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.3s ease;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.back-to-top-btn:hover,
.back-to-top-btn:focus {
  background-color: var(--color-pirate-gold);
  color: var(--color-pirate-black);
  border-color: var(--color-pirate-gold-dark);
  transform: translateY(-2px);
}

.back-to-top-btn.show {
  opacity: 1;
  visibility: visible;
}

/* Mobile Responsive - Prevent Horizontal Overflow */
@media screen and (max-width: 480px) {
  header {
    padding: 2rem 0;
  }

  header .cell {
    text-align: center;
    margin-bottom: 1rem;
  }

  header .cell:last-child {
    margin-bottom: 0;
  }

  header h1 {
    font-size: 4.5rem;
    margin: 0;
    text-align: center;
    justify-content: center;
  }

  header .logo-icon {
    width: auto;
    height: auto;
    margin: 0 auto;
    display: block;
  }

  header p {
    font-size: 1.3rem;
    margin: 1rem 0 0 0;
  }

  /* Ensure fixed position elements don't cause overflow */
  .music-control-fixed {
    left: 1rem;
    bottom: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
  }

  .back-to-top-btn {
    right: 1rem;
    bottom: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
  }

  /* Enhanced mobile modal styling for very small screens */
  .reveal {
    padding: 0.75rem;
    margin: 0.5rem;
    max-height: calc(100vh - 1rem);
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
    left: 0.5rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Ensure modal content has proper bottom spacing */
  .reveal .grid-container {
    padding-bottom: 1.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Prevent content elements from causing horizontal scroll */
  .reveal * {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Ensure tables and wide content wrap properly */
  .reveal table,
  .reveal pre,
  .reveal code {
    max-width: 100%;
    overflow-x: auto;
  }

  /* Further adjust close button for very small screens */
  .reveal .close-button {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.25rem;
    top: 0.5rem;
    right: 0.5rem;
  }

  /* Recipe notes extra spacing on small screens */
  #recipe-notes-section {
    padding-bottom: 1rem;
  }

  .recipe-notes-callout {
    margin-bottom: 1.5rem;
  }

  /* Ensure grid and form elements don't overflow */
  .grid-container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  input[type="search"] {
    font-size: 16px; /* Prevent zoom on iOS */
    width: 100%;
    min-width: 0;
  }

  /* Recipe card scaling controls - mobile friendly */
  .scaling-controls-unified {
    gap: 0.5rem;
  }

  .scaling-custom-input {
    max-width: 80px;
    font-size: 16px;
  }

  /* Recipe header actions - mobile layout */
  .recipe-actions-compact {
    gap: 0.375rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
  }

  .recipe-actions-compact .button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    gap: 0.25rem;
  }
}

/* Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  header,
  .scaling-controls,
  .copy-controls,
  .music-control-fixed,
  .back-to-top-btn {
    display: none;
  }

  .recipe-card {
    page-break-inside: avoid;
    border: 1px solid black;
    background: white;
    color: black;
  }

  .reveal {
    position: static;
    background: white;
    color: black;
  }

  .component-section {
    page-break-inside: avoid;
    border: 1px solid black;
    background: white;
    color: black;
  }

  .component-title {
    color: black;
    border-bottom-color: black;
  }
}