/* ===========================================================================
   Kër Atelier — boutique en ligne (démo Zephyr)
   Parti pris assume : galerie claire, une seule ambiance. Un theme sombre
   subi rendait les photos de mobilier ternes et le tout un peu triste.
   Autonome : aucune requête externe, polices système, zéro dépendance.
   Les visuels produits sont dessinés en CSS (aucune image à charger).
   =========================================================================== */

@layer reset, base, components, utils;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  img, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; cursor: pointer; }
  ul, ol { list-style: none; padding: 0; }
  a { color: inherit; }
  dialog { border: 0; padding: 0; color: inherit; }
}

@layer base {
  :root {
    --noir: #141414;
    --noir-2: #0c0c0c;
    --paper: #faf8f5;
    --paper-2: #f0ebe3;
    --laiton: #a8865b;
    --laiton-clair: #c4a87d;
    --fg: #1c1a17;
    --fg-soft: #6b645b;
    --line: rgba(28, 26, 23, 0.14);

    --teck: #9d6b43;
    --teck-clair: #c08f5f;
    --rotin: #cda873;
    --gres: #8b8375;
    --fer: #2a2724;
    --lin: #e8e0d4;

    --bg: var(--paper);
    --surface: #ffffff;

    --fs-hero: clamp(2.2rem, 3.4vw + 1rem, 4rem);
    --fs-h2: clamp(1.6rem, 1.6vw + 0.85rem, 2.35rem);
    --fs-lead: clamp(1rem, 0.3vw + 0.9rem, 1.14rem);

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --shell: 1220px;
    --pad: clamp(1.1rem, 4vw, 2.25rem);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    color-scheme: light;
  }

  body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }
  body:has(.cart:not([hidden])) { overflow: hidden; }

  h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.015em;
    text-wrap: balance;
  }
  h1 { font-size: var(--fs-hero); }
  h2 { font-size: var(--fs-h2); }
  h3 { font-size: 1.12rem; line-height: 1.25; }
  em { font-style: italic; color: var(--laiton); }
  p { text-wrap: pretty; }

  :focus-visible { outline: 2px solid var(--laiton); outline-offset: 3px; border-radius: 3px; }
  ::selection { background: var(--laiton); color: var(--paper); }
}

