/************ Google Fonts import ************/
@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Roboto:ital,wdth,wght@0,75..100,100..900;1,75..100,100..900&display=swap");

/************ CSS Variables ************/
:root {
  /************ Colors ************/
  --background-color: #1d1a21;
  --foreground-white: #ffffff;
  --window-color: #252733;
  --highlight-blue: #4f9aff;
  --correct-green: #4eb738;
  --wrong-red: #e83c5a;
  --star-gold: #f59527;
  --reverse_btn-hover: rgba(255, 255, 255, 0.2);

  /************ Typography ************/
  --primary-font: "Roboto", sans-serif;
  --secondary-font: "Inter", sans-serif;
}

/* Asterisk wildcard selector to override default styles added by the browser */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  /************ Background images ************/
  background-color: var(--background-color);
  background-image: url(../images/pop-quiz.svg),
    url(../images/lightbulb-silversoul.svg);
  background-repeat: no-repeat, no-repeat;
  background-position: center top 20px, left -25px top -40px;
  background-size: 350px auto, 300px auto;
  color: white;
}

/************ Typography ************/
h2 {
  font-family: var(--primary-font);
  font-weight: 500;
  font-size: 1.7rem;
  color: var(--highlight-blue);
  padding-bottom: 1rem;
  letter-spacing: 0.5px;
}

h3 {
  font-family: var(--primary-font);
  font-size: 1.2rem;
}

p,
ol {
  font-family: var(--secondary-font);
  word-wrap: break-word;
}

button {
  font-family: var(--secondary-font);
}

#info_panel p {
  font-size: 1.1rem;
}

#info_panel p,
#difficulty_panel p {
  margin-bottom: 12px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.results_text h3,
.results_text p {
  padding: 0 20px 20px 20px;
}

.results_score p {
  font-size: 1rem;
}

.quiz_score i {
  color: var(--star-gold);
}

/************ Containers ************/
/* Hide the headings for screen readers */
/* https://webaim.org/techniques/css/invisiblecontent/ */
.hidden_heading {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#info_panel,
#rules_panel,
#quiz_panel,
#difficulty_panel,
#results_panel,
#leaderboard_panel,
#error_panel {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 350px;
  height: auto;
  min-height: 450px;
  border-radius: 8px;
  background-color: var(--window-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
}

#info_panel,
#error_panel,
#rules_panel,
#difficulty_panel,
#leaderboard_panel,
#results_panel {
  padding: 18px;
}

#rules_panel,
#quiz_panel,
#difficulty_panel,
#results_panel,
#leaderboard_panel {
  transition: opacity 0.3s ease-in-out;
  display: none;
}

#results_panel {
  align-items: center;
  flex-direction: column;
  justify-content: center;
}

/* Show panels by adding the .show class */
#rules_panel.show,
#results_panel.show,
#leaderboard_panel.show,
#difficulty_panel.show {
  display: flex;
  z-index: 5;
}

#quiz_panel.show {
  display: block;
  z-index: 5;
}

/* Hide the info panel by adding the .hidden class */
#info_panel.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden; /* Hides from screen readers */
}

/************ Elements ************/

#quiz_header {
  position: relative;
  z-index: 2;
}

#quiz_footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  border-top: 1px solid var(--foreground-white);
  padding: 12px 18px;
  position: relative;
}

/* Ensure .exit_btn is left-aligned */
#quiz_exit_btn {
  margin-right: auto;
}

/* Center the .quiz_score */
.quiz_score {
  position: absolute;
  left: 50%;
  transform: translateX(-60%);
  text-align: center;
  white-space: nowrap;
}

/* Ensure .nextQuestion_btn is right-aligned */
#next_btn {
  margin-left: auto;
}

.question_total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 12px 18px;
  border-bottom: 1px solid var(--foreground-white);
}

.quiz_timer {
  background-color: var(--highlight-blue);
  border-radius: 32px;
  padding: 5px 17px;
  font-family: var(--primary-font);
  color: var(--background-color);
  font-weight: 800;
}

.time_line {
  position: absolute;
  bottom: -5px;
  left: 0;
  height: 4px;
  background: var(--highlight-blue);
  width: 100%;
  transition: width linear;
}

