/* prod. by henrik */

:root {
  --black: #000;
  --white: #fff;
  --ink: #1d1d1f;
  --gray: #86868b;
  --line: #d2d2d7;
  --paper: #f5f5f7;

  /* wood texture generated in public/assets/wood.png */
  --wood-tex: url("/assets/wood.png");

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--white);
  color: var(--black);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

::selection { background: var(--black); color: var(--white); }

button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }

/* ---------------- top bar / menu ---------------- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 999px;
  color: currentColor;
  transition: background 0.18s var(--ease), opacity 0.18s;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.06); }
.icon-btn:focus-visible { outline: 2px solid var(--black); outline-offset: 2px; }

.menu-btn {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 60;
}

.menu {
  position: fixed;
  top: 66px;
  left: 18px;
  z-index: 60;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  transform-origin: top left;
  animation: menuIn 0.2s var(--ease);
}
@keyframes menuIn {
  from { opacity: 0; transform: scale(0.94) translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: left;
  transition: background 0.15s;
}
.menu-item:hover { background: rgba(0, 0, 0, 0.06); }
.menu-item svg { color: var(--ink); }

/* ---------------- home / hero ---------------- */

#home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(80px, 11vh, 128px) clamp(20px, 5vw, 64px) clamp(16px, 4vh, 40px);
  gap: clamp(36px, 7vh, 84px);
}

.hero {
  margin: 0;
  font-size: clamp(2.5rem, 11vw, 9.5rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.92;
  text-align: center;
  white-space: nowrap;
  animation: heroIn 0.9s var(--ease) both;
}
@keyframes heroIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.crates {
  width: 100%;
  max-width: 1440px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 7vw, 120px);
  align-items: end;
  padding: 0 clamp(0px, 2vw, 24px);
}

.crate-col { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.crate-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.crate-count {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: var(--gray);
  font-weight: 500;
}

/* ---------------- crate ---------------- */

.crate {
  position: relative;
  width: 100%;
  max-width: 620px;
  aspect-ratio: 1 / 1.02;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.crate:focus-visible { border-radius: 10px; box-shadow: 0 0 0 2px var(--black); }

.crate-well {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 3%;
  bottom: 25%;
}

.piece {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--white);
  transition: transform 0.5s var(--ease), opacity 0.4s var(--ease);
  will-change: transform, opacity;
  transform-origin: 50% 90%;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}
.piece.art { border: 1px solid rgba(0, 0, 0, 0.1); }
.piece.art img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* vinyl record used for music */
.piece.music {
  background: transparent;
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}
.piece.music .vinyl {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%,
      #111 0 2px, #1c1c1c 2px 3px, #0a0a0a 3px 5px);
  box-shadow: inset 0 0 0 3px #050505, inset 0 0 40px rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.piece.music .label {
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6%;
  text-align: center;
  overflow: hidden;
}
.piece.music .label span {
  font-size: clamp(7px, 1.1vw, 13px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-transform: uppercase;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* crate shell — real wood */
.crate-back {
  position: absolute;
  left: 2%;
  right: 2%;
  top: 0;
  bottom: 8%;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(30, 18, 9, 0.42), rgba(30, 18, 9, 0.66)),
    var(--wood-tex) center / cover;
  box-shadow:
    inset 0 14px 26px rgba(0, 0, 0, 0.55),
    inset 0 -12px 22px rgba(0, 0, 0, 0.4),
    0 2px 0 rgba(0, 0, 0, 0.25);
  z-index: 0;
}

.crate-side {
  position: absolute;
  top: 0;
  bottom: 8%;
  width: 36px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.02) 42%, rgba(255, 255, 255, 0.2) 86%, rgba(0, 0, 0, 0.3)),
    var(--wood-tex) center / 220% auto;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 8px 16px rgba(0, 0, 0, 0.18);
  z-index: 8;
}
.crate-side.left { left: 0; border-radius: 8px 2px 2px 6px; }
.crate-side.right { right: 0; border-radius: 2px 8px 6px 2px; transform: scaleX(-1); }

.crate-front {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26%;
  border-radius: 4px 4px 8px 8px;
  z-index: 9;
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0) 0 27px,
      rgba(0, 0, 0, 0.5) 27px 29px,
      rgba(0, 0, 0, 0.18) 29px 31px,
      rgba(255, 255, 255, 0.12) 31px 33px,
      rgba(0, 0, 0, 0) 33px 34px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.2)),
    var(--wood-tex) center / cover;
  box-shadow:
    0 -2px 0 rgba(0, 0, 0, 0.28),
    0 22px 38px rgba(0, 0, 0, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.24);
}
.crate-front::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 5.5% 42%, rgba(20, 12, 6, 0.75) 0 2px, rgba(255, 255, 255, 0.22) 2px 3px, transparent 3.6px),
    radial-gradient(circle at 94.5% 42%, rgba(20, 12, 6, 0.75) 0 2px, rgba(255, 255, 255, 0.22) 2px 3px, transparent 3.6px);
  pointer-events: none;
}
.crate-front::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 24%;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.34)),
    var(--wood-tex) center / cover;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -3px 6px rgba(0, 0, 0, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.2);
}
.crate-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 20px;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.3)),
    var(--wood-tex) center / cover;
  box-shadow:
    0 3px 7px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  z-index: 1;
}

