/* ============================================================
   Constello — Portail client (app.constello.be)
   Même univers que le site vitrine : dessin technique / atelier.
   Signature du portail : la « fiche de chantier » tamponnée.
   Jaune métré = espace client · Bleu de traçage = espace admin.
   ============================================================ */

:root {
  --paper:      #E7E4DB;
  --paper-2:    #DFDBD0;
  --ink:        #1B1A16;
  --ink-soft:   #4C493F;
  --concrete:   #8C8778;
  --yellow:     #EBA200;
  --yellow-deep:#C98800;
  --blue:       #2E4C7C;
  --line:       rgba(27, 26, 22, 0.16);
  --line-soft:  rgba(27, 26, 22, 0.08);

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body:    "Instrument Sans", system-ui, sans-serif;
  --mono:    "Space Mono", ui-monospace, monospace;

  --edge: 1040px;
  --pad:  clamp(18px, 4.5vw, 56px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(16px, 1.05vw, 18px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; }
button { font: inherit; color: inherit; }

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

/* l'attribut hidden gagne toujours, même sur les éléments en flex/grid */
[hidden] { display: none !important; }

/* ---------- Réutilisables (mêmes conventions que le site) ---------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin-bottom: 1rem;
}
.eyebrow::before {
  content: "";
  width: 26px; height: 2px;
  background: var(--yellow);
}
.eyebrow-admin::before { background: var(--blue); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding: 0.85em 1.4em;
  border: 1.5px solid var(--ink);
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-cta { background: var(--yellow); color: var(--ink); }
.btn-cta:hover { background: var(--yellow-deep); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-small { padding: 0.5em 0.9em; font-size: 0.72rem; }

.linklike {
  background: none; border: none; padding: 0;
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}

.plumb { width: 14px; height: 30px; overflow: visible; }
.plumb line { stroke: var(--ink); stroke-width: 1.5; }
.plumb .plumb-bob { fill: var(--yellow); stroke: var(--ink); stroke-width: 1; }

/* ---------- Ruban démo ---------- */

.demo-ribbon {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.45em var(--pad);
  background: var(--ink);
  color: var(--paper);
}

/* ---------- En-tête ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem var(--pad);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
}
.brand-sep { color: var(--concrete); }
.brand-app { font-weight: 500; color: var(--ink-soft); }
.header-session {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
}
.session-who {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

/* ---------- Vues ---------- */

main { flex: 1; }
.view[hidden] { display: none; }
.wrap {
  max-width: var(--edge);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem) var(--pad) 3rem;
}

/* ---------- Vue entrée ---------- */

.view-gate { display: grid; min-height: 70dvh; place-items: center; padding: 2.5rem var(--pad); }
.gate { max-width: 560px; text-align: center; display: flex; flex-direction: column; align-items: center; }

.plumb-hero { width: 22px; height: 48px; margin-bottom: 1.6rem; transform-origin: 11px 0; }
@keyframes plumb-settle {
  0%   { transform: rotate(5deg); }
  35%  { transform: rotate(-3deg); }
  65%  { transform: rotate(1.5deg); }
  100% { transform: rotate(0deg); }
}
.plumb-hero { animation: plumb-settle 1.4s ease-out 1 both; }

.gate .eyebrow { margin-bottom: 1.2rem; }
.gate-title { font-size: clamp(2rem, 6vw, 3rem); }
.gate-lead { margin: 1.1rem 0 2rem; color: var(--ink-soft); }

.code-form { width: 100%; }
.code-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: left;
  margin-bottom: 0.5rem;
}
.code-row { display: flex; gap: 0.7rem; }
.code-input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.7em 0.9em;
  color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid var(--ink);
  border-radius: 0;
}
.code-input::placeholder { color: var(--concrete); font-weight: 400; }
.code-error {
  margin-top: 0.8rem;
  text-align: left;
  font-size: 0.92rem;
  color: #8A2D1F;
}

