/* =========================
   Base
========================= */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Poppins", sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f3f0ff;
  color: #333;
  line-height: 1.6;
}

img {
  max-width: 100%;
  display: block;
}

main {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.hidden {
  display: none;
}

/* =========================
   Header / Navigation
========================= */
.site-header {
  background: linear-gradient(270deg, #a78bfa, #c084fc, #a78bfa);
  background-size: 800% 800%;
  animation: movingGradient 12s ease infinite;
  padding: 1.5rem 2rem 2.5rem;
  border: none;
  border-radius: 0 0 80px 0;
  clip-path: polygon(
    0 0,
    100% 0,
    100% 75%,
    80% 85%,
    60% 80%,
    40% 90%,
    20% 85%,
    0 100%
  );
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: white;
  box-shadow: 0 6px 12px rgba(124, 58, 237, 0.2);
  position: relative;
}

.logo {
  font-size: 1.8rem;
  font-weight: 600;
  color: white;
  text-decoration: none;
  white-space: nowrap;
}

.user-name {
  color: white;
  font-weight: 500;
  margin-left: auto;
  margin-right: 1rem;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.main-nav a {
  text-decoration: none;
  padding: 0.55rem 1rem;
  color: white;
  border-radius: 8px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  background-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.hamburger {
  display: none;
  font-size: 2rem;
  line-height: 1;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

/* =========================
   Status / Messages
========================= */
#loading,
#error-message {
  text-align: center;
  margin: 1rem 0;
  color: #7c3aed;
  font-weight: 500;
}

#error-message {
  color: #b91c1c;
}

.message {
  margin-top: 1.5rem;
  font-size: 1rem;
  text-align: center;
  font-weight: 500;
  color: #4c1d95;
}

/* =========================
   Gallery
========================= */
.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.artwork-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.artwork-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.artwork-shape {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.artwork-shape:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(124, 58, 237, 0.25);
}

.artwork-link img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 8px;
}

.artwork-info {
  flex-grow: 1;
  padding: 1rem;
  margin-top: 1rem;
  background: #faf7ff;
  border-radius: 8px;
  overflow-wrap: break-word;
}

.artwork-info h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: #7c3aed;
}

.artwork-info p {
  margin: 0.25rem 0;
  color: #4a4a4a;
  font-size: 0.95rem;
}

/* =========================
   Artwork Detail Page
========================= */
#artwork-detail {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

#artwork-detail .artwork-shape {
  width: 100%;
  max-width: 900px;
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.15);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow: hidden;
  clip-path: none;
}

#artwork-detail img {
  width: 100%;
  height: auto;
  max-height: 500px;
  border-radius: 10px;
  object-fit: cover;
  margin-bottom: 1rem;
}

#artwork-detail .artwork-info {
  padding: 1.25rem;
  margin-top: 0;
  background-color: #faf7ff;
  border-radius: 10px;
  line-height: 1.7;
}

#artwork-detail .artwork-info h1 {
  font-size: 1.8rem;
  color: #7c3aed;
  margin: 0 0 1rem;
}

#artwork-detail .artwork-info p {
  margin: 0.5rem 0;
  font-size: 1rem;
  color: #333;
}

/* =========================
   Forms: Create / Edit
========================= */
#create-page {
  max-width: 950px;
  margin: 2rem auto;
  padding: 2rem 2.5rem;
  background: white;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(124, 58, 237, 0.08);
}

#create-page h1 {
  color: #7c3aed;
  font-size: 1.9rem;
  margin-bottom: 1.2rem;
  text-align: center;
  letter-spacing: -0.3px;
}

#create-form,
#edit-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.form-group {
  flex: 1 1 250px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #7c3aed;
  font-size: 0.85rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.8;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  border: 1px solid #e9e5ff;
  border-radius: 8px;
  background: #faf9ff;
  color: #333;
  transition: border-color 0.2s ease, box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.auth-card input:focus {
  outline: none;
  border-color: #a78bfa;
  background-color: #fff;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.12);
}

