/* Reusable components (buttons, chips, cards, progress…), used by both spaces. */

/* Brand — hand-drawn logo (img/logo-jolly.svg, img/logo-j.svg), painted with the text colour
   through a CSS mask so it follows Day / Night. In headers, "Jolly" turns into the J once the
   page is scrolled (html.is-scrolled, set by js/shared/brand-init.js). */
.brand { position: relative; display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.logo-jolly, .logo-j { display: block; flex: none; background: currentColor; }
.logo-jolly {
  height: 44px; aspect-ratio: 2189 / 1543;
  -webkit-mask: url("/img/logo-jolly.svg") center / contain no-repeat; mask: url("/img/logo-jolly.svg") center / contain no-repeat;
}
.logo-j {
  height: 38px; aspect-ratio: 1415 / 2062;
  -webkit-mask: url("/img/logo-j.svg") center / contain no-repeat; mask: url("/img/logo-j.svg") center / contain no-repeat;
}
.brand .logo-j { position: absolute; left: 0; top: 50%; }
.brand .logo-jolly, .brand .logo-j { transition: opacity .3s ease, transform .4s cubic-bezier(.3, 1.4, .5, 1); }
.brand .logo-j { opacity: 0; transform: translateY(-50%) rotate(-25deg) scale(.6); }
.is-scrolled header .brand .logo-jolly { opacity: 0; transform: scale(.8); }
.is-scrolled header .brand .logo-j { opacity: 1; transform: translateY(-50%); }

/* Page loader — the J spins on itself while the page loads (html.jh-loading, brand-init.js) */
.jh-loading::before, .jh-loading::after { content: ""; position: fixed; transition: opacity .4s ease; }
.jh-loading::before { inset: 0; z-index: 9998; background: var(--bg); }
.jh-loading::after {
  z-index: 9999; left: 50%; top: 50%; width: 48px; height: 70px; margin: -35px 0 0 -24px; background: var(--pop);
  -webkit-mask: url("/img/logo-j.svg") center / contain no-repeat; mask: url("/img/logo-j.svg") center / contain no-repeat;
  animation: jh-spin 1.1s cubic-bezier(.45, 0, .55, 1) infinite;
}
.jh-loaded::before, .jh-loaded::after { opacity: 0; pointer-events: none; }
@keyframes jh-spin { from { transform: perspective(300px) rotateY(0deg); } to { transform: perspective(300px) rotateY(360deg); } }
@keyframes jh-breathe { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .jh-loading::after { animation: jh-breathe 1.2s ease-in-out infinite; }
  .brand .logo-jolly, .brand .logo-j { transition: opacity .2s; }
}

/* Day / Night switch (website, questionnaire, studio, client space) */
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
.theme-switch button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--muted);
}
.theme-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-switch button[data-theme-choice="day"] svg circle { fill: currentColor; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.theme-switch button[aria-pressed="true"][data-theme-choice="day"] { color: var(--pop); }
.theme-switch button[aria-pressed="true"][data-theme-choice="night"] { color: var(--accent); }
.theme-switch button:focus-visible { outline: 2px solid var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 9px 16px; border-radius: var(--r-sm);
  cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--muted); }
.btn.primary {
  background: var(--accent);
  border: 0; color: var(--on-accent);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--sunk); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Chips & statuses */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: var(--sunk); color: var(--ink);
}
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.example { background: transparent; border: 1px dashed var(--line); color: var(--muted); }

.is-nouveau, .is-review, .dv-review { background: var(--ochre-soft); color: var(--ochre); }
.is-analyse, .is-doing { background: var(--info-soft); color: var(--info); }
.is-proposition, .is-done, .is-approved { background: var(--ok-soft); color: var(--ok); }
.is-encours { background: var(--ok); color: var(--on-accent); }
.is-termine, .is-todo { background: var(--sunk); color: var(--muted); }
.is-changes { background: var(--danger-soft); color: var(--danger); }

/* Cards */
.panel { background: var(--surface); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Illustrated room cover (stands in for photos and renders) */
.cover {
  display: block; position: relative; aspect-ratio: 20 / 13; max-width: 100%;
  border-radius: var(--r); overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.cover svg, .cover img { display: block; width: 100%; height: 100%; }
.cover img { object-fit: cover; }
.cover .tag { position: absolute; top: 12px; left: 12px; }
.cover .tag .chip { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Progress meter */
.meter { display: block; position: relative; width: 100%; height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: inherit; z-index: 1; }
.meter > span.secondary { background: var(--accent-soft); outline: 1px solid var(--line); z-index: 0; }
.meter.big { height: 12px; border-radius: 6px; }

/* Alerts */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--sunk); font-size: .9rem; }
.alert::before { content: ""; border-radius: 4px; background: var(--muted); }
.alert.warn::before { background: var(--ochre); }
.alert.crit::before { background: var(--danger); }
.alert.info::before { background: var(--info); }
.alert b { display: block; }

/* Palette swatches */
.swatches { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; }
.swatch { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; }
.swatch i { display: block; aspect-ratio: 4 / 3; border-radius: 8px; border: 1px solid var(--line); }
.swatch code { font-family: var(--font-code); color: var(--muted); font-size: .7rem; }

/* Key / value list */
.kv { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr); gap: 6px 12px; font-size: .88rem; }
.kv > span:nth-child(odd) { color: var(--muted); }
.kv a { color: var(--accent); font-weight: 700; overflow-wrap: anywhere; }

/* Horizontal bars */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: .88rem; }
.bar .track { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.top .fill { background: var(--ochre); }
.bar .value { font-size: .8rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* List rows (label + value/status on the right) */
.line-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.line-item:first-child { border-top: 0; }
.line-item > :first-child { min-width: 0; flex: 1 1 180px; }
.line-item small { display: block; }

/* Message thread */
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.msg { background: var(--sunk); border-radius: 12px; padding: 9px 12px; font-size: .9rem; max-width: 92%; }
.msg.mine { background: var(--accent-soft); align-self: flex-end; }
.msg-meta { font-size: .75rem; color: var(--muted); margin-bottom: 2px; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 700; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }

/* Highlighted text blocks */
.next-step { background: var(--sunk); border-radius: 12px; padding: 14px 16px; }
.why { font-size: .92rem; border-left: 2px solid var(--line); padding-left: 14px; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: var(--r-sm); font-size: .9rem; z-index: 20;
  box-shadow: var(--shadow-hi);
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 860px) {
  .bar { grid-template-columns: 110px minmax(0, 1fr) 40px; }
}