#quiz_questions {
  padding: 12px 18px 0px 18px;
}

#question_title h2 {
  font-family: var(--primary-font);
  color: var(--foreground-white);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-wrap: balance;
  min-height: 92px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  padding-bottom: 0;
}

#results_panel .results_icon {
  font-size: 100px;
  margin-bottom: 10px;
}

#rules_panel ol {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

#rules_panel li {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--highlight-blue);
  border-radius: 8px;
  background: transparent;
  font-weight: 500;
  font-size: 0.9em;
  width: 100%;
  height: auto;
  min-height: 55px;
  text-align: left;
  margin-bottom: 10px;
  padding: 8px 25px 8px 55px;
  word-wrap: break-word;
  white-space: normal;
  position: relative;
  transition: background 0.3s ease;
}

/* Style the rules list items with a counter */
#rules_panel li::before {
  content: counter(rule-counter);
  counter-increment: rule-counter;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--highlight-blue);
  color: var(--background-color);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#rules_panel ol {
  counter-reset: rule-counter;
}

/************ Error Panel ************/

/* error panel animation applied to h2 */
#error_panel h2 {
  animation: shake 0.5s ease-in-out infinite alternate;
  padding-bottom: 0;
}

#error_panel p {
  font-family: var(--secondary-font);
  font-size: 1.2rem;
  text-wrap: balance;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#error_panel i {
  font-size: 5rem;
  color: var(--highlight-blue);
}

#error_panel a {
  color: var(--highlight-blue);
  text-decoration: none;
  font-weight: bold;
}

#error_panel a:hover {
  text-decoration: underline;
}

/************ Scores Form ************/

.submit_form {
  display: flex;
  width: 100%;
  padding-bottom: 20px;
}

.submit_form form {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0;
}

.submit_form input {
  flex: 1;
  padding: 6px 6px 6px 16px;
  font-size: 1rem;
  border: 2px solid var(--highlight-blue);
  border-radius: 20px 0 0 20px;
  outline: none;
}

.submit_form button {
  padding: 6px;
  border-radius: 0 20px 20px 0;
  border: 2px solid var(--highlight-blue);
  background-color: var(--highlight-blue);
  color: var(--background-color);
  cursor: pointer;
  transition: background 0.3s ease;
}

.submit_form button:hover {
  color: var(--foreground-white);
}

/************ Leaderboard table ************/

#high_scores {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

#high_scores th,
#high_scores td {
  font-family: var(--secondary-font);
  font-size: 1rem;
  padding: 3px;
  text-align: center;
  border: 2px solid var(--highlight-blue);
}

#high_scores th {
  background-color: var(--highlight-blue);
  color: var(--background-color);
  font-weight: bold;
}

/* Differentiate the background color of the table rows */
#high_scores tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.1);
}

/************ Buttons ************/

.buttons {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#results_panel .buttons {
  justify-content: space-between;
}

button {
  font-size: 17px;
  padding: 5px 17px;
  border-radius: 32px;
  cursor: pointer;
  flex: none;
}

.outline_btn {
  background: transparent;
  border: 2px solid var(--highlight-blue);
  color: var(--highlight-blue);
}

.reverse_btn {
  background: var(--highlight-blue);
  color: var(--background-color);
  border: none;
}

.answer_btn {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--highlight-blue);
  border-radius: 8px;
  background: transparent;
  color: var(--foreground-white);
  font-weight: 500;
  font-size: 0.9rem;
  width: 100%;
  min-height: 45px;
  height: auto;
  text-align: center;
  margin: 12px 0;
  padding: 8px 40px;
  word-wrap: break-word;
  white-space: normal;
  transition: all 0.3s ease-in-out;
}

#difficulty_panel .answer_btn {
  padding: 12px;
  text-align: left;
}

.difficulty_btn {
  width: 100%;
}

.nextQuestion_btn {
  background-color: var(--correct-green);
}

/* Hide next button when not needed */
.nextQuestion_btn.hide {
  display: none;
}

.nextQuestion_btn:hover {
  background: var(--foreground-white);
}

.outline_btn:hover {
  background: var(--foreground-white);
}

