/* Afana — finition professionnelle (chargée en dernier).
   Couche purement visuelle : aucun sélecteur métier ni règle [hidden] modifié.
   Toutes les couleurs dérivent des variables des quatre palettes, en clair
   comme en sombre ; aucune police distante n’est chargée. */

:root {
  --pro-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --pro-canvas: color-mix(in srgb, var(--soft) 38%, var(--page, var(--surface)));
  --pro-border: color-mix(in srgb, var(--line) 70%, var(--surface));
  --pro-radius: 12px;
  --pro-radius-sm: 8px;
  --pro-shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --pro-shadow-hover: 0 4px 12px rgb(16 24 40 / .08), 0 2px 4px rgb(16 24 40 / .05);
  --pro-shadow-pop: 0 20px 48px rgb(16 24 40 / .18), 0 4px 12px rgb(16 24 40 / .08);
  --pro-ink-hover: color-mix(in srgb, var(--ink) 86%, var(--surface));
  /* Teintes d’état : même sens qu’avant, contrastes renforcés. */
  --pro-pending: #d99a1e;
  --pro-return: #d9772b;
  --pro-danger: #b42318;
  font-family: var(--pro-font);
}
:root[data-appearance="dark"] {
  --pro-canvas: var(--page);
  --pro-shadow: 0 1px 2px rgb(0 0 0 / .3);
  --pro-shadow-hover: 0 6px 16px rgb(0 0 0 / .35);
  --pro-shadow-pop: 0 24px 56px rgb(0 0 0 / .5);
  --pro-danger: #f07167;
}

/* ---------- Base ---------- */
:root, :root[data-palette][data-appearance] { background: var(--pro-canvas); }
body {
  min-height: 100vh;
  background: var(--pro-canvas);
  font-family: var(--pro-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Relief validé : masque alpha local, teinté par la palette, derrière le contenu.
   L'ancrage au tiers garde Muraz au tiers de la largeur du fond visible. */
@supports (mask-image: url("")) or (-webkit-mask-image: url("")) {
  body { position: relative; isolation: isolate; }
  body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    /* Les textes secondaires posés directement sur le fond gardent leur contraste. */
    opacity: .5;
    background-color: color-mix(in srgb, var(--ink) 18%, var(--primary));
    -webkit-mask-image: url("/static/topographie-chablais.svg?v=0.61.0");
    mask-image: url("/static/topographie-chablais.svg?v=0.61.0");
    -webkit-mask-size: cover; mask-size: cover;
    -webkit-mask-position: 33.333333% center; mask-position: 33.333333% center;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    mask-mode: alpha;
  }
}
.topography-credit {
  display: block; width: fit-content; margin: 8px auto 0; padding: 4px 8px;
  color: var(--muted); font-size: 12px; line-height: 1.5; text-underline-offset: 3px;
  font-family: inherit; background: none; border: 0; border-radius: 0;
  text-decoration: underline; cursor: pointer;
}
.topography-dialog { width: min(420px, calc(100vw - 32px)); box-sizing: border-box; }
.topography-dialog h2 { font-size: 20px; }
.topography-dialog p { margin: 0 0 12px; }
.topography-dialog > a { font-size: 14px; }
footer.topography-auth-footer { background: transparent; border: 0; margin-top: 0; }
.topography-sources-page { max-width: 920px; padding-top: 40px; }
.topography-sources-page h1 { font-size: 28px; line-height: 1.3; }
.topography-sources-page li { margin-bottom: 12px; overflow-wrap: anywhere; }
@media print { body::before { display: none; } }
@media (forced-colors: active) { body::before { display: none; } }
main { min-height: calc(100vh - 220px); }
h1, h2, h3, h4 { letter-spacing: -.015em; }
.section-title h1, .page-title h1, .reservation-title h1 {
  font-size: clamp(26px, 2.6vw, 32px); font-weight: 700; letter-spacing: -.025em; line-height: 1.2;
}
.section-title { align-items: flex-end; margin-bottom: 4px; }
.section-title h1 + span, .section-title .muted { color: var(--muted); }
.muted, .booking-meta, .card-summary, .card-location { color: var(--muted); }

/* ---------- En-tête et navigation ---------- */
header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--pro-border);
  padding-block: 8px;
}
.brand-icon { border-radius: 9px; box-shadow: var(--pro-shadow); }
.beta { font-weight: 600; color: var(--muted); }
header > nav .nav, .member-bar .nav {
  font-weight: 600; color: color-mix(in srgb, var(--ink) 78%, var(--surface));
  border-radius: var(--pro-radius-sm); transition: background-color .15s, color .15s;
}
header > nav .nav:hover, .member-bar .nav:hover { background: var(--soft); color: var(--ink); }
header > nav .nav.active { background: var(--soft); color: var(--ink); }
.member-bar { background: var(--surface); border-bottom: 1px solid var(--pro-border); }
.member-bar .nav.active, #home-menu [aria-pressed=true] {
  background: transparent; text-decoration: none; color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0;
}
.notification-bell { border-radius: 10px; border-color: var(--pro-border); }
.notification-badge { font-variant-numeric: tabular-nums; }
#account-toggle { text-decoration: none; border-radius: var(--pro-radius-sm); }
#account-toggle:hover { background: var(--soft); }
#account-options {
  border: 1px solid var(--pro-border); border-radius: var(--pro-radius);
  box-shadow: var(--pro-shadow-pop); background: var(--surface);
}

