/* Game-page chrome: the bars above the board, and the dialogs. */

/* Two bars, exactly as wide as the playing field (--field-w, css/board.css):
   the nav bar (back link, game name), then the game bar (mode, readouts,
   actions). Their heights are fixed (--nav-h, --bar-h) because card sizing
   takes them off the page height. */
.bars {
  container: bars / inline-size;
  width: var(--field-w);
  margin-inline: auto;
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding-inline: 0.75rem;
  background: var(--bar-nav);

  & a {
    color: var(--paper);
    font-weight: 600;
    text-decoration: none;

    /* Hover styles only where there's a real hover (mouse, trackpad): iOS
       applies :hover after a tap and leaves it stuck. */
    @media (hover: hover) {
      &:hover {
        text-decoration: underline;
      }
    }
  }

  & h1 {
    margin: 0;
    font-size: 1.1rem;
  }
}

/* Undo on the left, readouts centred on the bar, New on the right. */
.game-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  height: var(--bar-h);
  padding-inline: 0.5rem;
  border-radius: 0 0 0.75rem 0.75rem;
  background: var(--bar-game);

  & .undo {
    justify-self: start;
  }

  & .new {
    justify-self: end;
  }
}

/* Buttons that are just an icon and a word. */
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding-inline: 0.5rem;
  background: transparent;
  color: var(--paper);

  & svg {
    width: 1.25rem;
    height: 1.25rem;
    flex: none;
  }

  @media (hover: hover) {
    &:hover:not(:disabled) {
      background: rgb(255 255 255 / 0.1);
    }
  }
}

/* On a narrow bar the words go, leaving the icons; they stay the buttons'
   accessible names. */
@container bars (width < 21rem) {
  .text-button .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.readouts {
  display: flex;
  gap: 1rem;
  margin: 0;
  font-variant-numeric: tabular-nums;

  & div {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  & dt {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.75;
  }

  & dd {
    margin: 0;
    font-weight: 600;
  }
}

button {
  min-height: 2.75rem; /* 44px touch target */
  padding: 0.25rem 0.9rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;

  &:disabled {
    opacity: 0.45;
    cursor: default;
  }

  &.secondary {
    background: rgb(255 255 255 / 0.12);
    color: var(--paper);
  }
}

dialog {
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 0;
  border-radius: 1rem;
  background: var(--paper);
  color: var(--ink);
  text-align: center;

  &::backdrop {
    background: rgb(0 0 0 / 0.5);
  }

  & h2 {
    margin-top: 0;
  }

  & form {
    display: grid;
    gap: 1rem;
  }

  & .readouts {
    justify-content: center;
  }

  & button.secondary {
    background: transparent;
    color: var(--ink);
  }

  & .choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;

    & button {
      display: grid;
      padding-block: 0.75rem;
      background: var(--felt);
      color: var(--paper);
      justify-items: center;
      gap: 0.5rem;
    }

    & .fan {
      display: flex;

      & .card {
        display: block;
        position: static;
        width: 2.5rem;
        height: calc(2.5rem * 1.4);

        & + .card {
          margin-left: -1.5rem;
        }
      }
    }
  }
}
