/* ============================================================
   UPBB — Union des Professionnels du Bâtiment de Bloléquin
   ============================================================ */

:root {
  --bg: #f4ecdc;
  --surface: #fbf6ec;
  --surface-2: #efe4d0;
  --ink: #1a1b2e;
  --ink-soft: #4a4b5e;
  --accent: #6b1f1a;
  --accent-soft: #8f2c25;
  --secondary: #1e2a4a;
  --line: #d9cbb2;
  --line-strong: #b9a888;
  --ok: #1f5d3a;
  --ok-bg: #e2efe4;
  --err: #8f2c25;
  --err-bg: #f7e4e0;
  --on-accent: #fdf8ee;
  --shadow: 0 1px 2px rgba(26, 27, 46, .06), 0 12px 32px -18px rgba(26, 27, 46, .35);

  --wrap: 1240px;
  --gutter: clamp(20px, 5vw, 72px);
  --section-y: clamp(64px, 9vw, 120px);

  --serif: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", "Inter", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14151f;
    --surface: #1c1e2b;
    --surface-2: #232636;
    --ink: #f2ece0;
    --ink-soft: #b9b6c4;
    --accent: #e08a7d;
    --accent-soft: #f0a99c;
    --secondary: #9fb2dd;
    --line: #33364a;
    --line-strong: #4a4e66;
    --ok: #8fd3a8;
    --ok-bg: #1c3327;
    --err: #f0a99c;
    --err-bg: #3a2320;
    --on-accent: #2a0f0c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -20px rgba(0, 0, 0, .8);
  }
}

:root[data-theme="dark"] {
  --bg: #14151f;
  --surface: #1c1e2b;
  --surface-2: #232636;
  --ink: #f2ece0;
  --ink-soft: #b9b6c4;
  --accent: #e08a7d;
  --accent-soft: #f0a99c;
  --secondary: #9fb2dd;
  --line: #33364a;
  --line-strong: #4a4e66;
  --ok: #8fd3a8;
  --ok-bg: #1c3327;
  --err: #f0a99c;
  --err-bg: #3a2320;
  --on-accent: #2a0f0c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -20px rgba(0, 0, 0, .8);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-soft); }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.3rem, 5.4vw, 4rem); }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.6rem); }
h3 { font-size: clamp(1.15rem, 1.8vw, 1.35rem); }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.prose { max-width: 68ch; }
.eyebrow {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .9rem;
}
.lede { font-size: 1.12rem; color: var(--ink-soft); max-width: 62ch; }
.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 68px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fdf8ee;
  font-family: var(--serif);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .02em;
  border-radius: 4px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; }
.brand-sub { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }

.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .7rem;
  font-size: .93rem;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 4px;
  transition: color .18s ease, background .18s ease;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 48px;
  padding: 0 1.4rem;
  font-family: var(--sans);
  font-size: .97rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-soft); color: var(--on-accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }

/* ---------- hero ---------- */
.hero { padding-block: clamp(40px, 6vw, 76px) var(--section-y); }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
}
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: 1.05fr .95fr; }
}
.hero h1 { margin-bottom: .35em; }
.hero h1 em {
  font-style: normal;
  color: var(--accent);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.8rem; }
.hero-figure {
  position: relative;
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-figure img {
  width: 100%;
  aspect-ratio: 4 / 3.4;
  object-fit: cover;
}
@media (min-width: 900px) {
  .hero-figure img { aspect-ratio: 4 / 4.6; }
}
.hero-figure figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.4rem 1.2rem .9rem;
  font-size: .82rem;
  color: #fdf8ee;
  background: linear-gradient(to top, rgba(20, 21, 31, .82), transparent);
}

/* ---------- stat band ---------- */
.stat-band {
  border-block: 1px solid var(--line);
  background: var(--surface);
}
.stat-band ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
}
@media (min-width: 760px) { .stat-band ul { grid-template-columns: repeat(4, 1fr); } }
.stat-band li {
  background: var(--surface);
  padding: 1.5rem clamp(14px, 2vw, 26px);
}
.stat-band .k {
  display: block;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.1;
  color: var(--accent);
  margin-bottom: .25rem;
}
.stat-band .v { font-size: .86rem; color: var(--ink-soft); line-height: 1.4; }

/* ---------- sections ---------- */
.section { padding-block: var(--section-y); }
.section-head { margin-bottom: clamp(28px, 4vw, 48px); }
.section-head h2 { margin-bottom: .4em; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }

/* ---------- corps de métiers ---------- */
.trades {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.trade {
  background: var(--bg);
  padding: 1.5rem 1.4rem;
}
.section-alt .trade { background: var(--surface); }
.trade h3 { margin-bottom: .35em; }
.trade p { font-size: .95rem; color: var(--ink-soft); }
.trade .num {
  display: block;
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--accent);
  margin-bottom: .8rem;
}