.reverse_btn:hover {
  color: var(--foreground-white);
}

.answer_btn:hover {
  background-color: var(--highlight-blue);
}

/************ Button styling for quiz answers ************/

.answer_btn.correct {
  border: 2px solid var(--correct-green);
}

.answer_btn.incorrect {
  border: 2px solid var(--wrong-red);
}

.answer_btn.disabled {
  pointer-events: none;
}

/* Position tick and cross icons */
.answer_btn::after {
  position: absolute;
  right: 35px;
}

/* Adds tick to button with correct answer */
.answer_btn[data-correct="true"]::after {
  font-family: "Font Awesome 6 Free";
  content: "\f058";
  font-size: 1rem;
  font-weight: 900;
  color: var(--correct-green);
}

/* Adds cross to button with incorrect answer */
.answer_btn.incorrect::after {
  font-family: "Font Awesome 6 Free";
  content: "\f057";
  font-size: 1rem;
  font-weight: 900;
  color: var(--wrong-red);
}

/************ Effects ************/

/************ Shake animation for error panel ************/
@keyframes shake {
  0% {
    transform: rotate(-2deg);
  }
  100% {
    transform: rotate(2deg);
  }
}

/************ sweetalert2 custom modal properties ************/
.swal2-popup {
  font-family: var(--primary-font), sans-serif !important;
}

/************ Media Queries ************/
/* Extra small devices (320px - 568px) */
@media screen and (max-width: 320px) and (max-height: 568px) {
  /* Remove background image */
  body {
    background-image: none !important; /* Removes background */
    background-color: var(--background-color); /* Ensures background remains */
  }

  /* Shift panel to top of screen */
  #info_panel,
  #rules_panel,
  #quiz_panel,
  #difficulty_panel,
  #results_panel,
  #leaderboard_panel,
  #error_panel {
    top: 1% !important;
    min-height: 453.13px !important;
  }

  /* Reduce padding around question no. and timer */
  .question_total {
    padding: 18px 10px 18px 10px;
  }
}

/* Extra small devices (up to 368px) */
@media screen and (max-width: 368px) {
  /* Change the background images to a single image */
  body {
    background-color: var(--background-color);
    background-image: url(../images/pop-quiz.svg);
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
  }

  /* Adjust container width */
  #info_panel,
  #rules_panel,
  #quiz_panel,
  #difficulty_panel,
  #results_panel,
  #leaderboard_panel,
  #error_panel {
    top: 200px;
    left: 50%;
    width: 90%;
    min-height: 400px;
    padding: 12px;
  }

  /* Reduce font sizes for better readability */
  h2 {
    font-size: 1.4rem;
  }

  h3 {
    font-size: 1rem;
  }

  p,
  ol {
    font-size: 0.9rem;
  }

  /* Adjust question text to fit */
  #question_title h2 {
    font-size: 1rem;
    min-height: 60px;
    padding: 5px;
  }

  /* Resize buttons */
  button {
    font-size: 14px;
    padding: 4px 12px;
  }

  .answer_btn {
    font-size: 14px;
    padding: 6px 15px;
    min-height: 40px;
  }

  /* Adjust position of tick and cross icons */
  .answer_btn::after {
    right: 40px;
  }

  /* Adjust leaderboard table */
  #high_scores th,
  #high_scores td {
    font-size: 0.8rem;
    padding: 2px;
  }

  /* Reduce form input size */
  .submit_form input {
    font-size: 14px;
    padding: 5px;
  }

  /* Adjust background image */
  body {
    background-size: contain;
    background-position: top center;
  }

  /* Fix quiz footer layout */
  #quiz_footer {
    height: 45px;
    padding: 10px;
  }
}

/* Mobile devices (up to 750px) */
@media screen and (max-width: 750px) {
  /* Change the background images */
  body {
    background-color: var(--background-color);
    background-image: url(../images/pop-quiz-background-390px.svg);
    background-repeat: no-repeat;
    background-position: left -23px top -30px;
    background-size: 100% auto;
  }
}

