/* ─────────────────────────────────────────────────────────────────────────────
   FONTS & GLOBAL RESET
───────────────────────────────────────────────────────────────────────────── */
@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Oi&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CSS VARIABLES
───────────────────────────────────────────────────────────────────────────── */
:root {
  --main-bg-color: #fffcf9;
  --main-accent: #ff8000;
  --main-light: #f2ebe4;
  --main-medium: #ded2c6;
  --main-dark: #806c57;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeBounce {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  60% {
    opacity: 1;
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
  BASE LAYOUT & TYPOGRAPHY
───────────────────────────────────────────────────────────────────────────── */

body {
  font-family: "Inter", sans-serif;
  padding: 1rem;
  max-width: 1000px;
  margin: auto;
  background-color: var(--main-bg-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.header {
  margin-bottom: 2rem;
  text-align: center;
}
.logo {
  width: 100%;
  max-width: 40rem;
  text-align: center;
  margin: 5rem 0;
  transition: width 0.3s ease-out;
}

.logo.shrink {
  width: 10rem;
  margin: 0.5rem 0;
}

h1 {
  font-family: "Instrument Serif", sans-serif;
  text-transform: uppercase;
  text-align: center;
  font-weight: 500;
  font-size: 6em;
  color: var(--main-accent);
}
h2 {
  color: var(--main-dark);
  font-weight: 400;
  font-size: 0.9em;
  text-align: center;
}
h3 {
  font-family: "Instrument Serif", serif;
  text-align: center;
  color: var(--main-dark);
  font-weight: 500;
  font-size: 2em;
  margin-bottom: 1rem;
}
p {
  color: var(--main-dark);
  text-align: center;
}

textarea,
input.text,
input[type="text"],
input[type="button"],
input[type="submit"],
.input-checkbox {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
}

.hidden {
  display: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DESCRIPTION & VISIBILITY CLASSES
───────────────────────────────────────────────────────────────────────────── */
#description {
  max-width: 300px;
  margin: auto;
}
#description.hidden {
  display: none;
  transform: translateY(-20px);
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROP AREA
───────────────────────────────────────────────────────────────────────────── */
#drop-area {
  border: 2.5px dashed var(--main-medium);
  width: 100%;
  max-width: 600px;
  padding: 2rem;
  text-align: center;
  margin: 5rem auto;
  border-radius: 50px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-content: center;
  align-items: center;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}
#drop-area button {
  margin: 0;
  width: max-content;
}

#drop-area.hidden {
  display: none;
  transform: translateY(-20px);
  pointer-events: none;
}

#drop-area.dragover {
  border-color: #666;
  background-color: rgba(0, 0, 0, 0.05);
}

/* ─────────────────────────────────────────────────────────────────────────────
   WORKSPACE
───────────────────────────────────────────────────────────────────────────── */
#workspace {
  display: none;
  transform: translateY(20px);
  pointer-events: none;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
  justify-content: center;
  align-content: flex-start;
  align-items: center;
  gap: 1rem;
}

#workspace.visible {
  display: block;
  transform: translateY(0);
  pointer-events: auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   WORKBENCH CARD
───────────────────────────────────────────────────────────────────────────── */
.workbench {
  border-radius: 40px;
  margin-bottom: 3rem;
  background-color: #ffffff79;
  box-shadow: 0 10px 30px var(--main-light);
  padding: 10px 10px 0;
  background-size: 20px 20px;
  background-position: -19px -19px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ASPECT SELECTOR
───────────────────────────────────────────────────────────────────────────── */
.aspect-container {
  color: var(--main-dark);
  display: flex;
  flex-direction: row;
  width: 200px;
  flex-grow: 2;
  align-content: center;
  align-items: center;
  gap: 0.5rem;
}

.aspect-selector {
  display: flex;
  gap: 0;
  justify-content: center;
  background-color: var(--main-light);
  border-radius: 100px;
  padding: 5px;
  vertical-align: middle;
  align-items: center;
}

.aspect-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  color: var(--main-dark);
  font-size: 0.9rem;
  transition: color 0.3s ease;
  position: relative;
}

.aspect-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.aspect-option input[type="radio"] ~ span {
  padding: 5px 10px;
  border-radius: 100px;
}

.aspect-option input[type="radio"]:checked ~ span {
  color: var(--main-accent);
  background-color: white;
  padding: 5px 10px;
  border-radius: 100px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CONTROLS & COLUMN GROUP
───────────────────────────────────────────────────────────────────────────── */
#controls {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  padding: 10px;
  box-shadow: 0 5px 10px var(--main-light);
  background-color: white;
  border-radius: 100px;
}

#controls label {
  display: flex;
  align-items: center;
  color: var(--main-dark);
}