/* ---------- Boutons ---------- */
.button {
  border-radius: 10px; font-weight: 600; letter-spacing: 0;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
  box-shadow: var(--pro-shadow);
}
.button:hover { background: var(--pro-ink-hover); color: var(--surface); border-color: var(--pro-ink-hover); }
.button:active { transform: translateY(1px); }
.button.outline {
  background: var(--surface); color: var(--ink); border-color: var(--pro-border); box-shadow: none;
}
.button.outline:hover { background: var(--soft); color: var(--ink); border-color: var(--line); }
#member-nav .button:not(.outline):not(.catalog-view-icon), .section-title .button, .filters .button {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
#member-nav .button:not(.outline):not(.catalog-view-icon):hover, .section-title .button:hover, .filters .button:hover {
  background: var(--pro-ink-hover); color: var(--surface);
}
.catalog-view-icon { box-shadow: none; border-color: transparent; color: var(--muted); }
.catalog-view-icon[aria-pressed=true] { background: var(--soft); color: var(--ink); border-color: var(--pro-border); }
.link { text-underline-offset: 3px; }

/* Catalogues et fiches : contours adoucis, action principale mise en avant. */
#hero-publish, #project-create, #group-create, #booking-create-nav,
:is(#catalog-view, #mine-view, #projects-view, #item-dialog, #project-detail) .button:not(.catalog-view-icon) {
  border-color: var(--line); border-radius: 10px;
}
:is(#catalog-view, #mine-view, #item-dialog) .button:is([data-reserve], #detail-reserve):not(:disabled),
#hero-publish, #project-create, #group-create, #booking-create-nav {
  background: var(--ink); color: var(--surface); border-color: var(--ink); box-shadow: var(--pro-shadow);
}
:is(#catalog-view, #mine-view, #item-dialog) .button:is([data-reserve], #detail-reserve):hover:not(:disabled),
#hero-publish:hover:not(:disabled), #project-create:hover:not(:disabled),
#group-create:hover:not(:disabled), #booking-create-nav:hover:not(:disabled) {
  background: var(--pro-ink-hover); color: var(--surface); border-color: var(--pro-ink-hover);
}

