/* ---- ROOT VARIABLES ---- */
:root {
  --light-background: #4e4e4e;
  --dark-background: #2e2e2e;
  --add-green: #5cb85c;
  --delete-red: #d9534f;
  --play-blue: rgb(79, 79, 194);
  --play-title-width: 100%;
}

/* ---- GLOBAL RESET ---- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: monospace;
  color: white;
}

body, html {
  background-color: var(--light-background);
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: row;
}

/* ---- SIDEBAR / BANNER ---- */
#banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--dark-background);
  width: fit-content;
  height: 100%;
  padding: 5vh 2vw 0 2vw;
  border: 0.5rem solid rgb(36, 36, 36);
  border-top: none;
  border-bottom: none;
}

#title {
  margin-bottom: 5vh;
  font-weight: bold;
  font-size: 6vh;
  text-decoration: underline;
  text-underline-offset: 0.5rem;
}

/* ---- MODE FORM ---- */
#mode-form {
  display: flex;
  flex-direction: row;
  gap: 2vw;
  font-weight: bold;
  font-size: 2.5vh;
}

.horizontal {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 1vw;
  border-radius: 0.3rem;
  border: 2px solid rgba(0,0,0,0.5);
}

.horizontal:has(label[for="add"]) {
  background-color: var(--add-green);
}

.horizontal:has(label[for="delete"]) {
  background-color: var(--delete-red);
}

.horizontal:hover {
  transform: scale(1.05);
}

.horizontal.disabled {
  filter: brightness(70%);
  cursor: not-allowed;
}

.horizontal.disabled:hover,
.horizontal.disabled label {
  cursor: not-allowed;
}

/* ---- CUSTOM RADIO BUTTONS ---- */
input[type="radio"] {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 4px solid white;
  border-radius: 50%;
  background-color: white;
}

input[type="radio"]:disabled {
  filter: none !important;
  cursor: not-allowed;
}

input[type="radio"]#add {
  outline: 2px solid green;
}

input[type="radio"]#add:checked {
  background-color: green;
}

input[type="radio"]#delete {
  outline: 2px solid rgb(196, 32, 32);
}

input[type="radio"]#delete:checked {
  background-color: rgb(196, 32, 32);
}

/* ---- ADD / DELETE FORM AREA ---- */
#banner-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 90%;
  max-width: 25vw;
  width: 25vw;
  min-height: 70vh;
  height: fit-content;
  background-color: var(--light-background);
  margin: auto;
  border-radius: 12px;
}

.horizontal2 {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
}

label {
  user-select: none;
  cursor: pointer;
}

label[for="card-title"],
label[for="description-text"] {
  font-weight: bold;
  font-size: 3.5vh;
}

#add-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 5vh 2vw;
  font-size: 16px;
}

#card-title {
  width: 60%;
  border-radius: 8px;
  height: 5vh;
  color: black;
  padding: 10px 8px;
  font-size: 2.5vh;
}

#card-title::placeholder,
#description-text::placeholder {
  color: var(--light-background);
  font-size: 2.5vh;
}

.vertical {
  min-width: 100%;
  width: fit-content;
  margin-top: 2vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#description-text {
  border-radius: 8px;
  width: 100%;
  height: 40vh;
  margin-top: 1vh;
  color: black;
  padding: 4px 8px;
  font-size: 2.5vh;
}

/* ---- BUTTONS ---- */
button {
  width: 10vw;
  height: 5vh;
  margin: 2vh;
  background-color: rgb(36, 36, 36);
  color: white;
  border: 3px solid white;
  font-size: 2.5vh;
  font-weight: bold;
  transition: transform 0s linear;
  display: flex;
  justify-content: center;
  align-items: center;
}

button:hover {
  border: none;
}

button:active {
  transform: scale(0.98);
  border: none;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  filter: brightness(70%);
}

#delete-container {
  width: 90%;
  height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

#select-p {
  font-size: 2.5vh;
  text-align: center;
  margin-top: 2vh;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  width: 100%;
}

