:root {
  --wall: #dccaa3;
  --wall-deep: #cab687;
  --wall-light: #e8dabb;
  --ink: #2a1c0f;
  --muted: #6d5a3c;
  --ochre: #3c2612;
  --accent: #8a4620;
  --accent-ink: #fbf3e4;
  --ember: #9c3b16;
  --mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--wall);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;

  /* Cave wall: a light limestone base, a very slight grain, and a soft
     vignette so the center (where the marks live) reads a touch brighter
     than the edges. */
  background-color: var(--wall);
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(255, 250, 230, 0.5), transparent 55%),
    radial-gradient(ellipse at 50% 115%, rgba(60, 38, 18, 0.16), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed, fixed, fixed;
}

a {
  color: inherit;
}

/* ---------------------------------------------------------------------- */
/* Top bar                                                                  */
/* ---------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  background: linear-gradient(var(--wall-deep) 40%, rgba(202, 182, 135, 0.75) 80%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.mark {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(42, 28, 15, 0.28);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.filter:hover,
.filter:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
  outline: none;
}

.filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

/* A real link out of the site, not a filter toggle -- styled like the
   pills but marked with a small external-link arrow, and separated from
   the edition buttons with a bit of extra space. */
.about-link {
  margin-left: 0.5rem;
}

.about-link::after {
  content: " \2197";
}

.back {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.back:hover,
.back:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------------------------------------------------------------------- */
/* Gallery grid                                                             */
/* ---------------------------------------------------------------------- */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 2.25rem 1.4rem;
  padding: 3rem 0 3.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
}

.card:focus-visible {
  outline: 1px dashed var(--muted);
  outline-offset: 6px;
}

.frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
}

/* The "pop" shape stays exactly the wall's own color -- it should never
   read as a distinct colored plaque, only as a shadow cast by something
   the same color as the rock lifting slightly off of it. */
.plaque-shadow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: var(--wall);
  filter: drop-shadow(0 10px 14px rgba(35, 22, 10, 0.38)) drop-shadow(0 2px 4px rgba(35, 22, 10, 0.28));
  opacity: 0;
  transform: translateY(5px) scale(0.96);
  transform-origin: center;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

/* Never transformed on hover -- it must stay pixel-registered to the
   plaque-shadow shape at all times. Only the shadow moves/fades; the
   artwork itself is perfectly static so the two can never drift apart. */
.engrave {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  clip-path: url(#plaque-clip);
  transition: filter 0.35s ease;
}

.card:hover .plaque-shadow,
.card:focus-visible .plaque-shadow {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.card:hover .engrave,
.card:focus-visible .engrave {
  filter: drop-shadow(0 2px 3px rgba(35, 22, 10, 0.2));
}

.tag {
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  opacity: 0.9;
}

/* ---------------------------------------------------------------------- */
/* Detail page                                                             */
/* ---------------------------------------------------------------------- */
.detail {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 4vw, 2.5rem) 1rem;
  display: grid;
  grid-template-columns: minmax(200px, 360px) 1fr;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: center;
}

.detail-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.detail-frame .plaque-shadow {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: drop-shadow(0 14px 18px rgba(35, 22, 10, 0.4)) drop-shadow(0 3px 6px rgba(35, 22, 10, 0.3));
}

.detail-frame .engrave {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 4px rgba(35, 22, 10, 0.22));
}

.detail-info {
  max-width: 52ch;
}

.detail-info h1 {
  font-family: var(--serif);
  font-size: 2rem;
  letter-spacing: 0.01em;
  margin: 0 0 1.1rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.detail-info h1 .meta {
  display: block;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.5rem;
}

.mechanism {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.7;
  margin: 0 0 1.2rem;
}

.description {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.75;
  margin: 0;
}

.description:empty {
  display: none;
}

.prevnext {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 2rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.prevnext-link {
  text-decoration: none;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}

.prevnext-link:hover,
.prevnext-link:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

@media (max-width: 700px) {
  .detail {
    grid-template-columns: 1fr;
    text-align: center;
    padding-top: 1.5rem;
  }

  .detail-frame {
    max-width: 280px;
    margin: 0 auto;
  }

  .detail-info {
    max-width: none;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 1.75rem 1rem;
  }
}