/* ---------- Champs ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea {
  border-color: var(--pro-border); border-radius: 10px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:not([type=checkbox]):not([type=radio]):hover, select:hover, textarea:hover { border-color: var(--line); }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 18%, transparent);
}
input::placeholder, textarea::placeholder { font-weight: 400; }
.filters {
  background: var(--surface); border: 1px solid var(--pro-border);
  border-radius: var(--pro-radius); box-shadow: var(--pro-shadow);
}

/* ---------- Cartes et panneaux ---------- */
.card, .booking, .admin-user, .financial-entry, .project-panel, .association-panel,
.allocation-panel, .idea-card, .project-card, .notification-event, #bookings-calendar {
  background: var(--surface); border: 1px solid var(--pro-border);
  border-radius: var(--pro-radius); box-shadow: var(--pro-shadow);
}
.card { overflow: hidden; transition: box-shadow .2s, transform .2s; }
.card:hover { box-shadow: var(--pro-shadow-hover); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .card, .card:hover { transition: none; transform: none; } }
.card-visual { min-height: 0; border-bottom: 1px solid var(--pro-border); }
.card-visual:not(.has-photo) { background: color-mix(in srgb, var(--primary) 45%, var(--surface)); }
.card-visual:not(.has-photo) .card-icon { opacity: .85; }
.category-badge {
  background: var(--surface); border: 1px solid var(--pro-border); font-weight: 600;
  letter-spacing: .01em; box-shadow: var(--pro-shadow);
}
.card h3 { font-size: 17px; font-weight: 700; }
.card-identifier { color: var(--muted); font-weight: 400; font-size: 13px; }
.card-price strong { font-size: 20px; }
.card-bottom { border-top-color: var(--pro-border); }
.empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--pro-radius);
}
.fact, .financial-summary > div { border-radius: var(--pro-radius); }

/* ---------- Badges d’état ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 1; padding: 6px 10px 6px 9px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--soft); color: var(--ink);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .7; flex: none; }
.status[data-status="pending"] { background: color-mix(in srgb, var(--pro-pending) 20%, var(--surface)); }
.status[data-status="pending"]::before { background: var(--pro-pending); opacity: 1; }
.status[data-status="accepted"] { background: color-mix(in srgb, var(--primary) 55%, var(--surface)); }
.status[data-status="in_use"] { background: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.status[data-status="return_requested"] { background: color-mix(in srgb, var(--pro-return) 18%, var(--surface)); }
.status[data-status="return_requested"]::before { background: var(--pro-return); opacity: 1; }
.status[data-status="completed"] { background: color-mix(in srgb, var(--line) 45%, var(--surface)); color: var(--muted); }
.status[data-status="cancelled"] { background: var(--surface); border: 1px dashed var(--line); color: var(--muted); }
.status[data-status="rejected"] { background: var(--surface); border: 1px dashed color-mix(in srgb, var(--pro-danger) 60%, var(--surface)); color: var(--pro-danger); }
.role-badge { border-radius: 999px; font-weight: 600; }

/* ---------- Liste des réservations ---------- */
.booking { padding: 20px 24px; margin-bottom: 14px; }
.booking-heading { align-items: center; }
.booking-heading h3 { font-size: 18px; margin-bottom: 0; }
/* Séparateurs en début de ligne masqués par le décalage et le rognage. */
.booking-meta { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 8px 0 0 -24px; overflow: hidden; }
.booking-meta > span { display: inline-flex; align-items: center; }
.booking-meta > span::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%; margin-inline: 10px;
  background: color-mix(in srgb, var(--muted) 55%, var(--surface));
}
.booking-meta > span:first-child { color: var(--ink); font-weight: 600; }
.booking-notice { color: var(--muted); }
.booking .booking-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--pro-border); padding-top: 14px; margin-top: 14px;
}
.booking .booking-actions .button { min-height: 40px; padding-block: 8px; }
.booking-tools select { max-width: 320px; }
#bookings-view .page-title, .reservation-title { margin-bottom: 8px; }

