/* Fires de Catalunya — disseny net i sobri */

:root {
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-soft: #f7f5f1;
  --line: #e4e0d7;
  --line-soft: #edeae3;
  --ink: #211e1a;
  --ink-2: #4c4841;
  --muted: #837d72;
  --faint: #a8a29a;
  --accent: #8e2f1c;
  --accent-ink: #6f2314;
  --accent-wash: #f6e8e1;
  --sage: #2e5d47;
  --sage-wash: #e5efe8;
  --amber: #7a5a1e;
  --amber-wash: #f3ecd8;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- estructura ---------- */

.site {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 32px) 48px;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  z-index: 30;
}

.content {
  min-width: 0;
  max-width: 780px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(22px, 3.4vw, 40px);
}

/* ---------- barra lateral ---------- */

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  border-radius: 8px;
  line-height: 1;
  padding-bottom: 1px;
}
.brand-text {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.25;
}

.icon-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--faint); color: var(--ink); }

.search { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--surface-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23837d72' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.2-4.2'/%3E%3C/svg%3E") no-repeat 11px center;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
}
.search input::placeholder { color: var(--faint); }
.search input:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--accent);
}

.tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 14px;
  overscroll-behavior: contain;
}
.tree::-webkit-scrollbar { width: 10px; }
.tree::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 3px solid var(--surface); }

.ptree { margin: 0 0 4px; }

.prov-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 4px;
}
.prov-tip {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
.prov-tip:hover { color: var(--accent); }
.prov-count {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.ptree.current .prov-tip { color: var(--accent); }

.cgroup { border-radius: 8px; }
.cgroup > .cgroup-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px 2px 0;
  border-radius: 8px;
}
.cgroup > .cgroup-head:hover { background: var(--surface-soft); }

.caret {
  width: 22px; height: 26px;
  display: grid; place-items: center;
  flex: none;
  border: none;
  background: none;
  color: var(--faint);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}
.caret svg { display: block; transition: transform 0.16s ease; }
.cgroup.open > .cgroup-head .caret svg { transform: rotate(90deg); }
.caret:hover { color: var(--ink); background: var(--line-soft); }

.cgroup-label {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.4;
  padding: 4px 6px 4px 0;
  border-radius: 6px;
}
.cgroup-label:hover { color: var(--ink); }
.cgroup-label .cnt {
  font-weight: 400;
  font-size: 12px; color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.munis {
  list-style: none;
  margin: 0 0 2px 11px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--line-soft);
  display: none;
}
.cgroup.open > .munis { display: block; }

.munis li a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.45;
}
.munis li a:hover { color: var(--ink); background: var(--surface-soft); }
.munis li a .cnt { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.cgroup.current > .cgroup-head .cgroup-label { color: var(--accent-ink); }
.munis li.current a { color: var(--accent-ink); font-weight: 700; background: var(--accent-wash); }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 11px 16px 13px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
}
.sidebar-foot p { margin: 0; }
.sidebar-foot .foot-stats { font-variant-numeric: tabular-nums; }
.sidebar-foot a { color: var(--ink-2); }

/* ---------- barra mòbil ---------- */

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  margin: 0 calc(-1 * clamp(14px, 3vw, 32px)) 0;
}
.menu-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  width: 36px; height: 36px;
  border-radius: 9px;
  font-size: 16px;
  cursor: pointer;
}
.topbar .topbar-brand {
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30, 24, 18, 0.38);
  z-index: 28;
}