/* Medium devices (landscape tablets, 751px - 1079px) */
@media screen and (min-width: 751px) and (max-width: 1079px) {
  /* Change the background images */
  body {
    background-color: var(--background-color);
    background-image: url(../images/pop-quiz.svg),
      url(../images/lightbulb-silversoul.svg);
    background-repeat: no-repeat, no-repeat;
    background-position: center top 20px, left -25px top -40px;
    background-size: 350px auto, 300px auto;
  }

  /* Increase the width of content containers */
  #info_panel,
  #rules_panel,
  #quiz_panel,
  #difficulty_panel,
  #results_panel,
  #leaderboard_panel,
  #error_panel {
    width: 60%;
    max-width: 600px;
    min-height: 600px;
  }

  #info_panel,
  #rules_panel,
  #difficulty_panel,
  #results_panel,
  #leaderboard_panel,
  #error_panel {
    padding: 30px;
  }

  #quiz_questions {
    padding: 20px 30px 0px 30px;
  }

  /* Adjust text for better readability */
  h2 {
    font-size: 2.3rem;
    letter-spacing: 1px;
  }

  h3 {
    font-size: 1.5rem;
  }

  p {
    font-size: 1.4rem;
  }

  #info_panel p,
  #difficulty_panel p {
    padding: 0 20px 0 20px;
    font-size: 1.3rem;
  }

  #difficulty_panel p {
    font-size: 1.5rem;
    padding: 0 20px 0px 20px;
  }

  #difficulty_panel h2 {
    font-size: 2.3rem;
    padding: 0 15px 15px 15px;
  }

  #info_panel h2 {
    padding: 0 22px 22px 22px;
  }

  #rules_panel li {
    font-size: 1.2rem;
    padding: 10px 40px 10px 70px;
    margin-bottom: 12px;
    justify-content: left;
    text-align: center;
    text-wrap: balance;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  #rules_panel li::before {
    left: 20px;
    width: 30px;
    height: 30px;
    font-size: 1.3rem;
  }

  #question_title h2 {
    font-size: 1.6rem;
    min-height: 120px;
  }

  .question_total {
    padding: 18px 30px 18px 30px;
  }

  #quiz_footer {
    height: 80px;
    padding: 18px 30px;
  }

  #error_panel p {
    font-size: 1.6rem;
  }

  /* Improve button spacing */
  button {
    font-size: 1.4rem;
    font-weight: 700;
  }

  .answer_btn {
    font-size: 1.3rem;
    min-height: 55px;
    padding: 10px 50px;
    margin: 18px 0;
  }

  /* Adjust leaderboard spacing */
  #high_scores {
    margin-bottom: 24px;
  }

  #high_scores th,
  #high_scores td {
    font-size: 1.3rem;
    padding: 4.5px;
  }

  /* Adjust position of tick and cross icons */
  .answer_btn::after {
    right: 55px;
  }

  /* Adds tick to button with correct answer */
  .answer_btn[data-correct="true"]::after {
    font-size: 1.5rem;
  }

  /* Adds cross to button with incorrect answer */
  .answer_btn.incorrect::after {
    font-size: 1.5rem;
  }
}

