/* HandballBoard – Taktikboard (Editor, Viewer, Übersicht) */

.hb-stage {
  width: 100%;
  overflow: hidden;
  line-height: 0;
}
.hb-stage .konvajs-content {
  margin: 0 auto;
  border-radius: .375rem;
  overflow: hidden;
}

/* ---------- Viewer ---------- */
.hb-viewer {
  position: relative;
}
.hb-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  justify-content: center;
  margin-top: .5rem;
}
.hb-controls .btn {
  min-width: 2.5rem;
  min-height: 2.25rem;
}
.hb-indicator {
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  min-width: 6.5em;
  text-align: center;
}
.hb-speed {
  min-width: 3.25rem;
}
.hb-note {
  text-align: center;
  font-size: .9rem;
  margin-top: .375rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hb-empty {
  display: none !important;
}
.hb-controls[hidden],
.hb-note[hidden] {
  display: none !important;
}
.hb-board-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* ---------- Editor ---------- */
.hb-editor {
  --hb-border: #dee2e6;
  --hb-accent: #1f4e9c;
  --hb-accent-bg: #e7eefb;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .5rem;
  border: 1px solid var(--hb-border);
  border-radius: .5rem;
  background: #fff;
  outline: none;
}
.hb-editor .hb-stage {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.hb-editor.hb-drawing .hb-stage {
  cursor: crosshair;
}

.hb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  align-items: center;
}
.hb-tb-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .25rem;
  align-items: center;
}
.hb-tb-group + .hb-tb-group {
  padding-left: .375rem;
  border-left: 1px solid var(--hb-border);
}
.hb-draw-actions:not(.hb-active) {
  visibility: hidden;
}
.hb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  min-height: 2.25rem;
  min-width: 2.25rem;
  touch-action: manipulation;
}
.hb-tool {
  border: 1px solid var(--hb-border);
}
.hb-tool.active,
.hb-tool.active:hover,
.hb-type-btn.active,
.hb-type-btn.active:hover {
  background: var(--hb-accent-bg);
  border-color: var(--hb-accent);
  box-shadow: 0 0 0 2px rgba(31, 78, 156, .25);
  color: inherit;
}
.hb-arrow-tool svg,
.hb-type-btn svg {
  width: 34px;
  height: 14px;
  display: block;
}
.hb-auto {
  font-size: .8rem;
  margin-right: .25rem;
  white-space: nowrap;
}
.hb-status {
  font-size: .8rem;
  color: #6c757d;
  min-height: 1.25em;
  line-height: 1.25;
}
.hb-status.hb-toast {
  color: #b02a37;
  font-weight: 600;
}

.hb-body {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 240px;
  gap: .5rem;
  align-items: start;
}
.hb-center {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

/* Bibliothek */
.hb-library {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}
.hb-lib-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6c757d;
  margin-top: .25rem;
}
.hb-field-switch {
  display: flex;
}
.hb-field-switch .btn {
  flex: 1 1 auto;
  white-space: nowrap;
}
.hb-field-switch .btn.active {
  background: var(--hb-accent);
  border-color: var(--hb-accent);
  color: #fff;
}
.hb-lib-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .45rem;
  border: 1px solid var(--hb-border);
  border-radius: .375rem;
  background: #fff;
  color: inherit;
  font-size: .8rem;
  line-height: 1.15;
  text-align: left;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.hb-lib-item:hover {
  background: #f8f9fa;
}
.hb-lib-item.active {
  background: var(--hb-accent-bg);
  border-color: var(--hb-accent);
  box-shadow: 0 0 0 2px rgba(31, 78, 156, .25);
}
.hb-lib-item:disabled {
  opacity: .5;
  cursor: default;
}
.hb-lib-icon svg {
  display: block;
  width: 24px;
  height: 24px;
}

