/* Fix for background image coverage */
@import url("https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap");

html,
body {
  height: 100vh;  /* Use viewport height */
  min-height: 100vh;  /* Ensure minimum height */
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

body {
  background-color: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  font-family: "Raleway", sans-serif;
}

.background-style {
  height: 100vh;
  overflow: hidden;
}

/* Ensure content doesn't create unwanted space */
#canvas-container {
  position: relative;
  margin-top: 100px; /* Adjust based on your header height */
  width: 100%;
  display: flex;
  justify-content: center;
}

canvas {
  border: 1px solid #000;
}

.button-container {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.controls-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  max-width: 300px;
}

.filter-options {
  display: flex;
  gap: 10px;
}

.filter-option {
  display: flex; /* Enables flexbox for centering */
  align-items: center; /* Centers text vertically */
  justify-content: center; /* Centers text horizontally */
  padding: 0.5rem 1rem;
  background-color: #333;
  color: white;
  border-radius: 1rem;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s;
}

.filter-option.selected {
  background-color: #db0a25;
  transform: scale(1.1);
}

.filter-option:hover {
  background-color: #db0a25; /* Keep the background color the same */
  transform: scale(1.05); /* Slightly increase size */
  box-shadow: 0 0 10px rgba(219, 10, 37, 0.9); /* Add a soft red glow */
}

button {
  font-family: "Raleway", sans-serif;
  font-size: 1rem;
  border-radius: 1rem;
  margin-top: 1rem;
  padding: 1rem 2rem;
  border: none;
  background-color: #db0a25;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
}

button:hover {
  background-color: #db0a25; /* Keep the background color the same */
  transform: scale(1.05); /* Slightly increase size */
  box-shadow: 0 0 10px rgba(219, 10, 37, 0.9); /* Add a soft red glow */
}

button:active {
  transform: scale(0.95);
}

label:active {
  transform: scale(0.95);
}

.hat-selection span {
  color: white !important;
}

.tab-container {
  width: 90%;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
  background-color: #222;
  border-radius: 2px;
  border: 2px solid #000;
  margin-bottom: 2rem;
}

.tabs {
  border-bottom: 1px #db0a25 solid;
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 10px 0;
}

.tab-link {
  flex: 1;
  text-align: center;
  padding: 12px 1px; /* Adjusted padding for a tighter, more refined look */
  cursor: pointer;
  background-color: transparent; /* Fully transparent background when not active */
  color: white; /* White color for font */
  font-size: 18px; /* Match the specified font size */
  transition: background-color 0.3s;
  word-wrap: break-word; /* Ensure text wraps if needed */
}

.tab-link:hover {
  background-color: #db0a25; /* Red background on hover */
}

.tab-link.current {
  background-color: #db0a25; /* Active tab background color */
  color: white; /* Ensure text is white on red background */
}

/* Content for each tab */
.tab-content {
  display: none;
  justify-content: center;
  min-height: 0; /* Prevent unwanted expansion */
}

.tab-content.current {
  display: flex;
  justify-content: center;
  width: 100%;  /* Ensure content stretches to fill container */
}

.control {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;  /* Ensure controls take full width of container */
}

.control span {
  color: white;
  margin-bottom: 10px;  /* Add more spacing below labels */
  font-size: 16px;  /* Slightly larger text for better readability */
}

.control input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;  /* Increase slider height */
  background: #a8a8a8;
  outline: none;
  border-radius: 5px;
  transition: background 0.3s;
  touch-action: none;
}

.control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
          appearance: none;
  width: 24px;  /* Increase thumb size */
  height: 24px;
  border-radius: 50%;
  background: #db0a25;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  transition: background 0.3s, transform 0.3s;
}

.control input[type="range"]::-webkit-slider-thumb:hover {
  background: #db0a25;
  transform: scale(1.1);
}

.control input[type="range"]:hover {
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.8); /* Red glow effect on hover */
}

.control input[type="range"]::-moz-range-thumb {
  width: 24px;  /* Increase thumb size */
  height: 24px;
  border-radius: 50%;
  background: #2a334e;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  transition: background 0.3s, transform 0.3s;
}

.control input[type="range"]::-moz-range-thumb:hover {
  background: #3b4b7e;
  transform: scale(1.1);
}

input[type="file"] {
  display: none;
}

label {
  display: inline-block;
  padding: 1rem 2rem;
  border-radius: 1rem;
  background-color: #db0a25;
  color: white;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
}