.gate-demo { margin-top: 2.6rem; padding-top: 1.4rem; border-top: 1px dashed var(--line); width: 100%; }
.gate-demo-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.8rem;
}
.gate-demo-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.chip {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.45em 0.8em;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.chip span { font-weight: 400; color: var(--ink-soft); margin-left: 0.4em; }
.chip:hover { transform: translateY(-2px); background: var(--yellow); }
.chip-admin:hover { background: var(--blue); color: var(--paper); }
.chip-admin:hover span { color: var(--paper-2); }

/* ---------- Tête d'espace ---------- */

.space-head { margin-bottom: 2rem; }
.eyebrow-ref { margin-bottom: 0.8rem; }
.space-title { font-size: clamp(1.7rem, 4.5vw, 2.5rem); }
.space-lead { margin-top: 0.6rem; color: var(--ink-soft); }

/* ---------- Tuiles compteurs ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-bottom: 2.6rem;
}
.tile {
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  padding: 1rem 1.1rem 0.9rem;
  position: relative;
}
.tile::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 34px; height: 3px;
  background: var(--yellow);
}
.tiles-admin .tile::before { background: var(--blue); }
.tile-number {
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.1;
}
.tile-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

/* ---------- Titres de section ---------- */

.section-title {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.4rem 0 1.2rem;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-title span { display: inline-flex; align-items: center; gap: 0.6em; }
.section-title span::before { content: ""; width: 10px; height: 10px; background: var(--yellow); border: 1px solid var(--ink); }
.section-title-admin span::before { background: var(--blue); }

/* ---------- Fiches d'automatisation (signature) ---------- */

.fiches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 1rem;
}
.fiche {
  position: relative;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  padding: 1.2rem 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
/* repères de cotes aux coins, comme sur un plan */
.fiche::before, .fiche::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  pointer-events: none;
}
.fiche::before { top: 6px; left: 6px; border-top: 1.5px solid var(--concrete); border-left: 1.5px solid var(--concrete); }
.fiche::after  { bottom: 6px; right: 6px; border-bottom: 1.5px solid var(--concrete); border-right: 1.5px solid var(--concrete); }

.fiche-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; }
.fiche-ref {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.fiche-name { font-size: 1.12rem; margin-top: 0.2rem; }
.fiche-desc { font-size: 0.95rem; color: var(--ink-soft); }

.stamp {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.35em 0.65em;
  border: 1.5px solid currentColor;
  transform: rotate(-3deg);
  white-space: nowrap;
  flex-shrink: 0;
}
.stamp-on  { color: var(--yellow-deep); }
.stamp-off { color: var(--concrete); }

.fiche-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1.2em;
  border-top: 1px dashed var(--line);
  padding-top: 0.7rem;
  margin-top: auto;
}
.fiche-action { margin-top: 0.2rem; }
.fiche-note { font-size: 0.85rem; color: var(--concrete); font-style: italic; }

/* mini-formulaire « message à l'équipe » dans la fiche */
.fiche-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.2rem; }
.fiche-form textarea {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6em 0.8em;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  resize: vertical;
  min-height: 70px;
}
.fiche-form-row { display: flex; gap: 0.6rem; align-items: center; }
.fiche-sent { font-size: 0.9rem; color: var(--yellow-deep); font-weight: 600; }

/* ---------- Journal ---------- */

.journal { display: flex; flex-direction: column; }
.journal li {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 0.95rem;
}
.journal-time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--concrete);
  white-space: nowrap;
  min-width: 5.5em;
}
.journal-client {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}
.journal-empty { color: var(--concrete); font-style: italic; padding: 0.55rem 0; }

/* ---------- Carte CTA ---------- */

.cta-card {
  margin-top: 3rem;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
}
.cta-card h3 { font-size: 1.2rem; }
.cta-card p { color: var(--paper-2); font-size: 0.95rem; margin-top: 0.3rem; }

/* ---------- Admin : dossiers clients ---------- */

.dossiers { display: flex; flex-direction: column; gap: 0.9rem; }
.dossier { border: 1.5px solid var(--ink); background: var(--paper-2); }
.dossier summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.95rem 1.1rem;
  flex-wrap: wrap;
}
.dossier summary::-webkit-details-marker { display: none; }
.dossier summary::before {
  content: "+";
  font-family: var(--mono);
  font-weight: 700;
  width: 1.2em;
  color: var(--blue);
}
.dossier[open] summary::before { content: "–"; }
.dossier-name { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.dossier-trade { font-size: 0.85rem; color: var(--ink-soft); }
.dossier-code {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.25em 0.6em;
  border: 1px solid var(--line);
  background: var(--paper);
  margin-left: auto;
}
.dossier-count { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); }

.dossier-body { border-top: 1px solid var(--line); padding: 0.4rem 1.1rem 1rem; }
.auto-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--line-soft);
  flex-wrap: wrap;
}
.auto-row:last-of-type { border-bottom: none; }
.auto-row-ref { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-soft); min-width: 4.2em; }
.auto-row-name { font-weight: 600; font-size: 0.98rem; }
.auto-row-meta { font-family: var(--mono); font-size: 0.68rem; color: var(--concrete); }
.auto-row-switch { margin-left: auto; display: inline-flex; align-items: center; gap: 0.6rem; }
.switch-state { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); min-width: 6.5em; text-align: right; }

.switch {
  position: relative;
  width: 46px; height: 26px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--ink);
  transition: transform 0.15s ease;
}
.switch[aria-checked="true"] { background: var(--yellow); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.dossier-actions { display: flex; gap: 0.8rem; margin-top: 0.9rem; flex-wrap: wrap; }

.admin-note {
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-left: 3px solid var(--blue);
  padding-left: 0.9rem;
}

/* ---------- Pied ---------- */

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem var(--pad);
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

/* ---------- Petits écrans ---------- */

@media (max-width: 560px) {
  .code-row { flex-direction: column; }
  .code-row .btn { width: 100%; }
  .fiche-top { flex-direction: column-reverse; align-items: flex-start; }
  .stamp { align-self: flex-start; }
  .dossier-code { margin-left: 0; }
  .auto-row-switch { margin-left: 0; width: 100%; justify-content: space-between; }
  .cta-card .btn { width: 100%; }
}

/* ---------- Mouvement réduit ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .plumb-hero { animation: none; }
  .btn, .chip, .switch, .switch::after { transition: none; }
}