/* ---------- Calendrier des réservations : calendrier + liste côte à côte ---------- */
#bookings-calendar:not([hidden]) {
  display: grid; padding: 20px; gap: 12px 28px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  grid-template-areas: "head list" "nav list" "month list" "legend list";
  align-items: start;
}
#bookings-calendar > .bookings-calendar-header { grid-area: head; }
#bookings-calendar > .bookings-calendar-nav { grid-area: nav; }
#bookings-calendar > .bookings-calendar-month { grid-area: month; }
#bookings-calendar > .bookings-calendar-legend { grid-area: legend; margin: 0; }
#bookings-calendar > .bookings-calendar-object-list {
  grid-area: list; margin: 0; border-top: 0; padding: 0 0 0 28px;
  border-left: 1px solid var(--pro-border); align-self: stretch;
}
.bookings-calendar-header { grid-template-columns: minmax(0, 1fr) auto; }
.bookings-calendar-header h3 { font-size: 17px; font-weight: 700; }
.bookings-calendar-today-slot { grid-column: 2; justify-content: flex-end; }
.bookings-calendar-today-slot .link {
  border: 1px solid var(--pro-border); border-radius: 10px; padding: 8px 14px;
  text-decoration: none; font-weight: 600; font-size: 14px; min-height: 40px;
}
.bookings-calendar-today-slot .link:hover { background: var(--soft); }
.bookings-calendar-nav strong { font-size: 18px; font-weight: 700; text-transform: capitalize; }
.bookings-calendar-nav .button { min-width: 44px; }
.bookings-calendar-table th {
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
}
.bookings-calendar-table .calendar-day::before {
  inset: 3px; border-radius: 10px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--pro-border);
}
.bookings-calendar-table .calendar-day:nth-child(n+6)::before {
  background: color-mix(in srgb, var(--soft) 45%, var(--surface));
}
.bookings-calendar-table .calendar-empty::before { box-shadow: none; background: transparent; }
.bookings-calendar-table .calendar-number {
  display: block; text-align: left; padding: 10px 0 0 12px;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.bookings-calendar-table .calendar-marked::before { outline: 0; box-shadow: inset 0 0 0 2px var(--ink); }
.bookings-calendar-table .calendar-marked .calendar-number::before {
  content: ""; position: absolute; left: 6px; top: 5px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--ink); z-index: -1;
}
.bookings-calendar-table .calendar-marked .calendar-number { color: var(--surface); z-index: 1; }
.bookings-calendar-week-bars { top: 44px; }
.bookings-calendar-table .bookings-calendar-event {
  height: 22px; line-height: 22px; font-weight: 600; font-size: 12px;
  margin-top: 2px;
}
.bookings-calendar-event.starts { border-start-start-radius: 6px; border-end-start-radius: 6px; }
.bookings-calendar-event.ends { border-start-end-radius: 6px; border-end-end-radius: 6px; }
.bookings-calendar-event:is(:hover, .is-highlighted) { filter: none; box-shadow: inset 0 0 0 2px var(--ink); }
#bookings-calendar [data-status="pending"] { background: color-mix(in srgb, var(--pro-pending) 55%, var(--surface)); }
#bookings-calendar [data-status="return_requested"] {
  background: color-mix(in srgb, var(--pro-return) 40%, var(--surface)); border-bottom: 0;
}
#bookings-calendar .bookings-calendar-event[data-status="pending"],
#bookings-calendar .bookings-calendar-event[data-status="return_requested"] { color: var(--ink); }
#bookings-calendar .bookings-calendar-event[data-status="cancelled"] { text-decoration: line-through; color: var(--muted); }
#bookings-calendar .bookings-calendar-event[data-status="rejected"] { color: var(--pro-danger); }
.bookings-calendar-legend { gap: 6px; font-size: 12px; }
.bookings-calendar-legend > span {
  padding: 4px 10px 4px 8px; border: 1px solid var(--pro-border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-weight: 600;
}
.bookings-calendar-legend .calendar-marker { width: 10px; height: 10px; border-radius: 50%; border-color: transparent; }
.bookings-calendar-legend .calendar-marker:is([data-status="cancelled"], [data-status="rejected"]) { border: 1px dashed var(--muted); }
.bookings-calendar-object-list h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.bookings-calendar-objects > li { border-bottom-color: var(--pro-border); }
.bookings-calendar-objects .bookings-calendar-booking-link {
  text-decoration: none; border-radius: var(--pro-radius-sm); padding: 8px; margin-inline: -8px;
  width: calc(100% + 16px); flex-wrap: wrap; gap: 4px 12px;
}
.bookings-calendar-booking-link > :first-child { font-variant-numeric: tabular-nums; }
@media (max-width: 1000px) {
  #bookings-calendar:not([hidden]) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "nav" "month" "legend" "list";
  }
  #bookings-calendar > .bookings-calendar-object-list {
    border-left: 0; padding: 16px 0 0; border-top: 1px solid var(--pro-border);
  }
}
@media (max-width: 600px) {
  #bookings-calendar:not([hidden]) { padding: 12px; gap: 10px; }
  .bookings-calendar-table td { height: 64px; }
  .bookings-calendar-table .calendar-number { padding: 8px 0 0 8px; font-size: 12px; }
  .bookings-calendar-table .calendar-marked .calendar-number::before { left: 3px; top: 4px; width: 22px; height: 22px; }
  .bookings-calendar-week-bars { top: 30px; }
  .bookings-calendar-table .bookings-calendar-event { font-size: 11px; height: 18px; line-height: 18px; }
}