label[for="image-upload"] {
  margin-top: 1rem;
  padding: 1rem 2rem;
  border: none;
  border-radius: 1rem;
  background-color: #db0a25;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
  height: 52px; /* Force exact same height */
  line-height: 21px; /* Consistent line height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

label:hover {
  background-color: #db0a25; /* Keep the background color the same */
  transform: scale(1.05); /* Slightly increase size */
  box-shadow: 0 0 10px rgba(219, 10, 37, 0.9); /* Add a soft red glow */
}

h1 {
  color: white;
  margin-top: 1rem;
  font-size: 2rem;  /* Larger title for better visibility */
  text-align: center;
}

.hat-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 hats per row */
  gap: 15px;
  justify-items: center;
}

.hat-option {
  width: 100%;
  height: auto;
  max-width: 80px;
  max-height: 80px;
  cursor: pointer;
  border: 2px solid transparent;
  background-color: rgba(73, 63, 63, 0.7); /* Semi-transparent background */
  border-radius: 5px; /* Optional: rounded corners */
  padding: 5px; /* Space between image and border */
  box-sizing: border-box;
  transition: transform 0.2s, border-color 0.3s, box-shadow 0.3s;
  object-fit: contain;
}

.hat-option:hover,
.hat-option.selected {
  border: 2px solid #f0023;
  transform: scale(1.1);
  background-color: rgba(255, 0, 0, 0.7);
  box-shadow: 0 0 8px 3px rgba(255, 0, 0, 0.6); /* Red glow effect */
}

#contrast-slider {
  background: linear-gradient(to right, #000, #fff);
}

#contrast-slider::-webkit-slider-thumb {
  background-color: #3c3b49; /* White themed thumb */
}

#contrast-slider::-moz-range-thumb {
  background-color: #fff;
}

#redness-slider {
  background: linear-gradient(to right, #300, #f00);
}

#redness-slider::-webkit-slider-thumb {
  background-color: #f00; /* Red themed thumb */
}

#redness-slider::-moz-range-thumb {
  background-color: #f00;
}

#contrast-slider:hover,
#redness-slider:hover {
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}

.add-hat-button-container {
  margin-top: 10px;  /* This provides the vertical spacing */
  margin-bottom: 10px;
}

.background-options {
  display: flex;
  justify-content: center;    /* Center the buttons horizontally */
  gap: 20px;                  /* Space between each button */
  margin-bottom: 10px;         /* Space below the options container */
}

.background-options label {
  color: white;
  display: flex;
  align-items: center;        /* Align the radio button and text vertically */
  cursor: pointer;
  gap: 10px;                  /* Space between the radio button and label text */
}

.background-options input[type="radio"] {
  appearance: none;            /* Remove the default radio button style */
  width: 20px;                 /* Fixed width */
  height: 20px;                /* Fixed height */
  border: 2px solid #e3a61d;   /* Custom border color */
  border-radius: 50%;          /* Make it circular */
  background-color: #333;      /* Dark background to match the style */
  position: relative;          /* For positioning the custom dot */
  transition: all 0.3s ease;   /* Smooth transition for effects */
  flex-shrink: 0;              /* Prevent shrinking inside flexbox */
}

/* Hover effect for the radio button */
.background-options input[type="radio"]:hover {
  background-color: #555;      /* Lighter background on hover */
}

/* Custom dot inside the radio button when checked */
.background-options input[type="radio"]:checked::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;                 /* Size of the inner dot */
  height: 12px;
  border-radius: 50%;
  background-color: #e3a61d;   /* Red dot when selected */
}

.controls-container span {
  display: flex; /* Enables flexbox for centering */
  align-items: center; /* Centers text vertically */
  justify-content: center; /* Centers text horizontally */
  text-align: center; /* Center text alignment within span */
  width: 100%; /* Ensures the span takes up full width */
  color: white;                      /* Ensure the text is white */
  display: inline-block;             /* Make sure the span doesn't wrap awkwardly */
  margin-bottom: 15px;                /* Add some space below for alignment */
  margin-top: 15px;
}

/* General Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Header Styles */
.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 30px 15px; /* Increased top padding by 25px */
  background-color: transparent; /* Fully transparent */
  position: fixed; /* Fixes the header to the top */
  top: 0;
  left: 0;
  z-index: 1001; /* Ensures the header is on top of other content */
}

/* Left Side: Title and Link */
.header-left {
  display: flex;
  align-items: center;
  gap: 20px; /* Space between title and link */
}