@layer components {
  .shell { width: min(100% - (var(--pad) * 2), var(--shell)); margin-inline: auto; }
  .section { padding-block: clamp(3.25rem, 7vw, 6rem); }

  .sr {
    position: absolute; width: 1px; height: 1px;
    padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .skip {
    position: absolute; left: 50%; translate: -50% -150%; z-index: 100;
    background: var(--noir); color: var(--paper); padding: 0.7rem 1.2rem; font-size: 0.85rem;
    transition: translate 0.2s var(--ease);
  }
  .skip:focus-visible { translate: -50% 0.6rem; }

  /* Un seul repère de lieu, en ouverture. Répéter une étiquette colorée
     au-dessus de chaque titre est ce qui donnait le ton « gabarit ». */
  .lieu {
    font-size: 0.78rem; color: var(--fg-soft); margin-bottom: 1rem;
    border-left: 2px solid var(--laiton); padding-left: 0.7rem;
  }
  .section-title { margin-bottom: 2.5rem; max-width: 22ch; }
  .lead { font-size: var(--fs-lead); color: var(--fg-soft); max-width: 40ch; }

  /* ---------- Barre haute ---------- */
  .topbar {
    position: sticky; top: 0; z-index: 30;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
  }
  .topbar-in { display: flex; align-items: center; gap: 1.5rem; min-height: 66px; }
  .brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; margin-inline-end: auto; }
  .brand-k {
    display: grid; place-items: center; width: 30px; height: 30px;
    background: var(--noir); color: var(--paper);
    font-family: var(--serif); font-size: 1rem;
  }
  .brand-word { font-family: var(--serif); font-size: 1.12rem; letter-spacing: 0.01em; }
  .brand-word i { font-style: italic; color: var(--fg-soft); }

  .nav { display: none; }
  @media (min-width: 860px) {
    .nav { display: block; }
    .nav ul { display: flex; gap: 1.75rem; }
    .nav a { text-decoration: none; font-size: 0.87rem; color: var(--fg-soft); }
    .nav a:hover { color: var(--fg); }
  }

  .cart-btn {
    display: inline-flex; align-items: center; gap: 0.55rem;
    min-height: 44px; padding: 0.5rem 1rem;
    border: 1px solid var(--line); font-size: 0.87rem;
    transition: border-color 0.25s var(--ease);
  }
  .cart-btn:hover { border-color: var(--laiton); }
  .cart-count {
    display: grid; place-items: center; min-width: 22px; height: 22px;
    padding-inline: 6px; border-radius: 999px;
    background: var(--noir); color: var(--paper);
    font-size: 0.72rem; font-variant-numeric: tabular-nums;
  }
  .cart-count[data-empty="true"] { background: var(--line); color: var(--fg-soft); }

  /* ---------- Boutons ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    min-height: 44px; padding: 0.65rem 1.3rem;
    font-size: 0.88rem; text-decoration: none; border: 1px solid transparent;
    transition: background-color 0.25s var(--ease), color 0.25s var(--ease),
                border-color 0.25s var(--ease), translate 0.25s var(--ease);
  }
  .btn-ink { background: var(--noir); color: var(--paper); }
  .btn-ink:hover { background: var(--laiton); translate: 0 -2px; }
  .btn-line { border-color: var(--line); color: var(--fg); }
  .btn-line:hover { border-color: var(--laiton); color: var(--laiton); }
  .btn-line.light { border-color: rgba(250, 248, 245, 0.3); color: var(--paper); }
  .btn-line.light:hover { border-color: var(--laiton-clair); color: var(--laiton-clair); }
  .btn-full { width: 100%; }

  /* ---------- Hero ---------- */
  .hero { padding-block: clamp(2.5rem, 6vw, 5rem); }
  .hero-in { display: grid; gap: clamp(2rem, 5vw, 3.5rem); align-items: center; }
  @media (min-width: 940px) { .hero-in { grid-template-columns: 1fr 0.85fr; } }
  .hero h1 { margin-bottom: 1.35rem; }
  .hero .lead { margin-bottom: 2rem; }

  .hero-piece { margin: 0; }
  .hero-piece figcaption {
    margin-top: 0.85rem; font-size: 0.78rem; letter-spacing: 0.06em;
    color: var(--fg-soft); text-align: end;
  }
  .piece-hero { aspect-ratio: 4 / 5; }

  /* ---------- Bandeau repères ---------- */
  .strip { background: var(--paper-2); border-block: 1px solid var(--line); }
  .strip-in {
    display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem;
    padding-block: 1rem; font-size: 0.85rem; color: var(--fg-soft);
  }
  .strip-in b { font-family: var(--serif); font-size: 1.05rem; color: var(--fg); }

  /* ---------- En-tête boutique ---------- */
  .shop-head {
    display: grid; gap: 1.5rem; margin-bottom: 2.5rem;
    padding-bottom: 1.5rem; border-bottom: 1px solid var(--line);
  }
  @media (min-width: 900px) {
    .shop-head { grid-template-columns: 1fr auto; align-items: end; }
  }
  .filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .chip {
    min-height: 40px; padding: 0.4rem 1rem;
    border: 1px solid var(--line); font-size: 0.83rem; color: var(--fg-soft);
    transition: background-color 0.22s var(--ease), color 0.22s var(--ease),
                border-color 0.22s var(--ease);
  }
  .chip:hover { border-color: var(--laiton); color: var(--fg); }
  .chip.is-on { background: var(--noir); border-color: var(--noir); color: var(--paper); }

  /* ---------- Grille produits (asymétrique, pas un damier) ---------- */
  /* Grille reguliere. Les deux cartes « speciales » d'avant (une sur deux
     rangees, une sur deux colonnes) creaient de grands vides des qu'un texte
     etait court : toutes les pieces ont maintenant le meme cadre. */
  .grid {
    display: grid;
    gap: clamp(1rem, 2.5vw, 1.75rem);
    grid-template-columns: repeat(2, 1fr);
  }
  @media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
  @media (max-width: 479px) { .grid { grid-template-columns: 1fr; } }

  .product {
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 3px;
    overflow: hidden;
    transition: border-color 0.3s var(--ease), transform 0.3s var(--ease);
  }
  .product:hover { border-color: color-mix(in srgb, var(--laiton) 55%, transparent); }
  @media (hover: hover) { .product:hover { transform: translateY(-3px); } }
  .product[hidden] { display: none; }

  /* ---------- Visuels produits ----------
     Conteneur a ratio fixe : la hauteur ne depend jamais du chargement de
     l'image, donc aucun saut de mise en page. */
  .product-visual {
    position: relative;
    aspect-ratio: 4 / 5;
    background: var(--paper-2);
    overflow: hidden;
  }
  .product-visual img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    transition: scale 0.7s var(--ease);
  }
  .product:hover .product-visual img { scale: 1.04; }

  /* Une photo qui ne charge pas ne laisse jamais un rectangle vide : on
     affiche un aplat lisible qui dit ce qui manque. */
  .product-visual[data-failed]::after {
    content: "Visuel indisponible";
    position: absolute; inset: 0;
    display: grid; place-items: center;
    padding: 1rem; text-align: center;
    font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--fg-soft);
    background:
      repeating-linear-gradient(135deg, transparent 0 11px,
        color-mix(in srgb, var(--laiton) 16%, transparent) 11px 12px),
      var(--paper-2);
  }
  .product-body {
    display: flex; flex-direction: column; gap: 0.4rem;
    flex: 1; padding: 1.1rem 1.15rem 1.25rem;
  }
  .product-desc { font-size: 0.9rem; color: var(--fg-soft); }
  .product-price { font-family: var(--serif); font-size: 1.05rem; margin-top: 0.35rem; }
  .product-price b { font-weight: 400; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
  .product-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; padding-top: 0.85rem; }
  .product-actions .btn { flex: 1 1 auto; }

  .empty-state {
    padding: 3rem 1rem; text-align: center; color: var(--fg-soft); font-size: 0.95rem;
  }

  /* ---------- Bandeau atelier ---------- */
  .atelier-band { background: var(--noir); color: var(--paper); }
  .atelier-in { display: grid; gap: clamp(1.75rem, 4vw, 3.5rem); }
  @media (min-width: 900px) { .atelier-in { grid-template-columns: 1fr 1fr; } }
  .atelier-band h2 { font-size: clamp(1.8rem, 2vw + 1rem, 2.8rem); }
  .atelier-band h2 em { color: var(--laiton-clair); }
  .atelier-text p { color: rgba(250, 248, 245, 0.72); margin-bottom: 1.1rem; max-width: 52ch; }
  .atelier-text .btn { margin-top: 0.6rem; }

  /* ---------- Matières ---------- */
  .matieres { display: grid; gap: 1px; background: var(--line); border-block: 1px solid var(--line); }
  @media (min-width: 760px) { .matieres { grid-template-columns: repeat(2, 1fr); } }
  .matieres > div { background: var(--bg); padding: 1.5rem; }
  .matieres dt {
    font-family: var(--serif); font-size: 1.1rem; margin-bottom: 0.35rem;
  }
  .matieres dd { margin: 0; font-size: 0.9rem; color: var(--fg-soft); }

  /* ---------- Pied de page ---------- */
  .footer { padding-block: 2.75rem 1.5rem; border-top: 1px solid var(--line); }
  .footer-in { display: grid; gap: 1.5rem; padding-bottom: 1.75rem; border-bottom: 1px solid var(--line); }
  @media (min-width: 760px) { .footer-in { grid-template-columns: 1fr auto; align-items: start; } }
  .footer-brand { font-size: 1.25rem; display: block; margin-bottom: 0.4rem; }
  .footer-in p { color: var(--fg-soft); font-size: 0.88rem; max-width: 40ch; }
  .footer nav { display: flex; flex-wrap: wrap; gap: 1.1rem; }
  .footer nav a { font-size: 0.85rem; text-decoration: none; color: var(--fg-soft); }
  .footer nav a:hover { color: var(--laiton); }
  .demo-note { padding-top: 1.4rem; }
  .demo-note p { font-size: 0.77rem; line-height: 1.6; color: var(--fg-soft); }
  .demo-note b { color: var(--fg); }
  .demo-note a { color: var(--laiton); }

  /* ---------- Panier ---------- */
  .cart { position: fixed; inset: 0; z-index: 60; }
  .cart-backdrop {
    position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%;
    background: rgba(12, 12, 12, 0.55); border: 0; cursor: pointer;
    animation: fade 0.25s var(--ease);
  }
  .cart-panel {
    position: absolute; z-index: 2; inset-block: 0; inset-inline-end: 0;
    width: min(420px, 100%); background: var(--bg);
    display: flex; flex-direction: column;
    border-inline-start: 1px solid var(--line);
    animation: slide 0.3s var(--ease);
  }
  @keyframes fade { from { opacity: 0; } }
  @keyframes slide { from { translate: 100% 0; } }
  .cart-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem var(--pad); border-bottom: 1px solid var(--line);
  }
  .cart-head h2 { font-size: 1.2rem; }
  .cart-close { font-size: 1.6rem; line-height: 1; min-width: 44px; min-height: 44px; }
  .cart-lines { flex: 1; overflow-y: auto; padding: 0.5rem var(--pad); }
  .cart-lines li {
    display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem;
    padding-block: 1rem; border-bottom: 1px solid var(--line);
  }
  .cart-name { font-family: var(--serif); font-size: 1rem; }
  .cart-unit { font-size: 0.8rem; color: var(--fg-soft); grid-column: 1; }
  .cart-line-price { font-variant-numeric: tabular-nums; font-size: 0.95rem; }
  .cart-qty { display: flex; align-items: center; gap: 0.5rem; grid-column: 2; }
  .cart-qty button {
    width: 30px; height: 30px; border: 1px solid var(--line); line-height: 1;
  }
  .cart-qty button:hover { border-color: var(--laiton); }
  .cart-qty span { min-width: 1.5ch; text-align: center; font-variant-numeric: tabular-nums; }
  .cart-empty { padding: 2.5rem var(--pad); color: var(--fg-soft); font-size: 0.92rem; }
  .cart-foot { padding: 1.25rem var(--pad); border-top: 1px solid var(--line); display: grid; gap: 0.85rem; }
  .cart-total { display: flex; justify-content: space-between; align-items: baseline; }
  .cart-total span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--fg-soft); }
  .cart-total b { font-family: var(--serif); font-size: 1.5rem; font-weight: 400; font-variant-numeric: tabular-nums; }
  .cart-note { font-size: 0.78rem; color: var(--fg-soft); }
  .cart-note[data-state="ok"] { color: var(--laiton); }

  /* ---------- Fiche produit ---------- */
  .sheet {
    width: min(760px, calc(100% - 2rem)); margin: auto;
    background: var(--bg); border: 1px solid var(--line);
    padding: 0; position: relative;
  }
  .sheet::backdrop { background: rgba(12, 12, 12, 0.6); }
  .sheet[open] { display: grid; }
  @media (min-width: 720px) { .sheet[open] { grid-template-columns: 1fr 1fr; } }
  .sheet-visual { background: var(--paper-2); aspect-ratio: 1 / 1; }
  .sheet-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
  @media (max-width: 719px) { .sheet-visual { aspect-ratio: 16 / 10; } }
  .sheet-body { padding: clamp(1.5rem, 4vw, 2.25rem); display: grid; gap: 0.7rem; align-content: start; }
  .sheet-cat {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.2em;
    color: var(--laiton);
  }
  .sheet-body > p:not(.sheet-cat):not(.product-price) { font-size: 0.93rem; color: var(--fg-soft); }
  .sheet-close {
    position: absolute; top: 0.5rem; inset-inline-end: 0.5rem; z-index: 2;
    min-width: 44px; min-height: 44px; font-size: 1.5rem; line-height: 1;
  }
  .sheet-specs { display: grid; gap: 0.4rem; margin-block: 0.4rem; }
  .sheet-specs div { display: flex; gap: 0.6rem; font-size: 0.85rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); }
  .sheet-specs dt { color: var(--fg-soft); min-width: 9ch; }
  .sheet-specs dd { margin: 0; }
  .sheet .btn { margin-top: 0.5rem; }
}

