/* =========================================
   MAGIC FRIDGE STYLES
   "Expansion Pack" - Independent File
   ========================================= */

:root {
  /* Fridge Colors (Mint Enamel) */
  --fridgePaint: #1f6f5b;      /* Deep Mint Base */
  --fridgeHighlight: #3ff3c3;  /* High Gloss Reflection */
  --fridgeShadow: #14493b;     /* Darker curve shadows */
  
  /* Interior */
  --fridgeInterior: #ffffff;   /* Clean white plastic */
  --shelfGlass: #e0f7fa80;     /* Glass shelves (Hex Alpha) */
  
  /* Chrome Hardware */
  --chromeLight: #e8eaeb;
  --chromeDark: #546e7a;

  /* Shadows (Hex Alpha) */
  --shadowDeep: #000000b3;     
  --shadowMedium: #00000080;   
  --shadowSoft: #00000033;     
}

/* 1. The Stage */
#pantrySection {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 800px;
  background-color: transparent; 
  padding: 50px 20px;
  perspective: 1200px; 
}

/* 2. The Fridge Body */
#pantryCabinet {
  position: relative;
  width: 500px; 
  height: 680px; /* Slightly taller */
  transform-style: preserve-3d;
  transition: transform 0.5s;
  border-radius: 40px; /* RETRO CURVES */
  
  /* Grounding Shadow */
  box-shadow: 0 30px 60px -10px var(--shadowDeep);
  
  /* Top Cap (The rounded top of a Smeg fridge) */
  background: var(--fridgePaint);
}

/* 3. The Interior (Clean White Plastic) */
.pantryInterior {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--fridgeInterior);
  border: 15px solid var(--fridgeShadow); /* The rubber seal area */
  border-radius: 35px;
  
  /* Default: Dark inside (Light off) */
  box-shadow: inset 0 0 150px #000000;
  transition: box-shadow 0.2s ease; /* Fast flicker for light */
    
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 50px 20px;
  z-index: 1; 
}

/* THE LIGHT: Turns on when .isOpen is present */
#pantryCabinet.isOpen .pantryInterior {
  /* Bright white glow inside */
  box-shadow: 
    inset 0 0 50px #ffffff,
    0 0 30px rgba(255, 255, 255, 0.2); 
}

/* Glass Shelves */
.shelf {
  height: 8px;
  background: linear-gradient(to right, rgba(255,255,255,0.4), var(--shelfGlass), rgba(255,255,255,0.4));
  border-bottom: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 5px 10px var(--shadowSoft);
  display: flex;
  align-items: flex-end; 
  justify-content: space-around;
  padding-bottom: 5px;
}

/* Items inside */
.jar {
  font-size: 3em; 
  filter: drop-shadow(0 5px 5px var(--shadowSoft));
}

/* 4. The Doors (Glossy Metal Slabs) */
.pantryDoor {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 10;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  transform-style: preserve-3d; 
  cursor: pointer;
  border: none;
  
  /* High Gloss Metal Finish */
  background: linear-gradient(135deg, var(--fridgePaint) 0%, var(--fridgeHighlight) 50%, var(--fridgePaint) 100%);
  
  /* Subtle border for the seam */
  border-top: 1px solid rgba(255,255,255,0.3);
}

/* --- Door Thickness (Metal Edge) --- */
.pantryDoor::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 15px;
  background-color: var(--fridgeShadow);
  /* Metallic sheen on edge */
  background-image: linear-gradient(to bottom, #fff 0%, #999 20%, #333 100%);
}

/* --- Door Back (White Plastic Liner) --- */
.pantryDoor::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateZ(-15px); 
  border-radius: 30px;
  /* White Plastic Liner with shelves molded in? */
  background-color: #f0f0f0; 
  border: 1px solid #ddd;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}

/* 5. Specific Door Logic */

/* Left Door */
.leftDoor {
  left: 0;
  transform-origin: left center;
  border-radius: 40px 0 0 40px;
}

.leftDoor::before {
  right: 0;
  transform-origin: right;
  transform: rotateY(90deg);
}

/* Right Door */
.rightDoor {
  right: 0;
  transform-origin: right center;
  border-radius: 0 40px 40px 0;
}

.rightDoor::before {
  left: 0;
  transform-origin: left;
  transform: rotateY(-90deg);
}

/* 6. CHROME HANDLES (Replacing Knobs) */