/* ---- STACK SPACE ---- */
#stack-space {
  min-width: 220px;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  column-gap: 5vw;   
  row-gap: 2.5rem;     
  justify-items: center;
  align-items: center;  
  padding: 3.5vw;
  overflow-y: auto;
}

/* ---- CARD FRONT ---- */
.card-stack {
  position: relative;
  width: 15vw;
  min-width: 150px;
  aspect-ratio: 5 / 6;
  background-color: white;
  border: 1px solid black;
  border-radius: 10%;
  color: black;
  transition: transform 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 1;
  z-index: 1;
  box-shadow:
    5px 5px 0 white,
    6px 6px 0 black,
    10px 10px 0 white,
    11px 11px 0 black,
    15px 15px 0 white,
    16px 16px 0 black;
}

.card-stack:not(.selected):hover {
  transform: translateY(-6px);
  box-shadow:
    3px 3px 0 white,
    4px 4px 0 black,
    6px 6px 0 white,
    7px 7px 0 black,
    9px 9px 0 white,
    10px 10px 0 black,
    15px 15px 20px rgba(0, 0, 0, 0.8);
  text-decoration: underline;
  cursor: pointer;
}

.selected {
  transform: translateY(-6px);
  box-shadow:
    3px 3px 0 white,
    4px 4px 0 black,
    6px 6px 0 white,
    7px 7px 0 black,
    9px 9px 0 white,
    10px 10px 0 black,
    15px 15px 20px rgba(0, 0, 0, 0.8);
  text-decoration: underline;
  cursor: default;
}

.card-stack > h1 {
  user-select: none;
  color: black;
  font-size: 3vh;
  line-height: 3.5vh;
  max-width: 90%;
  max-height: 90%;
  padding: 0.2rem;
  overflow-y: hidden;
  word-wrap: break-word;
  white-space: normal;
  text-align: center;
}

/* ---- ACTION BUTTON CONTAINER ---- */
#decide-container {
  position: absolute;
  top: -1.5vw;
  left: 0;
  min-width: 7.5vw;
  width: fit-content;
  height: 5vh;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  z-index: 5;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

#decide-container > button {
  border: 2px solid rgba(0,0,0,0.5);
  border-radius: 20%;
  padding: 2px 6px;
  height: 80%;
  width: 25%;
  font-size: 2vh;
  font: inherit;
  margin: 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

#decide-container > button:hover {
  filter: brightness(85%);
}

#edit-button {
  background-color: var(--add-green);
  color: white;
}

#cancel-button {
  background-color: var(--delete-red);
  color: white;
}

#play-button {
  background-color: rgb(79, 79, 194);
  color: white;
}

