/* variables */
:root {
  /* palette */
  --darkest: #1F1F1F;
  --dark: #3B3B3B;
  --mid: #6B6B6B;
  --light: #B3B3B3;
  --lightest: #F7F7F7;

  /* typography */
  --font: "Zilla Slab", serif;
  --font-size-base: 16px;
  --font-size-h1: 32px;
  --font-size-h2: 24px;

  /* layout */
  --top-bar-h: 72px;
  --bottom-bar-h: 52px;
  --sidebar-w: 220px;
  --sidebar-pad: 16px;

  --platform-w: 420px;
  --platform-gap: 16px;
  --player-size: 32px;

  /* animation */
  --anim-dur: 0.6s;
  --anim-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

a {
  color: var(--lightest);
  text-decoration: none;
}

a:hover {
  color: var(--lightest);
}

::selection {
  background: var(--mid);
  color: var(--lightest);
}

/* base and background */
body {
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--light);
  background: var(--darkest);
  min-height: 100vh;
  overflow: hidden;
  scrollbar-color: var(--lightest) var(--darkest);
  scrollbar-width: thin;

  background-image: url("../rsrc/images/startile.png");
  background-size: 40px 40px;
  background-repeat: repeat;
  image-rendering: auto;
  animation: bg-drift 8s linear infinite;
}

@keyframes bg-drift {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 40px 40px;
  }
}

/* header */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  background: var(--dark);
  z-index: 100;
  overflow: hidden;
  animation: slide-down var(--anim-dur) var(--anim-ease) both;
}

@keyframes slide-down {
  from {
    transform: translateY(-100%);
  }

  to {
    transform: translateY(0);
  }
}

#top-bar-inner {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
  padding: 0 var(--sidebar-pad);
  position: relative;
  z-index: 2;
}

#site-title {
  font-size: var(--font-size-h1);
  line-height: 1;
  color: var(--lightest);
  font-weight: normal;
  flex-shrink: 0;
}

#top-nav {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

#top-nav a {
  color: var(--light);
  font-size: 14px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-top-left-radius: 12px;
  transition: all 0.2s;
}

#top-nav a:hover,
#top-nav a.nav-active {
  color: var(--lightest);
  border-color: var(--mid);
}

#top-nav a.nav-active {
  border-color: var(--lightest);
  color: var(--lightest);
}

#cover-art-strip {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.cover-tile {
  width: 100%;
  height: 100%;
  background: url("../rsrc/images/startile.png") repeat;
  background-size: 40px 40px;
  image-rendering: auto;
  opacity: 0.08;
  animation: bg-drift 3s linear infinite;
}

/* layout and sidebar */
#layout {
  position: fixed;
  top: var(--top-bar-h);
  bottom: var(--bottom-bar-h);
  left: 0;
  right: 0;
  display: flex;
}

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  background: var(--dark);
  border-right: 1px solid var(--mid);
  padding: var(--sidebar-pad);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--mid) var(--dark);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slide-left var(--anim-dur) var(--anim-ease) both;
  z-index: 10;
}

@keyframes slide-left {
  from {
    transform: translateX(calc(var(--sidebar-w) * -1));
  }

  to {
    transform: translateX(0);
  }
}

#avatar-wrap {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

#avatar {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid var(--mid);
  outline: 2px solid var(--darkest);
  transition: all 0.2s;
}

#avatar:hover {
  border-color: var(--lightest);
  outline-color: var(--light);
}

#avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

#profile h1 {
  font-size: var(--font-size-h1);
  line-height: 1;
  font-weight: normal;
  color: var(--lightest);
  text-align: center;
}

.tagline {
  font-size: 12px;
  color: var(--mid);
  text-align: center;
  margin-top: 4px;
}

#bio {
  font-size: 13px;
  color: var(--mid);
  border-top: 1px dotted var(--mid);
  border-bottom: 1px dotted var(--mid);
  padding: 8px 0;
  margin: 8px 0;
}

.bio-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--light);
}

#sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#sidebar-nav a {
  display: block;
  background: var(--darkest);
  color: var(--light);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 2px;
  text-align: center;
  transition: all 0.2s;
}

#sidebar-nav a:hover {
  background: var(--dark);
  border-color: var(--lightest);
  color: var(--lightest);
}

#stamps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

#stamps img {
  image-rendering: auto;
  border: 1px solid var(--mid);
}

/* player and stage wrap */
#stage-wrap {
  flex: 1;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: var(--lightest) var(--darkest);
  scrollbar-width: thin;
  position: relative;
  cursor: default;
}

#stage {
  display: flex;
  align-items: flex-end;
  gap: var(--platform-gap);
  padding: 0 var(--platform-gap);
  height: 100%;
  min-width: max-content;
  position: relative;
}

#player {
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--player-size);
  height: var(--player-size);
  z-index: 20;
  pointer-events: none;
  overflow: visible;
}

#player-sprite {
  display: block;
  line-height: 0;
  font-size: 0;
}