/* ---------- galerie ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(10px, 1.6vw, 18px);
}
@media (min-width: 720px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1040px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.gallery figure {
  margin: 0;
  position: relative;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface-2);
}
.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2, .7, .1, 1);
}
.gallery figure:hover img { transform: scale(1.04); }
.gallery figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.6rem .8rem .6rem;
  font-size: .8rem;
  font-weight: 500;
  color: #fdf8ee;
  background: linear-gradient(to top, rgba(20, 21, 31, .85), transparent);
}
.gallery .wide { grid-column: span 2; }
.gallery .wide img { aspect-ratio: 8 / 3; }

/* ---------- adhésion / tarifs ---------- */
.fees {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: clamp(16px, 2.4vw, 28px);
}
.fee {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(22px, 3vw, 34px);
  display: flex;
  flex-direction: column;
}
.fee.featured { border-color: var(--accent); box-shadow: var(--shadow); }
.fee .tag {
  align-self: flex-start;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: .25rem .7rem;
  margin-bottom: 1rem;
}
.fee h3 { margin-bottom: .2em; }
.fee .amount {
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1;
  color: var(--ink);
  margin: .4rem 0 .1rem;
}
.fee .amount small { font-family: var(--sans); font-size: .9rem; font-weight: 500; color: var(--ink-soft); }
.fee ul {
  list-style: none;
  margin: 1.2rem 0 1.6rem;
  padding: 0;
  font-size: .95rem;
  color: var(--ink-soft);
}
.fee li { position: relative; padding-left: 1.4rem; margin-bottom: .55rem; }
.fee li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--accent);
  opacity: .55;
}
.fee .btn { margin-top: auto; }

/* ---------- formulaire ---------- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(22px, 3.4vw, 44px);
  box-shadow: var(--shadow);
}
fieldset {
  border: 0;
  margin: 0 0 2rem;
  padding: 0;
}
legend {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  padding: 0;
  margin-bottom: 1rem;
  color: var(--ink);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 1.2rem;
}
@media (min-width: 680px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.field label .req { color: var(--accent); }
.field .hint { font-size: .8rem; color: var(--ink-soft); font-weight: 400; }
input[type="text"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: .7rem .85rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; background-image: none; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}
input:user-invalid, select:user-invalid, textarea:user-invalid {
  border-color: var(--err);
}

.choices { display: flex; flex-wrap: wrap; gap: .6rem; }
.choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 48px;
  padding: .5rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--bg);
  font-size: .93rem;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.choice input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.choice:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
}
.choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: .5rem;
}
.form-status {
  margin: 1.2rem 0 0;
  padding: .9rem 1.1rem;
  border-radius: 4px;
  font-size: .95rem;
  border: 1px solid transparent;
}
.form-status[data-state="pending"] { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.form-status[data-state="ok"] { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); font-weight: 600; }
.form-status[data-state="err"] { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.form-status[hidden] { display: none; }

/* ---------- localités ---------- */
.locality-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 3vw, 36px);
}
@media (min-width: 760px) { .locality-cols { grid-template-columns: 1fr 1fr; } }
.locality-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(20px, 2.6vw, 30px);
}
.locality-block h3 { margin-bottom: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.chips li {
  font-size: .87rem;
  padding: .35rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--bg);
}

/* ---------- espace agent ---------- */
.agent-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: clamp(22px, 3.4vw, 40px);
  max-width: 560px;
}
.agent-card form { display: flex; flex-direction: column; gap: 1rem; }
.agent-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.agent-tools .count { font-size: .9rem; color: var(--ink-soft); margin-right: auto; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 760px; }
th, td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: .74rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td .del {
  min-height: 36px;
  padding: 0 .7rem;
  font-size: .82rem;
  background: transparent;
  color: var(--err);
  border: 1px solid var(--err);
  border-radius: 4px;
  cursor: pointer;
}
td .del:hover { background: var(--err-bg); }
.empty-row td { color: var(--ink-soft); font-style: italic; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-block: clamp(40px, 6vw, 72px) 1.5rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(24px, 3vw, 48px);
  margin-bottom: 2.5rem;
}
@media (min-width: 760px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer-grid h4 {
  font-family: var(--sans);
  font-size: .76rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .9rem;
}
.footer-grid ul { list-style: none; margin: 0; padding: 0; font-size: .93rem; }
.footer-grid li { margin-bottom: .5rem; }
.footer-grid a { color: var(--ink); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: .85rem;
  color: var(--ink-soft);
}
.attribution { margin: 0; font-size: .8rem; }
.attribution a { color: var(--ink-soft); }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes fadeRise {
    from { opacity: 0; translate: 0 14px; }
    to { opacity: 1; translate: 0 0; }
  }
  @supports (animation-timeline: view()) {
    .reveal {
      animation: fadeRise 420ms cubic-bezier(.2, .7, .1, 1) both;
      animation-timeline: view();
      animation-range: entry 0% cover 22%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

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

/* placeholder fill-ins */
.fill {
  border-bottom: 1px dotted var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}
