/* xennialmemes.com
   Palette: dot-matrix paper, ink navy, rec-room teal, grape, highlighter.
   Type: Archivo set wide for display, Atkinson Hyperlegible for reading. */

:root {
  --paper: #eef0f3;
  --paper-2: #e2e5ea;
  --ink: #1d1f2b;
  --muted: #5d6070;
  --teal: #0e8c8c;
  --grape: #6b3fa0;
  --highlight: #f2e14c;
  --surface: #ffffff;
  --line: #c9cdd6;
  --focus: #6b3fa0;
  --display: 'Archivo', 'Arial Black', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gap: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15161f;
    --paper-2: #1f2130;
    --ink: #eceef4;
    --muted: #a3a7b8;
    --teal: #3cc2c2;
    --grape: #a98ae0;
    --surface: #1f2130;
    --line: #353849;
    --focus: #f2e14c;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--body);
}

[hidden] {
  display: none !important;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration-color: var(--teal);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--highlight);
  color: #1d1f2b;
  font-weight: 700;
}
.skip:focus {
  top: 8px;
}

/* ---- Masthead ------------------------------------------------------------ */

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.masthead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px 16px 10px;
}

.wordmark {
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 125%;
  font-size: clamp(1.35rem, 3.6vw, 2.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
}

.band {
  display: block;
  width: 100%;
  height: 22px;
}

/* ---- Topic links --------------------------------------------------------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

main > .tags {
  max-width: 1600px;
  margin: 18px auto 14px;
  padding: 0 16px;
}

.tags a {
  padding: 3px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  background: var(--surface);
}
.tags a:hover {
  background: var(--ink);
  color: var(--paper);
}
.tags a[aria-current='page'] {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.page-title {
  max-width: 1600px;
  margin: 28px auto 0;
  padding: 0 16px;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 118%;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.1;
}

/* "All topics" closes the row and reads as a way out, not another tag. */
.tags a.tags-all {
  border-style: dashed;
  background: transparent;
}

/* ---- Tag pages and the topics index ---------------------------------------- */

.tag-head {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 16px;
}
.tag-head .page-title {
  margin-top: 6px;
  padding: 0;
}
.tag-head .page-title:first-child {
  margin-top: 28px;
}
.tags-lead {
  align-self: center;
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.875rem;
}
.crumbs {
  margin: 26px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}
.crumbs span {
  margin: 0 4px;
}
.tag-intro {
  max-width: 62ch;
  margin: 10px 0 0;
  font-size: 1.125rem;
}

.topic-filter {
  max-width: 420px;
  margin: 22px 0 6px;
}
.topic-filter label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.topic-filter input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 10px 12px;
}
.topic-filter input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 30%, transparent);
}

.topics {
  max-width: 1600px;
  margin: 18px auto 0;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 28px 36px;
  align-items: start;
}

.topic-group {
  border-top: 3px solid var(--ink);
  padding-top: 10px;
}
.topic-group h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
  font-size: 1.2rem;
}
.topic-group h2 .count {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}

/* Size carries how many memes a tag has. */
.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
}
.topic-list a {
  text-decoration-color: transparent;
}
.topic-list a:hover {
  text-decoration-color: var(--teal);
}
.topic-list .n {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--body);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.topic-list .w1 {
  font-size: 1rem;
}
.topic-list .w2 {
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 112%;
  font-size: 1.3rem;
}
.topic-list .w3 {
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 125%;
  font-size: 1.75rem;
  line-height: 1.15;
}

/* ---- More like this ------------------------------------------------------- */

.related {
  margin-top: 48px;
}
.related h2 {
  width: calc(100% - 32px);
  max-width: 1568px;
  margin: 0 auto 14px;
  padding: 18px 0 0;
  border-top: 2px solid var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
  font-size: 1.4rem;
}

/* ---- Mosaic -------------------------------------------------------------- */

.mosaic {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 16px;
  columns: 230px;
  column-gap: var(--gap);
}

/* JS replaces CSS columns with shortest-first placement. */
.mosaic.is-js {
  columns: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}