/* ---------- Accueil ---------- */
#homepage-original {
  margin-top: 32px; padding: clamp(24px, 4vw, 44px);
  background: var(--surface); border: 1px solid var(--pro-border);
  border-radius: 16px; box-shadow: var(--pro-shadow);
}
#homepage-original h1 { font-size: clamp(28px, 3.4vw, 40px); letter-spacing: -.03em; margin-bottom: 8px; }
#homepage-original > p { color: var(--muted); font-size: 17px; max-width: 60ch; }
#homepage-original .booking-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
#home-counts a {
  background: var(--surface); border: 1px solid var(--pro-border); box-shadow: var(--pro-shadow);
  border-radius: 10px;
}
#home-counts a:hover { background: var(--soft); }
#home-counts strong { font-variant-numeric: tabular-nums; }

/* ---------- Fenêtres ---------- */
dialog {
  border: 1px solid var(--pro-border); border-radius: 16px; box-shadow: var(--pro-shadow-pop);
}
dialog::backdrop {
  background: rgb(15 23 42 / .45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
dialog .close { border-radius: 10px; }

/* ---------- Pied de page ---------- */
footer {
  background: var(--surface); border-top: 1px solid var(--pro-border);
  padding: 20px 28px; margin-top: 48px; color: var(--muted);
}
footer .brand { font-size: 16px; color: var(--ink); }
.site-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.site-footer .topography-credit { grid-column: 1; justify-self: start; margin: 0; min-height: 44px; max-width: 100%; text-align: left; }
.site-footer .footer-links { grid-column: 2; justify-self: center; }
@media (max-width: 600px) {
  .site-footer { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
}


/* ---------- Notifications éphémères ---------- */
#toast { border-radius: var(--pro-radius); box-shadow: var(--pro-shadow-pop); }

/* ---------- Téléphone : en-tête compact, menus sur une ligne défilante ---------- */
@media (max-width: 1100px) {
  header > nav {
    flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin-inline: -4px; padding-inline: 4px;
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  header > nav::-webkit-scrollbar, .member-bar .secondary-inner nav::-webkit-scrollbar { display: none; }
  header > nav .nav { white-space: nowrap; flex: none; }
}
@media (max-width: 680px) {
  header { gap: 6px 12px; padding-inline: 14px; }
  .member-bar .secondary-inner { padding: 6px 14px; gap: 6px; min-height: 0; }
  .member-bar .secondary-inner nav {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  .member-bar .nav { white-space: nowrap; flex: none; padding: 10px; }
  .member-bar .nav.reservations-tab { margin-left: 0; }
  .secondary-inner > .button { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  main { padding-inline: 16px; }
  .booking { padding: 16px; }
  .booking-meta > span::before { display: none; }
  .booking-meta { flex-direction: column; gap: 2px; margin-left: 0; }
  .booking-actions .button { flex: 1 1 auto; }
  footer { margin-top: 32px; }
}