textarea {
  resize: vertical;
  min-height: 160px;
  font-family: inherit;
}

/* =========================
   Buttons
========================= */
#create-form button,
#edit-form button,
.auth-card button,
.save-button {
  padding: 0.9rem 1.8rem;
  background-color: #7c3aed;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.2);
}

#create-form button:hover,
#edit-form button:hover,
.auth-card button:hover,
.save-button:hover,
#create-form button:focus-visible,
#edit-form button:focus-visible,
.auth-card button:focus-visible,
.save-button:focus-visible {
  background-color: #5b21b6;
  transform: translateY(-1px);
}

#create-form button,
.save-button {
  align-self: flex-end;
  margin-top: 0.5rem;
}

.danger-button {
  background-color: #ef4444;
  color: white;
  border: none;
  padding: 0.95rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  margin-top: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.danger-button:hover,
.danger-button:focus-visible {
  background-color: #b91c1c;
  transform: translateY(-1px);
}

.edit-button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  background-color: #7c3aed;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.edit-button:hover,
.edit-button:focus-visible {
  background-color: #5b21b6;
  transform: translateY(-1px);
}

/* =========================
   Toast
========================= */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #4ade80;
  color: #065f46;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.hidden {
  display: none;
}

/* =========================
   Authentication
========================= */
.auth-card {
  max-width: 420px;
  margin: 4rem auto;
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.15);
  text-align: center;
}

.auth-card h1 {
  margin-bottom: 1.5rem;
  font-size: 1.7rem;
  color: #7c3aed;
}

.auth-card .form-group {
  text-align: left;
  margin-bottom: 1rem;
}

.auth-card input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-top: 0.3rem;
  font-size: 1rem;
  background: #f9f9f9;
}

.auth-card button {
  width: 100%;
  margin-top: 1rem;
}

/* =========================
   Footer
========================= */
.site-footer {
  background: linear-gradient(270deg, #a78bfa, #c084fc, #a78bfa);
  background-size: 800% 800%;
  animation: movingGradient 12s ease infinite;
  color: white;
  text-align: center;
  padding: 2rem;
  border: none;
  clip-path: polygon(
    0 25%,
    20% 15%,
    40% 20%,
    60% 10%,
    80% 15%,
    100% 5%,
    100% 100%,
    0% 100%
  );
  box-shadow: 0 -6px 12px rgba(124, 58, 237, 0.2);
  font-size: 0.95rem;
  margin-top: 4rem;
}

/* =========================
   Animation
========================= */
@keyframes movingGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* =========================
   Responsive
========================= */
@media (max-width: 1024px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .site-header {
    flex-wrap: wrap;
    align-items: center;
    padding: 1.25rem 1.25rem 2rem;
  }

  .user-name {
    order: 2;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }

  #create-page {
    padding: 1.5rem;
  }

  #artwork-detail .artwork-shape {
    padding: 1.25rem;
  }
}

@media (max-width: 600px) {
  main {
    width: min(100%, calc(100% - 1rem));
    padding: 1.25rem 0;
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .hamburger {
    display: block;
    margin-left: auto;
  }

  .main-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    background-color: #7c3aed;
    padding: 1rem;
    border-radius: 12px;
    width: 100%;
    margin-top: 1rem;
  }

  .main-nav a {
    display: block;
    text-align: center;
  }

  .main-nav.show {
    display: flex;
  }

  .site-header {
    flex-direction: row;
    align-items: center;
  }

  .logo {
    font-size: 1.4rem;
  }

  .form-row {
    flex-direction: column;
    gap: 1rem;
  }

  #create-page {
    padding: 1.25rem;
    margin: 1.5rem auto;
  }

  .auth-card {
    margin: 2rem auto;
    padding: 1.5rem;
  }

  .toast {
    right: 1rem;
    left: 1rem;
    bottom: 1rem;
  }
}
