/* Spud & Root: town/bar.html, table shuffleboard (bar-shuffleboard.js).
   The table is drawn on the canvas; this styles the scoreboard (a little
   wooden one with brass pegs), the turn line, and the cards over the table. */

.sb {
  position: absolute;
  inset: 0;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sb__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: grab;
}
.sb__canvas:active {
  cursor: grabbing;
}
/* the focus ring is drawn on the canvas, round the table */
.sb__canvas:focus,
.sb__canvas:focus-visible {
  outline: none;
}

/* ---------- Scoreboard ---------- */

.sb__top {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
}

.sb__board {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 9px;
  color: var(--cream);
  background: #5a341c;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.sb__side {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.sb__side--them {
  align-items: flex-end;
  text-align: right;
}

.sb__who {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.sb__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 3px solid transparent;
  padding-bottom: 1px;
}
.sb__side.is-turn .sb__name {
  border-bottom-color: var(--logo-yellow);
}
.sb__face {
  width: 26px;
  height: 26px;
  flex: none;
  object-fit: cover;
  object-position: 50% 8%;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.sb__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb__side--them .sb__row {
  flex-direction: row-reverse;
}
.sb__score {
  min-width: 2.1ch;
  padding: 1px 6px 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.1;
  text-align: center;
  color: #d9a441;
  background: #2a1810;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

/* the weights still to throw */
.sb__discs {
  display: flex;
  gap: 3px;
}
.sb__disc {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: #e2382c;
  box-shadow: inset 0 0 0 2px #d3dbe1;
}
.sb__side--them .sb__disc {
  background: #5b84a8;
}
.sb__disc.is-used {
  background: #2a1810;
  box-shadow: none;
  opacity: 0.6;
}

/* fifteen peg holes each, brass pegs for the points */
.sb__pegs {
  display: flex;
  gap: 2px;
}
.sb__side--them .sb__pegs {
  flex-direction: row-reverse;
}
.sb__pegs i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2a1810;
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.5);
}
.sb__pegs i:nth-child(5n) {
  margin-right: 3px;
}
.sb__side--them .sb__pegs i:nth-child(5n) {
  margin-right: 0;
  margin-left: 3px;
}
.sb__pegs i.is-on {
  background: #d9a441;
  box-shadow: 0 0 0 1px var(--ink);
}

.sb__mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--font-display);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.sb__to {
  font-size: 0.8125rem;
  color: #d9a441;
}
.sb__frame {
  font-size: 0.75rem;
  color: rgba(255, 248, 234, 0.75);
}

/* ---------- Turn line ---------- */

/* a fixed height, so the table never moves when the hint comes and goes */
.sb__status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  height: 36px;
}
.sb__turn {
  padding: 4px 14px 5px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.2;
  white-space: nowrap;
  background: var(--cream);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: 3px 3px 0 var(--ink);
}
.sb__turn.is-you {
  background: var(--logo-yellow);
}
.sb__hint {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.8125rem;
  line-height: 1.25;
  color: var(--cream);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.sb__q {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  background: var(--white);
  border: var(--stroke) solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  pointer-events: auto;
}
.sb__q:hover {
  background: var(--logo-yellow);
}
.sb__q:focus-visible,
.sb__btn:focus-visible {
  outline: 3px solid var(--logo-yellow);
  outline-offset: 3px;
}

/* ---------- Cards over the table ---------- */

.sb__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 24px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--logo-yellow);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
.sb__btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}
.sb__btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.sb__banner {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 22px 12px;
  background: var(--cream);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: sb-pop 0.35s var(--ease-spring);
  white-space: nowrap;
}
.sb__banner[hidden],
.sb__howto[hidden],
.sb__result[hidden] {
  display: none;
}
.sb__banner.is-still {
  animation: none;
}
.sb__banner-frame {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.sb__banner-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.1;
  text-align: center;
}
/* on a tall screen it sits over the narrow strip, so it may wrap */
.is-portrait .sb__banner {
  padding: 8px 12px 10px;
  white-space: normal;
}
.is-portrait .sb__banner-text {
  font-size: 1.25rem;
}

@keyframes sb-pop {
  from {
    transform: translate(-50%, -50%) scale(0.7);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.sb__howto,
.sb__result {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 32px));
  max-height: calc(100% - 140px);
  overflow: auto;
  padding: 18px 20px 20px;
  background: var(--cream);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.sb__howto h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
}
.sb__howto p {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.sb__howto .sb__btn {
  margin-top: 4px;
}

.sb__result {
  text-align: center;
}
.sb__result-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.1;
}
.sb__result-score {
  margin: 6px 0 16px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--ink-soft);
}

.sb__live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Small screens ---------- */

@media (max-width: 420px) {
  .sb__board {
    gap: 6px;
    padding: 6px 10px 7px;
  }
  .sb__name {
    font-size: 0.9375rem;
  }
  .sb__score {
    font-size: 1.5rem;
  }
  .sb__disc {
    width: 11px;
    height: 11px;
  }
  .sb__pegs i {
    width: 5px;
    height: 5px;
  }
  .sb__pegs i:nth-child(5n) {
    margin-right: 2px;
  }
  .sb__side--them .sb__pegs i:nth-child(5n) {
    margin-left: 2px;
  }
  .sb__mid .sb__frame {
    display: none;
  }
  .sb__status {
    gap: 6px;
  }
  .sb__hint {
    font-size: 0.75rem;
  }
}

/* landscape phones: one slim row so the table gets the height */
@media (max-height: 500px) and (orientation: landscape) {
  .sb__top {
    top: 64px;
    width: min(760px, calc(100% - 24px));
    flex-direction: row;
    gap: 10px;
  }
  .sb__board {
    flex: 1 1 auto;
    padding: 3px 10px;
  }
  .sb__side {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .sb__side--them {
    flex-direction: row-reverse;
  }
  .sb__pegs {
    display: none;
  }
  .sb__face {
    width: 22px;
    height: 22px;
  }
  .sb__score {
    font-size: 1.25rem;
  }
  .sb__status {
    flex: 0 1 auto;
    min-width: 0;
  }
  .sb__hint {
    display: none;
  }
  .sb__turn {
    font-size: 0.875rem;
    padding: 3px 12px 4px;
  }
  .sb__howto {
    width: min(620px, calc(100% - 32px));
    max-height: calc(100% - 24px);
    padding: 14px 18px 16px;
  }
  .sb__howto p {
    margin-bottom: 8px;
    font-size: 0.875rem;
    line-height: 1.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb__banner {
    animation: none;
  }
  .sb__btn {
    transition: none;
  }
}
