/* scoreboard.css — unified layout + polish */

/* ===== Theme & base ===== */
:root {
  --gap: 0.75rem;
  --panel: #272727;
  --panel-b: #eeeeee;
  --faint-opacity: 0.2; /* updated by Settings */
  /* --hr-alpha-fill: #999;  default fallback */
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  background: #111;
  color: #eee;
}

/* ===== Main layout: two full-height halves touching in the middle ===== */
.scoreboard-grid {
  display: grid;
  grid-template-columns: 1fr 0 1fr;
  padding: 0;
  column-gap: 0;
  width: 100vw;
  height: 100vh; /* fallback */
  min-height: 100vh;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

/* On modern mobile browsers (including Chrome on Android),
   use the *small* viewport height so content never becomes taller
   than the visible area when the address bar moves around. */
@supports (height: 100svh) {
  .scoreboard-grid {
    height: 100svh;
    min-height: 100svh;
  }
}

.team-box {
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
}

.team-name {
  min-width: 0;
  display: block;
  width: 100%;
  text-align: center;
  font-size: 7vh;
  font-weight: 600;
  margin: 0 !important;
  padding: 0.5rem 1rem;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  z-index: 5;
  user-select: none;
  color: var(--team-fg, #fff);
}

.scorebox {
  container-type: size;
  position: relative;
  display: grid;
  place-items: center;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  background-clip: padding-box;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.scorebox:active,
.scorebox:focus,
.scorebox:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
}
@media (hover: hover) {
  .scorebox:hover {
    box-shadow: none !important;
  }
}

.score-value {
  font-size: 80vh;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  text-align: center;
  transform: translateY(-0.12em);
  line-height: 0.85;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  outline: none;
}
@supports (font-size: 1cqh) {
  .score-value {
    font-size: 80cqh;
  }
}

.logo-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
}
.team-logo {
  width: 80%;
  height: 80%;
  object-fit: contain;
  object-position: center;
  display: block;
  user-select: none;
}

/* container keeps the clipping + rounding */
.scorebox .logo-wrap {
  display: grid;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  user-select: none;
}

/* image is 80% of the scorebox, but still rounded */
.scorebox .logo-wrap img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  border-radius: inherit;
  display: block;
}

/* ===== Center column pinned widgets ===== */

/* Tighten spacing between INNING label and number only */
.center-column #inningNumber {
  margin-top: -1.5rem;
}

.center-column {
  position: static;
}

/* INNING box */
.center-column .box:nth-of-type(1) {
  position: fixed;
  top: 0 !important;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  user-select: none;
  cursor: cell;
  border: 3px solid #2563eb !important;
  border-top: 0 !important;
}

/* OUT box */
.center-column .box:nth-of-type(2) {
  position: fixed;
  bottom: 0 !important;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  user-select: none;
  cursor: cell;
  border: 3px solid #dc2626 !important; /* set all sides first */
  border-bottom: 0 !important; /* remove the bottom */
}

.center-column .box {
  display: grid;
  place-items: center;
  gap: 0.25;
  min-width: 9rem;
  padding: 0.35rem 0.75rem !important;
  border-radius: 5rem !important;
  background: #fff;
  border: 2px solid #000000 !important;
  color: #111;
}
.center-column .box:nth-of-type(1) .label {
  color: #2563eb;
}
.center-column .box:nth-of-type(2) .label {
  color: #dc2626;
}
.center-column .label {
  font-weight: 700;
  font-size: 5vh;
  letter-spacing: -0.05em;
  opacity: 0.85;
}
.center-column .value {
  font-weight: 800;
  line-height: 1;
}
.center-column .box:nth-of-type(1) {
  border-radius: 0 0 5vmin 5vmin !important;
}
.center-column .box:nth-of-type(2) {
  border-radius: 8vmin 8vmin 0 0 !important;
}
.center-column .box:nth-of-type(1) .value {
  font-family: "Oswald", ui-sans-serif, system-ui, sans-serif;
  font-size: 20vh;
}
.center-column .box:nth-of-type(2) .value {
  font-family: "Bebas Neue", ui-sans-serif, system-ui, sans-serif;
  font-size: 15vh;
}