/* Hide the old knobs if they exist in HTML, or style them as Chrome Bars */
.doorKnob {
  display: none; /* Hide the round knob div */
}

/* Create Vertical Handles using pseudo-elements on the Door Panel div */
.doorPanel {
  position: absolute;
  top: 150px; /* Start lower */
  bottom: 150px;
  width: 25px; /* Thin bar */
  background: linear-gradient(to right, var(--chromeDark), var(--chromeLight), var(--chromeDark));
  border-radius: 10px;
  box-shadow: 2px 5px 10px var(--shadowMedium);
  border: none;
  transform: translateZ(5px);
}

/* Position handles near the center seam */
.leftDoor .doorPanel {
  right: 20px;
  left: auto; /* Override default */
}

.rightDoor .doorPanel {
  left: 20px;
  right: auto;
}

/* 7. OPEN STATE Animations */

#pantryCabinet.isOpen .leftDoor {
  transform: rotateY(-105deg);
}

#pantryCabinet.isOpen .rightDoor {
  transform: rotateY(105deg);
}

/* 8. The "Brain" (Input Box) */
.pantryInputGroup {
  text-align: center;
  width: 100%;
}

.pantryInputGroup label {
  color: #333; /* Dark text on white plastic */
  font-family: 'Indie Flower', cursive;
  font-size: 1.8em;
  display: block;
  margin-bottom: 10px;
  text-shadow: none; /* No shadow needed on white */
}

#pantryInput {
  width: 90%;
  padding: 12px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-family: 'Jost', sans-serif;
  margin-bottom: 15px;
  background-color: #fff;
  color: #333;
}

#pantrySearchBtn {
  background-color: var(--fridgePaint);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 25px;
  cursor: pointer;
  transition: background-color 0.3s;
}

#pantrySearchBtn:hover {
  background-color: var(--fridgeHighlight);
  color: #000;
}

/* Hint Text */
.pantryHint {
  text-align: center;
  margin-top: 30px;
  color: #1f6f5b;
  font-family: 'Indie Flower';
  font-size: 1.5em;
  font-weight: bold;
  opacity: 0.8;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  #pantryCabinet {
    width: 300px;
    height: 550px;
  }
}

/* Recipe Modals */

/* =========================================
   ADDITIONS: SEARCH RESULTS & MODAL STYLES
   ========================================= */

/* --- 1. The Results Grid (Below the Fridge) --- */
#pantryResults {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 32px;
  max-width: 2000px;
  margin: 0 auto;
}

/* --- 2. The Recipe Card (Thumbnail) --- */
.mealCard {
  background-color: #fff;
  border-radius: 1em;
  box-shadow: 0 0.25em 0.5em #0000001a; 
  overflow: hidden;
  transition: transform 0.2s ease;
  text-align: center;
  padding-bottom: 1em;
}

.mealCard:hover {
  transform: translateY(-0.3em);
}

.mealCard img {
  width: 100%;
  height: 12em;
  object-fit: cover;
}

.mealCard h3 {
  color: #333;
  font-family: 'Jost', sans-serif;
  font-size: 1.2em;
  margin: 0.8em 0.5em;
}

/* --- 3. Card Buttons --- */
.cardActions {
  display: flex;
  justify-content: center;
  gap: 0.5em;
  margin-top: 0.5em;
}

.viewRecipeBtn {
  background-color: var(--fridgePaint);
  color: #fff;
  border: none;
  padding: 0.5em 1em;
  border-radius: 2em;
  font-family: 'Jost', sans-serif;
  font-size: 0.9em;
  cursor: pointer;
  transition: background-color 0.2s;
}

.viewRecipeBtn:hover {
  background-color: var(--fridgeHighlight);
  color: #000;
}

/* =========================================
   MODAL STYLES (The Popup)
   ========================================= */

/* The Dark Background Overlay */
#recipeModal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 2000; /* Above the fridge doors */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: #00000099; 
  backdrop-filter: blur(5px);   /* Nice blur effect */
}

/* The White Box */
.modal-content {
  background-color: #fff;
  margin: 5% auto;
  padding: 2em;
  border: 1px solid #888;
  width: 90%;
  max-width: 40em;
  border-radius: 1.5em;
  box-shadow: 0 0.5em 1.5em #0000004d;
  position: relative;
  font-family: 'Jost', sans-serif;
}