/* Schrittleiste */
.hb-stepbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.hb-chips {
  position: relative;
  display: flex;
  gap: .25rem;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.hb-chip {
  flex: 0 0 auto;
  min-width: 2.25rem;
  min-height: 2.25rem;
  white-space: nowrap;
  touch-action: manipulation;
}
.hb-step-fields {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  align-items: center;
  flex: 1 1 320px;
}
.hb-step-fields.hb-disabled {
  opacity: .55;
}
.hb-inline {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin: 0;
  font-size: .85rem;
}
.hb-duration {
  width: 4.75rem;
}
.hb-note-input {
  flex: 1 1 180px;
  min-width: 140px;
  width: auto;
}

/* Eigenschaften */
.hb-props {
  border: 1px solid var(--hb-border);
  border-radius: .375rem;
  padding: .5rem .6rem;
  font-size: .875rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
}
.hb-props-title {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 600;
}
.hb-props-icon svg {
  display: block;
  max-height: 22px;
  width: auto;
}
.hb-props-hint {
  font-size: .78rem;
  color: #6c757d;
}
.hb-field {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin: 0;
}
.hb-field > span:first-child {
  font-size: .75rem;
  color: #495057;
}
.hb-rot {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.hb-rot .form-range {
  flex: 1 1 auto;
  min-width: 60px;
}
.hb-rot-val {
  min-width: 2.6em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: .8rem;
}
.hb-type-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .25rem;
}
.hb-type-btn {
  border: 1px solid var(--hb-border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: .25rem;
}
.hb-props-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}

.hb-editor.hb-playing .hb-library,
.hb-editor.hb-playing .hb-stepbar {
  opacity: .55;
  pointer-events: none;
}

/* Tablet / Smartphone */
@media (max-width: 991.98px) {
  .hb-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .hb-library {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: .3rem;
    scrollbar-width: thin;
  }
  .hb-lib-title {
    display: none;
  }
  .hb-field-switch {
    flex: 0 0 auto;
    flex-direction: column;
  }
  .hb-field-switch .btn {
    font-size: .72rem;
    padding: .15rem .4rem;
  }
  .hb-field-switch.btn-group > .btn:not(:last-child) {
    border-radius: .25rem .25rem 0 0;
  }
  .hb-field-switch.btn-group > .btn:not(:first-child) {
    border-radius: 0 0 .25rem .25rem;
    margin-left: 0;
    margin-top: -1px;
  }
  .hb-lib-item {
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    width: 4.6rem;
    gap: .15rem;
    padding: .25rem;
    font-size: .66rem;
    text-align: center;
  }
  .hb-type-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}
@media (max-width: 575.98px) {
  .hb-editor {
    padding: .35rem;
  }
  .hb-btn-label {
    display: none;
  }
  .hb-tb-group + .hb-tb-group {
    padding-left: 0;
    border-left: 0;
  }
  .hb-toolbar .hb-tools {
    order: 5;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .hb-tools .hb-btn {
    flex: 0 0 auto;
  }
  .hb-arrow-tool svg {
    width: 28px;
  }
  .hb-type-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media print {
  .hb-controls,
  .hb-editor .hb-toolbar,
  .hb-editor .hb-library,
  .hb-editor .hb-stepbar,
  .hb-editor .hb-props,
  .hb-editor .hb-status {
    display: none !important;
  }
  .hb-board-img,
  .hb-stage {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Druck: ein Bild pro Situation */
.hb-steps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.hb-field-full .hb-steps-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.hb-step-figure { margin: 0; break-inside: avoid; page-break-inside: avoid; }
.hb-step-figure img { width: 100%; height: auto; display: block; border-radius: 4px; }
.hb-step-figure figcaption { font-size: .78rem; line-height: 1.25; margin-top: .2rem; }
@media print {
  .hb-steps-grid { grid-template-columns: repeat(3, 1fr); }
  .hb-field-full .hb-steps-grid { grid-template-columns: repeat(2, 1fr); }
}
