/* ============ Atelier minimal ============ */
:root {
  --ivory: #F6F3EC;
  --ivory-deep: #EDE8DD;
  --ink: #1C1915;
  --ink-soft: #6E675C;
  --camel: #9A7B4F;
  --camel-deep: #7E6340;
  --card: #FFFDF8;
  --danger: #A4442E;
  --good: #4C7A5A;
  --radius: 20px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", -apple-system, sans-serif;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--ivory);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 24px calc(96px + env(safe-area-inset-bottom));
}

.view { animation: fade-in .35s ease both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ============ Stylist ============ */
/* first screen fills the viewport; the outfit lives below the fold */
.dress-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 132px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.dress-screen .btn-dress {
  margin-top: auto;
}

.today-header { padding: 24px 0; }

.today-date {
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--camel);
  margin-bottom: 8px;
}

.today-greeting {
  font-family: var(--font-display);
  font-weight: 380;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.weather-line {
  margin-top: 16px;
  font-size: 15px;
  color: var(--ink-soft);
  min-height: 1.4em;
}

.weather-retry {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--camel);
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dress-input {
  width: 100%;
  height: 108px;
  font-family: var(--font-display);
  font-weight: 360;
  font-size: 20px;
  line-height: 1.4;
  padding: 16px;
  border: 1.5px solid rgba(154, 123, 79, .35);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  resize: none;
  margin-bottom: 24px;
  box-shadow: 0 0 0 5px rgba(154, 123, 79, .06), 0 4px 24px rgba(28, 25, 21, .05);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.dress-input::placeholder { color: #B4AC9E; transition: opacity .3s ease; }
.dress-input.ph-fade::placeholder { opacity: 0; }
.dress-input:focus {
  outline: none;
  border-color: var(--camel);
  box-shadow: 0 0 0 5px rgba(154, 123, 79, .12), 0 4px 24px rgba(28, 25, 21, .06);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.chip-row-label {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--camel);
  margin-bottom: 10px;
}

.chip {
  font-family: var(--font-body);
  font-weight: 450;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 100px;
  border: 1px solid var(--ivory-deep);
  background: var(--card);
  color: var(--ink);
  transition: transform .15s ease, background .18s ease, color .18s ease, border-color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { transform: scale(.94); }
.chip.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ivory);
}

/* ============ Buttons ============ */
.btn-primary, .btn-secondary {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 17px;
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  border: none;
  transition: transform .12s ease, opacity .18s ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--ivory);
  letter-spacing: .01em;
  box-shadow: 0 6px 20px rgba(28, 25, 21, .14);
}
.btn-primary:disabled { opacity: .35; box-shadow: none; }
.btn-primary:active, .btn-secondary:active { transform: scale(.97); }
.btn-primary, .btn-secondary, .btn-icon, .tab, .filter-tab, .closet-item, .add-option, .btn-again, .btn-delete {
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary {
  background: var(--card);
  border: 1px solid var(--ivory-deep);
  color: var(--ink);
}

.btn-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--ivory);
  font-size: 24px;
  line-height: 1;
}

.row-2 { display: flex; gap: 8px; }
.row-2 > * { flex: 1; }

/* ============ Loading ============ */
.outfit-area { margin-top: 32px; scroll-margin-top: 16px; }

.outfit-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.loading-dots { display: flex; gap: 6px; }
.loading-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--camel);
  animation: dot-wave 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-wave {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============ Outfit card ============ */
.outfit-card {
  background: var(--card);
  border: 1px solid var(--ivory-deep);
  border-radius: var(--radius);
  padding: 24px;
  animation: fade-in .4s ease both;
}

.outfit-label, .why-title {
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--camel);
  margin-bottom: 16px;
}

/* ---- composition: clothes laid out like on a bed ---- */
.outfit-canvas {
  position: relative;
  padding: 8px 0 4px;
}