/* ---------- capçalera de pàgina ---------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px;
}
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .sep { color: var(--faint); font-size: 12px; }
.crumbs .here { color: var(--ink); font-weight: 600; }

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1.heading {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(28px, 3.6vw, 38px);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: balance;
}

.page-sub {
  margin: 10px 0 0;
  color: var(--ink-2);
  font-size: 15px;
  max-width: 62ch;
  line-height: 1.6;
}

/* ---------- xifres ---------- */
.stat-strip {
  display: flex;
  gap: 28px;
  margin: 22px 0 0;
  padding: 16px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.stat { padding: 0; }
.stat .n {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat .l {
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--muted);
}

/* ---------- filtres ---------- */
.filters {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.filter-label {
  margin-right: 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  padding: 7px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.2;
}
.chip:hover { border-color: var(--faint); color: var(--ink); }
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.chip .chip-n {
  opacity: 0.6;
  font-weight: 400;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

/* ---------- llista ---------- */

.list { margin-top: 6px; }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 10px;
}
.list-head .count {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.fair {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 10px;
}
.fair:hover { border-color: #cfc9bc; }

.fair-date {
  width: 56px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  color: var(--ink);
  align-self: start;
  line-height: 1;
}
.fair-date .day {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.fair-date .mon {
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.fair-date.is-pending {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  gap: 2px;
}

.fair.is-current { border-color: #d8b9ad; }
.fair.is-current .fair-date { background: var(--accent); border-color: var(--accent); color: #fff; }
.fair.is-current .fair-date .mon { color: rgba(255,255,255,0.82); }
.fair.is-soon .fair-date { background: var(--sage-wash); border-color: #cfded4; color: var(--sage); }
.fair.is-soon .fair-date .mon { color: var(--sage); }
.fair.is-past { background: #fbfaf8; }
.fair.is-past .fair-body { opacity: 0.78; }
.fair.is-past .fair-date { background: var(--surface-soft); color: var(--muted); }

.fair-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.fair h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.fair-status {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.fair-status::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.fair.is-current .fair-status { color: var(--accent-ink); }
.fair.is-current .fair-status::before { background: var(--accent); }
.fair.is-soon .fair-status { color: var(--sage); }
.fair.is-soon .fair-status::before { background: var(--sage); }
.fair.is-later .fair-status::before { background: #b99a3f; }
.fair.is-later .fair-status { color: var(--amber); }
.fair.is-undated .fair-status::before { background: var(--faint); }

.fair-where {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}
.fair-where a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.fair-where a:hover { text-decoration: underline; text-underline-offset: 3px; }
.fair-where .sep { margin: 0 2px; color: var(--faint); }

.fair-dates {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 600;
}

.fair-meta {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 3px 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}
.fair-meta li { display: inline; }
.fair-meta li span { color: var(--muted); }
.fair-meta li + li::before {
  content: "·";
  margin: 0 8px;
  color: var(--faint);
}

.fair-desc {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fair-actions {
  margin-top: 10px;
  display: flex;
  gap: 4px 18px;
  flex-wrap: wrap;
}
.fair-actions a {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.fair-actions a:hover { border-bottom-color: currentColor; }
.fair-actions a[href^="mailto:"] { color: var(--ink-2); font-weight: 500; }

.empty { padding: 32px 0; color: var(--muted); }
.empty p { margin: 0 0 4px; }
.empty .empty-big { font-family: var(--font-serif); font-size: 20px; color: var(--ink-2); }

/* ---------- peu contingut ---------- */

.content-foot {
  margin-top: 32px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}
.content-foot a { color: var(--ink-2); }

/* ---------- seccions portada ---------- */

.section-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 34px 0 0;
  color: var(--ink);
}
.section-lead { color: var(--ink-2); margin: 4px 0 0; font-size: 14px; max-width: 62ch; }

.more { color: var(--muted); font-size: 13.5px; margin: 12px 0 0; }

.nav-box {
  margin-top: 32px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.nav-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.nav-links { display: flex; flex-direction: column; gap: 1px; }
.nav-links a {
  padding: 3px 0;
  font-size: 13.5px;
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 500;
}
.nav-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.nav-links .nav-current { padding: 3px 0; font-weight: 700; color: var(--ink); font-size: 13.5px; }

.dir-prov {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.dir-prov:first-of-type { border-top: none; padding-top: 0; }
.dir-prov a {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--ink);
  text-decoration: none;
}
.dir-prov a:hover { color: var(--accent-ink); }
.dir-prov .cnt { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 24px;
  margin-top: 10px;
}
.dir-c > div:first-child a {
  font-weight: 650;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
}
.dir-c > div:first-child a:hover { color: var(--accent-ink); }
.dir-m { display: flex; flex-wrap: wrap; gap: 1px 0; margin-top: 2px; }
.dir-m a { font-size: 13px; color: var(--ink-2); text-decoration: none; line-height: 1.65; }
.dir-m a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.dir-m a + a::before { content: ",\00a0"; color: var(--faint); white-space: pre; }

/* ---------- responsiu ---------- */

@media (max-width: 1000px) {
  .site { grid-template-columns: 1fr; padding: 0 0 40px; gap: 0; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(330px, 88vw);
    max-height: none;
    height: 100%;
    border-radius: 0 14px 14px 0;
    transform: translateX(-103%);
    transition: transform 0.22s ease;
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  body.drawer-open .overlay { display: block; }
  .icon-btn { display: grid; place-items: center; }
  .content { border: none; border-radius: 0; max-width: none; padding: 20px 18px 40px; background: transparent; }
  .fair { background: #fff; }
  .stat-strip { gap: 22px; }
}

@media (max-width: 560px) {
  .fair { grid-template-columns: 48px 1fr; gap: 12px; padding: 15px 15px; }
  .fair-date { width: 48px; height: 54px; }
  .fair-date .day { font-size: 18px; }
  .fair h3 { font-size: 15px; }
  .fair-status { font-size: 12px; }
  .stat-strip { gap: 18px; padding: 14px 0; }
  .stat .n { font-size: 22px; }
}

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

/* Plantilles antigues: es mantenen sense estils propis */
