/*
 * Univers visuel : le tapis de découpe de l'atelier (vert, quadrillé de jaune)
 * sur lequel repose la carte. Le quadrillage est à l'échelle : 1 carreau = 5 mm.
 */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/ui/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../fonts/ui/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/ui/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/ui/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("../fonts/ui/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

/* Polices proposées sur la carte, pour montrer chaque choix dans son propre dessin. */
@font-face { font-family: "Carte Atelier"; font-display: swap; src: url("../fonts/card/barlow-700.ttf") format("truetype"); }
@font-face { font-family: "Carte Ronde"; font-display: swap; src: url("../fonts/card/outfit-700.ttf") format("truetype"); }
@font-face { font-family: "Carte Classique"; font-display: swap; src: url("../fonts/card/lora-700.ttf") format("truetype"); }
@font-face { font-family: "Carte Technique"; font-display: swap; src: url("../fonts/card/mono-700.ttf") format("truetype"); }

:root {
  --mat: #1f5a46;
  --mat-deep: #17443a;
  --mat-line: rgba(242, 194, 48, 0.16);
  --mat-line-strong: rgba(242, 194, 48, 0.34);
  --yellow: #f2c230;
  --yellow-deep: #d9a90f;
  --paper: #f3f5f2;
  --white: #ffffff;
  --ink: #14211c;
  --muted: #4f5f58;
  --line: #d3dad5;
  --line-strong: #93a39b;
  --danger: #a3231b;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--body);
}

h1, h2, h3, legend { font-family: var(--display); font-weight: 700; line-height: 1; margin: 0; }
h2 { font-size: clamp(2rem, 4vw, 2.75rem); margin-bottom: 1.75rem; }
h3 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.4rem; }
p { margin: 0 0 1rem; max-width: 62ch; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.band :focus-visible, .panel :focus-visible, .sheet :focus-visible { outline-color: var(--mat); }

.skip { position: absolute; left: -999px; top: 0; background: var(--yellow); color: var(--ink); padding: 0.6rem 1rem; z-index: 20; }
.skip:focus { left: 0; }

/* ---------- Tapis de découpe ---------- */

.mat {
  --cell: calc(var(--mm, 4.4px) * 5);
  color: var(--white);
  background-color: var(--mat);
  background-image:
    linear-gradient(var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(var(--mat-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
  background-size:
    calc(var(--cell) * 2) calc(var(--cell) * 2), calc(var(--cell) * 2) calc(var(--cell) * 2),
    var(--cell) var(--cell), var(--cell) var(--cell);
}

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

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  background: var(--mat-deep); color: var(--white);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; font: 700 1.6rem/1 var(--display); letter-spacing: 0.01em; }
.brand svg { width: 30px; height: 30px; fill: none; stroke: var(--yellow); stroke-width: 1.7; stroke-linecap: round; }
.toplink { text-underline-offset: 0.25em; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0.7rem 1.4rem;
  background: var(--yellow); color: var(--ink);
  border: 2px solid var(--ink); border-radius: var(--radius);
  font: 600 1.0625rem/1.1 var(--body); text-decoration: none; cursor: pointer;
  transition: background-color 0.12s, transform 0.12s;
}
.btn:hover { background: var(--yellow-deep); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn--small { min-height: 40px; padding: 0.45rem 1rem; font-size: 1rem; border-color: transparent; }
.btn--quiet { background: transparent; }
.btn--quiet:hover { background: rgba(20, 33, 28, 0.08); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: rgba(163, 35, 27, 0.08); }

/* ---------- Accueil : la carte sur le tapis ---------- */

.hero {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center;
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(2.5rem, 7vw, 6rem) clamp(1rem, 4vw, 2.5rem) clamp(3rem, 8vw, 7rem);
  overflow: hidden;
}
.hero h1 { font-size: clamp(3rem, 7.2vw, 6rem); line-height: 0.92; letter-spacing: -0.005em; margin-bottom: 1.5rem; max-width: 9em; text-wrap: balance; }
.lead { font-size: 1.2rem; line-height: 1.5; max-width: 34em; color: #e3efe9; margin-bottom: 2rem; }

.try label { display: block; font-weight: 500; margin-bottom: 0.4rem; }
.try-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.try input[type="text"] { flex: 1 1 14rem; width: auto; min-width: 0; min-height: 48px; border: 2px solid var(--ink); font-weight: 500; }

.hero-stage { position: relative; aspect-ratio: 1 / 0.82; width: min(100%, 620px); justify-self: center; }
.hero-card {
  position: absolute; width: 66%; aspect-ratio: 85.6 / 53.98;
  filter: drop-shadow(0 1px 1px rgba(4, 24, 17, 0.45)) drop-shadow(0 16px 22px rgba(4, 24, 17, 0.42));
}
.hero-card svg, .face-card svg, .material-card svg { display: block; width: 100%; height: auto; }
.hero-card--verso { left: 1%; top: 3%; transform: rotate(-6deg); }
.hero-card--recto { right: 6%; bottom: 8%; transform: rotate(3deg); }

/* Cotes de la carte, comme sur un plan. */
.dim { position: absolute; display: flex; align-items: center; gap: 0.5em; color: var(--yellow); font: 500 0.8125rem/1 var(--body); white-space: nowrap; }
.dim::before, .dim::after { content: ""; flex: 1; height: 1px; background: currentColor; }
.dim--w { left: 0; right: 0; top: calc(100% + 10px); }
.dim--h { left: calc(100% + 10px); top: 0; height: 100%; writing-mode: vertical-rl; }
.dim--h::before, .dim--h::after { width: 1px; height: auto; }

/* Le faisceau passe une fois : la gravure apparaît derrière lui. */
.cr-reveal { transform: scaleX(0); transform-origin: 0 0; animation: cr-reveal 1.7s 0.5s cubic-bezier(0.45, 0, 0.3, 1) forwards; }
.cr-beam { opacity: 0; animation: cr-beam 1.7s 0.5s cubic-bezier(0.45, 0, 0.3, 1) forwards; }
@keyframes cr-reveal { to { transform: scaleX(1); } }
@keyframes cr-beam {
  0% { opacity: 0.95; transform: translateX(0); }
  94% { opacity: 0.95; }
  100% { opacity: 0; transform: translateX(86.6px); }
}

/* ---------- Sections de l'accueil ---------- */

.band { padding: clamp(3rem, 7vw, 5.5rem) clamp(1rem, 4vw, 2.5rem); }
.band > * { max-width: 1040px; margin-left: auto; margin-right: auto; }
.band--tint { background: var(--white); }

.steps { list-style: none; padding: 0; margin-top: 0; margin-bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.5rem; counter-reset: etape; }
.steps li { counter-increment: etape; }
.steps li::before { content: counter(etape); display: block; font: 700 4.5rem/0.9 var(--display); color: var(--mat); margin-bottom: 0.75rem; }
.steps p { color: var(--muted); margin: 0; }

.materials { list-style: none; padding: 0; margin-top: 0; margin-bottom: 1.25rem; }
.material { display: grid; grid-template-columns: 168px minmax(0, 1fr) auto; align-items: center; gap: 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.material:last-child { border-bottom: 1px solid var(--line); }
.material-card { filter: drop-shadow(0 1px 1px rgba(20, 33, 28, 0.25)) drop-shadow(0 6px 10px rgba(20, 33, 28, 0.16)); }
.material-text p { margin: 0; color: var(--muted); }
.material-text h3 { margin-bottom: 0.2rem; }
.price { font: 700 2.5rem/1 var(--display); margin: 0; white-space: nowrap; }
.fine { color: var(--muted); font-size: 0.9375rem; margin-bottom: 1.5rem; }
.notice { padding: 0.8rem 1rem; background: #fff6d6; border-left: 4px solid var(--yellow-deep); border-radius: 0 var(--radius) var(--radius) 0; }

.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 1.1rem 2rem 1.1rem 0; font: 600 1.4rem/1.15 var(--display); list-style: none; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0.25rem; top: 50%; transform: translateY(-52%); font: 500 1.6rem/1 var(--body); color: var(--mat); }
.faq details[open] summary::after { content: "–"; }
.faq details p { color: var(--muted); padding-bottom: 1.1rem; margin: 0; }

.foot { padding: 2rem clamp(1rem, 4vw, 2.5rem); background: var(--mat-deep); color: #d5e5dd; font-size: 0.9375rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }
.foot p { margin: 0; }
.contact { color: var(--white); font-weight: 500; }

.plain { padding: clamp(3rem, 10vw, 7rem) clamp(1rem, 4vw, 2.5rem); max-width: 760px; margin: 0 auto; }
.plain h1 { font-size: clamp(2.5rem, 6vw, 4rem); margin-bottom: 1rem; }
.plain .btn { margin: 0.5rem 0.5rem 0 0; }

/* ---------- Éditeur ---------- */

/* Les barres collantes ne doivent pas masquer le champ qui reçoit le focus. */
html:has(.page-editor) { scroll-padding: 1rem 0 6.5rem; }

.editor { display: grid; grid-template-columns: minmax(360px, 480px) minmax(0, 1fr); align-items: start; }

.stage {
  order: 2; position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
}
.faces { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; width: 100%; }
.face { margin: 0; width: min(100%, 540px, calc((100dvh - 17rem) / 2 * 1.586)); }
.faces--single .face { width: min(100%, 600px, calc((100dvh - 14rem) * 1.586)); }
.face-card { aspect-ratio: 85.6 / 53.98; filter: drop-shadow(0 1px 1px rgba(4, 24, 17, 0.45)) drop-shadow(0 12px 18px rgba(4, 24, 17, 0.4)); }
.face figcaption { margin-top: 0.5rem; text-align: center; font-size: 0.875rem; font-weight: 500; color: #cfe2d9; }

.warnings { list-style: none; margin: 0; padding: 0; width: min(100%, 540px); }
.warnings li { background: var(--yellow); color: var(--ink); padding: 0.55rem 0.8rem; border-radius: var(--radius); font-size: 0.9375rem; line-height: 1.35; }
.warnings li + li { margin-top: 0.4rem; }

.stage-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.5rem; font-size: 0.875rem; color: #cfe2d9; }
.stage-foot p { margin: 0; }

.panel { order: 1; padding: 2rem clamp(1rem, 3vw, 2.25rem) 0; min-width: 0; }
.panel h1 { font-size: clamp(2.25rem, 4vw, 3rem); margin-bottom: 1.75rem; }

fieldset { border: 0; padding: 0; margin: 0 0 2.25rem; min-width: 0; }
legend { font-size: 1.5rem; padding: 0; margin-bottom: 0.9rem; }

.field { margin-bottom: 1rem; min-width: 0; flex: 1 1 0; }
.field-row { display: flex; gap: 0.9rem; }
.field--narrow { flex: 0 0 6.5rem; }
.field label { display: block; font-weight: 500; margin-bottom: 0.3rem; }
.opt { font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-left: 0.3em; }

input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; min-height: 46px; padding: 0.55rem 0.75rem;
  background: var(--white); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  font: 400 1.0625rem/1.3 var(--body);
}
textarea { resize: vertical; }
input::placeholder { color: #8a9992; }
.panel input:focus-visible, .sheet input:focus-visible, .sheet select:focus-visible, .sheet textarea:focus-visible { border-color: var(--mat); outline-offset: 0; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.help { font-size: 0.9375rem; color: var(--muted); margin: 0.35rem 0 0; }
.error { font-size: 0.9375rem; color: var(--danger); font-weight: 500; margin: 0.35rem 0 0; }

.check { display: flex; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.6rem; cursor: pointer; line-height: 1.35; }
.check input { flex: none; width: 1.25rem; height: 1.25rem; margin: 0.1rem 0 0; accent-color: var(--mat); }
.check--onmat { margin: 0; align-items: center; }
.check--onmat input { accent-color: var(--yellow); margin: 0; }

.choices { display: grid; gap: 0.6rem; }
.choices--fonts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
  position: relative; display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75rem 0.9rem; background: var(--white);
  border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice:hover { border-color: var(--line-strong); }
.choice:has(input:checked) { border-color: var(--mat); box-shadow: inset 0 0 0 1.5px var(--mat); background: #edf5f0; }
.choice:has(input:focus-visible) { outline: 3px solid var(--mat); outline-offset: 2px; }
.choice-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.choice-title { font-weight: 600; line-height: 1.2; }
.choice-hint { font-size: 0.875rem; color: var(--muted); line-height: 1.3; margin-top: 0.15rem; }
.choice-price { font: 700 1.5rem/1 var(--display); white-space: nowrap; }
.choices--fonts .choice-title { font-size: 1.3rem; font-weight: 400; }
.font-barlow { font-family: "Carte Atelier", var(--body); }
.font-outfit { font-family: "Carte Ronde", var(--body); }
.font-lora { font-family: "Carte Classique", Georgia, serif; }
.font-mono { font-family: "Carte Technique", ui-monospace, monospace; font-size: 1.1rem !important; }
.swatch { flex: none; display: grid; place-items: center; width: 54px; height: 34px; border-radius: 4px; font: 700 0.95rem/1 var(--body); box-shadow: 0 0 0 1px rgba(20, 33, 28, 0.18); }

.orderbar {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin: 0 calc(-1 * clamp(1rem, 3vw, 2.25rem)); padding: 0.9rem clamp(1rem, 3vw, 2.25rem);
  background: var(--paper); border-top: 1px solid var(--line);
}
.total { margin: 0; color: var(--muted); }
.total strong { font: 700 2.1rem/1 var(--display); color: var(--ink); margin-right: 0.2rem; }
.orderbar .notice { margin: 0; }

/* ---------- Fenêtre de commande ---------- */

.sheet { width: min(calc(100% - 1.5rem), 540px); max-height: calc(100dvh - 1.5rem); padding: clamp(1.25rem, 4vw, 2rem); border: 0; border-radius: 10px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px rgba(4, 24, 17, 0.45); }
.sheet::backdrop { background: rgba(13, 44, 34, 0.72); }
.sheet h2 { font-size: 2.25rem; margin-bottom: 0.75rem; }
.recap { color: var(--muted); font-size: 0.9375rem; overflow-wrap: anywhere; margin-bottom: 1.25rem; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Écrans étroits ---------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-stage { order: -1; width: min(100%, 440px); }
  .steps { grid-template-columns: 1fr; gap: 1.75rem; }
  .steps li { display: grid; grid-template-columns: 3rem 1fr; column-gap: 0.75rem; }
  .steps li::before { grid-row: span 2; font-size: 3.5rem; }
  .material { grid-template-columns: 96px minmax(0, 1fr) auto; gap: 0.9rem; }
  .price { font-size: 2rem; }

  html:has(.page-editor) { scroll-padding-top: 19rem; }
  .editor { grid-template-columns: 1fr; }
  .stage { order: 0; height: auto; z-index: 3; padding: 0.9rem 0 0.7rem; gap: 0.6rem; box-shadow: 0 6px 14px rgba(4, 24, 17, 0.25); }
  .faces { flex-direction: row; align-items: flex-start; justify-content: flex-start; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0.9rem; padding: 0 9% 0.4rem; scrollbar-width: none; }
  .faces::-webkit-scrollbar { display: none; }
  .face, .faces--single .face { flex: 0 0 82%; width: auto; max-width: 340px; scroll-snap-align: center; }
  .faces--single { justify-content: center; }
  .face figcaption { margin-top: 0.35rem; font-size: 0.8125rem; }
  .warnings { width: auto; margin: 0 0.9rem; }
  .warnings li { font-size: 0.875rem; padding: 0.4rem 0.6rem; }
  .stage-foot { display: none; }
  .panel { padding-top: 1.5rem; }
  .orderbar { flex-wrap: nowrap; gap: 0.75rem; }
  .orderbar .btn { padding: 0.6rem 0.9rem; font-size: 1rem; }
  .total { line-height: 1.15; }
  .total strong { display: block; font-size: 1.9rem; }
}

@media (max-width: 480px) {
  .field-row { flex-direction: column; gap: 0; }
  .field--narrow { flex: 1 1 auto; }
  .choices--fonts { grid-template-columns: 1fr; }
  .dim--h { display: none; }
}

@media (max-height: 520px) and (max-width: 900px) {
  .stage { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cr-reveal { animation: none; transform: none; }
  .cr-beam { display: none; }
  .btn { transition: none; }
}
