/* Global reset + single-font brutalist base. */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: only light;
}

/* Overall page layout and neutral gray background. */
body {
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.5;
  background: #9c9c9c;
  position: relative;
  color: #2b2b2b;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(200, 200, 200, 0.28) 35%,
      rgba(225, 225, 225, 0.4) 50%,
      rgba(200, 200, 200, 0.28) 65%,
      transparent 100%
    ),
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(210, 210, 210, 0.22) 30%,
      rgba(230, 230, 230, 0.34) 50%,
      rgba(210, 210, 210, 0.22) 70%,
      transparent 100%
    ),
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(195, 195, 195, 0.2) 30%,
      rgba(220, 220, 220, 0.32) 50%,
      rgba(195, 195, 195, 0.2) 70%,
      transparent 100%
    );
  background-repeat: no-repeat;
  background-size: 980px 64px, 1120px 64px, 900px 64px;
  background-position: -30% 18%, 30% 55%, 0% 82%;
  opacity: 0.16;
  animation: drift-pills 78s ease-in-out infinite;
  filter: blur(3.6px);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(
      120% 120% at -40% 25%,
      rgba(176, 196, 205, 0.28),
      transparent 76%
    ),
    radial-gradient(
      120% 120% at 140% 60%,
      rgba(166, 160, 196, 0.28),
      transparent 76%
    );
  opacity: 0.32;
  animation: drift-glow 60s ease-in-out infinite alternate;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: 16px;
  font-weight: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

a {
  color: inherit;
  text-decoration: underline;
}

ul {
  list-style: none;
  padding-left: 0;
}

li::before {
  content: "~ ";
}

code {
  font-family: "Times New Roman", Times, serif;
}

.site-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.site-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.logo {
  font-weight: normal;
}

/* Grid tiles with square cells on desktop. */
.sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  grid-auto-rows: minmax(0, 1fr);
  grid-auto-flow: dense;
  position: relative;
}

.sections.is-physics {
  display: block;
}

/* Each tile is a square viewport for scrolling content. */
.section {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: transform 0.3s ease;
  cursor: grab;
  pointer-events: none;
}

.section.is-dragging {
  cursor: grabbing;
}

/* Hide tiles until JS finishes hydration. */
body.is-loading .section {
  opacity: 1;
}

.section--empty {
  padding: 0;
  min-height: 0;
}

/* Helium-like hover/press float. */
.section.is-float {
  transform: translateY(-8px);
  animation: helium-bob 3.5s ease-in-out infinite;
}

/* Content block, padded to create the looping gap. */
.section-content {
  column-count: 1;
  column-gap: 0;
  pointer-events: auto;
  padding: 6px 0;
  opacity: 0;
  animation: content-fade 1.6s ease forwards;
  animation-delay: 0.6s;
}

.section-content--image {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0;
  pointer-events: auto;
}

.section-content--image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: grayscale(100%);
  transition: filter 0.4s ease;
}

.section--image:hover .section-content--image img {
  filter: grayscale(0%);
}

.section--image {
  padding: 0;
}

/* Helium bobbing motion. */
@keyframes helium-bob {
  from {
    transform: translateY(-6px);
  }
  to {
    transform: translateY(-10px);
  }
}

@keyframes footer-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes content-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes drift-pills {
  0% {
    background-position: -30% 18%, 30% 55%, 0% 82%;
  }
  50% {
    background-position: 120% 22%, 90% 50%, 70% 78%;
  }
  100% {
    background-position: -30% 18%, 30% 55%, 0% 82%;
  }
}

@keyframes drift-glow {
  0% {
    transform: translateX(-2%);
    opacity: 0.35;
  }
  50% {
    transform: translateX(0%);
    opacity: 0.55;
  }
  100% {
    transform: translateX(2%);
    opacity: 0.4;
  }
}

.section-content p,
.section-content ul {
  margin-bottom: 12px;
  break-inside: avoid;
}

.section-meta {
  display: flex;
  gap: 12px;
  text-transform: uppercase;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  opacity: 0;
}

body.is-ready .site-footer {
  animation: footer-fade 2.5s ease forwards;
  animation-delay: 2s;
}

body.image-overlay-open {
  overflow: hidden;
}

.image-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(160, 160, 160, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.image-overlay.is-open {
  opacity: 1;
}

.image-overlay img {
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  object-fit: contain;
  display: block;
}

@media (max-width: 900px) {
  .sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-content {
    column-count: 1;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 15px;
    padding: 8px;
  }

  .sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 420px) {
  body {
    padding: 16px;
    font-size: 16px;
  }

  .sections {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .section {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .section {
    animation: none;
    transform: none;
  }

  .section-content {
    animation: none;
    opacity: 1;
  }

  .site-footer {
    animation: none;
    opacity: 1;
  }

  body::before,
  body::after {
    animation: none;
  }
}
