/* ==========================================================
   QR Art — feuille de style partagée (art.html, collection.html)

   Palette et typographie pensées pour un usage en extérieur,
   sur mobile, avec un réseau parfois faible : pas de police
   distante, pas d'animation superflue.
   ========================================================== */

:root {
  --paper: #f6f5f1;
  --paper-raised: #ffffff;
  --ink: #1c1d1a;
  --ink-soft: #63645f;
  --line: #ddd9d0;
  --accent: #33513f;
  --accent-soft: #e4ece7;
  --locked-bg: #eceae4;
  --radius: 6px;

  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;

  --container-wide: 960px;
}

* {
  box-sizing: border-box;
}

/* Sans ceci, un élément avec l'attribut [hidden] mais aussi une règle
   d'ID définissant `display` (ex: #share) reste visible : l'ID gagne
   en spécificité sur la règle UA [hidden]{display:none}. */
[hidden] {
  display: none !important;
}


html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;

  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: white;
}

main {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 48px) clamp(16px, 5vw, 32px) 64px;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  margin: 0 0 8px;
}

p {
  color: var(--ink-soft);
  margin: 0 0 12px;
  max-width: 60ch;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
.artwork-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ----------------------------------------------------------
   En-tête de page / progression (collection.html)
   ---------------------------------------------------------- */

.page-header {
  margin-bottom: 8px;
}

.progress {
  margin-top: 14px;
  max-width: 320px;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.4s ease;
}

.progress-label {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Badge de statut (message d'import, découverte sur art.html) */

.badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
  background: var(--paper-raised);
}

.badge.badge-accent {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Camera */
#video {
  position: fixed;
  inset: 0;

  width: 100vw;
  height: 100vh;

  object-fit: cover;

  z-index: 1;
}

/* Generative drawing */
#canvas {
  position: fixed;
  inset: 0;

  width: 100vw;
  height: 100vh;

  display: block;

  z-index: 2;

  pointer-events: none;
}

/* Hidden canvas used for QR recognition */
#camera {
  display: none;
}

/* Status */
#info {
  position: fixed;
  left: 10px;
  top: 10px;

  z-index: 10;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#info a {
  padding: 6px 8px;

  font-family: monospace;
  font-size: 12px;

  color: rgba(255,255,255,.75);
  text-decoration: none;

  background: rgba(0,0,0,.5);

  border-radius: 4px;
}

#info a:hover {
  color: white;
}

#share {
  position: fixed;
  left: 10px;
  bottom: 10px;

  z-index: 10;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 8px;

  font-family: monospace;
  font-size: 12px;

  color: white;
  background: rgba(0,0,0,.5);

  border-radius: 4px;
  padding: 6px 8px;

  font-family: monospace;
  font-size: 12px;

  color: rgba(255,255,255,.75);
  text-decoration: none;

  background: rgba(0,0,0,.5);

  border-radius: 4px;
}

.focus-marker {
  position: fixed;
  width: 60px;
  height: 60px;
  margin-left: -30px;
  margin-top: -30px;
  border: 2px solid white;
  border-radius: 50%;
  pointer-events: none;
  animation: focus-pulse 0.6s ease-out forwards;
}

@keyframes focus-pulse {
  from { transform: scale(1.3); opacity: 1; }
  to   { transform: scale(0.8); opacity: 0; }
}


/* Liens discrets (collection + site) */
#links {
  position: fixed;
  right: 10px;
  bottom: 10px;

  z-index: 10;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#links a {
  padding: 6px 8px;

  font-family: monospace;
  font-size: 12px;

  color: rgba(255,255,255,.75);
  text-decoration: none;

  background: rgba(0,0,0,.5);

  border-radius: 4px;
}

#links a:hover {
  color: white;
}

/* Liens discrets (collection + site) */
#project {
  position: fixed;
  right: 10px;
  top: 10px;

  z-index: 10;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#project a {
  padding: 6px 8px;

  font-family: monospace;
  font-size: 12px;

  color: rgba(255,255,255,.75);
  text-decoration: none;

  background: rgba(0,0,0,.5);

  border-radius: 4px;
}

#project a:hover {
  color: white;
}

#copied-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  font-family: monospace;
  font-size: 12px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  border-radius: 4px;
}

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

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 14px;
  margin: 28px 0 48px;
}

@media (min-width: 640px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
  }
}

.artwork-card {
  display: block;
  text-decoration: none;
  color: inherit;
  text-align: left;
}

.artwork-card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1.5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--locked-bg);
  border: 1px solid var(--line);
}

.artwork-card .thumb canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.artwork-card .name {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.artwork-card.locked .name {
  opacity: 0.7;
}

.artwork-card:not(.locked):hover .thumb,
.artwork-card:not(.locked):focus-visible .thumb {
  border-color: var(--accent);
}


/* ----------------------------------------------------------
   Section de partage (export / import QR)
   ---------------------------------------------------------- */

.share {
  border-top: 1px solid var(--line);
  padding-top: 28px;
  display: grid;
  gap: 24px;
}

@media (min-width: 720px) {
  .share {
    grid-template-columns: 1fr 260px;
    align-items: start;
  }
}

.share-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

button {
  font: inherit;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}

button:hover {
  opacity: 0.85;
}

button.secondary {
  background: transparent;
  color: var(--ink);
}

.share-visual {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

#qrcode {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--paper-raised);
  display: inline-block;
}

.link-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
  display: block;
}


/* ----------------------------------------------------------
   Choix de variante (art.html, première rencontre avec une œuvre)
   ---------------------------------------------------------- */

#picker {
  position: fixed;
  inset: 0;
  z-index: 20;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;

  padding: 24px;
  background: var(--paper);
}

#picker-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  text-align: center;
  max-width: 30ch;
  margin: 0;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 140px));
  gap: 16px;
}

.picker-option {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  aspect-ratio: 1 / 1.5;
  overflow: hidden;
  cursor: pointer;
}

.picker-option canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.picker-option:hover,
.picker-option:focus-visible {
  border-color: var(--accent);
}

/* ----------------------------------------------------------
   art.html
   ---------------------------------------------------------- */

.artwork-view {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.canvas-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--paper-raised);
  display: inline-block;
}

.canvas-card canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.back-link {
  display: inline-block;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}


@media (prefers-reduced-motion: reduce) {
  .progress-fill {
    transition: none;
  }
}


/* ----------------------------------------------------------
   Pied de page — lien discret vers le site
   ---------------------------------------------------------- */

.site-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.site-link {
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.site-link:hover {
  color: var(--accent);
}
