/* Le Labo des Cabanes
   Palette : papier, bois clair, terre cuite, sauge. */

:root {
  --paper: #efe7d9;
  --paper-2: #e7dccb;
  --card: #fbf7ef;
  --card-2: #f6f0e4;
  --ink: #2b2721;
  --ink-2: #4c453b;
  --muted: #7d7263;
  --line: #ded2bf;
  --line-2: #e9e0d1;
  --terracotta: #b4552f;
  --terracotta-2: #cf7148;
  --sage: #5f7458;
  --gold: #c1964e;
  --danger: #b23b2e;
  --shadow: 0 1px 1px rgb(60 45 30 / .04), 0 8px 24px rgb(60 45 30 / .06);
  --shadow-lg: 0 2px 4px rgb(60 45 30 / .05), 0 24px 60px rgb(60 45 30 / .12);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 18% -10%, #faf5ea 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 110%, #e7dbc7 0%, transparent 55%),
    var(--paper);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: #e7c9b5; }

.app {
  position: relative;
  height: 100dvh;
  padding: 18px 20px 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  max-width: 1680px;
  margin: 0 auto;
}

/* ---------- Barre haute ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 4px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand-mark {
  width: 46px; height: 46px;
  color: var(--terracotta);
  flex: none;
  background: #f7f1e6;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.brand-kicker {
  display: block;
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(19px, 2vw, 24px);
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand h1 em { font-style: italic; color: var(--muted); font-weight: 400; }

.packbar { display: flex; align-items: center; gap: 14px; }

.pack-pill {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: #f3eadb;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 7px 13px;
  white-space: nowrap;
}
.pack-pill strong { font-size: 12px; letter-spacing: .01em; }
.pack-pill span { color: var(--muted); }

/* ---------- Grille ---------- */

.layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr) 342px;
  gap: 14px;
  min-height: 0;
}

.panel {
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  backdrop-filter: blur(6px);
}

/* ---------- Galerie ---------- */

.gallery {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 16px 10px;
}
.gallery-head h2 {
  margin: 0; font-family: var(--serif); font-weight: 500; font-size: 18px; letter-spacing: -.01em;
}
.gallery-head .count {
  font-size: 11px; color: var(--muted); background: var(--card-2);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 8px;
}

.filters { padding: 0 16px 12px; border-bottom: 1px solid var(--line-2); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  line-height: 1.3;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--card-2); }
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fbf7ef;
}

.switch {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--ink-2); cursor: pointer; user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 30px; height: 18px; border-radius: 999px;
  background: #ddd1bf; position: relative; transition: background .18s;
  flex: none;
}
.switch-dot {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fffdf8; box-shadow: 0 1px 2px rgb(0 0 0 / .2);
  transition: transform .18s;
}
.switch input:checked + .switch-track { background: var(--sage); }
.switch input:checked + .switch-track .switch-dot { transform: translateX(12px); }

.gallery-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: #d5c7b2 transparent;
}

