/* =============================================
   MURARZ 3D — stylesheet v2
   ============================================= */

:root {
  --color-bg:        #1a1814;
  --color-surface:   rgba(30, 28, 24, 0.92);
  --color-surface-2: #252320;
  --color-border:    rgba(255,255,255,0.07);
  --color-text:      #d8d4cc;
  --color-text-muted:#7a7870;
  --color-text-faint:#4a4844;
  --color-primary:   #b8a882;
  --color-primary-hover: #cfc09a;
  --panel-blur:      14px;
  --panel-radius:    10px;
  --shadow-md: 0 4px 16px rgba(0,0,0,0.28);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.36);
  --transition: 160ms cubic-bezier(0.16,1,0.3,1);
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'Azeret Mono', monospace;

  /* Kolory bloków — paleta GALI dopasowana do realnych klocków na zdjęciu blocks-trio-color.jpg */
  /* Piaskowy Beż (jasny kremowy) */
  --piaskowiec-top:   #d8c8ad;
  --piaskowiec-front: #c8b89a;
  --piaskowiec-right: #a89880;

  /* Ceglana Czerwień (terakota, jak wypalana cegła) */
  --szary-top:   #b96d4e;
  --szary-front: #a55a3d;
  --szary-right: #8a4830;

  /* Ziemisty Brąz (ciepły czekoladowy brąz, dopasowany do realnego klocka) */
  --beton-top:   #7a5742;
  --beton-front: #5e4030;
  --beton-right: #43291c;
}

