* {
  box-sizing: border-box;
}

:root {
  --bg: #0f0f10;
  --card-bg: #1a1a1c;
  --text: #efeff1;
  --accent: #3b82f6;
  --border: #2d2d30;
  --input-bg: #252529;
}

body,
html {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Inter", sans-serif;
  display: flex;
  flex-direction: column;
}

body {
  width: 90%;
  margin: 0 auto;
}

header {
  flex-shrink: 0;
  padding: 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);

  align-items: center;
  display: flex;
  justify-content: space-between;
}

header h1 {
  margin: 0;
}

header a {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: start;
  padding: 1.25rem 0;
  gap: 0.625rem;
}

input,
select,
button {
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 0.625rem 0.9375rem;
  outline: none;
  color: #d7d5d5;
  border-radius: 0.3rem;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

input[type="text"] {
  flex: 1;
  min-width: 12.5rem;
}

select {
  cursor: pointer;
}

select:disabled,
select[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--card-bg);
  filter: blur(0.5px);
}

button {
  background: var(--accent);
  border: none;
  font-weight: bold;
  cursor: pointer;
}

button:hover {
  background: #2563eb;
}

button:active {
  transform: scale(0.98);
}

.container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: 1.25rem;
}

.post {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  position: relative;
}

.post-score {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  margin: 0;
  padding: 0.25rem 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffd700;
  font-weight: bold;
  border-radius: 0.25rem;
  text-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 10;
}

.post:hover p {
  opacity: 1;
  visibility: visible;
}

.post img {
  width: 100%;
  height: 15.625rem;
  object-fit: cover;
  display: block;
  filter: brightness(100%);
  border-color: transparent;
  transition: filter 0.3s ease, border-color 0.3s ease;
}

.post img:hover {
  filter: brightness(50%);
}

.post-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1rem;
  width: 75%;
  margin: 0 auto;
}

.post-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  max-width: 850px;
}

.post-content-wrapper video,
.post-content-wrapper img {
  max-width: 100%;
  border-radius: 0.75rem;
  box-shadow: 0 0.625rem 2.5rem rgba(0, 0, 0, 0.6);
  align-self: center;
}

.post-content-wrapper img {
  max-height: 80vh;
  object-fit: contain;
}

.post-info p {
  overflow: scroll;
}

.post-content-wrapper .post-meta {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 0.5rem 1.25rem;
  margin: 0.625rem 0;
}

.post-meta p {
  margin: 0;
  overflow: visible;
}

.post-meta-source {
  grid-column: 1 / -1;
}

.post-meta-source a {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.post-meta strong {
  color: var(--accent);
  margin-right: 0.3125rem;
}

.post-meta a {
  color: var(--accent);
  text-decoration: none;
}

.post-meta a:hover {
  text-decoration: underline;
}

.post-content-wrapper .image-container {
  display: flex;
  justify-content: center;
  width: 100%;
  align-self: center;
}

.post-info p,
.post-info details {
  width: 100%;
  max-width: 850px;
}

.post-info a[href*="tags"] {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  margin: 0.1875rem;
  background: var(--input-bg);
  color: #ccc;
  text-decoration: none;
  border-radius: 1.25rem;
  font-size: 0.85rem;
}

.post-info a[href*="tags"]:hover {
  background: var(--accent);
  color: white;
}

details {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 0.9375rem;
  cursor: pointer;
}

details:first-of-type {
  margin-bottom: 1rem;
}

.pagination {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  display: flex;
  gap: 3rem;
}

.arrow,
.back-to-top {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.arrow {
  background-color: #405dcc;
}

.prev-page {
  transform: rotate(-90deg);
}

.next-page {
  transform: rotate(90deg);
}

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: rgba(10, 10, 10, 0.85);
}

.back-to-top:hover {
  opacity: 1;
}

.back-to-top img {
  width: 1.25rem;
  height: 1.25rem;
  filter: invert(1);
}

footer {
  margin-top: 1rem;
}

@media (max-width: 48rem) {
  .container {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .post-content-wrapper img {
    max-height: 60vh;
  }

  body {
    padding: 0.5rem;
    width: 100%;
  }

  .search-form {
    flex-direction: column;
  }

  .post-info {
    width: 100%;
  }

  .post-meta-source {
    grid-column: auto;
  }
}

pre {
  background-color: #000000;
  color: #a6accd;
  padding: 1.25rem;
  border-radius: 0.625rem;
  border: 1px solid var(--border);
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: inset 0 0.125rem 0.625rem rgba(0, 0, 0, 0.5);
  margin-top: 0.625rem;
}

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

pre:hover {
  cursor: text;
}