// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@import "theme";

.pf-home-page {
  height: 100%;
  display: grid;
  align-items: stretch;
  justify-items: center;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas: "center" "footer";
  font-family: var(--pf-font-compact);

  .pf-home-page__center {
    grid-area: center;

    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;

    .logo {
      height: 1em;
      margin-right: 16px;
    }

    .pf-home-page__title {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      font-size: 60px;
      margin: 25px;
      text-align: center;
      font-weight: 300;
    }

    .pf-home-page__hints {
      display: flex;
      flex-direction: column;
      gap: 24px;
      margin-bottom: 32px;

      .pf-hotkey {
        display: inline-flex;
        vertical-align: middle;
      }
    }

    .pf-home-page__links {
      width: 100%;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: baseline;
      gap: 24px;
      margin-top: 8px;
      font-size: 0.9em;
      color: var(--pf-color-text-muted);

      &-separator {
        width: 1px;
        height: 16px;
        background-color: var(--pf-color-border);
      }
    }

    .pf-home-page__section {
      background: var(--pf-color-background-secondary);
      border-radius: 7px;
      padding: 20px 24px;
      flex: 1;
      display: flex;
      flex-direction: column;

      &-title {
        font-size: 12px;
        font-weight: 500;
        text-transform: uppercase;
        // letter-spacing: 0;
        color: var(--pf-color-text-muted);
        margin-bottom: 12px;
      }

      &-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 8px;
      }

      &-footer {
        margin-top: auto;
        padding-top: 12px;
        border-top: 1px solid var(--pf-color-border);
      }
    }

    .pf-home-page__getting-started-buttons {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin: -4px -8px; // Offset button padding to align text with section
    }

    .pf-home-page__button {
      font-family: var(--pf-font-compact);
      line-height: 1;
      user-select: none;
      border-radius: $border-radius;
      padding: 4px 8px;
      white-space: nowrap;
      cursor: pointer;

      & > .pf-left-icon {
        margin-right: 6px;
        // color: var(--pf-color-text-muted);
      }

      &:hover {
        background: color_hover(transparent);
      }

      &:active {
        background: color_active(transparent);
      }
    }

    .pf-home-page__shortcut {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 24px;

      &-label {
        color: var(--pf-color-text);
      }
    }
  } // .pf-home-page__center

  .pf-home-page__privacy {
    font-size: 0.9em;
    grid-area: footer;
    align-self: center;
    margin-bottom: 40px;
  }
} // .pf-home-page

.pf-channel-select {
  text-align: center;
  font-size: 16px;

  --chan-num: 2;
  --chan-padding: 3px;

  &--with-autopush {
    --chan-num: 3;
  }

  // Hide the radio buttons
  input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  &__text {
    text-align: center;
    margin-bottom: 12px;
    color: var(--pf-color-text-muted);
    font-size: 0.9em;
  }

  &__switch {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    padding: var(--chan-padding);
    margin-bottom: 20px;
    position: relative;
    background-color: var(--pf-color-background-secondary);
    border-radius: 7px;
    // box-shadow: inset 0 1px 3px var(--pf-color-box-shadow);
    border: 0;
    user-select: none;
  }

  &__pill {
    @include transition(0.2s);
    position: absolute;
    top: var(--chan-padding);
    bottom: var(--chan-padding);
    left: var(--chan-padding);
    // Width is 1/N of the inner area (fieldset width minus padding on both sides)
    width: calc((100% - var(--chan-padding) * 2) / var(--chan-num));
    z-index: 1;
    border-radius: 5px;
  }

  input[type="radio"]:nth-of-type(1):checked {
    & + label {
      color: var(--pf-color-text-on-success);
    }
    & ~ .pf-channel-select__pill {
      transform: translateX(0);
      background-color: #3fa643;
      background: var(--pf-color-success);
    }
  }
  input[type="radio"]:nth-of-type(2):checked {
    & + label {
      color: var(--pf-color-text-on-warning);
    }
    & ~ .pf-channel-select__pill {
      transform: translateX(100%);
      background-color: #d4af00; // Matches sidebar canary (#ffd700)
      background: var(--pf-color-warning);
    }
  }
  input[type="radio"]:nth-of-type(3):checked {
    & + label {
      color: var(--pf-color-text-on-danger);
    }
    & ~ .pf-channel-select__pill {
      transform: translateX(200%);
      background-color: #e65100; // Matches sidebar autopush (#ff7043)
      background: var(--pf-color-danger);
    }
  }

  label {
    @include transition(0.2s);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 8px 32px;
    z-index: 2;
    text-transform: uppercase;
    color: var(--pf-color-text-muted);

    &:hover {
      color: var(--pf-color-text);
    }
  }

  &__reload-hint {
    @include transition(0.2s);
    opacity: 0;

    &--visible {
      opacity: 1;
    }

    &-text {
      font-size: smaller;
      color: var(--pf-color-danger);
      margin-bottom: 12px;
    }
  }
}