/* ===== HR chips ===== */
#hrAwayContainer {
  position: absolute;
  left: var(--gap);
  bottom: var(--gap);
  z-index: 2;
  cursor: cell;
}
#hrHomeContainer {
  position: absolute;
  right: var(--gap);
  bottom: var(--gap);
  z-index: 2;
  cursor: cell;
}
.hrbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border-radius: 0.6rem;
  padding: 0.35rem 0.6rem;
  user-select: none;
  -webkit-text-stroke: 3px #000;
}
.hr-label {
  font-size: 6vh;
  font-weight: 700;
  color: #ff0;
  text-shadow: 3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000,
    3px 3px 0 #000, -3px 3px 0 #000, 3px -3px 0 #000, -3px -3px 0 #000;
}
.hr-value {
  font-size: 12vh;
  line-height: 1;
  -webkit-text-stroke: 3px #000;
}
.hrbox .hr-value {
  white-space: nowrap;
  line-height: 1;
  text-shadow: 3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000,
    3px 3px 0 #000, -3px 3px 0 #000, 3px -3px 0 #000, -3px -3px 0 #000;
}
.hrbox[data-team-id="home"] {
  flex-direction: row-reverse;
  justify-content: flex-end;
}
.hrbox[data-team-id="home"] .hr-value {
  direction: rtl;
  text-align: right;
}
.hrbox[data-team-id="home"] .hr-label {
  direction: rtl;
}

/* ===== Info button ===== */
.info-btn {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  background: var(--panel);
  border: 1px solid var(--panel-b);
  color: #eee;
  padding: 0.45rem 1rem;
  border-radius: 0.75rem;
  font-weight: 700;
  cursor: help;
  font-size: 3vh;
}

/* ===== Fainting ===== */
.is-zero {
  opacity: var(--faint-opacity, 0.2);
}

/* Smooth fade for INNING, OUT, HR, and Info */
.center-column .box,
.hrbox,
.info-btn {
  transition: opacity 0.2s ease;
}

/* ----- Desktop hover only (prevents stuck hover on tablets) ----- */
@media (hover: hover) {
  .center-column .box:hover,
  .hrbox:hover,
  .info-btn:hover {
    opacity: 1 !important;
  }
}

/* ----- Keyboard focus always allowed (desktop + tablet) ----- */
.center-column .box:focus-visible,
.hrbox:focus-visible,
.info-btn:focus-visible {
  opacity: 1 !important;
}

/* ===== Team picker ===== */
.team-select {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.25rem;
  z-index: 6;
  min-width: 14rem;
  max-height: 60vh;
  overflow: auto;
  background: #1b1b1b;
  border: 1px solid #333;
  border-radius: 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.team-select .option {
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  cursor: auto;
}
.team-select .option + .option {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.team-select .thumb-wrap {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.4rem;
  overflow: hidden;
}
.team-select .thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.team-select .label {
  font-weight: 600;
}

/* ===== HR overlay ===== */
#hrFx {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  display: none;
}
#hrFx.show {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
#hrFx.fadeout {
  animation: hrFade 0.3s linear forwards;
}
#hrFxInner {
  position: relative !important;
  isolation: isolate;
  width: 100vw !important;
  height: 100vh !important;
}
#hrFxInner .hr-fill {
  position: absolute;
  inset: 0;
  background: var(--hr-alpha-fill, #111);
  z-index: 0;
}
#hrFx img,
#hrFx video {
  position: relative;
  z-index: 1;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: fill !important;
  object-position: center !important;
}

@keyframes hrFade {
  to {
    opacity: 0;
  }
}

/* ===== Dialog polish ===== */
dialog {
  color: #eee;
  border: 1px solid #333;
  border-radius: 0.8rem;
  background: #1e1e1e;
  padding: 1rem 1.2rem;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
dialog form button,
.info-links a[role="button"] {
  background: #666666;
  border: 1px solid #3a3a3a;
  color: #ffffff;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
button.danger {
  background: #970f0f;
  border-color: #888888;
}

/* --- unified “green” buttons --- */
:root {
  --btn-green: #2ecc71;
  --btn-green-border: #29b765;
  --btn-green-text: #0b2616;
  --action-button-min: 14rem; /* base width for equal buttons */
}

.btn-green {
  background: var(--btn-green) !important;
  border-color: var(--btn-green-border) !important;
  color: var(--btn-green-text) !important;
  font-weight: 650;
}

/* Remove underline for link-buttons used as buttons */
.info-links a[role="button"] {
  text-decoration: none !important;
}

/* Group of Import/Export buttons fills width, equal sizes */
.btn-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* always 5 inline */
  gap: 0.5rem;
  width: 100%;
}
.btn-group > button {
  width: 100%;
}

/* Left-only link buttons, same size as Import/Export (see JS below) */
.btn-equal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--action-button-col-width, 14rem);
  min-width: max-content;
}

