*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #efefef;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.ibn {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ibn__stage {
  --design-w: 1440;
  --design-h: 1024;
  --stage-pad-x: clamp(12px, 3.2vw, 48px);
  --stage-pad-top: clamp(18px, 9vh, 96px);
  --stage-pad-bottom: clamp(64px, 14vh, 148px);
  --paper-max-w: 754px;
  position: relative;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
}

.ibn__wallpaper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.ibn__wallpaper-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.8s ease-in-out;
  will-change: opacity;
}

.ibn__wallpaper-slide.is-active {
  opacity: 1;
  z-index: 1;
}

.ibn__wallpaper-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

@media (prefers-reduced-motion: reduce) {
  .ibn__wallpaper-slide {
    transition: none;
  }
}

.ibn__wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.08) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.2) 100%);
}

.ibn__paper-wrap {
  --paper-w: 754.069;
  --paper-h: 833;
  --paper-pad-x: 169;
  --paper-pad-y: 96;
  --paper-scale: min(
    var(--paper-max-w),
    calc(100vw - (var(--stage-pad-x) * 2)),
    calc((100svh - var(--stage-pad-top) - var(--stage-pad-bottom)) * var(--paper-w) / var(--paper-h))
  );
  z-index: 3;
  position: absolute;
  left: 50%;
  top: var(--stage-pad-top);
  width: var(--paper-scale);
  max-height: calc(100svh - var(--stage-pad-top) - var(--stage-pad-bottom));
  aspect-ratio: var(--paper-w) / var(--paper-h);
  transform: translateX(-50%);
  font-size: clamp(9px, calc((11.1 / var(--paper-w)) * var(--paper-scale)), 14.5px);
}

.ibn__paper-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  box-shadow:
    0 calc(572.247 / var(--paper-h) * 100%) calc(160.68 / var(--paper-h) * 100%) 0 rgba(48, 48, 48, 0),
    0 calc(366.464 / var(--paper-h) * 100%) calc(146.585 / var(--paper-h) * 100%) 0 rgba(48, 48, 48, 0.01),
    0 calc(205.783 / var(--paper-h) * 100%) calc(124.034 / var(--paper-h) * 100%) 0 rgba(48, 48, 48, 0.05),
    0 calc(91.616 / var(--paper-h) * 100%) calc(91.616 / var(--paper-h) * 100%) 0 rgba(48, 48, 48, 0.09),
    0 calc(22.552 / var(--paper-h) * 100%) calc(50.741 / var(--paper-h) * 100%) 0 rgba(48, 48, 48, 0.1);
}

.ibn__paper {
  position: absolute;
  display: block;
  width: 118.5%;
  height: 107.28%;
  max-width: none;
  left: -10.28%;
  top: -4.57%;
  object-fit: cover;
  object-position: center;
}

.ibn__paper-cloud {
  position: absolute;
  z-index: 2;
  left: calc((569 / var(--paper-w)) * 100%);
  top: calc((41 / var(--paper-h)) * 100%);
  width: calc((116.054 / var(--paper-w)) * 100%);
  height: auto;
  aspect-ratio: 116.054 / 54;
  pointer-events: none;
}

.ibn__paper-content {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding:
    calc((var(--paper-pad-y) / var(--paper-w)) * 100%)
    calc((var(--paper-pad-x) / var(--paper-w)) * 100%);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.ibn__paper-content::-webkit-scrollbar {
  display: none;
}

.ibn__manifesto {
  width: 100%;
  margin: auto 0;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 1em;
  font-weight: 400;
  font-style: normal;
  line-height: 1.42;
  color: #000;
  overflow-wrap: break-word;
  word-break: break-word;
}

.ibn__manifesto p {
  margin: 0;
}

.ibn__manifesto p + p {
  margin-top: 1.35em;
}

.ibn__manifesto p + p:last-child {
  margin-top: 1.65em;
}

.ibn__manifesto strong {
  font-weight: 700;
}

.ibn__manifesto.is-typing .ibn__typewriter-cursor {
  display: inline-block;
  width: 0.52em;
  height: 0.95em;
  margin-left: 0.05em;
  background: currentColor;
  vertical-align: text-bottom;
  transform: translateY(-0.06em);
  animation: ibn-typewriter-cursor 1s step-end infinite;
}

@keyframes ibn-typewriter-cursor {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ibn__manifesto.is-typing .ibn__typewriter-cursor {
    animation: none;
  }
}

.ibn__brand {
  z-index: 3;
  position: absolute;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 16px;
  border-radius: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
}

.ibn__brand-icon {
  width: auto;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

.ibn__brand-text {
  margin: 0;
  font-family: "Instrument Serif", serif;
  font-size: clamp(20px, 1.45vw + 12px, 24px);
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  color: #fff;
  white-space: nowrap;
}

.ibn__vinyl-btn {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
  border-radius: 4px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ibn__vinyl-btn:hover {
  opacity: 0.85;
}

.ibn__vinyl-btn:active {
  transform: scale(0.96);
}

.ibn__vinyl-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.ibn__view {
  position: absolute;
  inset: 0;
}

.ibn__view--home {
  z-index: 1;
}

.ibn__view--home:not(.is-active) {
  visibility: hidden;
  pointer-events: none;
}

.ibn__view--tv {
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.55s ease,
    visibility 0.55s ease;
}

.ibn__view--tv.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.ibn__tv-canvas {
  --tv-image-w: 1672;
  --tv-image-h: 941;
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, calc(100svh * var(--tv-image-w) / var(--tv-image-h)));
  height: max(100svh, calc(100vw * var(--tv-image-h) / var(--tv-image-w)));
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.ibn__tv-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
}

.ibn__tv-bg img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.ibn__tv-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.06);
}