.piece {
  position: relative;
  display: block;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

/* garments flow vertically, gently overlapping */
.g-jacket, .g-top, .g-bottom, .g-shoes { margin: 0 auto; }
.g-jacket { width: 64%; margin-bottom: -10%; transform: rotate(-2deg); z-index: 1; }
.g-top    { width: 58%; z-index: 2; }
.g-bottom { width: 50%; margin-top: -7%; transform: rotate(1.2deg); z-index: 1; }
.g-shoes  { width: 38%; margin-top: -5%; transform: rotate(-1.5deg); z-index: 2; }

/* side pieces sit where they'd naturally fall */
.g-watch     { position: absolute; right: 5%; top: 24%; width: 16%; z-index: 3; transform: rotate(6deg); }
.g-acc1      { position: absolute; left: 5%; top: 20%; width: 16%; z-index: 3; transform: rotate(-6deg); }
.g-acc2      { position: absolute; left: 6%; top: 42%; width: 14%; z-index: 3; transform: rotate(4deg); }
.g-fragrance { position: absolute; right: 3%; bottom: 1%; width: 18%; z-index: 3; transform: rotate(2deg); }

.piece-img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

/* photos with background: soft editorial tile */
.piece-img:not(.cutout) {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 16px;
  background: var(--ivory-deep);
  box-shadow: 0 6px 20px rgba(28, 25, 21, .10);
}

/* background-removed pieces float free */
.piece-img.cutout {
  filter: drop-shadow(0 8px 18px rgba(28, 25, 21, .16));
}

.piece-img.placeholder {
  aspect-ratio: 1;
  border-radius: 16px;
  background: var(--ivory-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--camel);
}

/* staggered reveal */
.piece.reveal {
  animation: piece-in .45s cubic-bezier(.2, .9, .3, 1) both;
  animation-delay: var(--d, 0s);
}
@keyframes piece-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
}
/* keep composed rotations while revealing */
.g-jacket.reveal { animation-name: piece-in-jacket; }
.g-bottom.reveal { animation-name: piece-in-bottom; }
.g-shoes.reveal  { animation-name: piece-in-shoes; }
@keyframes piece-in-jacket { from { opacity: 0; transform: rotate(-2deg) translateY(14px) scale(.96); } to { transform: rotate(-2deg); } }
@keyframes piece-in-bottom { from { opacity: 0; transform: rotate(1.2deg) translateY(14px) scale(.96); } to { transform: rotate(1.2deg); } }
@keyframes piece-in-shoes  { from { opacity: 0; transform: rotate(-1.5deg) translateY(14px) scale(.96); } to { transform: rotate(-1.5deg); } }

/* lock */
.lock-badge {
  display: none;
  position: absolute;
  top: 6px; right: 6px;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--camel);
  color: var(--ivory);
  padding: 4px 8px;
  border-radius: 100px;
  z-index: 4;
  pointer-events: none;
}
.piece.locked .lock-badge { display: block; }
.piece.locked .piece-img.cutout { filter: drop-shadow(0 0 0 var(--camel)) drop-shadow(0 8px 18px rgba(154, 123, 79, .35)); }
.piece.locked .piece-img:not(.cutout) { box-shadow: 0 0 0 2px var(--camel), 0 6px 20px rgba(28, 25, 21, .10); }

.piece.lock-pulse { animation: lock-pulse .45s ease; }
@keyframes lock-pulse {
  35% { transform: scale(1.05); }
}
.g-jacket.lock-pulse { animation-name: lock-pulse-r; --rot: -2deg; }
.g-bottom.lock-pulse { animation-name: lock-pulse-r; --rot: 1.2deg; }
.g-shoes.lock-pulse  { animation-name: lock-pulse-r; --rot: -1.5deg; }
.g-watch.lock-pulse  { animation-name: lock-pulse-r; --rot: 6deg; }
.g-acc1.lock-pulse   { animation-name: lock-pulse-r; --rot: -6deg; }
.g-acc2.lock-pulse   { animation-name: lock-pulse-r; --rot: 4deg; }
.g-fragrance.lock-pulse { animation-name: lock-pulse-r; --rot: 2deg; }
@keyframes lock-pulse-r {
  35% { transform: rotate(var(--rot)) scale(1.05); }
  100% { transform: rotate(var(--rot)); }
}

.outfit-caption {
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 20px;
  line-height: 1.6;
}

/* ---- why it works ---- */
.outfit-why {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--ivory-deep);
}

.outfit-reasons {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.outfit-reasons li {
  font-family: var(--font-display);
  font-weight: 360;
  font-size: 17px;
  line-height: 1.45;
  padding-left: 22px;
  position: relative;
  animation: fade-in .45s ease both;
  animation-delay: var(--d, 0s);
}
.outfit-reasons li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--camel);
}

.error-note {
  background: #F4E3DC;
  color: var(--danger);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.45;
}

/* ---- swipe ---- */
.swipe-card {
  position: relative;
  touch-action: pan-y;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

.swipe-badge {
  position: absolute;
  top: 20px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  border: 2px solid;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.badge-good { left: 16px; transform: rotate(-8deg); color: var(--good); border-color: var(--good); }
.badge-bad { right: 16px; transform: rotate(8deg); color: var(--danger); border-color: var(--danger); }

.swipe-card.voted-good { border-color: rgba(76, 122, 90, .55); animation: glow-good 1.2s ease; }
.swipe-card.voted-bad { border-color: rgba(164, 68, 46, .55); animation: glow-bad 1.2s ease; }
@keyframes glow-good {
  30% { box-shadow: 0 8px 56px rgba(76, 122, 90, .55); }
  100% { box-shadow: none; }
}
@keyframes glow-bad {
  30% { box-shadow: 0 8px 56px rgba(164, 68, 46, .55); }
  100% { box-shadow: none; }
}

.swipe-hint {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
  margin-top: 16px;
  animation: fade-in .5s ease both;
  animation-delay: .7s; /* appears after the pieces settle */
}

.btn-again {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink-soft);
  background: none;
  border: none;
  padding: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============ Closet ============ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 0 24px;
}

.view-title {
  font-family: var(--font-display);
  font-weight: 380;
  font-size: 34px;
}

.filter-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -24px 24px;
  padding: 0 24px;
  gap: 24px;
  border-bottom: 1px solid var(--ivory-deep);
}
.filter-row::-webkit-scrollbar { display: none; }