/* ===== Accessibility ===== */
[aria-live="polite"] {
  outline: none;
}

/* Settings: dirty field highlight */
.settings-dirty {
  outline: 2px solid #2ecc71;
  outline-offset: 2px;
  border-radius: 0.35rem;
}

/* ===== NEW: 3-column settings grid & counters ===== */
.settings-grid {
  --pill-bg: #262626;
  --col-gap: 16px;
  align-items: stretch;
  column-gap: var(--col-gap);
  display: grid;
  grid-template-columns: auto 1fr auto; /* Enable | Label | Max */
  gap: 10px 16px;
}
.settings-grid .enable,
.settings-grid .label,
.settings-grid .max {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--pill-bg);
  padding: 0.5rem 0.75rem;
}
.settings-grid .enable {
  border-radius: 0.5rem 0 0 0.5rem;
}
.settings-grid .max {
  border-radius: 0 0.5rem 0.5rem 0;
}
.settings-grid .enable::after,
.settings-grid .label::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: calc(-1 * var(--col-gap));
  width: var(--col-gap);
  background: var(--pill-bg);
  pointer-events: none;
}
.settings-grid .label::before,
.settings-grid .max::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(-1 * var(--col-gap));
  width: var(--col-gap);
  background: var(--pill-bg);
  pointer-events: none;
}
.settings-grid .checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.settings-grid .checkline input[type="checkbox"] {
  margin: 0;
}

.settings-grid .enable label.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  text-align: left;
}

/* Put title and input on the same line, right-aligned */
.settings-grid .label,
.settings-grid .max {
  display: grid;
  grid-template-columns: max-content max-content; /* title | input */
  align-items: center;
  justify-content: end;
  column-gap: 8px;
}

.settings-grid .label .title,
.settings-grid .max .title {
  display: inline;
  text-align: right;
  margin: 0;
  font-weight: 600;
}

.input-with-count {
  position: relative;
}
.input-with-count > input {
  width: auto;
  padding-right: 2.2em;
}
.input-with-count .count {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #444;
  opacity: 0.5;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

/* stack on small screens */
@media (max-width: 520px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .settings-grid .label .title,
  .settings-grid .max .title {
    text-align: left;
  }
}

/* Number inputs: visually 2 digits wide */
input.digits-2 {
  width: 2rem;
}

/* Compact, spinnerless number inputs */
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* pill */
.settings-dirty-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4ch;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.9rem;
  color: #ffd666;
  background: #3b2d10;
  border: 1px solid #5a4312;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
  white-space: nowrap;
}
.settings-dirty-pill::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #ffd666;
  opacity: 0.9;
}

.is-hidden {
  display: none !important;
}

/* pushes everything after it to the right in a flex row */
.push-left {
  margin-right: auto;
}

.center-column .box.disabled,
.hrbox.disabled {
  pointer-events: none;
  opacity: var(--faint-opacity, 0.2);
}

/* HR animations: 2-col pill row (Enable | Duration → right-aligned) */
.settings-grid.hr-anim-grid {
  display: grid;
  grid-template-columns: auto 1fr !important; /* beat the 3-col default */
  column-gap: var(--col-gap);
  --pill-bg: #262626 !important; /* concrete color, not var() */
  margin-block-start: var(--row-gap, 8px); /* space beneath this row */
}
.hr-anim-grid .enable,
.hr-anim-grid .max {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--pill-bg);
  padding: 0.5rem 0.75rem;
}
.hr-anim-grid .enable {
  border-radius: 0.5rem 0 0 0.5rem;
}
.hr-anim-grid .max {
  border-radius: 0 0.5rem 0.5rem 0;
  justify-content: flex-end;
  gap: 8px;
}
.hr-anim-grid .enable::after,
.hr-anim-grid .max::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--col-gap);
  background: var(--pill-bg);
  pointer-events: none;
}
.hr-anim-grid .enable::after {
  right: calc(-1 * var(--col-gap));
}
.hr-anim-grid .max::before {
  left: calc(-1 * var(--col-gap));
}
.hr-anim-grid .checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.hr-anim-grid .checkline input[type="checkbox"] {
  margin: 0;
}

/* (Optional) ensure consistent spacing between any two rows, just in case */
.settings-grid + .settings-grid {
  margin-top: var(--row-gap, 8px);
}

