/* ————— BCN Poster Wall ————— */

:root {
  --wall-dark: #3d3a36;
  --wall-mid: #4a463f;
  --ink: #1a1712;
  --paper: #f2ead8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  background-color: var(--wall-dark);
  /* orange brick — the standard backdrop for any category without its own texture */
  background-image: url("/textures/tb-orange-brick.jpg");
  background-size: 700px 545px;
  background-position: top center;
  background-repeat: repeat;
  background-attachment: scroll;
  min-height: 100vh;
  color: var(--paper);
  transition: background-image 0.25s ease;
}

/* category-specific backdrops — the shortlist (tb-*.jpg in textures/) */
body[data-cat="clubs"] {
  background-image: url("/textures/tb-black-brick.jpg");
  background-size: 1400px 530px;
  background-repeat: repeat;
}
body[data-cat="expos"] {
  background-image: url("/textures/tb-concrete.jpg");
  background-size: 1400px 1400px;
  background-repeat: repeat;
}
body[data-cat="escena"] {
  background-image: url("/textures/tb-white-brick-tile.jpg");
  background-size: 1400px 530px;
  background-repeat: repeat;
}
body[data-cat="kids"] {
  background-image: url("/textures/tb-kids3.jpg");
  background-size: 1400px 530px;
  background-repeat: repeat;
}
body[data-cat="music"] {
  background-image: url("/textures/tb-orange-brick-2.jpg");
  background-size: 700px 545px;
  background-repeat: repeat;
}
body[data-cat="festes"] {
  background-image: url("/textures/tb-natural-wood.jpg");
  background-size: 1400px 605px;
  background-repeat: repeat;
}
body[data-cat="cinema"] {
  background-image: url("/textures/tb-black-wood.jpg");
  background-size: 1400px 604px;
  background-repeat: repeat;
}
body[data-cat="visites"] {
  background-image: url("/textures/tb-stucco-tile.jpg");
  background-size: 2000px 1314px;
  background-repeat: repeat;
}
body[data-cat="lletres"] {
  background-image: url("/textures/tb-concrete-panels.jpg");
  background-size: 2100px 1377px;
  background-repeat: repeat;
}

/* ————— top bar: like a street sign bolted to the wall ————— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(20, 18, 15, 0.88);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid #c8371e;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; min-height: 52px; }
.brand-logo { height: 52px; width: auto; display: block; }
/* text wordmark (used for the ENGANXATS variant) — bold red block */
.brand-word {
  font-family: "Archivo Black", sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
  line-height: 1;
  color: #fff;
  background: #c8371e;
  padding: 6px 13px;
  text-transform: uppercase;
}
.brand-bcn {
  font-family: "Archivo Black", sans-serif;
  font-size: 26px;
  color: #fff;
  background: #c8371e;
  padding: 1px 8px;
  letter-spacing: 1px;
}
.brand-wall {
  font-family: "Anton", sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--paper);
}

/* one line: LOGO — CATEGORIES — FILTERS (dates) — SEARCH */
.brand { order: 1; flex: 0 0 auto; }

.filterbar {
  order: 2;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 16px;
  min-width: 0; /* let the children's own overflow-x scroll instead of the row wrapping */
}

/* categories: takes the stretch, scrolls sideways if it doesn't fit */
.filters {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 3px 0;
}
.filters::-webkit-scrollbar { display: none; }

/* dates ("filters"): fixed to its content, own scroll only if truly needed */
.filters.when {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  max-width: 34vw;
}
.filters.when::-webkit-scrollbar { display: none; }

.filter-chip { flex: 0 0 auto; }

.search {
  order: 3;
  flex: 0 0 auto;
  width: 210px;
}

.search input {
  width: 100%;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--paper);
  background: rgba(242, 234, 216, 0.08);
  border: 1.5px solid rgba(242, 234, 216, 0.4);
  border-radius: 999px;
  padding: 7px 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.search input::placeholder { color: rgba(242, 234, 216, 0.5); }
