:root {
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #111;
}

button, input { font: inherit; color: inherit; }

:focus { outline: none; }

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

body[data-theme="formula"]   { --ink: #1a4fd0; --paper: #ffffff; --accent: #1a4fd0; }
body[data-theme="plumbing"]  { --ink: #6a2d86; --paper: #ffffff; --accent: #6a2d86; }
body[data-theme="catalog"]   { --ink: #5f7d2c; --paper: #f3f3f1; --accent: #e10600; }
body[data-theme="lightleak"] { --ink: #fff8f2; --paper: #3a120c; --accent: #ffe7c2; }
body[data-theme="basement"]  { --ink: #f4efe6; --paper: #1a120e; --accent: #e23b2f; }
body[data-theme="blank"]     { --ink: #2a2622; --paper: #e6e0d4; --accent: #2a2622; }
body[data-theme="receiver"]  { --ink: #c4161c; --paper: #d5d3cc; --accent: #2a4b9b; }
body[data-theme="ribs"]      { --ink: #d7e37a; --paper: #c41212; --accent: #fff4f2; }
body[data-theme="forest"]    { --ink: #efe6c8; --paper: #050505; --accent: #efe6c8; }
body[data-theme="concrete"]  { --ink: #1c1a17; --paper: #b7b3aa; --accent: #1c1a17; }

.deck {
  height: 100vh;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.deck::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  flex: 0 0 100vw;
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 2vw;
  padding: 4vh 6vw 7.5rem;
  align-items: center;
}

.band {
  margin: 0 0 0.35rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  max-width: 100%;
  font-size: clamp(1.8rem, 3.6vw, 3.5rem);
  line-height: 0.95;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.kicker {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.blurb {
  margin: 0.8rem 0 1rem;
  max-width: 36rem;
  line-height: 1.35;
}

.blurb:empty,
.kicker:empty { display: none; }

.media {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
}

.tracks {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(46vh, 28rem);
  overflow: auto;
}

.track {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0.38rem 0;
  cursor: pointer;
}

.track__n {
  flex: 0 0 1.8rem;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.track.is-on .track__t {
  box-shadow: inset 0 -2px 0 currentColor;
}

.playbar {
  position: absolute;
  left: 6vw;
  right: 6vw;
  bottom: 4.4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem 1rem;
  align-items: center;
}

.playbar__now {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 1.2em;
}

.playbar__time { font-variant-numeric: tabular-nums; }

.playbar__bar {
  grid-column: 1 / -1;
  height: 3px;
  background: color-mix(in srgb, currentColor 28%, transparent);
  cursor: pointer;
}

.playbar__fill {
  height: 100%;
  width: 0;
  background: currentColor;
}

.edge {
  position: fixed;
  top: 50%;
  z-index: 5;
  width: 3rem;
  height: 3rem;
  margin-top: -1.5rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  color: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.edge--prev { left: 1rem; }
.edge--next { right: 1rem; }

.rail {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 0.55rem;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.1rem 0.15rem;
  width: min(1040px, calc(100vw - 7rem));
  color: var(--ink);
}

.rail::-webkit-scrollbar { display: none; }

.rail button {
  background: transparent;
  border: 0;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.45;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rail button.is-here { opacity: 1; box-shadow: inset 0 -2px 0 currentColor; }
.rail button.is-playing { opacity: 1; }

/* formula — лист с молекулой */
.slide[data-theme="formula"] {
  background: #fff;
  color: #161616;
  font-family: "Manrope", sans-serif;
}
.slide[data-theme="formula"] .band,
.slide[data-theme="formula"] h1,
.slide[data-theme="formula"] .kicker { color: #1a4fd0; font-family: "Manrope", sans-serif; font-weight: 700; }
.slide[data-theme="formula"] .track { border-bottom: 1px solid #d9e2f5; }

/* plumbing — белый каталог фитингов */
.slide[data-theme="plumbing"] {
  background: #fff;
  color: #6a2d86;
  font-family: "Unbounded", sans-serif;
}
.slide[data-theme="plumbing"] .media img { width: min(46vw, 640px); }

/* catalog — студия, труба, оливковый трафарет */
.slide[data-theme="catalog"] {
  background: #f3f3f1;
  color: #5f7d2c;
  font-family: "Russo One", sans-serif;
}
.slide[data-theme="catalog"] .kicker { color: #e10600; }
.slide[data-theme="catalog"] .playbar__fill,
.slide[data-theme="catalog"] .track.is-on .track__t { background: none; }
.slide[data-theme="catalog"] .playbar__fill { background: #e10600; }
.slide[data-theme="catalog"] .track.is-on .track__t { box-shadow: inset 0 -2px 0 #e10600; }
.slide[data-theme="catalog"] .media img {
  width: min(50vw, 760px);
  align-self: flex-start;
  margin-top: 6vh;
}

/* light leak — кадр на весь экран */
.slide[data-theme="lightleak"] {
  display: block;
  padding: 0;
  color: #fff8f2;
  font-family: "Manrope", sans-serif;
}
.slide[data-theme="lightleak"] .media {
  position: absolute;
  inset: 0;
}
.slide[data-theme="lightleak"] .media img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}
.slide[data-theme="lightleak"] .copy {
  position: absolute;
  left: 4vw;
  right: 28vw;
  bottom: 7.5rem;
  text-shadow: 0 2px 16px #1a0906;
}
.slide[data-theme="lightleak"] .playbar { color: #fff8f2; text-shadow: 0 1px 8px #1a0906; }

/* basement — полароид и маркер */
.slide[data-theme="basement"] {
  background: #140e0c;
  color: #f4efe6;
  font-family: "Permanent Marker", cursive;
}
.slide[data-theme="basement"] .media img {
  width: min(42vw, 520px);
  max-height: 68vh;
  object-fit: cover;
  transform: rotate(-3.5deg);
  border: 14px solid #efece4;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
}
.slide[data-theme="basement"] .track.is-on .track__n { color: #e23b2f; }

/* blank — пустая пластинка */
.slide[data-theme="blank"] {
  background:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,0.04), transparent 40%),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.025) 4px),
    #e6e0d4;
  color: #2a2622;
  font-family: "Special Elite", serif;
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
}
.slide[data-theme="blank"] .media { display: none; }
.slide[data-theme="blank"] h1 { font-size: clamp(3rem, 8vw, 7rem); }
.slide[data-theme="blank"] .tracks { max-height: none; }

/* receiver — стена и панель */
.slide[data-theme="receiver"] {
  display: block;
  padding: 0;
  color: #f2f0ea;
  font-family: "Russo One", sans-serif;
}
.slide[data-theme="receiver"] .media { position: absolute; inset: 0; }
.slide[data-theme="receiver"] .media img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center 62%;
}
.slide[data-theme="receiver"] .copy {
  position: absolute;
  top: 4vh;
  left: 4vw;
  width: min(34vw, 28rem);
}
.slide[data-theme="receiver"] .band { color: #c4161c; text-shadow: 2px 2px 0 #141414; }
.slide[data-theme="receiver"] h1 { color: #2a4b9b; text-shadow: 2px 2px 0 #141414; }
.slide[data-theme="receiver"] .blurb,
.slide[data-theme="receiver"] .tracks { color: #1a1a1a; text-shadow: none; }
.slide[data-theme="receiver"] .playbar { color: #1a1a1a; }

/* ribs — макро гофры */
.slide[data-theme="ribs"] {
  background: repeating-linear-gradient(
    to bottom,
    #ff564e 0 8px,
    #ef241c 8px 14px,
    #b10d0d 14px 19px,
    #7d090c 19px 23px,
    #c41212 23px 30px,
    #ff2a22 30px 36px
  );
  color: #d7e37a;
  font-family: "Russo One", sans-serif;
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
}
.slide[data-theme="ribs"] .media { display: none; }
.slide[data-theme="ribs"] h1,
.slide[data-theme="ribs"] .band,
.slide[data-theme="ribs"] .track {
  -webkit-text-stroke: 1px #3c4a10;
}
.slide[data-theme="ribs"] .tracks { width: min(40rem, 88vw); }

/* forest — черное поле и квадрат */
.slide[data-theme="forest"] {
  background: #050505;
  color: #efe6c8;
  font-family: "Special Elite", serif;
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
  align-content: center;
}
.slide[data-theme="forest"] .media img {
  width: min(46vh, 70vw);
  height: min(46vh, 70vw);
  max-height: none;
  object-fit: cover;
}
.slide[data-theme="forest"] .copy { width: min(36rem, 88vw); }

/* concrete — голая стена, без пластинки */
.slide[data-theme="concrete"] {
  background:
    linear-gradient(90deg, transparent 18%, #c8b48a 18.2%, #c8b48a 18.5%, transparent 18.7%),
    linear-gradient(90deg, transparent 78%, #c8b48a 78.2%, #c8b48a 78.5%, transparent 78.7%),
    #b7b3aa;
  color: #1c1a17;
  font-family: "Manrope", sans-serif;
  grid-template-columns: 1fr;
  justify-items: center;
}
.slide[data-theme="concrete"] .media { display: none; }
.slide[data-theme="concrete"] .copy { width: min(36rem, 88vw); }

@media (max-width: 860px) {
  .slide {
    grid-template-columns: 1fr;
    align-content: start;
    padding: 4.5rem 1.2rem 8rem;
    gap: 1rem;
  }
  .media img { max-height: 34vh; }
  .slide[data-theme="catalog"] .media img { margin-top: 0; width: 100%; }
  .slide[data-theme="basement"] .media img { width: min(78vw, 420px); }
  .slide[data-theme="lightleak"] .copy,
  .slide[data-theme="receiver"] .copy {
    left: 1rem;
    right: 1rem;
    width: auto;
  }
  .slide[data-theme="receiver"] .copy { top: 4.2rem; }
  .playbar { left: 1.2rem; right: 1.2rem; }
  .edge { width: 2.4rem; height: 2.4rem; font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .deck { scroll-behavior: auto; }
}