/* ========================================================= */
/* Info + Settings modals: button shape + explicit colors    */
/* ========================================================= */
.info-links .btn-equal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 0.9rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-weight: 700;
  text-decoration: none !important;
}
.btn--settings {
  background: #ffeb3b;
  color: #111;
}
.btn--teams {
  background: #1976d2;
  color: #fff;
  border-color: transparent;
}
.btn--animations {
  background: #dc2626;
  color: #fff;
  border-color: transparent;
}
.btn--teams:hover,
.btn--animations:hover {
  filter: brightness(1.05);
}

/* === Force colors for Tutorial + Settings modals (wins over generic link styles) === */
#infoDialog .info-links .btn-equal,
#settingsDialog .info-links .btn-equal {
  height: 44px;
  padding: 0 0.9rem;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.15);
  text-decoration: none !important;

  /* override global .btn-equal width for dialogs */
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

/* Settings = yellow */
#infoDialog .info-links .btn--settings,
#settingsDialog .info-links .btn--settings {
  background: #ffeb3b !important;
  color: #111 !important;
}

/* Teams = blue (cover both classed + id-ed anchors) */
#infoDialog .info-links .btn--teams,
#settingsDialog .info-links .btn--teams,
#infoDialog .info-links #goTeams,
#settingsDialog .info-links a[href*="teams-config.html"] {
  background: #1976d2 !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Animations = red (cover both classed + id-ed anchors) */
#infoDialog .info-links .btn--animations,
#settingsDialog .info-links .btn--animations,
#infoDialog .info-links #goAnimations,
#settingsDialog .info-links a[href*="hr-animations.html"] {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Subtle hover lift for the colored anchors */
#infoDialog .info-links .btn--teams:hover,
#settingsDialog .info-links .btn--teams:hover,
#infoDialog .info-links .btn--animations:hover,
#settingsDialog .info-links .btn--animations:hover {
  filter: brightness(1.05);
}

/* Dialog nav buttons: single row, equal-ish widths */
#infoDialog .info-links,
#settingsDialog .info-links {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
  flex-wrap: nowrap; /* keep them on a single line */
  margin: 1rem 0; /* top/bottom spacing around the row */
}

#infoDialog .info-links .btn,
#settingsDialog .info-links .btn,
#infoDialog .info-links .btn-equal,
#settingsDialog .info-links .btn-equal {
  width: 100% !important; /* stretch to the grid cell */
  min-width: 0; /* avoid overflow clipping */
  justify-content: center; /* center labels */
}

/* Settings dialog: make the new Scoreboard button white like other pages */
#settingsDialog .btn--scoreboard {
  background: #fff;
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

#settingsDialog .btn--scoreboard:hover {
  filter: brightness(0.98);
}
#settingsDialog .btn--scoreboard:active {
  transform: translateY(1px);
}

/* keep keyboard ring consistent */
#settingsDialog .btn--scoreboard:focus-visible {
  outline: 2px solid var(--focus, #66afe9);
  outline-offset: 2px;
}

/* Settings dialog: unify button height + padding */
#settingsDialog .info-links .btn-equal,
#settingsDialog .info-links a[role="button"],
#settingsDialog form button {
  font-size: 1rem;
  line-height: 1.1;
  padding: 0.625rem 1rem; /* same as Animations page */
  border-radius: 6px; /* keep corners consistent */
}

/* Quick Tutorial (Info dialog): center all text except lists */
#infoDialog {
  text-align: center;
}

/* Keep lists left-aligned (while the block itself is centered) */
#infoDialog ul,
#infoDialog ol {
  text-align: left;
  display: inline-block; /* centers the list block, but its contents are left-aligned */
  margin: 0.75rem auto;
  padding-left: 1.25rem; /* normal list indent */
  list-style-position: outside;
}

/* Ensure nested items stay left-aligned */
#infoDialog li {
  text-align: left;
}

/* Ghost link: same color as text until hover/focus */
.ghost-link,
.ghost-link:visited {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent; /* subtle underline only on hover/focus */
  transition: border-color 120ms ease, text-decoration-color 120ms ease;
}

/* Reveal only on hover and keyboard focus */
.ghost-link:hover,
.ghost-link:focus-visible {
  border-bottom-color: currentColor;
}

/* Don’t show mouse-focus outline; keep keyboard focus visible via the underline */
.ghost-link:focus {
  outline: none;
}