.card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 7px 9px 7px 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  transition: background .15s, border-color .15s, transform .15s;
}
.card:hover { background: #f7f0e3; }
.card.active {
  background: #fffaf0;
  border-color: var(--line);
  box-shadow: 0 1px 2px rgb(60 45 30 / .05);
}
.card.active .card-name { color: var(--terracotta); }

.card-thumb {
  width: 64px; height: 54px;
  border-radius: 9px;
  background: linear-gradient(160deg, #f4ecdd, #eee3d1);
  border: 1px solid var(--line-2);
  overflow: hidden;
  display: grid; place-items: center;
}
.card-thumb svg { width: 100%; height: 100%; display: block; }

.card-body { min-width: 0; }
.card-name {
  font-size: 13px; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sub {
  margin-top: 2px; font-size: 10.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.badge {
  font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 3px 6px; white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok { color: #47603f; background: #e8efe1; border-color: #d3e0c8; }
.badge.over { color: #9a4a2c; background: #f8e7db; border-color: #eed3c0; }
.badge.partial { color: #7d6430; background: #f7eed6; border-color: #ecdfba; }

/* ---------- Scène ---------- */

.stage {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, #fffdf8 0%, #fbf6ec 55%, #f4ecdd 100%);
}

.stage-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 16px 18px 8px;
}

.eyebrow {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--terracotta); font-weight: 600;
}

.stage-title {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(22px, 2.4vw, 31px);
  letter-spacing: -.02em;
  line-height: 1.05;
}

.stage-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 10px;
  padding: 6px 9px;
  font-size: 11px; color: var(--ink-2);
  transition: background .15s, border-color .15s;
}
.icon-btn svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn:hover { background: #fff; border-color: #cbbcA6; }
.icon-btn[aria-pressed="false"] { opacity: .55; }

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 260px;
  margin: 4px 10px 0;
  border-radius: 14px;
  overflow: hidden;
}
.canvas-wrap::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(222 210 191 / .55);
  border-radius: 14px;
}
#scene { display: block; width: 100%; height: 100%; touch-action: none; }

.canvas-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  font-size: 10.5px; color: #8a7d6a;
  background: rgb(251 247 239 / .82);
  border: 1px solid var(--line-2);
  padding: 4px 9px; border-radius: 999px;
  pointer-events: none;
  transition: opacity .4s;
  white-space: nowrap;
}
.canvas-hint.hide { opacity: 0; }

.scalebar {
  position: absolute; right: 14px; bottom: 13px;
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; letter-spacing: .06em; color: #8a7d6a;
  text-transform: uppercase;
  pointer-events: none;
}
.scalebar-line {
  display: block; width: 40px; height: 6px;
  border-left: 1px solid #a79880; border-right: 1px solid #a79880;
  border-bottom: 1px solid #a79880;
}

.stage-badges {
  position: absolute; left: 12px; top: 12px;
  display: flex; gap: 5px; flex-wrap: wrap; pointer-events: none;
}
.stage-badge {
  font-size: 10px; background: rgb(251 247 239 / .9);
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 3px 8px; color: var(--ink-2);
}

.stage-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 10px 16px 14px;
}

.budget { display: flex; gap: 16px; flex-wrap: wrap; }
.budget-item { min-width: 112px; }
.budget-label { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.budget-value { font-size: 12.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.budget-value strong { font-size: 15px; }
.budget-bar { height: 3px; border-radius: 99px; background: #e4d8c7; margin-top: 4px; overflow: hidden; }
.budget-bar > span { display: block; height: 100%; background: var(--sage); border-radius: 99px; }
.budget-item.over .budget-bar > span { background: var(--danger); }
.budget-item.over .budget-value { color: var(--danger); }

.nav { display: flex; gap: 6px; align-items: center; }
.ghost-btn {
  border: 1px solid var(--line); background: transparent;
  border-radius: 9px; padding: 6px 10px; font-size: 11.5px; color: var(--ink-2);
}
.ghost-btn:hover { background: #fffaf0; }
.ghost-btn:first-child, .ghost-btn:nth-child(2) { width: 34px; padding: 6px 0; }

/* ---------- Détail ---------- */

.detail { overflow: hidden; display: flex; }
.detail-scroll {
  overflow-y: auto; padding: 20px 20px 22px; width: 100%;
  scrollbar-width: thin; scrollbar-color: #d5c7b2 transparent;
}

.tag-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
  font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 5px;
  background: #f1e7d7; color: #75664f; border: 1px solid #e6d9c5;
}
.tag.accent { background: #f6e3d6; color: #9d4b2a; border-color: #ecccb8; }

.detail h2 {
  margin: 0 0 6px;
  font-family: var(--serif); font-weight: 500;
  font-size: 30px; line-height: 1.02; letter-spacing: -.025em;
}

.pitch { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); }

.story {
  margin: 16px 0 4px;
  padding: 12px 14px;
  border-left: 2px solid var(--terracotta-2);
  background: linear-gradient(90deg, #fbf1e4, #fbf7ef);
  border-radius: 0 10px 10px 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.45;
  color: #5a4e40;
}
.story:empty { display: none; }

.block { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line-2); }
.block h3 {
  margin: 0 0 10px;
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}

.meter { margin-bottom: 10px; }
.meter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--ink-2); margin-bottom: 4px;
}
.meter-head strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.meter-head small { font-size: 11px; color: var(--muted); font-weight: 400; }
.meter-track { height: 5px; background: #e8ddcc; border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--sage); border-radius: 99px; transition: width .4s ease; }
.meter.over .meter-fill { background: var(--danger); }
.meter.over .meter-head strong { color: var(--danger); }
.meter.warn .meter-fill { background: var(--gold); }

.fit-note { margin: 8px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.fit-note strong { color: var(--ink-2); }

.dims { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.dims .num {
  font-family: var(--serif); font-size: 24px; letter-spacing: -.02em;
}
.dims .x { color: var(--muted); font-size: 14px; }
.dims-legend { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.steps li {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: baseline;
  font-size: 12px; color: var(--ink-2);
}
.steps .n {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; color: var(--terracotta);
  border: 1px solid #e7cdb9; background: #fbf1e4;
}
.steps .qty { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.notes { margin: 0; padding: 0; list-style: none; font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.notes li { margin-bottom: 6px; padding-left: 13px; position: relative; }
.notes li::before { content: "·"; position: absolute; left: 2px; color: var(--terracotta); font-weight: 700; }
.notes strong { color: var(--ink-2); font-weight: 600; }
.dots { display: inline-flex; gap: 3px; vertical-align: -1px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: #d8cbb7; display: block; }
.dots i.on { background: var(--terracotta); }

.learn-btn {
  margin-top: 18px; width: 100%;
  border: 1px dashed #cdbca3; background: transparent;
  padding: 9px 12px; border-radius: 10px;
  font-size: 11.5px; color: var(--ink-2);
}
.learn-btn:hover { background: #faf3e7; }

/* ---------- Modale ---------- */

.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgb(43 39 33 / .25);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .18s ease;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } }

.modal-card {
  position: relative;
  max-width: 840px; width: 100%;
  max-height: 88vh; overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 30px 32px;
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  border: 0; background: transparent; font-size: 26px; line-height: 1;
  color: var(--muted); padding: 4px;
}
.modal-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 26px; align-items: center; }
.modal h2 { font-family: var(--serif); font-weight: 500; font-size: 32px; margin: 4px 0 12px; letter-spacing: -.025em; }
.modal p { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.modal .fine { font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 10px; }
.modal-figure { text-align: center; }
.modal-figure svg { width: 100%; max-width: 300px; }
.figure-caption { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Encombrement et montage (dépliant) ---------- */

.more { padding: 0; overflow: hidden; }
.more > summary {
  list-style: none;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: -.01em;
  user-select: none;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary::after {
  content: '+';
  font-family: var(--sans);
  font-size: 17px;
  color: var(--muted);
  margin-left: auto;
}
.more[open] > summary::after { content: '−'; }
.more > summary:hover { background: var(--card-2); }
.more-hint { font-family: var(--sans); font-size: 10.5px; color: var(--muted); letter-spacing: 0; }
.more-body { padding: 0 16px 16px; border-top: 1px solid var(--line-2); }
.more-body h3 { margin-top: 14px; }
.more-body h3:first-child { margin-top: 12px; }

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
  .layout { grid-template-columns: 264px minmax(0, 1fr) 316px; }
  .brand h1 em { display: none; }
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: 244px minmax(0, 1fr); }
  .detail {
    position: fixed; right: 16px; bottom: 16px; top: auto;
    width: 330px; max-height: 62vh; z-index: 20;
    box-shadow: var(--shadow-lg);
  }
  .app { padding: 14px; }
}

@media (max-width: 760px) {
  html, body { height: auto; }
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; padding: 12px; gap: 12px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .brand { gap: 10px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand h1 { font-size: 18px; white-space: normal; }
  .brand h1 em { display: none; }
  .brand-kicker { font-size: 9.5px; }
  .packbar { width: 100%; }
  .pack-pill { width: 100%; justify-content: center; flex-wrap: wrap; row-gap: 2px; }
  .layout { grid-template-columns: 1fr; gap: 12px; }
  .stage { order: 1; min-height: 58dvh; }
  .gallery { order: 2; max-height: none; }
  .detail { order: 3; position: static; width: auto; max-height: none; }
  .detail-scroll { max-height: none; padding: 18px 16px 22px; }
  .gallery-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding: 8px 12px 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .card {
    flex: 0 0 208px;
    scroll-snap-align: start;
    background: #fffaf0;
    border-color: var(--line-2);
    padding: 9px;
  }
  .card-thumb { width: 54px; height: 48px; }
  .stage-head { padding: 14px 14px 6px; flex-wrap: wrap; }
  .stage-actions { gap: 6px; }
  .icon-btn { min-height: 44px; padding: 8px 10px; }
  .stage-foot { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 14px 14px; }
  .nav { display: grid; grid-template-columns: 44px 44px 1fr; gap: 8px; }
  .ghost-btn { min-height: 44px; font-size: 13px; }
  .ghost-btn:first-child, .ghost-btn:nth-child(2) { width: auto; padding: 0; }
  .canvas-hint { font-size: 10px; left: 12px; bottom: 12px; }
  .scalebar { right: 12px; bottom: 12px; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 22px; }
  .more > summary { padding: 16px; min-height: 48px; }
}

@media (max-width: 420px) {
  .stage { min-height: 52dvh; }
  .stage-title { font-size: 22px; }
  .icon-btn span { display: none; }
  .icon-btn { width: 44px; justify-content: center; }
  .pack-pill span { font-size: 10.5px; }
}