.ibn__tv-screen {
  position: absolute;
  left: calc(670.4 / var(--tv-image-w) * 100%);
  top: calc(257.7 / var(--tv-image-h) * 100%);
  width: calc(322.2 / var(--tv-image-w) * 100%);
  height: calc(206.6 / var(--tv-image-h) * 100%);
  background: #000;
  border-radius: clamp(12px, 1.65vw, 24px);
  overflow: hidden;
}

.ibn__tv-screen iframe,
#ibn-tv-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.ibn__tv-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0 clamp(12px, 3.2vw, 48px);
  pointer-events: none;
}

.ibn__tv-footer > * {
  pointer-events: auto;
}

.ibn__tv-controls {
  position: absolute;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 420px);
}

.ibn__tv-playlist {
  width: 100%;
  max-height: min(52vh, 420px);
  overflow: hidden;
  border-radius: clamp(12px, 1.2vw, 16px);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.ibn__tv-playlist:not([hidden]) {
  display: block;
}

.ibn__tv-playlist-list {
  margin: 0;
  padding: clamp(6px, 0.6vw, 10px);
  list-style: none;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ibn__tv-playlist-item {
  margin: 0;
}

.ibn__tv-playlist-btn {
  display: block;
  width: 100%;
  padding: clamp(8px, 0.8vw, 12px) clamp(10px, 1vw, 14px);
  border: 0;
  border-radius: clamp(8px, 0.8vw, 10px);
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-family: "Space Mono", monospace;
  font-size: clamp(10px, 0.75vw + 8px, 13px);
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.ibn__tv-playlist-btn:hover,
.ibn__tv-playlist-btn:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}

.ibn__tv-playlist-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 1px;
}

.ibn__tv-playlist-btn.is-active {
  background: rgba(255, 255, 255, 0.2);
  font-weight: 700;
}

.ibn__tv-remote {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  padding: clamp(5px, 0.5vw, 8px) clamp(8px, 0.8vw, 12px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.ibn__tv-btn {
  display: grid;
  place-items: center;
  width: clamp(30px, 2.6vw, 42px);
  height: clamp(30px, 2.6vw, 42px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.ibn__tv-btn:hover,
.ibn__tv-btn:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.06);
  outline: none;
}

.ibn__tv-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.ibn__tv-btn--play {
  width: clamp(38px, 3.2vw, 52px);
  height: clamp(38px, 3.2vw, 52px);
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.ibn__tv-btn--play:hover,
.ibn__tv-btn--play:focus-visible {
  background: rgba(255, 255, 255, 0.34);
}

.ibn__tv-btn--play .ibn__tv-ico-pause {
  display: none;
}

.ibn__tv-btn--play.is-playing .ibn__tv-ico-play {
  display: none;
}

.ibn__tv-btn--play.is-playing .ibn__tv-ico-pause {
  display: block;
}

.ibn__tv-btn[data-action="playlist"].is-open {
  background: rgba(255, 255, 255, 0.28);
}

.ibn__tv-btn--manifesto {
  display: none;
}

.ibn__tv-btn--manifesto img {
  width: auto;
  height: clamp(14px, 3.8vw, 18px);
  display: block;
}

.ibn__tv-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 16px;
  border-radius: 8px;
  width: max-content;
  max-width: calc(100% - 24px);
}

.ibn__tv-brand-icon {
  height: 20px;
}

@media (prefers-reduced-motion: reduce) {
  .ibn__view--tv {
    transition: none;
  }

  .ibn__vinyl-btn {
    transition: none;
  }

  .ibn__tv-btn {
    transition: none;
  }
}

@media (max-width: 960px) {
  .ibn__paper-wrap {
    --paper-pad-x: 150;
    --paper-pad-y: 88;
    --stage-pad-top: clamp(16px, 7vh, 72px);
    --stage-pad-bottom: clamp(68px, 16vh, 136px);
    font-size: clamp(8.5px, calc((10.2 / var(--paper-w)) * var(--paper-scale)), 12.5px);
  }

  .ibn__manifesto p + p {
    margin-top: 1.2em;
  }

  .ibn__manifesto p + p:last-child {
    margin-top: 1.45em;
  }
}

@media (max-width: 600px) {
  .ibn__paper-wrap {
    --paper-pad-top: 72;
    --paper-pad-right: 110;
    --paper-pad-bottom: 68;
    --paper-pad-left: 132;
    --stage-pad-x: 10px;
    --stage-pad-top: clamp(12px, 4vh, 28px);
    --stage-pad-bottom: clamp(74px, 17vh, 130px);
    font-size: clamp(7.2px, calc((8.5 / var(--paper-w)) * var(--paper-scale)), 9.4px);
  }

  .ibn__paper-content {
    padding:
      calc((var(--paper-pad-top) / var(--paper-h)) * 100%)
      calc((var(--paper-pad-right) / var(--paper-w)) * 100%)
      calc((var(--paper-pad-bottom) / var(--paper-h)) * 100%)
      calc((var(--paper-pad-left) / var(--paper-w)) * 100%);
    -webkit-overflow-scrolling: touch;
  }

  .ibn__manifesto {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.34;
    color: #111;
    overflow-wrap: normal;
    word-break: normal;
  }

  .ibn__manifesto p {
    line-height: 1.34;
  }

  .ibn__manifesto p + p {
    margin-top: 1.05em;
  }

  .ibn__manifesto p + p:last-child {
    margin-top: 1.3em;
  }

  .ibn__tv-btn--manifesto {
    display: grid;
  }

  .ibn__tv-footer {
    display: none;
  }
}