@layer utils {
  .obs { opacity: 0; translate: 0 18px; transition: opacity 0.6s var(--ease), translate 0.6s var(--ease); }
  .obs.seen { opacity: 1; translate: 0 0; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
    .obs { opacity: 1; translate: none; }
  }
}

/* ===========================================================================
   Parcours de commande (demonstration)
   =========================================================================== */
@layer components {
  .checkout {
    width: min(620px, calc(100% - 2rem)); margin: auto;
    background: var(--bg); border: 1px solid var(--line);
    padding: 0; position: relative;
  }
  .checkout::backdrop { background: rgba(12, 12, 12, 0.6); }
  .checkout[open] { display: block; }

  .co-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.25rem var(--pad); border-bottom: 1px solid var(--line);
  }
  .co-head h2 { font-size: 1.2rem; }
  .co-close { font-size: 1.5rem; line-height: 1; min-width: 44px; min-height: 44px; }

  /* Fil des etapes */
  .co-steps {
    display: flex; gap: 0.5rem; padding: 1rem var(--pad) 0;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--fg-soft);
  }
  .co-steps li { display: flex; align-items: center; gap: 0.5rem; }
  .co-steps li::after { content: ""; width: 18px; height: 1px; background: var(--line); }
  .co-steps li:last-child::after { display: none; }
  .co-steps li[aria-current] { color: var(--laiton); }
  .co-steps b {
    display: grid; place-items: center; width: 20px; height: 20px;
    border: 1px solid currentColor; border-radius: 50%; font-size: 0.66rem;
  }

  .co-body { padding: 1.25rem var(--pad) 1.5rem; display: grid; gap: 1rem; }
  .co-panel[hidden] { display: none; }
  .co-panel { display: grid; gap: 0.9rem; }

  .co-field { display: grid; gap: 0.35rem; }
  .co-field label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--fg-soft); }
  .co-field input, .co-field textarea, .co-field select {
    min-height: 44px; padding: 0.65rem 0.85rem;
    background: var(--surface); color: var(--fg);
    border: 1px solid var(--line); border-radius: 3px;
  }
  .co-field textarea { resize: vertical; min-height: 84px; }
  .co-field input:focus-visible, .co-field textarea:focus-visible, .co-field select:focus-visible {
    border-color: var(--laiton); outline: 2px solid color-mix(in srgb, var(--laiton) 40%, transparent);
    outline-offset: 1px;
  }
  .co-field[data-invalid] input, .co-field[data-invalid] textarea { border-color: #b4462f; }
  .co-err { font-size: 0.78rem; color: #b4462f; }
  .co-row { display: grid; gap: 0.9rem; }
  @media (min-width: 560px) { .co-row { grid-template-columns: 1fr 1fr; } }

  /* Moyens de paiement */
  .co-pay { display: grid; gap: 0.5rem; }
  .co-pay label {
    display: flex; align-items: center; gap: 0.75rem;
    border: 1px solid var(--line); border-radius: 3px;
    padding: 0.85rem 1rem; cursor: pointer;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
  }
  .co-pay label:hover { border-color: var(--laiton); }
  .co-pay input { accent-color: var(--laiton); width: 18px; height: 18px; }
  .co-pay span { display: grid; gap: 0.1rem; }
  .co-pay b { font-weight: 400; font-family: var(--serif); font-size: 1rem; }
  .co-pay small { color: var(--fg-soft); font-size: 0.8rem; }
  .co-pay input:checked + span b { color: var(--laiton); }

  /* Recapitulatif */
  .co-recap { border: 1px solid var(--line); border-radius: 3px; padding: 1rem; display: grid; gap: 0.5rem; }
  .co-recap li { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.88rem; }
  .co-recap .tot {
    display: flex; justify-content: space-between; align-items: baseline;
    border-top: 1px solid var(--line); padding-top: 0.6rem; margin-top: 0.3rem;
  }
  .co-recap .tot b { font-family: var(--serif); font-size: 1.3rem; font-weight: 400; }

  .co-foot { display: flex; gap: 0.6rem; flex-wrap: wrap; }
  .co-foot .btn { flex: 1 1 auto; }

  /* Confirmation */
  .co-done { display: grid; gap: 0.8rem; justify-items: center; text-align: center; padding-block: 1rem; }
  .co-check {
    display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%;
    background: color-mix(in srgb, var(--laiton) 20%, transparent); color: var(--laiton);
    font-size: 1.5rem;
  }
  .co-ref {
    font-family: var(--mono, ui-monospace, monospace); font-size: 1.05rem;
    letter-spacing: 0.08em; padding: 0.4rem 0.9rem;
    background: var(--paper-2); border-radius: 3px;
  }
  .co-note { font-size: 0.82rem; color: var(--fg-soft); line-height: 1.6; max-width: 44ch; }
  .co-demo {
    border: 1px dashed color-mix(in srgb, var(--laiton) 55%, transparent);
    border-radius: 3px; padding: 0.7rem 0.9rem;
    font-size: 0.8rem; color: var(--fg-soft); line-height: 1.55;
  }
  .co-demo b { color: var(--fg); }
}
