@charset "utf-8";



.game-container {
  max-width: 600px;
  margin: 0 auto;

}


/* ==========================================================================
    Variables de color
    ========================================================================== */

.game-cover, .game-board {
  --color-primary-light: #f93a06;        /* .playBtn, .help (bg-grad) */
  --color-primary-dark: #0eff70d6;       /* .playBtn, .help (bg-grad) */
  --color-secondary-light: #a7e9b8;      /* .playBtn:hover, .help:hover (bg-grad) */
  --color-secondary-dark: #f93a06;       /* .playBtn:hover, .help:hover (bg-grad) */
  --color-text-light: #EFEBE9;           /* .playBtn, .help (text) */
  --color-bg-light: #feffe0;              /* .helpbox (bg), .close (bg), .dialog-box .close (bg) */
  --color-bg-white: white;               /* .close:hover (bg), .digit-cell (bg), .close:hover (bg), .whites (bg), .status .help (text), .attempts-grid (bg) */
  --color-border-default: black;         /* .game-cover (borde) */
  --color-border-light: #ddd;            /* .digit-cell, .result-cell (borde) */
  --color-result-bg: #84ecff;            /* .result-cell (bg) */
  --color-black-result: #000;            /* .blacks (bg) */
  --color-white-result: #ffffff;         /* .whites (bg) */
  --color-null-border: #a39b9b;          /* .null (borde) */
  --color-keyboard-bg: #f0f0f0;          /* .virtual-keyboard .key (bg) */
  --color-special-key: #84ecff;          /* .virtual-keyboard .special-key (bg) */
  --color-special-key-hover: #B3E5FC;    /* .virtual-keyboard .special-key:hover (bg) */
  --color-board-bg: #3f51b59c;           /* .game-board::before (bg) */
  --color-level-button: #1b37ad;         /* .status .levelbtn (bg) */
  --color-level-button-active: #53d4eb;  /* .status .levelbtn.active (bg) */
  --color-level-button-text-active: black; /* .status .levelbtn.active (txt) */
  box-sizing: border-box;
  user-select: none;
  font-family: system-ui, sans-serif;
}

/* ==========================================================================
    Globals
    ========================================================================== */

.container {
  container-type: inline-size;
}


/* ==========================================================================
    Game cover
    ========================================================================== */

.game-cover {
  width: 100%;
  height: 400px;
  border: 1px solid var(--color-border-default);
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  flex-direction: column;
  background-image: url(cover.webp);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;

 

  :is(.playBtn, .help) {
    text-align: center;
    width: 20%;
    cursor: pointer;
    background: linear-gradient(to right, var(--color-primary-light), var(--color-primary-dark));
    color: var(--color-text-light);
    font-size: 1.2rem;
    margin-bottom: 2rem;
    margin-right: 2rem;
    padding: 6px 0;
    border-radius: 15px;

    &:hover {
      background: linear-gradient(to right, var(--color-secondary-light), var(--color-secondary-dark));
    }
  }

  .helpbox {
    position: absolute;
    display: block;
    left: 0;
    margin: 0 2%;
    height: 0;
    background: var(--color-bg-light);
    text-wrap: auto;
    overflow-y: auto;
    padding: 0 1rem;
    z-index: 10;
    transition: height 400ms ease;
    .close {
      position: sticky;
      display: inline-block;
      text-align: center;
      top: 0;
      padding: 2px 8px;
      float: right;
      background: var(--color-bg-light);
      cursor: pointer;

      &:hover {
        background: var(--color-bg-white);
        font-weight: 600;
      }
    }
  }
}

/* ==========================================================================
    Game playground
    ========================================================================== */