/* ---- NEXT BUTTON ---- */
.next-button {
  width: 10%;
  height: 10%;
  border: 2px solid rgba(0,0,0,0.5);
  border-radius: 20%;
  padding: 2px 8px;
  font-size: 2vh;
  font: inherit;
  position: absolute;
  bottom: 5%;
  right: 5%;
  z-index: 5;
  background-color: var(--light-background);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.next-button:hover {
  filter: brightness(70%);
}

/* ---- CARD BACK ---- */
.card-stack-back {
  position: relative;
  width: 15vw;
  min-width: 150px;
  aspect-ratio: 5 / 6;
  background-color: white;
  border: 1px solid black;
  border-radius: 10%;
  color: black;
  transition: transform 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 1;
  z-index: 1;
  box-shadow:
    5px -5px 0 white,
    6px -6px 0 black,
    10px -10px 0 white,
    11px -11px 0 black,
    15px -15px 0 white,
    16px -16px 0 black;
}

.card-stack-back:not(.selected):hover {
  transform: translateY(6px);
  box-shadow:
    3px -3px 0 white,
    4px -4px 0 black,
    6px -6px 0 white,
    7px -7px 0 black,
    9px -9px 0 white,
    10px -10px 0 black,
    15px -15px 20px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

.card-stack-back > p {
  user-select: none;
  color: black;
  line-height: 3.5vh;
  max-width: 90%;
  max-height: 90%;
  padding: 0.2rem;
  overflow-y: hidden;
  word-wrap: break-word;
  white-space: normal;
  text-align: center;
}

.description-body {
  width: 80%;
  height: 80%;
  background-color: var(--dark-background);
  border-radius: 10%;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  padding: 20px;
  overflow: hidden;
  font-size: 1.5vh;
}

/* ---- CARD STATE LOGIC ---- */
.card-stack-back {
  display: none;
}

.parent-stack.show-back .card-stack {
  display: none;
}

.parent-stack.show-back .card-stack-back {
  display: flex;
}

/* ---- EDIT MODE ---- */
.parent-stack.edit-mode {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2vw;
}

.parent-stack.edit-mode .card-stack,
.parent-stack.edit-mode .card-stack-back {
  display: flex !important;
  position: static;
  transform: none;
  box-shadow: none;
  border: 2px solid black;
}

.parent-stack.edit-mode .card-stack-back {
  animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideOut {
  from {
    opacity: 0;
    transform: translateX(-1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.parent-stack.edit-mode .card-stack {
  position: relative;
}

.parent-stack.edit-mode #decide-container {
  position: absolute;
  top: -1.5vw;
  left: 0;
  z-index: 5;
}

/* ---- EDIT INPUT FIELDS ---- */
.stack-name-input {
  width: 90%;
  max-height: 90%;
  text-align: center;
  padding: 0.2rem;
  font-size: 3vh;
  line-height: 3.5vh;
  border-radius: 10%;
  color: black;
  background-color: white;
  font-family: monospace;
  font-weight: bold;
  text-decoration: underline;
  outline: none;
  border: 2px dashed black;
  filter: brightness(90%);
}

.back-description-input {
  width: 100%;
  height: 100%;
  padding: 15px;
  font-size: 1.5vh;
  line-height: 3.5vh;
  border-radius: 10%;
  border: 2px dashed black;
  color: black;
  background-color: white;
  font-family: monospace;
  resize: none;
  line-height: normal;
  overflow: hidden;
  filter: brightness(90%);
  outline: none;
}

/* ---- PLAY MODE HEADER + EXIT ---- */
#play-mode-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--dark-background);
  border-radius: 10px;
  padding: 1rem;
  position: relative;
  margin-bottom: 0;
  box-sizing: border-box;
}

#play-mode-header * {
  margin: 0;
  padding: 0;
  line-height: 1;
  box-sizing: border-box;
}

#play-stack-title {
  font-size: 3vh;
  color: white;
  text-align: center;
  flex: 1;
  box-sizing: border-box;
}

#exit-play-mode {
  width: 3.5vh;
  height: 3.5vh;
  background-color: var(--play-blue);
  color: white;
  font-weight: bold;
  font-size: 1.8vh;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  position: absolute;
  left: 10px;
  border: none;
}

/* --- PLAY MODE ADD CARD FORM --- */
#play-add-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vh;
  width: 100%;
  height: fit-content;
  margin: 0;
  padding: 1.5vw;
  border-radius: 5px;
  background-color: var(--dark-background);
  box-sizing: border-box;
}

#play-add-form .form-row {
  display: flex;
  justify-content: center;
  gap: 4vw;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

#play-add-form .form-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 280px;
  gap: 1vh;
  box-sizing: border-box;
}

#play-add-form label {
  font-size: 2vh;
  font-weight: bold;
}

#play-add-form input[type="text"],
#play-add-form textarea {
  width: 20vw;
  height: 20vw;
  font-size: 2vh;
  padding: 1vh;
  border-radius: 0.6rem;
  color: black;
  border: none;
  resize: vertical;
  min-height: 10vh;
  background-color: white;
  box-sizing: border-box;
}

#play-add-form button {
  background-color: var(--add-green);
  color: white;
  font-size: 2.5vh;
  border: none;
  border-radius: 0.6rem;
  cursor: pointer;
  width: 3.5vh;
  height: 3.5vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#play-add-form button:hover {
  filter: brightness(1.1);
}

#play-mode-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow-y: auto;
  padding: 5vh;
  gap: 10vh;
  border: 1px solid blue;
}