/* Large devices (large laptops and desktops, 1080px and up) */
@media screen and (min-width: 1080px) {
  /* Increase the width of content containers */
  #info_panel,
  #rules_panel,
  #quiz_panel,
  #difficulty_panel,
  #results_panel,
  #leaderboard_panel,
  #error_panel {
    width: 60%;
    max-width: 600px;
    min-height: 600px;
  }

  #info_panel,
  #rules_panel,
  #difficulty_panel,
  #results_panel,
  #leaderboard_panel,
  #error_panel {
    padding: 30px;
  }

  #quiz_questions {
    padding: 20px 30px 0px 30px;
  }

  /* Increase font size, spacing and padding */
  h2 {
    font-size: 2.5rem;
    letter-spacing: 1px;
  }

  h3 {
    font-size: 1.5rem;
  }

  p {
    font-size: 1.4rem;
  }

  body #info_panel p,
  body #difficulty_panel p {
    padding: 0 20px 0 20px;
    font-size: 1.55rem;
    margin-bottom: 22px;
  }

  #info_panel h2,
  #difficulty_panel h2 {
    padding: 0 22px 22px 22px;
  }

  .difficulty_btn {
    padding-bottom: 32px;
  }

  #rules_panel li {
    font-size: 1.3rem;
    padding: 10px 40px 10px 70px;
    margin-bottom: 25px;
    text-align: center;
    text-wrap: balance;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  #rules_panel li::before {
    left: 20px;
    width: 30px;
    height: 30px;
    font-size: 1.3rem;
  }

  #question_title h2 {
    font-size: 1.6rem;
    min-height: 120px;
  }

  .question_total {
    padding: 18px 30px 18px 30px;
  }

  #quiz_footer {
    height: 80px;
    padding: 18px 30px;
  }

  .results_text h3,
  .results_text p {
    padding: 10px 80px 40px 80px;
  }

  .results_text p {
    font-size: 1.5rem;
  }

  #error_panel p {
    font-size: 1.8rem;
  }

  /* Improve button spacing */
  button {
    font-size: 1.4rem;
    padding: 8px 25px;
    font-weight: 700;
  }

  .answer_btn {
    font-size: 1.3rem;
    min-height: 55px;
    padding: 10px 50px;
    margin: 18px 0;
  }

  #high_scores th,
  #high_scores td {
    font-size: 1.4rem;
    padding: 8px;
  }

  #high_scores th,
  #high_scores td {
    font-size: 1.1rem;
    padding: 6.5px;
  }

  #rules_panel li {
    font-size: 1.2rem;
    padding: 10px 40px 10px 70px;
    margin-bottom: 15px;
  }

  /* Adjust position of tick and cross icons */
  .answer_btn::after {
    right: 55px;
  }

  /* Adds tick to button with correct answer */
  .answer_btn[data-correct="true"]::after {
    font-size: 1.5rem;
  }

  /* Adds cross to button with incorrect answer */
  .answer_btn.incorrect::after {
    font-size: 1.5rem;
  }

  .quiz_timer {
    font-size: 1.2rem;
  }

  @media screen and (max-height: 870px) {
    /* Change the background images on shallow screens */
    body {
      background-color: var(--background-color);
      background-image: url(../images/pop-quiz.svg),
        url(../images/lightbulb-silversoul.svg);
      background-repeat: no-repeat, no-repeat;
      background-position: right 10px top 20px, left -25px top -40px;
      background-size: 300px auto, 300px auto;
    }

    /* Adjust panel position for shallow screens */
    #info_panel,
    #rules_panel,
    #quiz_panel,
    #difficulty_panel,
    #results_panel,
    #leaderboard_panel,
    #error_panel {
      top: 10%;
    }
  }
}

/* Extra large devices (large laptops and desktops, 1700px and up) */
@media only screen and (min-width: 1700px) {
  body {
    background-color: var(--background-color);
    background-image: url(../images/pop-quiz.svg),
      url(../images/lightbulb-silversoul.svg),
      url(../images/large-lightbulb.svg);
    background-repeat: no-repeat, no-repeat, no-repeat;
    background-position: center top 20px, left -35px top -55px,
      right -22px top 14px;
    background-size: 450px auto, 450px auto, 100% auto;
  }

  h2 {
    font-size: 2.5rem;
    letter-spacing: 1px;
  }

  #info_panel p,
  #difficulty_panel p {
    padding: 0 20px 0 20px;
    font-size: 1.55rem;
  }

  #info_panel h2,
  #difficulty_panel h2 {
    padding: 0 22px 22px 22px;
  }

  .difficulty_btn {
    padding-bottom: 32px;
  }

  #rules_panel li {
    font-size: 1.3rem;
    padding: 10px 40px 10px 70px;
    margin-bottom: 25px;
    text-align: center;
    text-wrap: balance;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Improve button spacing */
  button {
    font-size: 1.4rem;
    padding: 8px 25px;
    font-weight: 700;
  }

  #high_scores th,
  #high_scores td {
    font-size: 1.4rem;
    padding: 8px;
  }

  #high_scores th,
  #high_scores td {
    font-size: 1.1rem;
    padding: 6.5px;
  }

  #rules_panel li {
    font-size: 1.2rem;
    padding: 10px 40px 10px 70px;
    margin-bottom: 15px;
  }
}