.mosaic-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.tile {
  position: relative;
  display: block;
  margin: 0 0 var(--gap);
  break-inside: avoid;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-2);
  aspect-ratio: var(--ar);
}
.mosaic.is-js .tile {
  margin: 0;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-title {
  position: absolute;
  inset: auto 0 0 0;
  padding: 22px 10px 8px;
  background: linear-gradient(to top, rgba(29, 31, 43, 0.92), rgba(29, 31, 43, 0));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  opacity: 0;
}
.tile:hover .tile-title,
.tile:focus-visible .tile-title {
  opacity: 1;
}
.tile:focus-visible {
  outline-offset: -3px;
}

@media (hover: none) {
  .tile-title {
    display: none;
  }
}

.more {
  text-align: center;
  margin: 28px 0 8px;
}

.empty {
  max-width: 46ch;
  margin: 48px auto;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
}

/* ---- Buttons ------------------------------------------------------------- */

.button,
.button-quiet,
.fav {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
  padding: 9px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.button {
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
}
.button:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button-quiet {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--line);
}
.button-quiet:hover {
  border-color: var(--ink);
}

.link-button {
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

/* The favorite button is the one place the highlighter shows up. */
.fav {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
}
.fav svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.fav[aria-pressed='true'] {
  background: var(--highlight);
  color: #1d1f2b;
  border-color: #1d1f2b;
}
.fav[aria-pressed='true'] svg {
  fill: var(--grape);
  stroke: #1d1f2b;
}
.fav-count {
  font-variant-numeric: tabular-nums;
  padding-left: 8px;
  border-left: 1.5px solid currentColor;
}

/* ---- Post page ----------------------------------------------------------- */

.post {
  max-width: 1320px;
  margin: 24px auto 0;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr);
  gap: 36px;
  align-items: start;
}

.post-figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.post-figure img {
  margin: 0 auto;
  max-height: 85vh;
  width: auto;
}

.post-side {
  max-width: 60ch;
}

.post-title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 115%;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.post-desc {
  margin: 0 0 6px;
  font-size: 1.125rem;
}

.post-date {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.alt-text {
  margin: 20px 0;
  padding: 12px 14px;
  background: var(--surface);
  border-left: 4px solid var(--teal);
  border-radius: 0 6px 6px 0;
}
.alt-text summary {
  cursor: pointer;
  font-weight: 700;
}
.alt-text p {
  margin: 10px 0 0;
}

.comments h2 {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
  font-size: 1.3rem;
  margin: 28px 0 10px;
}
.comments h2 .count {
  color: var(--muted);
  font-weight: 700;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.comment-meta {
  margin: 0 0 2px;
  font-size: 0.9rem;
}
.comment-meta time {
  color: var(--muted);
  margin-left: 6px;
}
.comment-body {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.empty-small {
  color: var(--muted);
  margin: 4px 0 12px;
}

.comment-gate p {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--paper-2);
  border-radius: 6px;
}

.comment-form label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.95rem;
}

textarea,
input[type='text'],
.handle-dialog input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
textarea:focus,
.handle-dialog input:focus {
  border-color: var(--teal);
  outline: none;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.form-msg {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 6px 0 0;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 32px 0 0;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
  font-size: 0.95rem;
}
.post-nav a[rel='next'] {
  text-align: right;
}

.handle-dialog {
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 22px;
  max-width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
}
.handle-dialog::backdrop {
  background: rgba(29, 31, 43, 0.55);
}
.handle-dialog h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
}
.handle-dialog label {
  display: block;
  font-weight: 700;
  margin: 14px 0 6px;
}

.notfound {
  text-align: center;
  padding-bottom: 40px;
}
.notfound .page-title {
  max-width: 22ch;
}

/* ---- Footer -------------------------------------------------------------- */

.footer {
  max-width: 1600px;
  margin: 56px auto 0;
  padding: 20px 16px 36px;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 860px) {
  .post {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .post-figure {
    padding: 6px;
  }
}

@media (max-width: 520px) {
  :root {
    --gap: 6px;
  }
  .masthead-row {
    flex-wrap: wrap;
  }
  .mosaic,
  main > .tags {
    padding: 0 8px;
  }
  main > .tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