/* --- STUDY MODE VIEW --- */

#study-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4vh;
}

/* --- FLASHCARD DISPLAY AREA --- */

#study-card {
  min-width: 200px;
  min-height: 180px;
  width: 25vw;
  height: 20vw;
  background-color: white;
  border-radius: 1rem;
  padding: 0 3vw 2vh 3vw;
  position: relative;
  font-size: 2.3vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

#study-card > * {
  color: black;
}

#flip-button {
  position: absolute;
  top: 0;
  left: 2vh;
  width: 3.5vh;
  height: 3.5vh;
  font-size: 1.8vh;
  background-color: rgb(95, 1, 95);
  color: white;
  border: none;
  border-radius: 0 0 0.5rem 0.5rem;
  cursor: pointer;
  margin: 0;
}


/* --- NAVIGATION CONTROLS --- */

#study-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

#study-controls button {
  font-size: 1.8vh;
  border: none;
  border-radius: 0.6rem;
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

#delete-card {
  min-width: 20px;
  min-height: 20px;
  width: 2vw;
  height: 2vw;
  background-color: var(--delete-red);
}

#add-card {
  min-width: 20px;
  min-height: 20px;
  width: 2vw;
  height: 2vw;
  background-color: var(--add-green);
}

#shuffle-cards {
  min-width: 20px;
  min-height: 20px;
  width: 2vw;
  height: 2vw;
  background-color: rgb(112, 112, 255);
}

#next-card, #prev-card {
  min-width: 40px;
  min-height: 40px;
  width: 3vw;
  height: 3vw;
  background: var(--dark-background);
}

#study-controls button:hover {
  filter: brightness(1.1);
}

@media (max-width: 465px) {
  body, html {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
  }

  #banner {
    width: 100vw;
    height: 50vh;
    flex-direction: row;
    align-items: flex-start;
    padding: 2vw 2vw 2vw 2vw;
    border: none;
    border-bottom: 0.5rem solid rgb(36, 36, 36);
    box-sizing: border-box;
  }

  #title {
    display: none;
  }

  .horizontal2 label {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
  }

  .vertical label {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
  }
  #mode-form {
    flex-direction: column;
    gap: 1vh;
    align-items: flex-start;
    justify-content: flex-start;
    margin-right: 2vw;
    width: fit-content;
  }

  .horizontal {
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    padding: 0.5rem 0.5rem;
    gap: 0.5rem;
  }

  .horizontal > label {
    display: none;
  }

  #banner-body {
    width: calc(100vw - 60px);
    min-height: 30vh;
    margin: 0;
    border-radius: 0 0 12px 12px;
    align-items: flex-start;
    justify-content: flex-start;
    font-size: 1.5vh;
    padding: 1vw 2vw;
    box-sizing: border-box;
    border-radius: 12px;
  }

  #add-form,
  #delete-container {
    width: 100%;
    font-size: 1.5vh;
    margin: 1vh 0;
    padding: 0;
  }

  #add-form {
    flex-direction: column;
    align-items: stretch;
    gap: 1vh;
  }

  #add-form .vertical {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin: 0;
    gap: 0.5vh;
  }

  #add-form label,
  #add-form input,
  #add-form textarea {
    font-size: 1.5vh !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  #add-form label {
    margin-bottom: 0.2em;
    text-align: left;
  }

  #add-form input,
  #add-form textarea {
    padding: 0.5em 0.5em !important;
    margin-bottom: 0.5em;
  }

  #add-form textarea {
    min-height: 8vh;
    height: 12vh;
    resize: vertical;
  }

  #add-form button {
    font-size: 1.5vh !important;
    width: 80% !important;
    height: 4vh !important;
    margin: 1vh auto !important;
    display: block;
  }

  #add-form .horizontal2 {
    flex-direction: row;
    gap: 2vw;
    width: 100%;
    align-items: flex-start;
    justify-content: space-between;
  }

  #add-form .horizontal2 > .vertical {
    width: 48%;
    min-width: 0;
  }

  #delete-container > * {
    font-size: 1.5vh !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}

