/* ═══════════════════════════════════
   Puzzelio — shared.css
   Styles communs à toutes les pages
   ═══════════════════════════════════ */

:root {
    --bg: #f0ede8;
    --surface: #ffffff;
    --surface2: #f5f3ef;
    --border: #ddd9d2;
    --accent: #c8782a;
    --accent2: #2a6ec8;
    --accent3: #c82a6e;
    --text: #1a1815;
    --text-dim: #7a7060;
    --locked: #1a9e55;
    --radius: 12px;
  }

* { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    line-height: 1.05;
    background: linear-gradient(135deg, var(--accent) 0%, #3a2800 60%, var(--accent2) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: 8px;
  }

select {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); border-radius: 8px; padding: 10px 16px; font-family: inherit;
    font-size: .95rem; cursor: pointer; transition: border-color .2s;
  }

select:focus { outline: none; border-color: var(--accent); }

/* hardcore same shape as other diff buttons */

  .btn-start {
    background: var(--accent); color: #111; border: none; border-radius: 10px;
    padding: 14px 40px; font-family: 'Playfair Display', serif; font-size: 1.1rem;
    font-weight: 700; cursor: pointer; transition: all .2s; letter-spacing: .02em;
  }

.btn-start:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(232,200,122,.3); }

.btn-start:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

#stat-score { color: var(--accent); font-weight: 700; }

/* ── Loading overlay ── */
  #loading {
    display: none; position: fixed; inset: 0; z-index: 20000;
    background: var(--bg); align-items: center; justify-content: center;
    flex-direction: column; gap: 16px;
  }

.spinner {
    width: 48px; height: 48px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .8s linear infinite;
  }

@keyframes spin { to { transform: rotate(360deg); } }

#loading p { color: var(--text-dim); font-size: .9rem; }

/* ── Toast ── */
  #toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 12px 24px; font-size: .9rem;
    z-index: 50000; transition: transform .3s; pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
  }

#toast.show { transform: translateX(-50%) translateY(0); }

/* ── iPad & touch devices ── */
  @media (hover: none) and (pointer: coarse) {
    /* ══ TABLETTE TACTILE — Optimisations complètes ══ */

    /* ── Empêche le zoom navigateur au double-tap ── */
    #board-wrap, #piece-pool, .pool-piece, .sort-btn, .diff-btn, .header-btn {
      touch-action: manipulation;
    }
    #board-wrap { touch-action: none; } /* géré manuellement */

    /* ── Header : compact mais lisible ── */
    .game-header {
      padding: 8px 12px;
      gap: 10px;
      flex-wrap: nowrap;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    .game-title { font-size: 1rem; flex-shrink: 0; }
    .stat { flex-shrink: 0; }
    .stat-val { font-size: 1rem; }
    .stat-lbl { font-size: .62rem; }
    .header-btn {
      padding: 10px 14px;
      font-size: .88rem;
      flex-shrink: 0;
      min-width: 44px; min-height: 44px; /* cible tactile min 44px */
      display: flex; align-items: center; justify-content: center;
    }

    /* ── Sidebar : plus large, scroll fluide ── */
    #sidebar { width: 240px; }
    .sort-btns { gap: 5px; padding: 8px; }
    .sort-btn {
      padding: 12px 6px;
      font-size: .76rem;
      min-height: 44px;
    }
    #piece-pool {
      grid-template-columns: repeat(2, 1fr) !important;
      grid-auto-rows: 90px !important;
      gap: 8px;
      padding: 8px;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
    }
    .pool-piece {
      height: 90px !important;
      min-height: unset;
      cursor: pointer;      /* pas de grab sur tactile */
    }
    .pool-piece:hover { transform: none; } /* désactive hover sur tactile */
    .pool-piece:active { transform: scale(.95); opacity: .85; }

    /* ── Pièce sélectionnée visuellement avant dépôt ── */
    .pool-piece.touching {
      transform: scale(1.08);
      border-color: var(--accent);
      box-shadow: 0 4px 20px rgba(200,120,42,.4);
      z-index: 10;
    }

    /* ── Zoom controls : gros boutons ── */
    .zoom-controls { bottom: 20px; right: 12px; gap: 8px; }
    .zoom-btn {
      width: 52px; height: 52px;
      font-size: 1.4rem;
      border-radius: 12px;
      box-shadow: 0 2px 12px rgba(0,0,0,.15);
    }

    /* ── Widget flottant : position adaptée ── */
    .float-widget { width: 180px; }
    #preview-container { height: 130px; }
    .fw-header { padding: 8px 10px; }

    /* ── Toast plus grand ── */
    #toast {
      font-size: 1rem;
      padding: 14px 28px;
      bottom: 32px;
    }

    /* ── Indicateur de rotation tactile ── */
    .rotate-hint {
      position: absolute;
      bottom: 80px; right: 16px;
      background: rgba(200,120,42,.9);
      color: #fff;
      font-size: .78rem;
      padding: 8px 14px;
      border-radius: 20px;
      pointer-events: none;
      opacity: 0;
      transition: opacity .3s;
      z-index: 20;
    }
    .rotate-hint.show { opacity: 1; }

    /* ── Victory banner ── */
    #victory-banner { padding: 14px 16px; }
    .vbanner-inner { gap: 12px; flex-wrap: wrap; justify-content: center; }
    .vbanner-text strong { font-size: 1rem; }
    .vbanner-score { font-size: 1.3rem; padding-left: 12px; }
    .vbanner-btns .btn-start { padding: 10px 18px; }

    /* ── Page accueil : difficulty grid 2 colonnes ── */
    .difficulty-grid {
      grid-template-columns: repeat(2, 1fr);
    }
    .diff-btn {
      padding: 14px 10px;
      min-height: 70px;
    }
    .cat-images {
      grid-template-columns: repeat(3, 1fr);
    }
  }
