/* Backgammon custom styles */

/* Colour theme, a backgammon board: wood frame, green felt, cream and burgundy points. Change these to re-theme the app */
:root {
  --bg-felt: #2F5D46;             /* Green felt - page background */
  --bg-felt-dark: #234736;        /* Darker felt - cards */
  --bg-wood: #5B3A24;             /* Wood frame - navbar */
  --bg-cream: #F3E9D2;            /* Cream points and checkers - main text */
  --bg-burgundy: #8E2C3A;         /* Burgundy points - buttons */
  --bg-burgundy-dark: #6E1F2B;    /* Pressed buttons */
  --bg-gold: #D9B26F;             /* Brass trim - highlights and links */
  --bg-muted: #B9C9BC;            /* Secondary text */
}

/* Base page */
body {
  background-color: var(--bg-felt);
  color: var(--bg-cream);
}

a,
a:hover {
  color: var(--bg-gold);
}

h1,
h3,
.navbar-brand,
.navbar .nav-link {
  font-family: tintin, Georgia, "Times New Roman", serif;
}

.navbar.bg-dark {
  background-color: var(--bg-wood) !important;
  border-bottom: 3px solid var(--bg-gold);
}

.navbar-dark .navbar-brand {
  color: var(--bg-cream);
}

.navbar-dark .navbar-nav .nav-link {
  color: var(--bg-gold);
}

.card {
  background-color: var(--bg-felt-dark);
  border: 1px solid var(--bg-gold);
  border-radius: 12px;
}

.btn-info {
  background-color: var(--bg-burgundy);
  border-color: var(--bg-burgundy);
  color: var(--bg-cream);
}

.btn-info:hover,
.btn-info:focus,
.btn-info:active {
  background-color: var(--bg-burgundy-dark) !important;
  border-color: var(--bg-burgundy-dark) !important;
  color: var(--bg-cream);
}

.form-control:focus {
  border-color: var(--bg-gold);
  box-shadow: 0 0 0 0.2rem rgba(217, 178, 111, 0.35);
}

.modal-content {
  background-color: var(--bg-cream);
  color: var(--bg-wood);
}

/* Shown with a fade rather than Bootstrap's modal(), which is what usually lets a modal scroll. The move viewer can be
   taller than a phone screen once a Why? and its facts are open */
#boardViewModal,
#analyseWhyModal {
  overflow-y: auto;
}

.loader {
  border-color: var(--bg-cream);
  border-top-color: var(--bg-burgundy);
}

.bg-placeholder {
  color: var(--bg-muted);
}

/* Board */
.bg-board {
  max-width: 560px;
  margin: 0 auto 6px auto;
}

.bg-board-svg {
  width: 100%;
  height: auto;
  display: block;
  -webkit-tap-highlight-color: transparent;
}

.bg-tap {
  cursor: pointer;
}

/* Play, Puzzles, Skills and Analyse: one column on an upright phone (what's above the board, the board, then the
   controls). On a wide screen (a phone on its side, a laptop) the board goes on the left and the controls on the right,
   sized to fit the screen's height and kept in view while the controls scroll. Analyse's photo corners span both */
.bg-split {
  display: grid;
  grid-template-columns: 100%;
  grid-template-areas: "top" "corners" "top2" "board" "side";
}

.bg-split-top { grid-area: top; min-width: 0; }
.bg-split-corners { grid-area: corners; min-width: 0; }
.bg-split-top2 { grid-area: top2; min-width: 0; }
.bg-split-board { grid-area: board; min-width: 0; }
.bg-split-side { grid-area: side; min-width: 0; }