.search input:focus {
  border-color: var(--paper);
  background: rgba(242, 234, 216, 0.14);
}
.filter-chip {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 13px;
  border: 1.5px solid rgba(242, 234, 216, 0.4);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--paper); transform: translateY(-1px); }
.filter-chip.active {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

.filters.when { flex: none; }
.filters.when .filter-chip {
  border-color: rgba(200, 55, 30, 0.85);
}
.filters.when .filter-chip:hover { border-color: #e8443a; }
.filters.when .filter-chip.active {
  background: #c8371e;
  border-color: #c8371e;
  color: #fff;
}

/* "Destacats" — premium/paid placement chip at the start of the category row */
.filter-chip.destacats {
  border-color: #f5c518;
  color: #f5c518;
}
.filter-chip.destacats::before { content: "★ "; }
.filter-chip.destacats:hover { border-color: #ffd534; color: #ffd534; }
.filter-chip.destacats.active {
  background: #f5c518;
  border-color: #f5c518;
  color: var(--ink);
}

/* "La meva paret" — a mode toggle living at the end of the category row */
.filter-chip.meva { border-color: rgba(200, 55, 30, 0.85); }
.filter-chip.meva:hover { border-color: #e8443a; }
.filter-chip.meva.active {
  background: #c8371e;
  border-color: #c8371e;
  color: #fff;
}

/* ————— the wall ————— */
.wall {
  columns: 5 250px;
  column-gap: 32px;
  padding: 140px 40px 85px;
  max-width: 1700px;
  margin: 0 auto;
}

.loading { column-span: all; display: flex; justify-content: center; padding: 90px 0; }
.loading-poster {
  font-family: "Anton", sans-serif;
  font-size: 42px;
  line-height: 1.05;
  color: var(--ink);
  background: var(--paper);
  padding: 34px 40px;
  transform: rotate(-3deg);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: wobble 1.2s ease-in-out infinite alternate;
}
@keyframes wobble { from { transform: rotate(-3deg); } to { transform: rotate(2deg); } }

/* ————— posters ————— */
.poster {
  display: flex;
  flex-direction: column;
  aspect-ratio: 210 / 297; /* A4 */
  break-inside: avoid;
  margin: 0 0 32px;
  position: relative;
  text-decoration: none;
  color: inherit;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease, z-index 0s;
  filter: saturate(0.96);
  /* tight, barely-blurred shadow — paper sitting flush against the wall, not floating */
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.4);
}
.poster:hover {
  transform: rotate(0deg) scale(1.035);
  z-index: 30;
  filter: saturate(1.05) brightness(1.04);
  box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.45);
}

/* torn-paper alpha masks — posters age with their events.
   light: mask zoomed in so only edge nibbles show
   medium: the full tear
   heavy: two masks intersected, damage compounds */
.poster.torn,
.banner.torn {
  mask-image: var(--mask);
  mask-size: var(--msize, 100% 100%);
  mask-position: center;
  mask-repeat: no-repeat;
}
.poster.torn.heavy {
  mask-image: var(--mask), var(--mask2);
  mask-size: 100% 100%, 108% 108%;
  mask-composite: intersect;
}

/* paper also fades and yellows as it ages */
.poster.age1 { filter: saturate(0.92) brightness(0.98); }
.poster.age2 { filter: saturate(0.82) sepia(0.08) brightness(0.95); }
.poster.age3 { filter: saturate(0.68) sepia(0.18) brightness(0.9); }

/* real glued-paper texture overlay (scan picked per event, random flips) */
.poster .tex {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-size: 100% 100%;
  mix-blend-mode: multiply;
  opacity: 0.75;
  transform: scale(var(--fx, 1), var(--fy, 1));
  z-index: 3;
}

/* — RA flyer posters (photo) — */
.poster-img img {
  display: block;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  object-fit: cover;
  background: #222;
}
.poster-img .strip { flex: none; }
.poster-img .strip {
  background: var(--ink);
  color: var(--paper);
  padding: 9px 11px 11px;
}
.poster-img .strip .t {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.poster-img .strip .v {
  font-size: 10.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.65;
  margin-top: 4px;
}

/* — BCN typographic posters — */
.poster-type {
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23p)' opacity='0.07'/%3E%3C/svg%3E");
}
.poster-type .cat {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  border: 1.5px solid currentColor;
  align-self: flex-start;
  padding: 3px 8px;
}
.poster-type .title {
  font-size: clamp(20px, 2.1vw, 30px);
  line-height: 1.02;
  text-transform: uppercase;
  overflow-wrap: break-word;
  flex: 1;
  min-height: 0;
  overflow: hidden; /* long titles get cropped by the A4 edge, like real prints */
}
.poster-type.f-anton .title { font-family: "Anton", sans-serif; letter-spacing: 0.5px; }
.poster-type.f-archivo .title { font-family: "Archivo Black", sans-serif; font-size: clamp(17px, 1.8vw, 25px); }
.poster-type.f-playfair .title { font-family: "Playfair Display", serif; font-style: italic; text-transform: none; }

.poster-type .foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  border-top: 2px solid currentColor;
  padding-top: 9px;
}
.poster-type .when {
  font-family: "Anton", sans-serif;
  font-size: 17px;
  letter-spacing: 1px;
}
.poster-type .where {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: right;
  opacity: 0.75;
}

/* pin-to-personal-wall pushpin — centred on top, where the tear masks
   least often bite, so it doesn't get clipped away */
.pin {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(20, 18, 15, 0.5);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  user-select: none;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.pin svg { width: 16px; height: 16px; display: block; }
.poster:hover .pin { opacity: 1; }
.pin:hover { transform: translateX(-50%) scale(1.15); }
.pin.on {
  opacity: 1;
  color: #fff;
  background: #e8443a;
}
/* touch devices have no hover — always show the pin there */
@media (hover: none) {
  .pin { opacity: 0.9; }
}

/* date badge on photo posters */
.datebadge {
  position: absolute;
  top: 14px;
  left: 12px;
  z-index: 6;
  background: #c8371e;
  color: #fff;
  font-family: "Anton", sans-serif;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 4px 10px;
  transform: rotate(-2deg);
}

.sentinel { column-span: all; height: 1px; }

/* — horizontal ad banners, wheat-pasted between poster rows — */
.banner {
  column-span: all;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  margin: 12px 0 24px;
  padding: 22px 26px;
  min-height: 120px;
  background: var(--paper);
  transform: rotate(var(--rot, 0deg));
  text-decoration: none;
  filter: saturate(0.96);
  transition: transform 0.18s ease;
}
.banner:hover { transform: rotate(0deg) scale(1.008); }
.banner .tex { background-size: cover; }
.banner .b-title {
  font-family: "Anton", sans-serif;
  font-size: clamp(26px, 4vw, 52px);
  letter-spacing: 3px;
  color: #c8371e;
  text-transform: uppercase;
  text-align: center;
}
.banner .b-sub {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.65;
  text-align: center;
}
.banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.banner .adsense-box { width: 100%; }

.empty {
  column-span: all;
  text-align: center;
  font-family: "Anton", sans-serif;
  font-size: 28px;
  opacity: 0.5;
  padding: 80px 0;
}

@media (max-width: 640px) {
  .wall { columns: 2 150px; column-gap: 8px; padding: 44px 10px 60px; }
  .poster { margin-bottom: 8px; }
  /* too narrow for one line — stack: brand, then search, then the chip rows */
  .topbar { flex-direction: column; align-items: stretch; padding: 10px 12px; gap: 8px; }
  .brand { order: 1; justify-content: center; }
  .brand-bcn { font-size: 20px; }
  .brand-wall { font-size: 16px; }
  .search { order: 2; width: 100%; }
  .filterbar { order: 3; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; }
  .filters.when { max-width: none; }
}
