/* === Fonts === */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Crimson Pro';
  src: url('../fonts/CrimsonPro-VariableFont_wght.ttf') format('truetype');
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: 'Crimson Pro';
  src: url('../fonts/CrimsonPro-Italic-VariableFont_wght.ttf') format('truetype');
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
}

/* === Variables === */
:root {
  --trr-border-radius: clamp(0.5rem, calc(2.5vw * -1 + 2rem), 1rem);
  --brand-color: hsl(149, 65%, 34%);
  --desaturated-brand-color: hsl(149, 33%, 47%);
  --neutral-background-color: hsl(149, 56%, 95%);
  --separator-color: #ddd;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  background: linear-gradient(
    180deg,
    var(--desaturated-brand-color) 0%,
    var(--desaturated-brand-color) 250px,
    var(--neutral-background-color) 1000px
  ) no-repeat;
  background-color: var(--neutral-background-color);
}

/* === Layout === */
main {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.layout-box {
  position: relative;
  background-color: white;
  border-radius: var(--trr-border-radius);
  padding: 2rem;
  margin: 1rem;
  width: 25rem;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.layout-box:has(.logo) {
  margin-top: 4rem;
  margin-bottom: 4rem;
  padding-top: 6.5rem;
}

.layout-box h1,
.layout-box h2,
.layout-box h3,
.layout-box h4,
.layout-box h5,
.layout-box h6 {
  font-family: "Crimson Pro", serif;
  margin-top: 0;
  margin-bottom: 1rem;
  align-self: center;
  text-align: center;
}

@media (max-width: 599px) {
  .layout-box {
    padding: 1.4rem;
  }

  .layout-box:has(.logo) {
    padding-top: 6.5rem;
  }
}

/* === Logo === */
.logo {
  position: absolute;
  align-self: center;
  top: -2rem;
  width: 141px;
}

/* === Typography === */
p {
  line-height: 1.6;
  color: #333;
  margin-top: 0;
}

/* === Buttons === */
button {
  background-color: #eee;
  color: #111;
  font-size: 0.9rem;
  border: none;
  border-radius: 0.5rem;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: transform 0.1s ease-in-out;
}

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

button.dark {
  background-color: #111;
  color: white;
}

a {
  color: black;
}

/* === Upload form === */
#upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

#drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border: 2px dashed var(--desaturated-brand-color);
  border-radius: var(--trr-border-radius);
  padding: 1.5rem 1rem;
  cursor: pointer;
  text-align: center;
  color: #555;
  transition: background-color 0.15s, border-color 0.15s;
}

#drop-zone:hover,
#drop-zone:focus {
  background-color: hsl(149, 40%, 92%);
  border-color: var(--brand-color);
  outline: none;
}

#drop-zone.drag-over {
  background-color: hsl(149, 50%, 88%);
  border-color: var(--brand-color);
  border-style: solid;
}

.drop-icon {
  color: var(--desaturated-brand-color);
  flex-shrink: 0;
}

.drop-text {
  margin: 0;
  font-size: 0.9rem;
  color: #444;
}

.drop-text button {
  display: inline;
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
  background-color: transparent;
  color: var(--brand-color);
  border: 1.5px solid var(--brand-color);
  border-radius: 0.35rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.drop-text button:hover {
  background-color: var(--brand-color);
  color: white;
}

.drop-text button:active {
  transform: scale(0.95);
}

.drop-hint {
  margin: 0;
  font-size: 0.75rem;
  color: #888;
}

/* --- Thumbnail grid --- */
#preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

#preview-grid:empty {
  display: none;
}

.preview-card {
  position: relative;
  border-radius: 0.4rem;
  overflow: hidden;
  aspect-ratio: 1;
  background-color: #eee;
}

.preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.remove-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  font-weight: 400;
  cursor: pointer;
  border: none;
  transition: background-color 0.15s;
}

.remove-btn:hover {
  background-color: rgba(180, 0, 0, 0.85);
}

.remove-btn:active {
  transform: scale(0.9);
}

/* --- Name input --- */
.name-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.name-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
}

.optional {
  font-weight: 400;
  color: #888;
}

#submitter-email, #submitter-name {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  border: 1.5px solid var(--separator-color);
  border-radius: 0.5rem;
  color: #222;
  background-color: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#submitter-email:disabled, #submitter-name:disabled {
  background-color: #f5f5f5;
  color: #888;
  border-color: #ddd;
  cursor: default;
}

#submitter-email:focus, #submitter-email:focus {
  outline: none;
  border-color: var(--desaturated-brand-color);
  box-shadow: 0 0 0 3px hsl(149, 50%, 88%);
}

/* --- Privacy checkbox --- */
.privacy-field {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.privacy-field input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
  border: 1.5px solid var(--separator-color);
  border-radius: 0.3rem;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.privacy-field input[type="checkbox"]:focus {
  outline: none;
  border-color: var(--desaturated-brand-color);
  box-shadow: 0 0 0 3px hsl(149, 50%, 88%);
}

.privacy-field input[type="checkbox"]:checked {
  background-color: var(--brand-color);
  border-color: var(--brand-color);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='white' d='M13.7 4.3a1 1 0 0 0-1.4 0L6 10.6 3.7 8.3a1 1 0 0 0-1.4 1.4l3 3a1 1 0 0 0 1.4 0l7-7a1 1 0 0 0 0-1.4z'/%3E%3C%2Fsvg%3E");
  background-size: 90%;
  background-position: center;
  background-repeat: no-repeat;
}

.privacy-field label {
  font-size: 0.85rem;
  color: #333;
  line-height: 1.5;
  cursor: pointer;
}

.privacy-field a {
  color: var(--brand-color);
}

/* --- Submit button --- */
.submit-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

.submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.upload-hint {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  line-height: 1.5;
}

/* --- Status messages --- */
#status-msg {
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 1.2em;
}

.status-error {
  color: hsl(5, 70%, 45%);
}

.status-success {
  color: var(--brand-color);
  font-weight: 600;
}

/* === Upload progress === */
#upload-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  color: #555;
  font-size: 0.9rem;
}

#upload-progress[hidden] {
  display: none;
}

/* --- Post-upload actions --- */
#post-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

#post-upload-actions[hidden] {
  display: none;
}

.progress-track {
  width: 100%;
  max-width: 360px;
  height: 8px;
  background: hsl(149, 56%, 85%);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--brand-color);
  border-radius: 4px;
  transition: width 0.2s ease;
}

.progress-bar--processing {
  width: 100% !important;
  animation: pulse-opacity 1.2s ease-in-out infinite;
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

#slow-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  animation: fadein 0.6s ease;
}

#slow-hint[hidden] {
  display: none;
}

@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.alert-member {
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  color: #664d03;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* === Alert Modal === */
#alert-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#alert-modal[hidden] { display: none; }
#alert-box {
  background: #fff;
  border-radius: var(--trr-border-radius);
  padding: 2rem 2.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}
#alert-msg {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
}
#alert-box.alert-error #alert-msg  { color: hsl(5, 70%, 45%); }
#alert-box.alert-success #alert-msg { color: var(--brand-color); font-weight: 600; }