@media (orientation: landscape) and (min-width: 600px) {
  .bg-split-section {
    max-width: 1140px;
  }

  .bg-split {
    grid-template-columns: auto minmax(260px, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "corners corners" "board top" "board top2" "board side";
    column-gap: 20px;
    align-items: start;
  }

  .bg-split-board {
    position: sticky;
    top: 64px;
    width: min(560px, calc((100vh - 135px) * 1.19));
  }

  .bg-split-board .bg-board {
    max-width: 100%;
  }
}

/* Dragging checkers mustn't select the point numbers */
.bg-board {
  user-select: none;
  -webkit-user-select: none;
}

.bg-counts {
  color: var(--bg-muted);
  font-size: 0.85em;
  text-align: center;
  margin-bottom: 8px;
}

.btn-outline-light.active,
.btn-outline-light:active {
  background-color: var(--bg-gold) !important;
  border-color: var(--bg-gold) !important;
  color: var(--bg-wood) !important;
}

.bg-photo-canvas {
  width: 100%;
  height: auto;
  border-radius: 6px;
  touch-action: manipulation;
}

/* Dragging a corner must not scroll the page, so the photo is kept short enough to leave room to scroll beside it */
.bg-corner-editor {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 60vh;
  margin: 0 auto;
  touch-action: none;
}

.bg-photo-notes {
  font-size: 0.85em;
  color: var(--bg-gold);
  padding-left: 18px;
}

/* Keep New game well apart from the turn buttons, so it isn't pressed by mistake (beats Bootstrap's .btn-block + .btn-block) */
.btn-block.bg-new-game {
  margin-top: 1.75rem;
}

/* Guide */
.bg-guide-heading {
  font-family: tintin, Georgia, "Times New Roman", serif;
  color: var(--bg-gold);
  margin-top: 1.25rem;
}

.bg-guide-list {
  padding-left: 1.2rem;
}

.bg-guide-list li {
  margin-bottom: 0.4rem;
}

/* A link to the Themes page, with its icon kept on the same line */
.bg-theme-link {
  text-decoration: underline;
  white-space: nowrap;
}

.bg-theme-link i {
  font-size: 0.7em;
  margin-left: 0.25em;
  vertical-align: 0.1em;
}

/* Grading after each move */
.bg-grade {
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.bg-grade-best {
  background-color: #2E7D4F;
  border: 2px solid #8FD19E;
}

.bg-grade-good {
  background-color: #4F7F5E;
  border: 2px solid #8FD19E;
}

.bg-grade-miss {
  background-color: var(--bg-burgundy-dark);
  border: 2px solid #E8A0A8;
}

/* Tables */
.bg-table {
  color: var(--bg-cream);
  font-size: 0.85em;
}

.bg-table th,
.bg-table td {
  border-top-color: rgba(243, 233, 210, 0.2);
}

/* A table in a modal (the cube decision in the game summary's viewer) sits on cream, so it's drawn in the wood colour */
.modal-content .bg-table {
  color: var(--bg-wood);
}

.modal-content .bg-table th,
.modal-content .bg-table td {
  border-top-color: rgba(91, 58, 36, 0.25);
}

.bg-result-row {
  cursor: pointer;
}

.bg-result-selected {
  background-color: rgba(217, 178, 111, 0.3);
}

.bg-row-bot {
  color: var(--bg-muted);
}

.bg-label {
  border-radius: 4px;
  padding: 0 4px;
  font-weight: bold;
  white-space: nowrap;
}

.bg-label-perfect { background-color: #2E7D4F; }
.bg-label-good { background-color: #4F7F5E; }
.bg-label-slip { background-color: #A9862F; }
.bg-label-mistake { background-color: #A0522D; }
.bg-label-blunder { background-color: var(--bg-burgundy); }

/* Account */
.bg-level {
  font-family: tintin, Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  color: var(--bg-gold);
  line-height: 1.2;
}

.bg-chart-box {
  position: relative;
  height: 280px;
}

/* A "Why?" explanation in the move viewer */
.bg-why-text {
  font-size: 0.95em;
}

/* The move viewer is cream, so its button and facts are in the wood colour */
.bg-why-button {
  color: var(--bg-wood);
  border-color: var(--bg-wood);
}

.bg-why-button:hover,
.bg-why-button:focus {
  background-color: var(--bg-wood);
  color: var(--bg-cream);
}

.bg-why-facts {
  font-size: 0.8em;
  color: var(--bg-wood);
}

.bg-why-facts summary {
  cursor: pointer;
}

/* "Your common errors" on Account: each theme's share as a bar */
.bg-error-row {
  margin-bottom: 8px;
  font-size: 0.9em;
}

.bg-error-bar {
  height: 6px;
  border-radius: 3px;
  background-color: rgba(0, 0, 0, 0.2);
}

.bg-error-bar div {
  height: 100%;
  border-radius: 3px;
  background-color: var(--bg-gold);
}

/* A very lucky or unlucky roll in the game summary */
.bg-luck-good {
  color: #8FD694;
}

.bg-luck-bad {
  color: #E8A0A0;
}

.bg-trend-toggle,
.bg-trend-toggle:hover {
  color: var(--bg-muted);
  text-decoration: none;
}

.bg-topup-button.active,
.bg-choice-button.active {
  color: var(--bg-felt-dark);
  background-color: var(--bg-gold);
  border-color: var(--bg-gold);
}

.bg-hint-error {
  color: #F4A6A6 !important;
}

#account_paypal_button_container {
  max-width: 500px;
  margin: 0 auto;
}

/* Play: the match score, and cube notes that never block a move */
.bg-scoreboard {
  text-align: center;
  color: var(--bg-gold);
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.bg-scoreboard:empty {
  display: none;
}

.bg-notice {
  border: 1px solid var(--bg-gold);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
  background-color: var(--bg-felt-dark);
}

/* The match clock under the score: gold under a minute of reserve, red at the end */
.bg-clock {
  text-align: center;
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.bg-clock-low {
  color: var(--bg-gold);
}

.bg-clock-out {
  color: #E25C5C;
  font-weight: bold;
}

/* Viewing a move from the game summary: the whole row opens it */
.bg-row-viewable {
  cursor: pointer;
}

/* Viewing a move from the game summary */
.btn.bg-view-button {
  color: var(--bg-gold);
  padding: 0 0.35rem;
}

.bg-view-key {
  font-size: 0.9em;
  margin-top: 0.4rem;
}

.bg-key-dot {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  margin-right: 0.4em;
  border: 1px solid var(--bg-wood);
}

/* Analyse: the home board corners, laid out like the board */
.bg-corner-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.bg-corner-buttons .btn {
  display: flex;
  height: 1.4rem;
  padding: 0.2rem;
}

/* A small mark in the button's own corner */
.bg-corner-mark {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  background: currentColor;
}

#analyse_home_top_right, #analyse_home_bottom_right {
  justify-content: flex-end;
}

#analyse_home_bottom_left, #analyse_home_bottom_right {
  align-items: flex-end;
}

/* Account: the links under the level graph, wrapping onto a new line on a phone */
.bg-graph-toggles {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1rem;
  row-gap: 0.25rem;
}

/* Puzzles: the difficulty as dots, the theme's reveal link, and the player's own row in the top moves */
.bg-difficulty {
  display: inline-flex;
  gap: 4px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.bg-difficulty-dot {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  border: 1px solid var(--bg-gold);
}

.bg-difficulty-on {
  background-color: var(--bg-gold);
}

.btn.bg-reveal-button {
  color: var(--bg-gold);
  vertical-align: baseline;
}

.bg-puzzle-yours td {
  color: var(--bg-gold);
  font-weight: bold;
}

/* Welcome page cards for new players: a small board or a large icon above each */
.bg-welcome-board {
  max-width: 320px;
  margin: 0 auto;
  pointer-events: none;
}

.bg-welcome-icon {
  font-size: 3.5rem;
  color: var(--bg-gold);
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}

/* Skills: the NEW badge in the menu (taken off once players have found the section) */
.bg-new-badge {
  background-color: var(--bg-gold);
  color: var(--bg-wood);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: top;
  margin-left: 2px;
  animation: bg-new-glow 2.4s ease-in-out infinite;
}

@keyframes bg-new-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(217, 178, 111, 0); }
  50% { box-shadow: 0 0 8px rgba(217, 178, 111, 0.9); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-new-badge,
  .bg-swipe-arrive {
    animation: none;
  }
}

/* Win %: a slider from them (left) to you (right) */
.bg-win-labels {
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.bg-win-labels #skills_win_you {
  color: var(--bg-gold);
}

.bg-win-slider::-webkit-slider-thumb { background-color: var(--bg-gold); }
.bg-win-slider::-moz-range-thumb { background-color: var(--bg-gold); }
.bg-win-slider::-webkit-slider-runnable-track { background-color: rgba(243, 233, 210, 0.3); }
.bg-win-slider::-moz-range-track { background-color: rgba(243, 233, 210, 0.3); }

/* Best Roll: each roll's two dice, in the roller's checker colours */
.bg-roll-button {
  padding: 8px 4px;
}

.bg-roll-die {
  margin: 0 3px;
}

/* Blunder Swipe: the card follows a drag, flies off when swiped, and shows a tick or a cross. Two outlines behind it
   look like the next cards in a stack: the next card comes forward from there, and a new one joins the back */
.bg-swipe-stack {
  position: relative;
  padding-bottom: 16px;
}

.bg-swipe-behind {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 16px;
  border: 2px solid rgba(243, 233, 210, 0.35);
  border-radius: 8px;
  background-color: rgba(59, 42, 28, 0.6);
  pointer-events: none;
}

.bg-swipe-behind-1 {
  transform: translateY(8px) scale(0.97);
}

.bg-swipe-behind-2 {
  transform: translateY(16px) scale(0.94);
  opacity: 0.7;
}

.bg-swipe-arrive {
  animation: bg-swipe-arrive 0.35s ease-out;
}

@keyframes bg-swipe-arrive {
  from { transform: translateY(30px) scale(0.9); opacity: 0; }
  to { transform: translateY(16px) scale(0.94); opacity: 0.7; }
}

.bg-swipe-card {
  position: relative;
  z-index: 1;
  touch-action: pan-y;
  user-select: none;
  transition: transform 0.35s ease, opacity 0.35s ease;
  cursor: grab;
}

.bg-swipe-card.bg-swipe-dragging,
.bg-swipe-card.bg-swipe-instant {
  transition: none;
  cursor: grabbing;
}

.bg-swipe-card.bg-swipe-gone {
  opacity: 0;
}

.bg-swipe-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  pointer-events: none;
}

.bg-swipe-mark.bg-swipe-right,
.bg-swipe-mark.bg-swipe-wrong {
  display: flex;
}

.bg-swipe-right {
  background-color: #2E7D4F;
  border: 3px solid #8FD19E;
  color: #F3E9D2;
}

.bg-swipe-wrong {
  background-color: var(--bg-burgundy-dark);
  border: 3px solid #E8A0A8;
  color: #F3E9D2;
}

.bg-swipe-streak {
  font-family: tintin, Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  color: var(--bg-gold);
  font-variant-numeric: tabular-nums;
}

.bg-swipe-streak::before {
  content: "\f0e7";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 1rem;
  margin-right: 6px;
}

/* Account's Skills card */
.bg-skills-table {
  color: var(--bg-cream);
}

.bg-skills-table td {
  border-top-color: rgba(243, 233, 210, 0.2);
}

.bg-skills-table tr:first-child td {
  border-top: none;
}

/* The welcome page's level graph and Analyse tables: pictures, so nothing in them can be tapped */
.bg-welcome-chart {
  position: relative;
  height: 220px;
  max-width: 320px;
  margin: 0 auto;
  pointer-events: none;
}

.bg-welcome-tables {
  max-width: 320px;
  margin: 0 auto;
  font-size: 0.85rem;
  pointer-events: none;
}

.bg-welcome-tables .bg-table {
  margin-bottom: 0.5rem;
}

/* "and 39 more" under the first few ranked moves */
.bg-more-row td {
  color: var(--bg-muted);
  text-align: center;
  font-size: 0.85em;
}

/* Photograph a real board: the photo top left, the board read from it offset bottom right over it, and arrows from one
   to the other, all placed on a 320 x 300 layout so they keep together at any width */
.bg-welcome-photo {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 320 / 300;
  margin: 0 auto;
  pointer-events: none;
}

.bg-welcome-photo-img {
  position: absolute;
  left: 0;
  top: 2%;
  width: 66%;
  border-radius: 6px;
  border: 2px solid var(--bg-cream);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  transform: rotate(-4deg);
}

.bg-welcome-photo-board {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 75%;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

.bg-welcome-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bg-welcome-arrows path:not([fill]) {
  fill: none;
  stroke: var(--bg-gold);
  stroke-width: 3;
  stroke-linecap: round;
}

/* Board colours in Settings: a tile per colour, and the colour modal's picker and ready-made colours */
.bg-colour-tile {
  padding: 6px 4px;
  line-height: 1.1;
}

.bg-colour-swatch {
  display: block;
  height: 28px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

.bg-colour-input {
  width: 64px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.bg-colour-presets {
  display: flex;
  flex-wrap: wrap;
}

.bg-colour-preset {
  width: 32px;
  height: 32px;
  margin: 3px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.35);
  padding: 0;
}

.bg-colour-warning {
  color: #8A5A00;
  min-height: 1em;
}

/* The PR and Elo card: a provisional Elo is marked after the number */
.bg-provisional {
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--bg-muted);
}

/* Analyse: the ? at the end of each move's row, asking why it isn't as good as the best (a small round button in the
   Why? colour; filled once asked, as it's free to look at again) */
.bg-why-cell {
  width: 2.2em;
  text-align: right;
}
.bg-why-mark {
  display: inline-block;
  width: 1.7em;
  height: 1.7em;
  padding: 0;
  border: 1px solid #f0ad4e;
  border-radius: 50%;
  background: transparent;
  color: #f0ad4e;
  font-weight: bold;
  font-size: 0.85rem;
  line-height: 1.55em;
  text-align: center;
}
.bg-why-mark:hover,
.bg-why-mark:focus {
  background: rgba(240, 173, 78, 0.2);
  color: #f0ad4e;
}
.bg-why-asked {
  background: #f0ad4e;
  color: #222;
}
.bg-why-sample {
  width: 1.5em;
  height: 1.5em;
  line-height: 1.35em;
  font-size: 0.75rem;
}

/* The follow-up Ask button: light on the dark pages (Puzzles), the wood colour in the cream modals, like their Why? button */
.modal .bg-followup .btn-outline-light {
  color: var(--bg-wood);
  border-color: var(--bg-wood);
}
.modal .bg-followup .btn-outline-light:hover,
.modal .bg-followup .btn-outline-light:focus {
  background-color: var(--bg-wood);
  color: var(--bg-cream);
}

/* Welcome page, Download your games: a sheet of paper with the start of a match file, slightly tilted, its name on a tab */
.bg-welcome-mat {
  max-width: 320px;
  margin: 0.5rem auto 0;
  transform: rotate(-2deg);
  pointer-events: none;
}

.bg-welcome-mat-tab {
  display: inline-block;
  background-color: #F7F4EC;
  color: var(--bg-wood);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 6px 6px 0 0;
}

.bg-welcome-mat-sheet {
  background-color: #FFFFFF;
  color: #2B2B2B;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.52rem;
  line-height: 1.45;
  padding: 10px 12px 18px;
  border-radius: 0 6px 6px 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  white-space: pre;
  overflow: hidden;
  /* The file carries on below: the last line fades out */
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
  mask-image: linear-gradient(to bottom, #000 75%, transparent);
}

/* Welcome page, Sharpen your skills: a Blunder Swipe card part way through a swipe right, with a tick, and the next
   cards behind it (as .bg-swipe-* in Skills) */
.bg-welcome-swipe {
  position: relative;
  max-width: 220px;
  margin: 1rem auto 0;
  padding-bottom: 14px;
  pointer-events: none;
}

.bg-welcome-swipe-behind {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 14px;
  border: 2px solid rgba(243, 233, 210, 0.35);
  border-radius: 8px;
  background-color: rgba(59, 42, 28, 0.6);
}

.bg-welcome-swipe-behind-1 {
  transform: translateY(7px) scale(0.96);
}

.bg-welcome-swipe-behind-2 {
  transform: translateY(14px) scale(0.92);
  opacity: 0.7;
}

.bg-welcome-swipe-card {
  position: relative;
  z-index: 1;
  transform: translateX(16%) rotate(8deg);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  border-radius: 6px;
}

.bg-welcome-swipe-card .bg-welcome-board {
  max-width: none;
}

.bg-welcome-swipe-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background-color: #2E7D4F;
  border: 3px solid #8FD19E;
  color: #F3E9D2;
}

/* Coming soon: a quieter badge than New, and the welcome card dashed and faded so it doesn't look like a broken
   feature */
.bg-soon-badge {
  background-color: rgba(243, 233, 210, 0.2);
  color: var(--bg-cream);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: top;
  margin-left: 2px;
}

h3 .bg-soon-badge,
h5 .bg-soon-badge {
  vertical-align: middle;
}

.bg-welcome-soon {
  border-style: dashed;
  opacity: 0.8;
}

/* Skills: the answers under a set's score */
.bg-skills-answers { color: var(--bg-cream); }
.bg-skills-answers th, .bg-skills-answers td { border-color: rgba(243, 233, 210, 0.15); }
.bg-answer-right { color: #7FBF8E; }
.bg-answer-wrong { color: #E0857A; }