.game-board {
  box-sizing: border-box;
  user-select: none;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  display: grid;
  gap: 10px;
  padding: 0 10px 10px 10px;
  grid-template-rows: 70px auto 1fr;
  grid-template-columns: 2fr 2fr;
  grid-template-areas:
    "h h"
    "s g"
    "k g";
  align-items: start;
  border: 2px solid red;
  *{
    box-sizing: border-box;
    user-select: none;
  }
  .helpbox {
    position: absolute;
    display: block;
    left: 0;
    width: 90%;
    margin: 0 2%;
    height: fit-content;
    background: var(--color-bg-light);
    text-wrap: auto;
    overflow-y: auto;
    padding: 0 1rem;
    z-index: 10;
    transition: height 400ms ease;
    .close {
      position: sticky;
      display: inline-block;
      text-align: center;
      top: 0;
      padding: 2px 8px;
      float: right;
      background: var(--color-bg-light);
      cursor: pointer;

      &:hover {
        background: var(--color-bg-white);
        font-weight: 600;
      }
    }
  }

  .title {
    grid-area: h;
    text-align: center;
  }

  > div:nth-child(2) {
    grid-area: s;
  }

  > div:nth-child(3) {
    grid-area: g;
  }

  > div:nth-child(4) {
    grid-area: k;
  }

  &::before {
    position: absolute;
    content: '';
    width: 100%;
    height: 100%;
    background-image: url('players.webp');
    background-size: cover;
    background-color: var(--color-board-bg);
    opacity: 0.09;
    z-index: -1;
  }

  .attempts-grid {
    display: grid;
    grid-template-rows: auto;
    grid-template-columns: auto;
    gap: 10px;
    background: var(--color-bg-white);

    .attempt-row {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      grid-template-rows: auto;
      gap: 5px;
    }

    .digit-cell,
    .result-cell {
      aspect-ratio: 1;
      border: 2px solid var(--color-border-light);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.8rem;
      font-weight: bold;
      text-transform: uppercase;
      padding: 0;
    }

    .digit-cell {
      background: var(--color-bg-white);
    }

    .result-cell {
      display: grid;
      grid-template-rows: 1fr 1fr;
      grid-template-columns: 1fr 1fr;
      justify-items: center;
      gap: 1px;
      align-items: center;
      background-color: var(--color-result-bg);
      border-radius: 20%;

      > div {
        transform: scale(0);
        transition: transform 300ms ease;
      }

      &.full > div {
        transform: scale(1);
      }

      > div:nth-child(1) {
        transition-delay: 0ms;
      }

      > div:nth-child(2) {
        transition-delay: 250ms;
      }

      > div:nth-child(3) {
        transition-delay: 550ms;
      }

      > div:nth-child(4) {
        transition-delay: 750ms;
      }

      :is(.blacks, .whites, .null) {
        width: 70%;
        height: 70%;
        border-radius: 50%;
      }

      .blacks {
        background: radial-gradient(circle at 30% 20%, var(--color-white-result) 0%, #cccccc 15%, var(--color-black-result) 100%);
        background-color: var(--color-black-result);
      }

      .whites {
        background: radial-gradient(circle at 30% 20%, var(--color-white-result) 0%, #eeeeee 15%, #acacac 80%);
        background-color: var(--color-white-result);
      }

      .null {
        background: #ffffff00;
        border: 1px solid var(--color-null-border);
      }
    }
  }
  /* ==========================================================================
      Keyboard
      ========================================================================== */
  .virtual-keyboard {
    width: 90%;
    margin: 10px auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    justify-items: center;
    gap: 10px;

    .level-notice {
      grid-column: 1 / 4;
      height: 2rem;
    }

    .key {
      width: 90%;
      height: 100%;
      font-size: 1.5rem;
      border-radius: 5px;
      border: none;
      background-color: var(--color-keyboard-bg);
      cursor: pointer;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 0.25rem;
      box-shadow: 2px 1px 2px 1px #c5c4c4;

    }
    &.active .key:hover {

      box-shadow: inset 2px 1px 2px 1px #c5c4c4;
    }
    .special-key {
      background-color: var(--color-special-key);
    }
    &.active .special-key:hover {
      background-color: var(--color-special-key-hover);
    }
  }
}

/* ==========================================================================
    Dialog box
    ========================================================================== */

.dialog-box {
  height: auto;
  width: 100%;
  position: absolute;
  font-size: 2rem;
  top: 50%;
  left: 50%;
  text-align: center;
  transform: translate(-50%, -50%);

  .close {
    position: absolute;
    display: inline-block;
    text-align: center;
    font-size: 1rem;
    top: 0;
    right: 0;
    padding: 2px 8px;
    float: right;
    background: var(--color-bg-light);
    cursor: pointer;
  }
}

/* ==========================================================================
    Icons
    ========================================================================== */

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  stroke-width: 0;
  stroke: currentColor;
  fill: currentColor;
}

/* ==========================================================================
    ARea for timer, level and help buttons
    ========================================================================== */

.status {
  display: grid;
  grid-template: 32px 32px / 1fr 1fr;
  gap: 10px;
  margin-bottom: 1rem;
  align-items: flex-start;
  justify-items: center;

  .timer {
    flex: 1 0 auto;
    display: flex;
    justify-content: center;
    font-weight: 600;
    font-size: 1.4rem;
    align-items: center;
  }

  .help {
    flex-shrink: 1;
    border-radius: 50%;
    background: red;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-bg-white);
    cursor: pointer;
    position: relative;
  }

  .levelbtn {
    border-radius: 10px;
    background: var(--color-level-button);
    width: 95%;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-bg-white);
    cursor: pointer;
    position: relative;

    &.active {
      background-color: var(--color-level-button-active);
      color: var(--color-level-button-text-active);
    }
  }

  .icon {
    stroke-width: 2px;
    stroke: currentColor;
    fill: currentColor;
  }
}

/* ==========================================================================
    Media Queries
    ========================================================================== */

@container (max-width: 450px) {
  .game-board {
    grid-template-columns: 1fr;
    grid-template-areas:
      "h"
      "s"
      "g"
      "k";

    .virtual-keyboard {
      margin-top: 20px;
      display: grid;
      grid-template-columns: repeat(3, auto);
      justify-items: center;
      gap: 10px;
      width: 100%;
      margin: 10px auto;
    }

    .attempt-row {
      margin: 0 auto;
      width: 100%;
      grid-template-columns: repeat(5, 1fr);
    }

    .key {
      width: 75%;
      aspect-ratio: 2 / 1;
      padding: 14px 0;
    }
  }
}