#controls select,
#controls button {
  margin: 0 0.5rem;
}

#column-group {
  display: flex;
  align-items: center;
  justify-content: end;
  color: var(--main-dark);
  flex-grow: 1;
  text-align: center;
}

#column-group button {
  border: 0;
  background-color: var(--main-light);
  padding: 5px;
  border-radius: 100px;
  width: 50px;
  font-size: 20px;
  color: var(--main-dark);
}

#column-group button.disabled {
  opacity: 0.5;
  pointer-events: none;
  transform: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON STYLES
───────────────────────────────────────────────────────────────────────────── */
button {
  transition: all 0.2s;
  margin: 1rem auto;
  text-align: center;
  border: 0;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.34);
  color: var(--main-dark);
  border-radius: 100px;
  font-size: 0.9rem;
  cursor: pointer;
}
button:hover {
  transform: scale(1.1);
}

button:active {
  transform: scale(0.9);
}

.main-button-container {
  width: 100%;
  text-align: center;
}
#split-btn {
  padding: 10px 20px;
  background-color: var(--main-accent);
  color: white;
  font-size: 20px;
  font-weight: 600;
  border-radius: 100px;
  margin-top: 2rem;
  text-align: center;
  margin-bottom: -40px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   PROGRESS
───────────────────────────────────────────────────────────────────────────── */
/* ensure it’s hidden initially */
#progress-container {
  display: none;
  align-items: center;
  gap: 0.5rem;
  max-width: 500px;
  margin: auto;
  margin-top: 3rem;
}

/* when .active is on, show it */
#progress-container.active {
  display: flex;
}

/* spinner & progress-bar styles remain the same */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

#progress-bar {
  flex-grow: 1;
  height: 0.5rem;
  appearance: none;
}

#progress-bar::-webkit-progress-bar {
  background: #eee;
  border-radius: 0.25rem;
}
#progress-bar::-webkit-progress-value {
  background: var(--main-accent);
  border-radius: 0.25rem;
}
#progress-bar::-moz-progress-bar {
  background: var(--main-accent);
  border-radius: 0.25rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   JOB COMPLETE MESSAGE
───────────────────────────────────────────────────────────────────────────── */
.job-complete {
  text-align: center;
  color: var(--main-dark);
  margin: auto;
  animation: fadeBounce 0.4s ease-out forwards;
}
.job-complete h2 {
  font-size: 3rem;
  font-family: "Instrument Serif";
  text-transform: uppercase;
}
.job-complete img {
  width: 150px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   PREVIEW CANVAS & THUMBNAILS
───────────────────────────────────────────────────────────────────────────── */
#preview {
  width: 100%;
  height: auto;
  display: block;

  --guide-width: 3px;
}

.preview-container {
  margin-bottom: 1rem;
  text-align: center;
}

#slice-previews {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#slice-previews canvas {
  flex: 0 0 auto;
  width: 100px;
  height: auto;
}

#slice-previews canvas:first-child {
  border-radius: 10px 0 0 10px;
}
#slice-previews canvas:last-child {
  border-radius: 0 10px 10px 0;
}

#slice-previews::-webkit-scrollbar {
  height: 6px;
}
#slice-previews::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}
#slice-previews::-webkit-scrollbar-track {
  background: transparent;
}

/* ─────────────────────────────────────────────────────────────────────────────
   FEEDBACK MESSAGES
───────────────────────────────────────────────────────────────────────────── */
.warning {
  color: var(--main-dark);
  font-size: 0.95rem;
  text-align: center;
  background-color: #ffefdc;
  padding: 10px;
  border-radius: 150px;
  border: 1px solid white;
  transition: all 0.2s;
  max-width: 310px;
  margin: 1rem auto;
  animation: fadeBounce 0.4s ease-out forwards;
}
.warning.critical {
  background-color: #ffcfcf;
  color: darkred;
}
.warning.success {
  background-color: #e2ffdc;
  width: max-content;
  padding: 10px 20px;
  color: #2e9717;
}

/* ─────────────────────────────────────────────────────────────────────────────
   FOOTER & LEGAL
───────────────────────────────────────────────────────────────────────────── */
.legal {
  font-size: 12px;
  font-weight: 300;
  color: var(--main-medium);
  text-align: center;
  padding: 10px;
  flex-grow: 2;
  align-content: flex-end;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MEDIA QUERIES
───────────────────────────────────────────────────────────────────────────── */
/* MOBILE */
@media screen and (max-width: 480px) {
  .logo {
    width: 20rem;
  }
  #controls {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    border-radius: 30px;
  }
  .aspect-container {
    justify-content: center;
    width: 100%;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--main-light);
  }
  .warning {
    margin-bottom: 10px;
  }
}