.crate-well::after {
  content: "Nothing here yet";
  position: absolute;
  left: 0;
  right: 0;
  top: 44%;
  text-align: center;
  color: var(--gray);
  font-size: 13px;
  letter-spacing: 0.02em;
  opacity: 0;
  z-index: 2;
  pointer-events: none;
}
.crate.empty .crate-well::after { opacity: 1; }

/* ---------------- overlays ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--white);
  display: flex;
  flex-direction: column;
  animation: overlayIn 0.28s var(--ease);
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 40px) 6px;
}
.overlay-title {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.035em;
}
.overlay .close { color: var(--black); }

.overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px clamp(18px, 4vw, 40px) 60px;
  -webkit-overflow-scrolling: touch;
}

/* segmented control */
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 10px clamp(18px, 4vw, 40px) 0;
  background: var(--paper);
  border-radius: 12px;
  align-self: flex-start;
}
.seg {
  border: 0;
  background: transparent;
  padding: 8px 20px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg.is-active {
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.overlay-body .segmented { margin-left: 0; }

/* ---------------- gallery ---------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: clamp(14px, 2vw, 28px);
}
.card {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: cardIn 0.4s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:hover .thumb { transform: scale(1.02); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2); }
.card:hover .card-play { opacity: 1; transform: none; }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.card-play svg { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)); }
.card.is-playing .card-play { opacity: 1; transform: none; }

.card-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: 12px; color: var(--gray); }

.empty-note {
  color: var(--gray);
  font-size: 15px;
  padding: 40px 0;
  text-align: center;
  grid-column: 1 / -1;
}

/* disc thumb for music in gallery */
.disc {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: repeating-radial-gradient(circle at 50% 50%, #111 0 3px, #1c1c1c 3px 5px, #0a0a0a 5px 8px);
  box-shadow: inset 0 0 0 3px #050505;
  display: flex;
  align-items: center;
  justify-content: center;
}
.disc::after {
  content: "";
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ---------------- admin ---------------- */

.gate, .upload { display: flex; flex-direction: column; gap: 18px; max-width: 460px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.field input {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 14px;
  background: var(--white);
  font-size: 15px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input[type="file"] { padding: 10px; }
.field input:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08); }

.btn {
  border: 0;
  background: var(--black);
  color: var(--white);
  padding: 13px 22px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: opacity 0.18s, transform 0.1s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.4; cursor: default; }

.gate-error, .upload-status { font-size: 13px; margin: 0; }
.gate-error { color: #c0392b; }
.upload-status { color: var(--gray); }
.upload-status.ok { color: #1a7f37; }
.upload-status.err { color: #c0392b; }

.admin-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 44px 0 14px;
  max-width: 720px;
}
.admin-list-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.link-btn { border: 0; background: transparent; color: var(--gray); font-size: 13px; text-decoration: underline; padding: 0; }

.admin-list { display: flex; flex-direction: column; max-width: 720px; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.admin-row:last-child { border-bottom: 1px solid var(--line); }
.admin-row .mini-thumb {
  width: 44px; height: 44px; border-radius: 5px; overflow: hidden; flex: 0 0 auto;
  background: var(--black); display: flex; align-items: center; justify-content: center;
}
.admin-row .mini-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-row .mini-thumb.audio { border-radius: 50%; }
.admin-row .mini-thumb.audio::after { content: ""; width: 34%; height: 34%; border-radius: 50%; background: var(--white); }
.admin-row .row-name { flex: 1; font-size: 14px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .row-meta { font-size: 12px; color: var(--gray); flex: 0 0 auto; }
.admin-row .row-del {
  border: 0; background: transparent; color: var(--gray); padding: 6px; border-radius: 8px; flex: 0 0 auto;
}
.admin-row .row-del:hover { color: #c0392b; background: rgba(0, 0, 0, 0.05); }

/* ---------------- player ---------------- */

.player {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 18px;
  background: rgba(0, 0, 0, 0.86);
  color: var(--white);
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  max-width: calc(100vw - 32px);
  animation: menuIn 0.25s var(--ease);
}
.player-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 260px; padding-right: 8px; }
.player-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.player-bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.24); overflow: hidden; }
.player-bar span { display: block; height: 100%; width: 0; background: var(--white); }
.player .icon-btn { color: var(--white); }
.player .icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  animation: menuIn 0.22s var(--ease);
}

/* ---------------- responsive ---------------- */

@media (max-width: 760px) {
  #home {
    padding-top: 96px;
    min-height: auto;
  }
  .hero { white-space: normal; }
  .crates {
    grid-template-columns: 1fr;
    gap: clamp(36px, 9vw, 64px);
    max-width: 420px;
  }
  .crate { max-width: 420px; }
}
