:root {
  /* Colors */
  --background: oklch(0% 0 0);
  --foreground: oklch(100% 0 0);
  --foreground-muted: oklch(100% 0.01 271 / 0.5);
  --muted: oklch(65% 0.01 16);
  --primary: oklch(66% 0.227 17);
  --primary-soft: oklch(62% 0.23 18 / 0.4);
  --brand-cyan: oklch(90% 0.15 194);
  --brand-pink: oklch(70% 0.32 328);
  --left-right-gradient: linear-gradient(
    90deg,
    var(--brand-cyan) 0%,
    var(--brand-pink) 100%
  );
  --off-black: oklch(23% 0 271);

  /* Sizes */
  --page-max: 512px;
  --page-min: 348px;
  --footer-nav-height: calc(49px + 0.9rem);

  /* Utilities */
  --radius-full: 999px;
  --tracking-tight: -0.02em;

  /* Icons */
  --icon-sm: 1.2rem;
  --icon-md: 1.25rem;
  --icon-lg: 1.5rem;

  /* Font */
  --font-sans: 'TikTok Sans', sans-serif;
}

/* BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body {
  display: grid;
  place-items: start center;
  font-family: var(--font-sans);
  color: var(--foreground);
  background-color: var(--background);
  color-scheme: dark;
}

button {
  user-select: none;
  border-radius: 0;
  text-align: inherit;
  background: none;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
  border: none;
  color: inherit;
  font: inherit;
  touch-action: manipulation; /* disable double-tap zoom on mobile */
}

a {
  text-decoration: none;
  color: inherit;
}

video {
  height: 100%;
  width: 100%;
  display: block;
  object-position: center;
  object-fit: cover;
}

i {
  color: var(--foreground);
}

/* PAGE CONTAINER */
.reel-page {
  height: 100dvh;
  max-width: var(--page-max);
  min-width: var(--page-min);
  position: relative;
  overflow: hidden;
}

/* HEADER */
.reel-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;

  /* Play and Search buttons */
  > button {
    padding: 1rem 1.15rem;

    i {
      font-size: var(--icon-sm);
    }
  }

  /* Navigation buttons */
  nav {
    display: flex;
    gap: 0.33rem;

    button {
      padding: 1rem 0.33rem;
      position: relative;
      font-size: 0.875rem;
      font-weight: 600;
      letter-spacing: var(--tracking-tight);
      color: var(--foreground-muted);

      /* New content indicator */
      &.new-content::after {
        content: '';
        position: absolute;
        top: 0.8rem;
        right: -0.08rem;
        width: 0.38rem;
        height: 0.38rem;
        background-color: var(--primary-soft);
        border-radius: 50%;
      }

      /* Active button */
      &.active {
        color: var(--foreground);

        /* Active button bottom border */
        &::after {
          content: '';
          position: absolute;
          bottom: 0.6rem;
          left: 50%;
          transform: translateX(-50%);
          width: 40%;
          height: 2.5px;
          background-color: var(--foreground);
        }
      }
    }
  }
}

/* SIDEBAR */
.sidebar {
  position: absolute;
  right: 0;
  bottom: var(--footer-nav-height);
  padding-bottom: 4.375rem;

  > :not(:first-child) {
    margin-top: 0.6rem;
  }

  /* Profile actions  */
  .profile {
    position: relative;
    text-align: center;

    /* Avatar */
    .avatar-link {
      img {
        background-color: var(--foreground);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
        padding: 0.1rem;
      }
    }

    /* Follow button */
    .follow-button {
      position: absolute;
      bottom: -0.3rem;
      left: 50%;
      transform: translateX(-50%);
      width: var(--icon-sm);
      height: var(--icon-sm);
      background-color: var(--primary);
      line-height: var(--icon-sm); /* vertically center the plus sign */
      text-align: center;
      border-radius: 50%;

      .plus {
        display: inline-block;
        color: var(--foreground);
        font-size: 1.3rem;
        font-weight: 600;
        position: relative;
        top: -1px;
      }
    }
  }

  /* Sidebar buttons */
  > button {
    display: block;
    text-align: center;
    padding: 0.6rem 1rem;

    i {
      font-size: var(--icon-lg);
    }

    span {
      display: block;
      font-size: 0.75rem;
      font-weight: 700;
    }
  }
}

/* FOOTER */
footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--foreground);

  /* Bottom Overlay */
  .bottom-overlay {
    padding: 0.5rem 0.75rem 0.75rem;

    /* Space between username and description */
    > :not(:first-child) {
      margin-top: 0.3rem;
    }

    /* Username */
    .username {
      font-size: 0.76rem;
      font-weight: 700;
      letter-spacing: var(--tracking-tight);

      &:hover {
        text-decoration: underline;
      }
    }

    /* Description */
    .description {
      max-width: 33ch;
      font-size: 0.76rem;
      font-weight: 600;
      line-height: 1.4;

      .expand {
        font-weight: 700;
      }
    }
  }

  /* Footer actions */
  nav {
    background-color: var(--background);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    padding: 0 0.25rem;

    button {
      flex: 1;
      padding: 0.85rem 0;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--muted);

      /* Active button state */
      &.active {
        color: var(--foreground);

        .label {
          font-weight: 700;
        }
      }

      /* Middle Create button (+) */
      &.create {
        --plus-button-width: 2.2rem;
        --plus-button-height: 1.625rem;
        --plus-offset-y: 0.4rem;
        --plus-radius: 0.48rem;

        position: relative;

        /* ? Create button left and right borders
        Avoided `border-left` and `border-right` due to iOS Safari rendering issue */
        &::before {
          content: '';
          width: calc(var(--plus-button-width) + 6px);
          height: var(--plus-button-height);
          position: absolute;
          inset: 0;
          margin: auto;
          translate: 0 calc(-1 * var(--plus-offset-y));
          border-radius: var(--plus-radius);
          background: var(--left-right-gradient);
        }

        .plus {
          width: var(--plus-button-width);
          height: var(--plus-button-height);
          position: relative;
          display: flex;
          justify-content: center;
          align-items: center;
          text-align: center;
          font-weight: 600;
          translate: 0 calc(-1 * var(--plus-offset-y));
          border-radius: var(--plus-radius);
          background-color: var(--foreground);

          i {
            -webkit-text-stroke: 0.15px currentcolor; /* slightly bolder */
            font-size: var(--icon-md);
            color: var(--off-black);
          }
        }
      }

      /* Icon */
      .icon-slot {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;

        i {
          font-size: var(--icon-md);
          color: inherit;
        }

        /* Notification Badge */
        .notification-badge {
          position: absolute;
          top: 0;
          right: 0;
          transform: translate(50%, -3%);
          display: inline-flex;
          align-items: center;
          justify-content: center;
          background-color: var(--primary);
          color: var(--foreground);
          font-size: 0.625rem;
          font-weight: 700;
          padding: 0.03rem 0.25rem;
          border-radius: var(--radius-full);
        }
      }

      /* Button Label */
      .label {
        font-size: 0.563rem;
        letter-spacing: var(--tracking-tight);
        font-weight: 500;
      }
    }
  }
}

/* ----------- DEBUG MODE ----------- */
.debug .reel-header {
  border: 2px dashed var(--foreground);
}

.debug footer {
  border: 2px dashed var(--foreground);
}

.debug .sidebar {
  border: 2px dashed var(--primary);
}
