/* Global */
:root {
  --grey-color: #212124;
  --tan-color: #f0d9b5;
  --brown-color: #b58863;
}

html, body {margin: 0; height: 100%; }

body {
  background-color: var(--grey-color);
  color: #eeeeee;
  /* Light-on-dark text renders artificially heavy on macOS without this */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* System fonts: SF Pro on Apple devices, Segoe on Windows, Roboto on
     Android. A locally-installed desktop Roboto renders too heavy, so it
     comes after the platform fonts. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  margin: 0;
  width: 100%;
  height: 100%;
  position: relative;
}

h1,h2,
p {
  margin-top: 0;
}

ol {
  padding-left: 1.1rem;
}

input {
  padding: 0.8rem 1rem;
}

input:focus {
  outline: none;
}

a {
  color: #cccccc;
}

.content-wrapper {
  position: relative;
  width: 100%;
  max-width: 32em;
  padding: 2rem;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Zoom is enabled page-wide for accessibility; keep double-tap from zooming
   the board mid-game, and keep iOS from auto-zooming the share-URL input
   (it zooms any focused input with text smaller than 16px). */
#myBoard {
  touch-action: manipulation;
}

.modal__input {
  font-size: 16px;
}

.chessboard-image {
  object-fit: cover;
  width: 100%;
  display: block;
  margin: 0 auto;
  max-width: 32em;
  box-sizing: border-box;
}

/* Header */
.header__title {
  margin-bottom: 0.5rem;
}

.header__details {
  font-size: 1.0rem;
  font-weight: normal;
}

/* Landing intro: the royal procession, airborne edition. Each piece slides
   in from a random spot just outside the board to its square — kings first,
   then queens, bishops, knights, rooks, and finally the pawns. JS sets each
   piece's random start offset (--from-x/--from-y) and wave delay, then
   removes .board-intro after the show. */
@media (prefers-reduced-motion: no-preference) {
  .board-intro img[data-piece] {
    animation: piece-arrive 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  @keyframes piece-arrive {
    0% {
      opacity: 0;
      transform: translate(var(--from-x, 0px), var(--from-y, 0px));
    }
    20% {
      opacity: 1;
    }
    100% {
      opacity: 1;
      transform: translate(0, 0);
    }
  }
}

/* Helper — the one line under the board that says what to do next */
.helper {
  text-align: center;
  color: var(--tan-color);
  font-size: 0.95rem;
  min-height: 1.3em;
  margin: 0.8rem 0 0.2rem;
}

.helper a {
  color: var(--tan-color);
}

/* Stack helper sentences on narrow screens instead of wrapping mid-phrase */
.helper__line {
  display: block;
}

@media screen and (min-width: 32em) {
  .helper__line {
    display: inline;
  }
}

/* Details */
.details {
  margin: 1.5rem 0;
}

.details__row {
  display: flex;
  align-items: baseline;
  margin: 0.5rem 0;
}

.details__title {
  color: #B4886B;
  font-weight: bold;
  text-align: right;
  margin-right: 0.5rem;
  text-transform: uppercase;
  width: 30%;
}

.details__text {
  width: 70%;
}

.notation-322f9 {
  font-size: 11px;
}

/* How it works (bare landing only) */
.howto {
  margin: 1rem 0;
  font-size: 0.85rem;
}

.howto__title {
  color: #B4886B;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.howto__steps {
  margin: 0 0 0.6rem;
}

.howto__steps li {
  margin: 0.25rem 0;
}

.howto__note {
  /* The closing value-prop line — styled as a statement in the page's tan
     "guidance voice", not a fourth bullet */
  text-align: center;
  font-style: italic;
  color: rgba(240, 217, 181, 0.75);
  font-size: 0.95em;
  margin-top: 1rem;
}

/* On the about page there's room to breathe — match the FAQ's sizing
   instead of the compact landing-page version */
.howto--about {
  font-size: 0.95rem;
}

.howto--about .howto__note {
  /* The about version is a full paragraph — keep it plain prose */
  text-align: left;
  font-style: normal;
  color: #cccccc;
  font-size: 1em;
}

/* About page FAQ */
.faq {
  margin: 1.5rem 0;
}

.faq__q {
  font-weight: bold;
  margin: 0.9rem 0 0.2rem;
}

.faq__a {
  color: #cccccc;
  font-size: 0.95rem;
}

/* Buttons */
.buttons {
  text-align: center;
  display: flex;
  justify-content: space-between;
}

.button--copy {
  display: none;
}

.button {
  color: var(--grey-color);
  background-color: var(--tan-color);
  border: none;
  padding: 0.8rem 1rem;
  text-align: center;
  text-decoration: none;
  font-size: 0.8rem;
  cursor: pointer;
  text-transform: uppercase;
  font-weight: bold;
  transition: background-color 0.25s;
  flex: 1;
  margin: 0 0.25rem;
  width: auto;
}

.button-share {
  /*
    The Share button is hidden by default, then shown by JS if the
    capability navigator.share is available
  */
  display: none;
}

.button:active {
  background-color: var(--brown-color);
  outline: none;
}

/* Modal */
.modal {
  position: absolute;
  z-index: 10000;
  top: 0;
  left: 0;
  visibility: hidden;
  width: 100%;
  height: 100vh;
}

.modal--is-visible {
  visibility: visible;
}

.modal__overlay {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s linear 0.3s, opacity 0.3s;
}

.modal--is-visible .modal__overlay {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.modal__wrapper {
  position: fixed;
  z-index: 9999;
  left: 50%;
  top: 50%;
  transform: translateY(-50%) translateX(-50%);
  width: 92%;
  max-width: 32em;
  /* Elevated-surface convention: the dialog is lighter than the page so it
     reads as floating above it, not a region of it */
  background-color: #2b2b31;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}

.modal__title {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.modal__lead {
  color: #cccccc;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal__input {
  width: 70%;
}

.modal__copy-wrapper {
  display: flex;
  width: 100%;
}

.modal__content {
  padding: 1.5rem;
  color: #eeeeee;
}

.modal .details__title {
  width: auto;
}

.modal .details,
.modal .details__row {
  margin-bottom: 0;
}

.modal__close {
  color: #aaaaaa;
  font-size: 1.0em;
  font-weight: bold;
  position: absolute;
  right: 1rem;
  top: 1rem;
  line-height: 0.6em;
  transition: color 0.25s;
}

.modal__close:active {
  color: #757575;
  text-decoration: none;
  cursor: pointer;
}

/* Quiet utility link in the top-right corner of the header */
.header__about {
  position: absolute;
  top: 1rem;
  right: 1.6rem;
  padding: 0.4rem;
  color: #999999;
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

@media screen and (min-width: 32em) {
  .details__title {
    width: 24%;
  }

  .details__text {
    width: 76%;
  }

  .button:hover {
    background-color: var(--brown-color);
    transition: background-color 0.25s;
    outline: none;
  }

  .modal__close:hover {
    color: #757575;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.25s;
  }
}
