:root {
  --ink: #16110d;
  --ink-soft: #5b5047;
  --paper: #faf6f0;
  --paper-deep: #efe7db;
  --walnut: #8f4a1f;
  --brass: #c9a24a;
  --rule: rgba(22, 17, 13, .1);
  --font: "Manrope", "Helvetica Neue", sans-serif;
  --row: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.photo {
  position: fixed;
  inset: 0;
  background: url("https://www.music-metropolis.com/wp-content/uploads/2022/11/slider-301195060_5612218242174949_868095001297840828_n.jpg") center / cover no-repeat, var(--ink);
}

/* ---------- Floating notes (until the first product is shown) ---------- */

.notes {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}
/* Outer element travels up the screen, inner one sways; transform/opacity only, so it stays on the GPU. */
.note {
  position: absolute;
  left: var(--x);
  bottom: -60px;
  animation: drift var(--dur) linear var(--delay) infinite;
}
.note svg {
  display: block;
  width: var(--size);
  height: var(--size);
  color: rgba(250, 246, 240, var(--op));
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35));
  animation: sway calc(var(--dur) / 4) ease-in-out var(--delay) infinite alternate;
}
.note:nth-child(3n) svg { color: rgba(201, 162, 74, var(--op)); }

@keyframes drift {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate3d(var(--dx), calc(-100vh - 120px), 0); opacity: 0; }
}
@keyframes sway {
  from { transform: translateX(-18px) rotate(-14deg); }
  to { transform: translateX(18px) rotate(12deg); }
}

/* ---------- Start screen ---------- */

.start {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(22, 17, 13, .15) 0%, rgba(22, 17, 13, .05) 40%, rgba(22, 17, 13, .78) 100%);
}

.start__tap {
  all: unset;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(12vh, env(safe-area-inset-top)) 24px max(9vh, env(safe-area-inset-bottom));
  cursor: pointer;
}

.start__badge {
  display: grid;
  place-items: center;
  width: min(58vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(250, 246, 240, .95);
  box-shadow: 0 0 0 1px rgba(201, 162, 74, .55), 0 0 0 10px rgba(250, 246, 240, .25), 0 24px 60px rgba(0, 0, 0, .35);
  animation: rise .9s cubic-bezier(.2, .7, .2, 1) both;
}
.start__badge img { width: 68%; height: auto; }

.start__hint {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-radius: 999px;
  border: 1px solid rgba(250, 246, 240, .55);
  background: rgba(22, 17, 13, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--paper);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .01em;
  animation: rise .9s .25s cubic-bezier(.2, .7, .2, 1) both;
}
.start__tap:active .start__hint { background: rgba(143, 74, 31, .8); }

.start__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 0 rgba(201, 162, 74, .7);
  animation: pulse 1.8s infinite;
}

/* ---------- App shell: main view above, history drawer below (never overlapping) ---------- */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.app__main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Camera ---------- */

.camera {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--ink);
}
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }

.camera__frame {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: min(34%, 180px);
  transform: translateY(-50%);
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(22, 17, 13, .4);
  outline: 2px solid rgba(250, 246, 240, .85);
  outline-offset: -2px;
  transition: outline-color .2s;
}
.camera__line {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 2px;
  background: #e2462f;
  box-shadow: 0 0 12px #e2462f;
  animation: sweep 2.2s ease-in-out infinite alternate;
}
.camera.is-hit .camera__frame { outline-color: var(--brass); }

.camera__status {
  position: absolute;
  left: 0;
  right: 0;
  top: max(18px, env(safe-area-inset-top));
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(22, 17, 13, .55);
  color: var(--paper);
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
}
.camera__status:empty { display: none; }

.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border-left: 4px solid #d9432f;
  background: var(--paper);
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  animation: rise .3s cubic-bezier(.2, .7, .2, 1) both;
}

/* ---------- Product ---------- */

.product-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 34px 14px;
  background: rgba(22, 17, 13, .35);
}

/* The card shrinks to the space left above the button and scrolls inside itself. */
.product {
  width: 100%;
  max-width: 460px;
  min-height: 0;
  flex: 0 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
  animation: rise .35s cubic-bezier(.2, .7, .2, 1) both;
}

.product__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #fff;
}

.product__badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #d9432f;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 6px 16px rgba(217, 67, 47, .35);
}
.product__media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.product__media img:not([src]) { visibility: hidden; }

.product__body { padding: 18px 20px 22px; }

.product__sku {
  margin: 0 0 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--walnut);
  word-break: break-all;
}

.product__name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.product__prices { margin: 14px 0 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.product__price { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; color: var(--walnut); }
.product__regular { color: var(--ink-soft); font-size: 1rem; font-weight: 500; }
.product__regular:empty { display: none; }

.product__desc {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: .95rem;
  line-height: 1.6;
  white-space: pre-line;
}
.product__desc:empty { display: none; }

.scan-again {
  all: unset;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 26px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  box-shadow: 0 0 0 2px var(--brass), 0 14px 30px rgba(0, 0, 0, .4);
  cursor: pointer;
}
.scan-again svg { color: var(--brass); }
.scan-again:active { background: var(--walnut); }

/* ---------- History drawer ---------- */

.drawer {
  flex: none;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .25);
  padding-bottom: env(safe-area-inset-bottom);
}

.drawer__head {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  height: 38px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  cursor: pointer;
}
.drawer__grip {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: rgba(22, 17, 13, .22);
}
.drawer__title { font-weight: 700; font-size: .82rem; color: var(--ink-soft); margin-top: 6px; }
.drawer__title::after { content: " ↑"; color: var(--walnut); }
.drawer.is-open .drawer__title::after { content: " ↓"; }
.drawer__count {
  margin-top: 6px;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
}
.drawer__count:empty { display: none; }

.drawer__list {
  list-style: none;
  margin: 0;
  padding: 0 12px;
  height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: height .28s cubic-bezier(.2, .8, .2, 1);
}
.drawer.is-open .drawer__list { height: calc(2.5 * var(--row)); }
.drawer__list:empty::before {
  content: "Još ništa nije skenirano.";
  display: block;
  padding: 12px 6px;
  color: var(--ink-soft);
  font-size: .9rem;
}

.history__item {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  height: var(--row);
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}
.history__item:active, .history__item.is-current { background: var(--paper-deep); }
.history__thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}
.history__text { min-width: 0; }
.history__name { display: block; font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history__meta { display: block; font-size: .74rem; color: var(--ink-soft); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history__price { font-weight: 800; font-size: .92rem; color: var(--walnut); }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(201, 162, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(201, 162, 74, 0); } }
@keyframes sweep { from { transform: translateY(-40px); } to { transform: translateY(40px); } }
@keyframes nudge { 50% { transform: translateY(-3px); } }

@media (prefers-reduced-motion: reduce) {
  .notes { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