/* editorial text tabs */
.filter-tab {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 450;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: none;
  border: none;
  padding: 10px 0 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .18s ease, border-color .18s ease;
}
.filter-tab.selected {
  color: var(--ink);
  border-bottom-color: var(--camel);
}

.closet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 16px;
}

.closet-item {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-family: var(--font-body);
  animation: fade-in .3s ease both;
  transition: transform .15s ease;
}
.closet-item:active { transform: scale(.97); }

.closet-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 16px;
  background: var(--ivory-deep);
}
.closet-photo.cutout {
  object-fit: contain;
  background: var(--card);
  border: 1px solid var(--ivory-deep);
  padding: 8%;
}
.closet-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--camel);
}

.closet-item-name {
  font-size: 14px;
  color: var(--ink);
  margin-top: 8px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 64px 16px;
  animation: fade-in .45s ease both;
}
.empty-state::before {
  content: "";
  display: block;
  width: 32px;
  height: 2px;
  background: var(--camel);
  margin: 0 auto 24px;
  border-radius: 1px;
}
.empty-big {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 380;
  margin-bottom: 12px;
}
.empty-sub { font-size: 15px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 32px; }

/* ============ Settings ============ */
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.label-optional {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-left: 6px;
}

.text-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  padding: 13px 14px;
  border: 1px solid var(--ivory-deep);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  -webkit-appearance: none;
}
.text-input:focus { outline: none; border-color: var(--camel); }

.field-hint {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 8px 0 16px;
}

.settings-divider { height: 1px; background: var(--ivory-deep); margin: 24px 0; }

/* ============ Tab bar ============ */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ivory) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--ivory-deep);
}

.tab {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 100px;
  border: none;
  background: none;
  color: var(--ink-soft);
  transition: all .18s ease;
}
.tab.active { background: var(--ink); color: var(--ivory); }

/* ============ Sheets ============ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 21, .38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 40;
  animation: backdrop-in .3s ease both;
}
@keyframes backdrop-in { from { opacity: 0; } }

.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--ivory);
  border-radius: 24px 24px 0 0;
  padding: 12px 24px calc(32px + env(safe-area-inset-bottom));
  z-index: 50;
  animation: sheet-up .42s cubic-bezier(.32, .72, .25, 1) both;
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: 0 -12px 48px rgba(28, 25, 21, .12);
}
@keyframes sheet-up { from { transform: translateY(100%); } }

.sheet.closing { animation: sheet-down .26s ease-in both; }
@keyframes sheet-down { to { transform: translateY(100%); } }
.sheet-backdrop.closing { animation: backdrop-out .26s ease both; }
@keyframes backdrop-out { to { opacity: 0; } }

.sheet-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--ivory-deep);
  margin: 0 auto 20px;
}

.sheet-title {
  font-family: var(--font-display);
  font-weight: 380;
  font-size: 26px;
  margin-bottom: 20px;
}

.add-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--ivory-deep);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 8px;
  font-family: var(--font-body);
}
.add-option:active { transform: scale(.98); }
.add-option-title { font-size: 16px; font-weight: 500; color: var(--ink); }
.add-option-sub { font-size: 13px; color: var(--ink-soft); }

.add-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--ink-soft);
  font-size: 13px;
}
.add-or::before, .add-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ivory-deep);
}

#add-name-input { margin-bottom: 8px; }

/* confirm step */
.confirm-row { display: flex; gap: 16px; margin-bottom: 20px; }
.confirm-photo {
  width: 96px; height: 96px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--card);
  border: 1px solid var(--ivory-deep);
  flex-shrink: 0;
}
.confirm-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* item detail */
.detail-photo {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 16px;
  background: var(--card);
  margin-bottom: 16px;
}
.detail-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  margin-bottom: 4px;
}
.detail-meta { font-size: 14px; color: var(--ink-soft); margin-bottom: 20px; }
.btn-delete {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: none;
  color: var(--danger);
  font-family: var(--font-body);
  font-size: 16px;
  transition: transform .15s ease;
}
.btn-delete:active { transform: scale(.97); }

/* images ease in as they hydrate */
.piece-img, .closet-photo, .detail-photo, .confirm-photo {
  animation: img-in .35s ease both;
}
@keyframes img-in { from { opacity: 0; } }

/* respect users who prefer stillness */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