.header-title {
  font-size: 1.5rem;
  color: #fff;
  margin: 0;
  padding-right: 30px;
  padding-left: 60px;
}

.header-link {
  font-size: 1.5rem; /* Match the title font size */
  color: #cec2c2; /* White color */
  text-decoration: none;
  line-height: 1; /* Ensures vertical alignment with title */
  transition: color 0.3s;
}

.header-link:hover {
  color: #db0a25; /* Slight yellow-orange tone on hover */
}

/* Magnifier Styles */
#magnifier {
  position: absolute;
  pointer-events: none; /* Allows interactions to pass through */
  width: 150px; /* Diameter of the magnifier */
  height: 150px;
  border: 3px solid #db0a25; /* Red border color */
  border-radius: 50%;
  overflow: hidden;
  display: none; /* Hidden by default */
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  z-index: 1001; /* Above other elements */
  background-repeat: no-repeat;
  background-size: 300%; /* 3x zoom */
}

/* Initial Load Screen Styles */
.load-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: #000; /* Dark background */
  z-index: 1000; /* Make sure it's on top */
}

.load-title {
  color: white;
  font-size: 2rem;
  text-align: center;
  margin-bottom: 1rem;
}

.load-subtitle {
  color: #db0a25;
  font-size: 2rem;
  text-align: center;
  margin-bottom: 2rem;
}

.load-subtext {
  color: white;
  text-align: center;
  margin-bottom: 2rem;
  margin-top: 2rem;
}

.profile-pictures {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.circle-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

.upload-btn {
  background-color: #db0a25;
  color: white;
  border: none;
  cursor: pointer;
}

.upload-btn:hover {
  background-color: #ff4040;
}

.hidden {
  display: none;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #ccc;
  border-top: 5px solid #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.error-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: red;
  color: white;
  padding: 10px;
  font-size: 20px;
  border-radius: 50%;
  z-index: 1000;
}

@media (max-width: 900px) {
  body {
    background-attachment: scroll;
    background-position: calc(50% - 150px) center; /* Shift 20px to the left */
  }

  .background-style {
    background-position: calc(50% - 150px) center; /* Shift 20px to the left */
  }

  /* Header adjustments for mobile */
  .header {
    padding: 12px 20px 10px; /* Reduce padding for mobile */
  }

  .header-title {
    font-size: 14px; /* Reduce font size for mobile */
    padding-left: 0; /* Remove extra padding on smaller screens */
    padding-right: 12px;
    text-underline-offset: 8px; /* Adjust underline offset */
  }

  .header-left {
    gap: 10px; /* Reduce gap between title and link on mobile */
  }

  .header-link {
    font-size: 14px; /* Reduce font size for better fit */
  }
}

/* Adjustments for mobile */
@media (max-width: 700px) {
  .tab-container {
    padding-bottom: 100px; /* Reduced padding for mobile */
  }

  .add-hat-button-container,
  .remove-all-button-container {
    display: flex;
    justify-content: flex-start; /* Align buttons to the left */
    align-items: flex-start;     /* Ensure they start from the top */
  }

  .circle-img {
    width: 75px;
    height: 75px;
  }

  .background-options {
    justify-content: flex-start;     /* Align to the left on small screens */
  }

  .background-options label {
    font-size: 14px;                 /* Smaller text size for smaller screens */
  }

  .tabs {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: none; /* Hide scrollbar in Firefox */
  }

  .tabs::-webkit-scrollbar {
    display: none; /* Hide scrollbar in Chrome, Safari, and Edge */
  }

  .tab-link {
    flex: 0 0 auto; /* Prevent the tabs from shrinking */
    padding: 10px; /* Adjust padding for smaller screens */
    font-size: 14px; /* Adjust font size for better readability */
  }

  /* Center the tab content on mobile */
  .tab-content.current {
    display: flex;
    flex-direction: column; /* Stack elements vertically if needed */
    align-items: center; /* Center items horizontally */
    text-align: center;
    width: 100%; /* Ensure full width within container */
  }

  canvas {
    max-width: 80%;  /* Ensure the canvas fits within the container */
    height: auto;     /* Maintain the aspect ratio */
  }

  /* Center the canvas container */
  #canvas-container {
    position: relative;
    margin-top: calc(24px + 15px); /* Matches padding from .header to keep it aligned */
    padding-top: 80px; /* Additional padding to ensure separation from header */
    width: 100%; /* Makes sure canvas container fills the width */
  }

  button,
  label {
    padding: 10px 20px;  /* Adjust padding for smaller screens */
  }
}
