.main {
  justify-content: normal;

  @media (orientation: portrait) {
    padding: 0;
  }
}

.picks-to-click {
  --border: 2px solid var(--box-border-color);
  --border-radius: 8px;
  --bg-color: var(--box-bg-color);

  .title {
    text-align: center;
    p {
      font-size: calc(var(--content-font-size) * 0.65);
    }
  }

  .container {
    display: grid;
    grid-template-columns: 1fr 0.75fr;
    grid-template-areas:
      "day             day"
      "top-matchup     top-matchup"
      "batters-sidebar selected-matchup";
    gap: 1em;
    width: 80vw;
    user-select: none;
    align-items: start;

    @media (orientation: portrait) {
      width: 90vw;
      grid-template-columns: 1fr;
      grid-template-areas:
        "day"
        "top-matchup"
        "selected-matchup"
        "batters-sidebar";
    }
  }

  .day-toggle-container {
    grid-area: day;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em;
    background-color: var(--bg-color);
    border: var(--border);
    border-radius: 99em;

    span {
      font-weight: bold;
      color: var(--box-color);
      transition: 0.4s;

      &:first-of-type {
        opacity: 1;
      }
      &:last-of-type {
        opacity: 0.25;
      }
    }

    &:has(#day-toggle:checked) {
      span:first-of-type {
        opacity: 0.25;
      }
      span:last-of-type {
        opacity: 1;
      }
    }

    #day-toggle {
      --toggle-width: 3em;
      --toggle-height: 1.5em;
      appearance: none;
      width: var(--toggle-width);
      height: var(--toggle-height);
      background: var(--secondary-color);
      border-radius: 99em;
      position: relative;
      cursor: pointer;
      font-size: var(--content-font-size);

      &::before {
        --slider-size: 1.125em;
        --slider-position: 0.2em;
        content: "";
        width: var(--slider-size);
        height: var(--slider-size);
        position: absolute;
        top: var(--slider-position);
        left: var(--slider-position);
        background: linear-gradient(
            to right,
            var(--header-color) 50%,
            white 50%
          )
          no-repeat;
        background-size: 205%;
        background-position: 100%;
        border-radius: 50%;
        transition: 0.4s;
      }

      &:checked::before {
        left: calc(100% - var(--slider-size) - var(--slider-position));
        background-position: 0;
      }
    }
  }

  .placeholder-msg {
    font-size: 0.8em;
    font-style: italic;
    text-align: center;
  }

  .player-name {
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .info-container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .info-item {
    font-family: monospace;
    color: #777;
  }

  .stat-value {
    font-family: monospace;
    font-weight: bold;
    color: #00ff66;
  }

  .active {
    background-color: rgba(0, 255, 100, 0.15);
    color: #00ff66;
    border: 1px solid rgba(0, 255, 100, 0.3);
    border-radius: 3px;
  }

  .badge-container {
    display: flex;
    gap: 0.5em;
    align-items: center;
    animation: fadeIn 0.3s ease-in-out;

    .badge {
      cursor: help;
      padding: 0.5em;
      font-size: 0.8rem;
      font-weight: bold;
      color: #ffcc00;
      border: 1px solid #ff4500;
      border-radius: 4px;
      box-shadow: 0 0 10px rgba(255, 69, 0, 0.2);
      animation: fire-flicker 2s infinite ease-in-out;

      &.matchup-score {
        border-radius: 1em;
        font-size: 1.5rem;
      }

      &:hover {
        color: black;
        background-color: #ff4500;
        transition: 0.4s;
      }
    }
  }

  .loader-container {
    display: flex;
    justify-content: center;
    min-height: 15em;

    .loader::after {
      content: "";
      height: 4px;
      width: 0%;
      display: block;
      background: #00ff66;
      animation: 2s lineGrow linear infinite;
    }
  }

  .matchup-card {
    display: flex;
    flex-direction: column;
    gap: 1em;
    animation: fadeIn 0.3s ease-in-out;

    .matchup {
      display: grid;
      grid-template-columns: 1fr 0.1fr 1fr;
      gap: 1em;
      align-items: center;
      justify-content: center;

      .batter,
      .pitcher {
        display: grid;
        grid-template-columns: 1fr 2fr;
        grid-template-areas:
          "player-name player-name"
          "headshot    team-name";
        align-items: center;
        border-radius: var(--border-radius);
        padding: 0.5em;
        font-size: calc(var(--content-font-size) * 0.85);

        .player-name {
          grid-area: player-name;
          text-align: center;
        }

        .headshot {
          grid-area: headshot;
          justify-self: center;
          height: 3em;
          width: 2em;
          border-radius: 50%;
        }

        .team-name {
          grid-area: team-name;
          font-style: italic;
        }
      }

      .vs {
        background: #222;
        padding: 0 4px;
        border-radius: 4px;
        border: 1px solid #444;
      }
    }

    .game-details {
      display: flex;
      flex-direction: column;
      gap: 0.25em;
      align-items: center;
      font-size: 1rem;
      font-weight: bold;

      .vs {
        font-weight: normal;
      }

      .game-details-teams {
        display: flex;
        gap: 1em;

        .batter-team-name,
        .pitcher-team-name {
          padding: 2px 6px;
          border-radius: 5px;
        }
      }
    }

    .h2h-stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1em;
      border-top: var(--border);
      padding-top: 1em;

      .stat-box {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 1em;

        span:first-child {
          font-size: 1rem;
        }
      }
    }
  }

  aside#top-batters-sidebar {
    grid-area: batters-sidebar;
    height: 20em;
    overflow-y: auto;
    border: var(--border);
    background-color: var(--bg-color);
    border-radius: var(--border-radius);

    ul#top-batters {
      list-style-type: none;
      text-align: center;
      margin: 0;
      padding: 0;
      color: var(--box-color);
      overflow: hidden;

      .list-header,
      .batter-item {
        display: grid;
        grid-template-columns: 0.25fr 3fr 1fr 1fr 0.5fr 1fr;
        gap: 1em;
        align-items: center;
        padding: 0.25em;
      }

      .list-header {
        border-bottom: var(--border);
        font-size: 0.75rem;
        letter-spacing: 1px;
      }

      .batter-item {
        border-bottom: 1px solid var(--box-border-color);
        cursor: pointer;
        border-left: 3px solid transparent; /* Reserve space for the hover state */

        &:last-child {
          border-bottom: none;
        }

        /* High-contrast focus/hover state for quick keyboard navigation */
        &:hover,
        &:focus {
          background-color: rgba(0, 255, 100, 0.2);
          outline: none;
          border-left: 3px solid #00ff66; /* Sharp accent line */
        }

        .batter-team-name {
          font-size: 0.75rem;
          font-weight: bold;
          padding: 2px 6px;
          text-align: center;
          border-radius: 5px;
        }

        .batter-has-game {
          font-size: 0.75rem;
          text-align: center;
          padding: 2px 4px;
        }
      }
    }
  }

  .matchup-detail {
    padding: 1.5em;
    border: var(--border);
    background-color: var(--bg-color);
    border-radius: var(--border-radius);

    &#top-matchup-detail {
      grid-area: top-matchup;
      justify-self: center;
      width: 50%;

      @media (orientation: portrait) {
        justify-self: normal;
        width: auto;
      }
    }

    &#selected-matchup-detail {
      grid-area: selected-matchup;
      align-self: center;
    }
  }

  .btn-container {
    display: flex;
    align-items: center;
    justify-content: center;
    column-gap: 1em;
    max-width: 100%;
    padding: 1em 0;
  }

  button {
    background-color: var(--secondary-color);
    color: var(--header-color);
    font-size: var(--content-font-size);
    padding: 0.2em 0.5em;
    cursor: pointer;
    border-radius: 15px;
  }

  #how-this-works {
    width: 100%;
    font-size: calc(var(--content-font-size) * 0.75);

    h2 {
      text-align: left;
    }

    .algo-container {
      display: flex;
      justify-content: center;

      .algo {
        font-family: "Times New Roman", serif;
        font-size: 1.2rem;
        font-style: italic;
      }
    }

    .legend-container {
      padding: 0.5em 1em;

      .legend-title {
        font-weight: bold;
        text-decoration: underline;
      }

      .legend-list {
        list-style: none;
        line-height: 1.5;
        padding: 0;
        font-size: calc(var(--content-font-size) * 0.65);

        .variable {
          font-family: "Times New Roman", serif;
          font-weight: bold;
          font-style: italic;
        }
      }
    }

    @media (orientation: portrait) {
      max-width: 80%;
    }
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fire-flicker {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(255, 69, 0, 0.3);
    border-color: #ff4500;
  }
  50% {
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.6);
    border-color: #ff8c00;
  }
}

@keyframes lineGrow {
  to {
    width: 100%;
  }
}