/* Close Button (X) */
.closeBtn {
  color: #aaa;
  float: right;
  font-size: 2em;
  font-weight: bold;
  cursor: pointer;
  line-height: 0.8em;
}

.closeBtn:hover {
  color: #000;
}

/* Modal Content Styling */
#modalTitle {
  color: var(--fridgePaint);
  font-family: 'Indie Flower', cursive;
  font-size: 2.2em;
  margin-top: 0;
  text-align: center;
}

#modalImage {
  width: 100%;
  max-height: 20em;
  object-fit: cover;
  border-radius: 1em;
  margin: 1em 0;
  border: 2px solid var(--fridgePaint);
}

.modalActions {
  display: flex;
  justify-content: center;
  gap: 1em;
  margin-bottom: 1.5em;
}

.iconBtn {
  background: none;
  border: 2px solid #ccc;
  border-radius: 50%;
  width: 2.5em;
  height: 2.5em;
  font-size: 1.2em;
  cursor: pointer;
  color: #555;
  transition: 0.2s;
}

.iconBtn:hover {
  border-color: var(--fridgePaint);
  color: var(--fridgePaint);
}

/* Save Button Active State */
.saveBtnActive {
  background-color: #e91e63; /* Pink for love */
  color: #fff;
  border-color: #e91e63;
}

.saveBtnActive:hover {
  background-color: #c2185b;
  color: #fff;
}

/* Ingredients & Instructions Layout */
.recipeBody {
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.recipeBody h3 {
  color: var(--fridgeShadow);
  border-bottom: 2px solid #eee;
  padding-bottom: 0.3em;
  font-size: 1.3em;
}

#modalIngredients {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12em, 1fr));
  gap: 0.5em;
}

#modalIngredients li {
  background-color: #f5f5f5;
  padding: 0.5em;
  border-radius: 0.3em;
  font-size: 0.9em;
  color: #444;
}

#modalInstructions {
  line-height: 1.6;
  color: #333;
  font-size: 1em;
}

/* =========================================
   DARK MODE OVERRIDES
   ========================================= */

[data-theme="dark"] {
  /* --- Global Backgrounds --- */
  background-color: #121212;
  color: #ddd;
}

/* --- Search Results & Cards --- */
[data-theme="dark"] .mealCard {
  background-color: #1e1e1e;
  box-shadow: 0 0.25em 0.5em #000;
  border: 1px solid #333;
}

[data-theme="dark"] .mealCard h3 {
  color: #333;
}

[data-theme="dark"] .mealCard p {
  color: #aaa !important; /* Overrides the dark green missing ingredient text */
}

/* --- The Modal (Popup) --- */
[data-theme="dark"] .modal-content {
  background-color: #1e1e1e;
  border: 1px solid #444;
  color: #eee;
}

[data-theme="dark"] #modalTitle {
  color: var(--fridgeHighlight); /* Brighter mint for contrast */
}

[data-theme="dark"] .closeBtn {
  color: #fff;
}

[data-theme="dark"] .recipeBody h3 {
  color: #81c784; /* Soft green */
  border-bottom-color: #444;
}

[data-theme="dark"] #modalIngredients li {
  background-color: #2c2c2c;
  color: #ddd;
}

[data-theme="dark"] #modalInstructions {
  color: #ccc;
}

/* --- Buttons in Dark Mode --- */
[data-theme="dark"] .iconBtn {
  border-color: #555;
  color: #ccc;
}

[data-theme="dark"] .iconBtn:hover {
  border-color: var(--fridgeHighlight);
  color: var(--fridgeHighlight);
}

[data-theme="dark"] #pantryInput {
  background-color: #2c2c2c;
  color: #fff;
  border-color: #444;
}

/* --- Fridge Adaptation (Optional) --- */
/* Dims the white interior so it isn't blinding in dark mode */
[data-theme="dark"] .pantryInterior {
  background-color: #cccccc; 
  border-color: #0f2e26;
}

/* =========================================
   MEDIA QUERIES (Mobile)
   ========================================= */

@media (max-width: 600px) {
  #pantryResults {
    /* Less padding on small screens */
    padding: 1em; 
    
    /* Smaller gap between cards */
    gap: 10px; 
    
    /* Allow cards to be smaller (160px) so two can fit side-by-side on phones */
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  /* Optional: Adjust card text size for mobile */
  .mealCard h3 {
    font-size: 1em;
    margin: 0.5em 0.2em;
  }
}