[data-theme='light'] {
  --color-bg:        #ede9e2;
  --color-surface:   rgba(240,237,230,0.92);
  --color-surface-2: #f5f3ee;
  --color-border:    rgba(0,0,0,0.09);
  --color-text:      #2a2620;
  --color-text-muted:#7a7060;
  --color-text-faint:#b0a898;
  --color-primary:   #8a7858;
  --color-primary-hover: #6e6044;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  width: 100vw; height: 100dvh;
  overflow: hidden;
  user-select: none;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

/* ---- Canvas ---- */
#canvas-container { position: fixed; inset: 0; z-index: 0; }
#canvas-container canvas { display: block; width: 100%; height: 100%; }
#drop-overlay { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#drop-overlay.drag-active { pointer-events: auto; }

/* ---- Panel ---- */
.game-panel {
  background: var(--color-surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
}

/* ---- Topbar ---- */
.topbar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 14px;
  min-width: 420px; max-width: 680px; width: calc(100% - 340px);
  box-shadow: var(--shadow-md);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo-svg { width: 28px; height: 28px; flex-shrink: 0; }
.app-title {
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  letter-spacing: 0.04em; color: var(--color-text);
}
.topbar-right { display: flex; align-items: center; gap: 6px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 6px; font-size: 12px; font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-ghost { color: var(--color-text-muted); background: transparent; }
.btn-ghost:hover { background: var(--color-border); color: var(--color-text); }
.btn-secondary {
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  color: var(--color-text);
}
.btn-secondary:hover { background: var(--color-border); }
.btn-primary {
  background: linear-gradient(135deg, #c8b89a 0%, #a89878 100%);
  color: #1a1612;
  border: 1px solid rgba(0,0,0,0.15);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-shake {
  animation: btn-shake 0.4s ease-in-out;
}
@keyframes btn-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.toast-warn {
  background: rgba(180, 80, 50, 0.92) !important;
  color: #fff !important;
  border-color: rgba(255, 100, 70, 0.4) !important;
}
.icon-btn { padding: 5px 7px; }

/* ---- Palette ---- */
.palette {
  position: fixed; left: 12px; top: 50%; transform: translateY(-50%);
  z-index: 20; display: flex; flex-direction: column; gap: 8px;
  padding: 14px 12px; width: 140px; box-shadow: var(--shadow-lg);
}
.palette-label {
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.12em; color: var(--color-text-faint);
  text-transform: uppercase; margin-bottom: 2px;
}
.palette-blocks { display: flex; flex-direction: column; gap: 5px; }
.palette-block {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; cursor: grab;
  border: 1.5px solid transparent;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
}
.palette-block:hover { background: var(--color-border); transform: scale(1.03); }
.palette-block:active { cursor: grabbing; transform: scale(0.97); }
.palette-block.selected {
  border-color: var(--color-primary);
  background: rgba(184,168,130,0.10);
}
.block-key {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 8px; font-weight: 700;
  color: var(--color-text-faint);
}

/* Kolorowe próbki materiałów */
.mat-swatch {
  display: block; flex-shrink: 0;
  width: 28px; height: 18px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.18);
  position: relative; overflow: hidden;
}
.mat-swatch::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, transparent 55%,rgba(0,0,0,0.10) 100%);
}
.swatch-piaskowiec { background: #c8b89a; } /* Piaskowy Beż — kremowy */
.swatch-szary      { background: #a55a3d; } /* Ceglana Czerwień — terakota */
.swatch-beton      { background: #5e4030; } /* Ziemisty Brąz — ciepły czekoladowy */

.block-name { font-size: 10px; font-weight: 600; color: var(--color-text-muted); flex: 1; }

/* Obrót */
.rotation-control {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; padding: 2px 0;
}
.rot-btn {
  width: 30px; height: 30px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center;
  color: var(--color-text-muted); border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  transition: all var(--transition);
}
.rot-btn:hover { color: var(--color-primary); border-color: var(--color-primary); }
.rot-display {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: var(--color-primary); min-width: 32px; text-align: center;
}

.palette-divider { height: 1px; background: var(--color-border); margin: 2px 0; }

/* Narzędzia */
.tool-row { display: flex; flex-direction: column; gap: 4px; }
.tool-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: 6px; font-size: 11px; font-weight: 600;
  color: var(--color-text-muted); border: 1.5px solid transparent;
  transition: all var(--transition);
}
.tool-btn:hover { background: var(--color-border); color: var(--color-text); }
.tool-btn.active {
  background: rgba(184,168,130,0.12); border-color: var(--color-primary);
  color: var(--color-primary);
}

.tips-list { list-style: none; display: flex; flex-direction: column; gap: 3px; }
.tips-list li {
  font-size: 9px; color: var(--color-text-faint); line-height: 1.5;
  padding-left: 8px; position: relative; white-space: normal;
  overflow: visible;
}
.tips-list li::before { content: '·'; position: absolute; left: 0; }

/* ---- HUD ---- */
.hud-counter {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
  z-index: 20; padding: 14px; width: 148px; box-shadow: var(--shadow-lg);
}
.counter-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.counter-item { display: flex; align-items: center; gap: 7px; }
.counter-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.piaskowiec-dot { background: #c8b89a; } /* Piaskowy Beż — kremowy */
.szary-dot      { background: #a55a3d; } /* Ceglana Czerwień — terakota */
.beton-dot      { background: #5e4030; } /* Ziemisty Brąz — ciepły czekoladowy */
.counter-label { font-size: 10.5px; color: var(--color-text-muted); flex: 1; }
.counter-val {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  color: var(--color-text); min-width: 24px; text-align: right;
  transition: color 0.2s, transform 0.15s;
  font-variant-numeric: tabular-nums;
}
.counter-val.bump { color: var(--color-primary); transform: scale(1.2); }
.counter-divider { height: 1px; background: var(--color-border); margin: 2px 0; }
.total-item .counter-label { font-weight: 700; color: var(--color-text); }
.total-item .counter-val { color: var(--color-primary); }

/* ---- Wymiary budowli ---- */
.hud-dims {
  position: fixed; right: 12px; top: calc(50% + 110px);
  z-index: 20; padding: 10px 14px; width: 148px; box-shadow: var(--shadow-lg);
}
.dims-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 4px 8px; margin-top: 6px; align-items: center;
}
.dims-label { font-size: 10px; color: var(--color-text-muted); }
.dims-val {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  color: var(--color-text); text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Ghost info ---- */
.ghost-info {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 25; background: var(--color-surface);
  backdrop-filter: blur(10px); border: 1px solid var(--color-border);
  border-radius: 20px; padding: 5px 16px; font-size: 11.5px; font-weight: 600;
  color: var(--color-text-muted); pointer-events: none;
}

/* ---- Toast ---- */
#toast-container {
  position: fixed; bottom: 48px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  background: var(--color-surface); backdrop-filter: blur(12px);
  border: 1px solid var(--color-border); border-radius: 8px;
  padding: 7px 16px; font-size: 12px; font-weight: 600;
  color: var(--color-text); box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease, toastOut 0.3s ease 1.8s forwards;
  pointer-events: none;
}
@keyframes toastIn  { from { opacity:0; transform:translateY(8px) scale(0.95); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(-6px); } }

/* ---- Loader ---- */
#loader-screen {
  position: fixed; inset: 0; background: var(--color-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; flex-direction: column; gap: 14px;
  font-family: var(--font-body); color: var(--color-text-muted);
}
#loader-msg { font-size: 13px; font-weight: 600; }

/* ---- Drop highlight ---- */
#canvas-container.drop-hover::after {
  content: 'Upuść blok tutaj';
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: rgba(184,168,130,0.06);
  border: 2px dashed var(--color-primary);
  font-size: 18px; font-weight: 700; color: var(--color-primary);
  pointer-events: none; z-index: 10;
}

/* Touch-owe wskazówki pokazujemy tylko na urządzeniach dotykowych (patrz @media) */
.tips-touch { display: none; }

/* ═══════════════════════════════════════════════════════════
   MOBILE / TELEFON — layout dotykowy (≤ 768px)
   Desktop był budowany pod mysz+klawiaturę; tu przestawiamy
   sterowanie na palce: topbar kompaktowy, paleta jako dolny pasek,
   liczniki jako mały chip, panele boczne nie zjadają ekranu.
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Topbar: pełna szerokość, ikony zamiast długich etykiet ── */
  .topbar {
    min-width: 0; max-width: none; width: calc(100% - 16px);
    top: 8px; padding: 6px 8px; gap: 5px;
  }
  .app-title { display: none; }
  .btn-optional { display: none !important; }          /* Wczytaj, motyw — mniej istotne na telefonie */
  .topbar-right { gap: 4px; }
  /* Ghost/secondary → tylko ikona (font-size:0 chowa tekst, svg ma własne wymiary) */
  .topbar .btn-ghost, .topbar .btn-secondary {
    font-size: 0; gap: 0; padding: 8px;
  }
  .topbar .btn-primary { padding: 8px 12px; font-size: 12px; }
  .btn-more { display: none; }                          /* „Zamów ten projekt" → „Zamów" */

  /* ── Paleta: z bocznej kolumny na DOLNY pasek (zasięg kciuka) ── */
  .palette {
    left: 8px; right: 8px; top: auto; bottom: 8px; transform: none;
    width: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; justify-content: center; gap: 8px 10px;
    padding: 10px; max-height: 40vh; overflow-y: auto;
  }
  .palette > .palette-label { display: none; }          /* nagłówki sekcji — zbędne w pasku */
  .palette-divider { display: none; }
  .palette-blocks { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .palette-block { padding: 8px 10px; }                 /* większy cel dotykowy */
  .block-key { display: none; }                         /* numery klawiszy bez sensu na telefonie */
  .rotation-control, .tool-row { margin: 0; }
  .rot-btn, .tool-btn { min-height: 40px; min-width: 40px; } /* wygodne dla palca */
  /* wskazówki: chowamy desktopowe (mysz/klawiatura), pokazujemy dotykowe */
  .tips-desktop, .tips-only { display: none; }
  .tips-touch {
    display: flex; flex-basis: 100%; flex-direction: row; flex-wrap: wrap;
    justify-content: center; gap: 4px 12px; margin-top: 2px;
  }
  .tips-touch li::before { content: ''; }
  .tips-touch li { padding-left: 0; }

  /* ── Licznik: kompaktowy chip w lewym górnym rogu pod topbarem ── */
  .hud-counter {
    top: 56px; left: 8px; right: auto; transform: none;
    width: auto; max-width: 180px; padding: 8px 10px;
  }
  /* ── Wymiary: drugorzędne — ukrywamy, by nie zaśmiecać ── */
  .hud-dims { display: none; }
}

/* Bardzo wąskie ekrany — jeszcze ciaśniejszy topbar */
@media (max-width: 380px) {
  .topbar .btn-ghost, .topbar .btn-secondary { padding: 7px; }
  .topbar .btn-primary { padding: 7px 10px; }
  .hud-counter { max-width: 150px; }
}