#player-sprite canvas {
  display: block;
  image-rendering: pixelated;
}

/* postcards (platforms? TODO: add platform mech) */
.platform {
  flex-shrink: 0;
  width: var(--platform-w);
  align-self: flex-end;
  position: relative;
  animation: platform-rise var(--anim-dur) var(--anim-ease) both;
}

.platform:nth-child(1) {
  animation-delay: 0.05s;
}

.platform:nth-child(2) {
  animation-delay: 0.12s;
}

.platform:nth-child(3) {
  animation-delay: 0.19s;
}

.platform:nth-child(4) {
  animation-delay: 0.26s;
}

.platform:nth-child(5) {
  animation-delay: 0.33s;
}

.platform:nth-child(6) {
  animation-delay: 0.40s;
}

@keyframes platform-rise {
  from {
    transform: translateY(32px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.post-card {
  background: var(--darkest);
  border-top: 4px solid var(--mid);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../rsrc/images/startile.png") repeat;
  background-size: 40px 40px;
  opacity: 0;
  image-rendering: auto;
  transition: opacity 0.4s;
  pointer-events: none;
}

.platform.active .post-card,
.platform:focus-within .post-card {
  border-color: var(--light);
  background: var(--darkest);
}

.platform.active .post-card::before {
  animation: bg-drift 3s linear infinite;
}

.post-card img {
  max-width: 100%;
  border-radius: 4px;
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--mid);
  padding-bottom: 8px;
  font-size: 13px;
}

.post-author {
  color: var(--lightest);
}

time {
  color: var(--mid);
  font-size: 11px;
  font-style: italic;
}

.post-card h2 {
  font-size: var(--font-size-h2);
  line-height: 1.2;
  font-weight: normal;
  color: var(--lightest);
}

.post-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--light);
}

.post-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--mid);
  padding-top: 8px;
  margin-top: auto;
}

.post-tags a {
  font-size: 12px;
  color: var(--lightest);
  background: var(--darkest);
  border: 1px solid var(--light);
  border-radius: 2px;
  padding: 2px 6px;
  transition: all 0.15s;
}

.post-tags a:hover {
  background: var(--lightest);
  color: var(--darkest);
}

.readmore summary {
  color: var(--lightest);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
  list-style: none;
}

.readmore summary::-webkit-details-marker {
  display: none;
}

.readmore[open] summary {
  color: var(--light);
}

.platform.hidden {
  display: none;
}

/* bottom bar */
#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-h);
  background: var(--darkest);
  border-top: 2px solid var(--light);
  z-index: 100;
  animation: slide-up var(--anim-dur) var(--anim-ease) both;
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

#bottom-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  gap: 24px;
}

#tag-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}

#tag-filters::-webkit-scrollbar {
  display: none;
}

.tag-label {
  color: var(--mid);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tag-btn {
  background: var(--darkest);
  color: var(--light);
  border: 1px solid var(--mid);
  border-radius: 2px;
  padding: 3px 8px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tag-btn:hover {
  border-color: var(--lightest);
  color: var(--lightest);
}

.tag-btn.active {
  background: var(--lightest);
  border-color: var(--lightest);
  color: var(--darkest);
}

#hud {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

#status-readout {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--mid);
}

.hud-label {
  color: var(--lightest);
  font-size: 11px;
}

#hud-post-title {
  color: var(--light);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* image lightbox modal */
.post-card img {
  cursor: zoom-in;
  transition: filter 0.2s;
}

.post-card img:hover {
  filter: brightness(1.1);
}

#image-modal {
  position: fixed;
  inset: 0;
  background: rgba(25, 25, 25, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
  cursor: zoom-out;
}

#image-modal.modal-hidden {
  opacity: 0;
  pointer-events: none;
}

#modal-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: px solid var(--mid);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

#image-modal.modal-hidden #modal-image {
  transform: scale(0.95);
}

#modal-close {
  position: absolute;
  top: 24px;
  right: 32px;
  font-size: 40px;
  line-height: 1;
  color: var(--light);
  cursor: pointer;
  transition: color 0.2s;
}

#modal-close:hover {
  color: var(--lightest);
}

/* queeries */
@media (max-width: 640px) {
  :root {
    --top-bar-h: 112px;
    --bottom-bar-h: 80px;
    --sidebar-w: 0px;
    --platform-w: 88vw;
    --platform-gap: 16px;
  }

  body {
    overflow: hidden;
  }

  #top-bar-inner {
    flex-wrap: wrap;
    align-content: center;
    row-gap: 4px;
    padding: 8px var(--sidebar-pad);
  }

  #top-nav {
    gap: 8px;
  }

  #sidebar,
  #player,
  #controls-hint {
    display: none;
  }

  #bottom-inner {
    flex-wrap: wrap;
    row-gap: 4px;
    align-content: center;
    padding: 8px 12px;
  }
}

/* desktop (>= 641px) */

@media (min-width: 641px) and (max-width: 1024px) {
  :root {
    --sidebar-w: 180px;
    --platform-w: 340px;
  }
}
