/* =====================================================
   Teddy's Magnets — Content Pipeline
   Warm, mobile-first, brand-aligned styling
   ===================================================== */

:root {
  /* Brand palette — warm cream + Teddy orange + ink */
  --tm-cream: #faf6f0;
  --tm-cream-deep: #f1ebe0;
  --tm-paper: #ffffff;
  --tm-ink: #1a1612;
  --tm-ink-soft: #4a4339;
  --tm-ink-muted: #8b8275;
  --tm-orange: #e85d2a;
  --tm-orange-deep: #c44a1f;
  --tm-orange-soft: #fde4d8;
  --tm-blue: #2c5fc4;          /* reserved for clickable buttons */
  --tm-blue-deep: #224ba0;
  --tm-success: #2d8659;
  --tm-error: #b73a2a;
  --tm-line: #e6dfd3;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(26, 22, 18, 0.06),
               0 1px 1px rgba(26, 22, 18, 0.04);
  --shadow-md: 0 4px 14px rgba(26, 22, 18, 0.08),
               0 2px 4px rgba(26, 22, 18, 0.05);
  --shadow-lg: 0 18px 40px rgba(26, 22, 18, 0.12),
               0 6px 14px rgba(26, 22, 18, 0.08);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--tm-cream);
  color: var(--tm-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  background:
    radial-gradient(circle at 20% 0%, var(--tm-orange-soft) 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, #fce8d8 0%, transparent 50%),
    var(--tm-cream);
  background-attachment: fixed;
}

/* ===========================
   Typography
   =========================== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--tm-ink);
}

h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.5rem;  line-height: 1.2;  }
h3 { font-size: 1.15rem; line-height: 1.3;  }

p { margin: 0; }

a {
  color: var(--tm-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ===========================
   Layout — mobile first
   =========================== */
.view {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===========================
   LOGIN VIEW
   =========================== */
.login-view {
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--tm-paper);
  border: 1px solid var(--tm-line);
  border-radius: var(--radius-lg);
  padding: 40px 28px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.brand-mark {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 12px;
}

.brand-title {
  font-size: 2rem;
  margin-bottom: 4px;
}

.brand-subtitle {
  font-family: var(--font-body);
  color: var(--tm-orange);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 24px;
}

.login-help {
  color: var(--tm-ink-soft);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* ===========================
   APP HEADER
   =========================== */
.app-view {
  align-items: stretch;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--tm-paper);
  border-bottom: 1px solid var(--tm-line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-mark {
  font-size: 1.6rem;
  line-height: 1;
}

.header-text h1 {
  font-size: 1.05rem;
  line-height: 1.1;
}

.header-text p {
  font-size: 0.7rem;
  color: var(--tm-orange);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#userPic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--tm-line);
  object-fit: cover;
}

/* ===========================
   FORM
   =========================== */
.form-section {
  padding: 24px 20px 80px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.form-intro {
  margin-bottom: 28px;
}

.form-intro h2 {
  font-size: 1.7rem;
  margin-bottom: 4px;
}

.form-intro p {
  color: var(--tm-ink-muted);
  font-size: 0.95rem;
}

.field {
  margin-bottom: 24px;
}

.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--tm-ink);
  margin-bottom: 4px;
}

.field-help {
  font-size: 0.85rem;
  color: var(--tm-ink-muted);
  margin-bottom: 10px;
}

.text-input,
.select-input {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  color: var(--tm-ink);
  background: var(--tm-paper);
  border: 1px solid var(--tm-line);
  border-radius: var(--radius-md);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--tm-orange);
  box-shadow: 0 0 0 3px rgba(232, 93, 42, 0.18);
}

.select-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='%231a1612' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 10px 7px;
  padding-right: 44px;
}

/* ---- Drop zone ---- */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 140px;
  padding: 28px 20px;
  background: var(--tm-paper);
  border: 2px dashed var(--tm-line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--tm-orange);
  background: var(--tm-orange-soft);
}

.drop-icon {
  font-size: 2.2rem;
  font-weight: 300;
  line-height: 1;
  color: var(--tm-orange);
}

.drop-text {
  font-size: 0.95rem;
  color: var(--tm-ink-soft);
  text-align: center;
}

/* ---- Thumbnail grid ---- */
.thumb-grid {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--tm-cream-deep);
  border: 1px solid var(--tm-line);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  touch-action: none; /* needed for SortableJS on touch */
}

.thumb.sortable-ghost {
  opacity: 0.4;
}

.thumb.sortable-chosen {
  cursor: grabbing;
  transform: scale(1.04);
}

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

.thumb-index {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(26, 22, 18, 0.85);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  pointer-events: none;
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: rgba(26, 22, 18, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 22px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s,
              color 0.15s, border-color 0.15s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-large {
  padding: 16px 24px;
  font-size: 1.05rem;
  width: 100%;
  max-width: 420px;
}

.btn-primary {
  /* Brand rule: blue is reserved for clickable buttons */
  background: var(--tm-blue);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) {
  background: var(--tm-blue-deep);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--tm-paper);
  color: var(--tm-ink);
  border-color: var(--tm-line);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--tm-ink-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--tm-ink-soft);
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: var(--radius-pill);
}
.btn-ghost:hover { color: var(--tm-ink); }

.btn-submit {
  margin-top: 8px;
  display: flex;
}

/* ===========================
   ERROR MESSAGE
   =========================== */
.error-msg {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fdecea;
  border: 1px solid #f4c4be;
  color: var(--tm-error);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

/* ===========================
   PROGRESS
   =========================== */
.progress-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.progress-card {
  width: 100%;
  max-width: 400px;
  background: var(--tm-paper);
  border: 1px solid var(--tm-line);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--tm-orange-soft);
  border-top-color: var(--tm-orange);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-step {
  color: var(--tm-orange);
  font-weight: 600;
  font-size: 1rem;
  margin-top: 8px;
  min-height: 1.5em;
}

.progress-help {
  margin-top: 16px;
  color: var(--tm-ink-muted);
  font-size: 0.85rem;
}

/* ===========================
   SUCCESS
   =========================== */
.success-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.success-card {
  width: 100%;
  max-width: 460px;
  background: var(--tm-paper);
  border: 1px solid var(--tm-line);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.success-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tm-success);
  color: #fff;
  font-size: 1.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}

.success-details {
  color: var(--tm-ink-muted);
  font-size: 0.9rem;
  margin: 8px 0 24px;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.captions-details {
  text-align: left;
  border-top: 1px solid var(--tm-line);
  padding-top: 16px;
  margin-top: 8px;
}

.captions-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--tm-ink);
  padding: 6px 0;
  list-style: none;
}

.captions-details summary::-webkit-details-marker { display: none; }
.captions-details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--tm-orange);
  transition: transform 0.15s;
}
.captions-details[open] summary::before {
  transform: rotate(90deg);
}

.caption-block {
  margin-top: 14px;
}

.caption-block h4 {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tm-orange);
  margin-bottom: 6px;
}

.caption-block p {
  font-size: 0.9rem;
  color: var(--tm-ink-soft);
  background: var(--tm-cream);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--tm-line);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===========================
   Tablet+ refinements
   =========================== */
@media (min-width: 600px) {
  .thumb-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .form-intro h2 { font-size: 2rem; }
  .success-actions {
    flex-direction: row;
    justify-content: center;
  }
  .success-actions .btn {
    width: auto;
    flex: 1;
  }
}

/* hidden attribute must win over .view display:flex */
[hidden] { display: none !important; }

